Merge WCM_SERVICES into HEAD 11697, 11698, 11702, 11751, 11801, 11924, 12023, 12073

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12076 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2008-11-21 13:59:09 +00:00
parent 71471108fa
commit 4981f27b3e
13 changed files with 159 additions and 555 deletions

View File

@@ -24,28 +24,15 @@
*/
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.util.Pair;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.util.VirtServerUtils;
/**
* Revert (undo) the selected files in the current user sandbox.
@@ -59,15 +46,7 @@ public class RevertSelectedDialog extends BaseDialogBean
private static final String MSG_REVERTSELECTED_SUCCESS = "revertselected_success";
protected AVMBrowseBean avmBrowseBean;
transient private ActionService actionService;
// The virtualization server might need to be notified
// because one or more of the files reverted could alter
// the behavior the virtual webapp in the target of the submit.
private String virtUpdatePath;
transient private SandboxService sbService;
/**
* @param avmBrowseBean The AVM BrowseBean to set
@@ -77,21 +56,18 @@ public class RevertSelectedDialog extends BaseDialogBean
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param actionService The actionService to set.
*/
public void setActionService(ActionService actionService)
public void setSandboxService(SandboxService sbService)
{
this.actionService = actionService;
this.sbService = sbService;
}
protected ActionService getActionService()
protected SandboxService getSandboxService()
{
if (this.actionService == null)
if (this.sbService == null)
{
this.actionService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getActionService();
this.sbService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSandboxService();
}
return actionService;
return this.sbService;
}
/**
@@ -100,33 +76,10 @@ public class RevertSelectedDialog extends BaseDialogBean
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
List<AVMNodeDescriptor> selected = this.avmBrowseBean.getSelectedSandboxItems();
List<Pair<Integer, String>> versionPaths = new ArrayList<Pair<Integer, String>>();
List<WorkflowTask> tasks = null;
for (AVMNodeDescriptor node : selected)
{
if (tasks == null)
{
tasks = AVMWorkflowUtil.getAssociatedTasksForSandbox(AVMUtil.getStoreName(node.getPath()));
}
if (AVMWorkflowUtil.getAssociatedTasksForNode(node, tasks).size() == 0)
{
String revertPath = node.getPath();
versionPaths.add(new Pair<Integer, String>(-1, revertPath));
if ( (this.virtUpdatePath == null) &&
VirtServerUtils.requiresUpdateNotification(revertPath) )
{
this.virtUpdatePath = revertPath;
}
}
}
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable)versionPaths);
Action action = this.getActionService().createAction(AVMUndoSandboxListAction.NAME, args);
this.getActionService().executeAction(action, null); // dummy action ref, list passed as action arg
String webApp = this.avmBrowseBean.getWebapp();
String userSandboxId = this.avmBrowseBean.getSandbox();
getSandboxService().revertAllWebApp(userSandboxId, webApp);
String msg = MessageFormat.format(Application.getMessage(
context, MSG_REVERTSELECTED_SUCCESS), this.avmBrowseBean.getUsername());
@@ -135,24 +88,6 @@ public class RevertSelectedDialog extends BaseDialogBean
return outcome;
}
/**
* Handle notification to the virtualization server
* (this needs to occur after the sandbox is updated).
*/
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// Force the update because we've already determined
// that update_path requires virt server notification.
if (this.virtUpdatePath != null)
{
AVMUtil.updateVServerWebapp(this.virtUpdatePath, true);
}
return outcome;
}
/**
* @return the confirmation to display to the user