Paul Holmes-Higgin cefda8c965 Updated header to LGPL
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18931 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2010-03-01 22:48:39 +00:00

96 lines
3.6 KiB
Java

/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.wcm.actions;
import java.util.List;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.wcm.sandbox.SandboxService;
/**
* WCM Undo example action (supercedes AVMUndoSandboxListAction)
*
* Undo (ie. throw away) changed assets in a user sandbox - either all or a list
*
* The actionedUponNodeRef is a dummy and can be null.
*
* @author janv
*/
public class WCMSandboxUndoAction extends ActionExecuterAbstractBase
{
public static final String NAME = "wcm-undo";
public static final String PARAM_PATH_LIST = "path-list"; // list of paths (relative to sandbox store)
public static final String PARAM_SANDBOX_ID = "sandbox-id"; // sandbox store id
/**
* The WCM SandboxService
*/
private SandboxService sbService;
public void setSandboxService(SandboxService sbService)
{
this.sbService = sbService;
}
/* (non-Javadoc)
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
*/
@SuppressWarnings("unchecked")
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
String sbStoreId = (String)action.getParameterValue(PARAM_SANDBOX_ID);
List<String> relativePaths = (List<String>)action.getParameterValue(PARAM_PATH_LIST);
if ((relativePaths == null) || (relativePaths.size() == 0))
{
sbService.revertAll(sbStoreId);
}
else
{
sbService.revertList(sbStoreId, relativePaths);
}
}
/* (non-Javadoc)
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
*/
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(
new ParameterDefinitionImpl(PARAM_PATH_LIST,
DataTypeDefinition.ANY,
false,
getParamDisplayLabel(PARAM_PATH_LIST)));
paramList.add(
new ParameterDefinitionImpl(PARAM_SANDBOX_ID,
DataTypeDefinition.TEXT,
true,
getParamDisplayLabel(PARAM_SANDBOX_ID)));
}
}