Remove rollback service method
This commit is contained in:
@@ -1828,74 +1828,6 @@ namespace Umbraco.Core.Services
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rollback an <see cref="IContent"/> object to a previous version.
|
||||
/// This will create a new version, which is a copy of all the old data.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The way data is stored actually only allows us to rollback on properties
|
||||
/// and not data like Name and Alias of the Content.
|
||||
/// </remarks>
|
||||
/// <param name="id">Id of the <see cref="IContent"/>being rolled back</param>
|
||||
/// <param name="versionId">Id of the version to rollback to</param>
|
||||
/// <param name="userId">Optional Id of the User issueing the rollback of the Content</param>
|
||||
/// <returns>The newly created <see cref="IContent"/> object</returns>
|
||||
public IContent Rollback(int id, int versionId, int userId = 0)
|
||||
{
|
||||
using (var uow = UowProvider.CreateUnitOfWork())
|
||||
{
|
||||
uow.WriteLock(Constants.Locks.ContentTree);
|
||||
var repository = uow.CreateRepository<IContentRepository>();
|
||||
|
||||
var currContent = repository.Get(id);
|
||||
var origContent = repository.GetVersion(versionId);
|
||||
|
||||
var rollbackEventArgs = new RollbackEventArgs<IContent>(origContent);
|
||||
if (uow.Events.DispatchCancelable(RollingBack, this, rollbackEventArgs))
|
||||
{
|
||||
uow.Complete();
|
||||
return origContent;
|
||||
}
|
||||
|
||||
// orig content versions
|
||||
// pk < published pk = normal, rollback to an older version
|
||||
// pk = published pk = normal, rollback to currently published version
|
||||
// pk > published pk = special, rollback to current 'edit' version
|
||||
//
|
||||
// in that last case, we want to copy the published values
|
||||
// what-if there's no 'published' version for now?
|
||||
// fixme WE DON'T WANT TO DO THIS HERE!
|
||||
var copyPublished = origContent.VersionId > origContent.PublishedVersionId;
|
||||
//((Content) currContent).CopyAllValues(origContent, copyPublished);
|
||||
((Content) currContent).CopyAllValues(origContent);
|
||||
currContent.WriterId = userId;
|
||||
|
||||
// builtin values
|
||||
if (copyPublished)
|
||||
{
|
||||
currContent.Name = origContent.PublishName;
|
||||
currContent.Template = origContent.PublishTemplate;
|
||||
}
|
||||
else
|
||||
{
|
||||
currContent.Name = origContent.Name;
|
||||
currContent.Template = origContent.Template;
|
||||
}
|
||||
|
||||
// save the values
|
||||
repository.AddOrUpdate(currContent);
|
||||
|
||||
rollbackEventArgs.CanCancel = false;
|
||||
uow.Events.Dispatch(RolledBack, this, rollbackEventArgs);
|
||||
uow.Events.Dispatch(TreeChanged, this, new TreeChange<IContent>(currContent, TreeChangeTypes.RefreshNode).ToEventArgs());
|
||||
Audit(uow, AuditType.RollBack, "Content rollback performed by user", currContent.WriterId, currContent.Id);
|
||||
|
||||
uow.Complete();
|
||||
|
||||
return currContent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sorts a collection of <see cref="IContent"/> objects by updating the SortOrder according
|
||||
/// to the ordering of items in the passed in <see cref="IEnumerable{T}"/>.
|
||||
|
||||
Reference in New Issue
Block a user