mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
One simple revert action, and a tool for encoding pick lists for more complicated actions
in the future. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4348 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.alfresco.repo.avm.actions;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Reverts a node and everything underneath it to a specified version.
|
||||
* @author britt
|
||||
*/
|
||||
public class AVMRevertStoreAction extends ActionExecuterAbstractBase
|
||||
{
|
||||
private static Logger fgLogger = Logger.getLogger(AVMRevertStoreAction.class);
|
||||
|
||||
public static final String NAME = "avm-revert-store";
|
||||
public static final String PARAM_VERSION = "version";
|
||||
|
||||
/**
|
||||
* The AVM Synchronization Service.
|
||||
*/
|
||||
private AVMSyncService fSyncService;
|
||||
|
||||
/**
|
||||
* Set the Sync Service.
|
||||
*/
|
||||
public void setAvmSyncService(AVMSyncService service)
|
||||
{
|
||||
fSyncService = service;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
// All this does is an override submit from the older version
|
||||
// to head of the store implied in the path.
|
||||
Pair<Integer, String> pathVersion =
|
||||
AVMNodeConverter.ToAVMVersionPath(actionedUponNodeRef);
|
||||
int revertVersion = (Integer)action.getParameterValue(PARAM_VERSION);
|
||||
List<AVMDifference> diffs =
|
||||
fSyncService.compare(revertVersion, pathVersion.getSecond(),
|
||||
-1, pathVersion.getSecond());
|
||||
String message = "Reverted to Version " + revertVersion + ".";
|
||||
fSyncService.update(diffs, false, false, true, true, message, message);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(
|
||||
new ParameterDefinitionImpl(PARAM_VERSION,
|
||||
DataTypeDefinition.INT,
|
||||
true,
|
||||
getParamDisplayLabel(PARAM_VERSION)));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user