mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fixed a wee bug.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4752 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -6,6 +6,7 @@ package org.alfresco.repo.avm.actions;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
@@ -62,31 +63,20 @@ public class AVMRevertToVersionAction extends ActionExecuterAbstractBase
|
|||||||
{
|
{
|
||||||
Pair<Integer, String> versionPath =
|
Pair<Integer, String> versionPath =
|
||||||
AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
|
AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
|
||||||
String [] storePath = versionPath.getSecond().split(":");
|
|
||||||
String store = storePath[0];
|
|
||||||
AVMNodeDescriptor toRevert =
|
AVMNodeDescriptor toRevert =
|
||||||
(AVMNodeDescriptor)action.getParameterValue(TOREVERT);
|
(AVMNodeDescriptor)action.getParameterValue(TOREVERT);
|
||||||
List<Pair<Integer, String>> paths = fAVMService.getPaths(toRevert);
|
List<Pair<Integer, String>> paths = fAVMService.getPaths(toRevert);
|
||||||
Pair<Integer, String> found = new Pair<Integer, String>(Integer.MAX_VALUE, "");
|
if (paths.size() == 0)
|
||||||
for (Pair<Integer, String> path : paths)
|
|
||||||
{
|
{
|
||||||
if (!path.getSecond().startsWith(store + ':'))
|
fgLogger.error("Unable to find path for: " + toRevert);
|
||||||
{
|
throw new AlfrescoRuntimeException("Could not find path for: " + toRevert);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (path.getFirst() < found.getFirst())
|
|
||||||
{
|
|
||||||
found = path;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// TODO I believe that this should always have found not
|
AVMDifference diff = new AVMDifference(paths.get(0).getFirst(), paths.get(0).getSecond(),
|
||||||
// the initial found. Must confirm.
|
|
||||||
AVMDifference diff = new AVMDifference(found.getFirst(), found.getSecond(),
|
|
||||||
-1, versionPath.getSecond(),
|
-1, versionPath.getSecond(),
|
||||||
AVMDifference.NEWER);
|
AVMDifference.NEWER);
|
||||||
List<AVMDifference> diffs = new ArrayList<AVMDifference>(1);
|
List<AVMDifference> diffs = new ArrayList<AVMDifference>(1);
|
||||||
diffs.add(diff);
|
diffs.add(diff);
|
||||||
String message = "Reverted " + versionPath.getSecond() + " to version in snapshot " + found.getFirst() + ".";
|
String message = "Reverted " + versionPath.getSecond() + " to version in snapshot " + paths.get(0).getFirst() + ".";
|
||||||
fAVMSyncService.update(diffs, null, false, false, true, true, "Reverted", message);
|
fAVMSyncService.update(diffs, null, false, false, true, true, "Reverted", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user