diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java
index 5123764b3b..2ad4b4983e 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java
@@ -29,7 +29,6 @@ import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -51,16 +50,12 @@ import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.AVMNodeType;
-import org.alfresco.repo.avm.actions.AVMRevertStoreAction;
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
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.avm.AVMStoreDescriptor;
-import org.alfresco.service.cmr.avmsync.AVMDifference;
-import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -77,6 +72,8 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.util.Pair;
import org.alfresco.util.VirtServerUtils;
+import org.alfresco.wcm.sandbox.SandboxInfo;
+import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.wcm.webproject.WebProjectInfo;
import org.alfresco.wcm.webproject.WebProjectService;
import org.alfresco.web.app.Application;
@@ -223,11 +220,11 @@ public class AVMBrowseBean implements IContextListener
/** WebProjectService bean reference */
transient protected WebProjectService wpService;
+ /** SandboxService bean reference */
+ transient protected SandboxService sbService;
+
/** AVM service bean reference */
transient protected AVMService avmService;
-
- /** AVM sync service bean reference */
- transient protected AVMSyncService avmSyncService;
/** Action service bean reference */
transient protected ActionService actionService;
@@ -275,6 +272,23 @@ public class AVMBrowseBean implements IContextListener
return wpService;
}
+ /**
+ * @param sbService The SandboxService to set.
+ */
+ public void setSandboxService(SandboxService sbService)
+ {
+ this.sbService = sbService;
+ }
+
+ protected SandboxService getSandboxService()
+ {
+ if (sbService == null)
+ {
+ sbService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSandboxService();
+ }
+ return sbService;
+ }
+
/**
* @param avmService The AVMService to set.
*/
@@ -291,23 +305,6 @@ public class AVMBrowseBean implements IContextListener
}
return avmService;
}
-
- /**
- * @param avmSyncService The AVMSyncService to set.
- */
- public void setAvmSyncService(AVMSyncService avmSyncService)
- {
- this.avmSyncService = avmSyncService;
- }
-
- protected AVMSyncService getAvmSyncService()
- {
- if (avmSyncService == null)
- {
- avmSyncService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMSyncService();
- }
- return avmSyncService;
- }
/**
* @param nodeService The NodeService to set.
@@ -498,22 +495,23 @@ public class AVMBrowseBean implements IContextListener
*/
public String getStagingSummary()
{
- final StringBuilder summary = new StringBuilder(128);
- final FacesContext fc = FacesContext.getCurrentInstance();
- final ResourceBundle msg = Application.getBundle(fc);
- final String stagingStore = this.getStagingStore();
- final AVMStoreDescriptor store = getAvmService().getStore(stagingStore);
- WebProject webProject = this.getWebProject();
- final String storeId = (String)webProject.getStoreId();
- if (store != null)
+ StringBuilder summary = new StringBuilder(128);
+ FacesContext fc = FacesContext.getCurrentInstance();
+ ResourceBundle msg = Application.getBundle(fc);
+
+ NodeRef wpNodeRef = getWebsite().getNodeRef();
+ WebProjectInfo wpInfo = getWebProjectService().getWebProject(wpNodeRef);
+ SandboxInfo sbInfo = getSandboxService().getStagingSandbox(wpInfo.getStoreId());
+
+ if (sbInfo != null)
{
summary.append(msg.getString(MSG_CREATED_ON)).append(": ")
- .append(Utils.getDateFormat(fc).format(new Date(store.getCreateDate())))
+ .append(Utils.getDateFormat(fc).format(sbInfo.getCreatedDate()))
.append("
");
summary.append(msg.getString(MSG_CREATED_BY)).append(": ")
- .append(store.getCreator())
+ .append(sbInfo.getCreator())
.append("
");
- final int numUsers = getWebProjectService().getWebUserCount(webProject.getNodeRef());
+ final int numUsers = getWebProjectService().getWebUserCount(wpNodeRef);
summary.append(MessageFormat.format(msg.getString(MSG_WORKING_USERS), numUsers));
}
@@ -729,14 +727,13 @@ public class AVMBrowseBean implements IContextListener
{
if (this.webapps == null)
{
- String path = AVMUtil.buildSandboxRootPath(getStagingStore());
- Map folders = getAvmService().getDirectoryListing(-1, path);
- List webapps = new ArrayList(folders.size());
- for (AVMNodeDescriptor node : folders.values())
+ List webAppNames = getWebProjectService().listWebApps(getWebsite().getNodeRef());
+ List webAppItems = new ArrayList(webAppNames.size());
+ for (String webAppName : webAppNames)
{
- webapps.add(new SelectItem(node.getName(), node.getName()));
+ webAppItems.add(new SelectItem(webAppName, webAppName));
}
- this.webapps = webapps;
+ this.webapps = webAppItems;
}
return this.webapps;
}
@@ -1341,7 +1338,7 @@ public class AVMBrowseBean implements IContextListener
*/
public boolean getIsStagingStore()
{
- return (this.sandbox != null && this.sandbox.indexOf(AVMUtil.STORE_SEPARATOR) == -1);
+ return AVMUtil.isMainStore(this.sandbox);
}
@@ -1686,38 +1683,10 @@ public class AVMBrowseBean implements IContextListener
String strVersion = params.get("version");
if (sandbox != null && strVersion != null && strVersion.length() != 0)
{
- UserTransaction tx = null;
try
{
+ getSandboxService().revertSnapshot(sandbox, Integer.valueOf(strVersion));
FacesContext context = FacesContext.getCurrentInstance();
- tx = Repository.getUserTransaction(context, false);
- tx.begin();
-
- String sandboxPath = AVMUtil.buildSandboxRootPath( sandbox );
-
- List diffs =
- this.getAvmSyncService().compare(
- -1,sandboxPath,Integer.valueOf(strVersion),sandboxPath,null);
-
- Map args = new HashMap(1, 1.0f);
- args.put(AVMRevertStoreAction.PARAM_VERSION, Integer.valueOf(strVersion));
- Action action = this.getActionService().createAction(AVMRevertStoreAction.NAME, args);
- this.getActionService().executeAction(action, AVMNodeConverter.ToNodeRef(-1, sandbox + ":/"));
-
- // commit the transaction
- tx.commit();
-
- // See if any of the files being reverted require
- // notification of the virt server.
-
- for (AVMDifference diff : diffs)
- {
- if ( VirtServerUtils.requiresUpdateNotification( diff.getSourcePath()) )
- {
- AVMUtil.updateVServerWebapp(diff.getSourcePath() , true);
- break;
- }
- }
// if we get here, all was well - output friendly status message to the user
this.displayStatusMessage(context,
@@ -1730,7 +1699,6 @@ public class AVMBrowseBean implements IContextListener
err.printStackTrace(System.err);
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
- try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
}
diff --git a/source/java/org/alfresco/web/bean/wcm/AVMUtil.java b/source/java/org/alfresco/web/bean/wcm/AVMUtil.java
index 1dacb60605..9e1a00d40f 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMUtil.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMUtil.java
@@ -24,7 +24,6 @@
*/
package org.alfresco.web.bean.wcm;
-import java.text.MessageFormat;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -39,9 +38,7 @@ import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.wcm.util.WCMUtil;
-import org.alfresco.wcm.webproject.WebProjectService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.preview.PreviewURIService;
@@ -88,7 +85,7 @@ public final class AVMUtil extends WCMUtil
public static String getStoreName(final String avmPath)
{
- return WCMUtil.getStoreName(avmPath);
+ return WCMUtil.getSandboxStoreId(avmPath);
}
public static boolean isPreviewStore(final String storeName)
@@ -108,7 +105,7 @@ public final class AVMUtil extends WCMUtil
public static boolean isMainStore(String storeName)
{
- return WCMUtil.isMainStore(storeName);
+ return WCMUtil.isStagingStore(storeName);
}
public static String getUserName(String storeName)
@@ -118,7 +115,7 @@ public final class AVMUtil extends WCMUtil
public static String getStoreId(final String storeName)
{
- return WCMUtil.getStoreId(storeName);
+ return WCMUtil.getWebProjectStoreId(storeName);
}
public static String getCorrespondingMainStoreName(final String storeName)
@@ -275,19 +272,10 @@ public final class AVMUtil extends WCMUtil
public static String buildStoreUrl(String store)
{
- if (store == null || store.length() == 0)
- {
- throw new IllegalArgumentException("Store name is mandatory.");
- }
- if (store.indexOf(':') != -1)
- {
- store = store.substring(0, store.indexOf(':'));
- }
+ ServiceRegistry serviceRegistry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
+ AVMService avmService = serviceRegistry.getAVMService();
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
- return MessageFormat.format(JNDIConstants.PREVIEW_SANDBOX_URL,
- lookupStoreDNS(store),
- config.getWCMDomain(),
- config.getWCMPort());
+ return WCMUtil.buildStoreUrl(avmService, store, config.getWCMDomain(), config.getWCMPort());
}
public static String buildWebappUrl(final String avmPath)
@@ -531,12 +519,6 @@ public final class AVMUtil extends WCMUtil
return linksManagementConfig;
}
- // Component Separator.
- public static final String STORE_SEPARATOR = WCMUtil.STORE_SEPARATOR;
-
- public static final String STORE_WORKFLOW = WCMUtil.STORE_WORKFLOW;
- public static final String STORE_PREVIEW = WCMUtil.STORE_PREVIEW;
-
// pattern for absolute AVM Path
//private final static Pattern STORE_RELATIVE_PATH_PATTERN =
// Pattern.compile("[^:]+:(.+)");
diff --git a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java
index 0074b25349..ab745c148e 100644
--- a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java
+++ b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java
@@ -32,9 +32,7 @@ import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
@@ -43,15 +41,12 @@ import javax.faces.context.FacesContext;
import org.alfresco.config.ConfigElement;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.WCMAppModel;
-import org.alfresco.model.WCMWorkflowModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
-import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService;
-import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -63,9 +58,8 @@ import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowPath;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
-import org.alfresco.service.cmr.workflow.WorkflowTaskQuery;
-import org.alfresco.service.namespace.QName;
import org.alfresco.wcm.sandbox.SandboxInfo;
+import org.alfresco.wcm.util.WCMWorkflowUtil;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.workflow.WorkflowUtil;
@@ -257,59 +251,21 @@ public class AVMWorkflowUtil extends WorkflowUtil
public static List getAssociatedTasksForSandbox(final String storeName)
{
- final String fromPath = AVMUtil.buildStoreRootPath(storeName);
- final FacesContext fc = FacesContext.getCurrentInstance();
- final WorkflowService workflowService = Repository.getServiceRegistry(fc).getWorkflowService();
- final WorkflowTaskQuery query = new WorkflowTaskQuery();
-
- final HashMap props = new HashMap(1, 1.0f);
- props.put(WCMWorkflowModel.PROP_FROM_PATH, fromPath);
- query.setProcessCustomProps(props);
- query.setActive(true);
- final List tasks = workflowService.queryTasks(query);
-
- if (logger.isDebugEnabled())
- logger.debug("found " + tasks.size() + " tasks originating user sandbox " + fromPath);
-
- return tasks;
+ FacesContext fc = FacesContext.getCurrentInstance();
+ WorkflowService workflowService = Repository.getServiceRegistry(fc).getWorkflowService();
+ return WCMWorkflowUtil.getAssociatedTasksForSandbox(workflowService, storeName);
}
public static List getAssociatedTasksForNode(AVMNodeDescriptor node, List tasks)
{
- final List result = new LinkedList();
- final FacesContext fc = FacesContext.getCurrentInstance();
- final AVMService avmService = Repository.getServiceRegistry(fc).getAVMService();
-
- for (final WorkflowTask task : tasks)
- {
- final NodeRef ref = task.path.instance.workflowPackage;
- final String path = AVMUtil.getCorrespondingPath(node.getPath(), ref.getStoreRef().getIdentifier());
- if (logger.isDebugEnabled())
- logger.debug("checking store " + ref.getStoreRef().getIdentifier() +
- " for " + node.getPath() + " (" + path + ")");
- try
- {
- final LayeringDescriptor ld = avmService.getLayeringInfo(-1, path);
- if (!ld.isBackground())
- {
- if (logger.isDebugEnabled())
- logger.debug(path + " is in the foreground. workflow active");
- result.add(task);
- }
- }
- catch (final AVMNotFoundException avmnfe)
- {
- if (logger.isDebugEnabled())
- logger.debug(path + " not found");
- }
- }
-
- return result;
+ FacesContext fc = FacesContext.getCurrentInstance();
+ AVMService avmService = Repository.getServiceRegistry(fc).getAVMService();
+ return WCMWorkflowUtil.getAssociatedTasksForNode(avmService, node, tasks);
}
public static List getAssociatedTasksForNode(AVMNodeDescriptor node)
{
final List tasks = AVMWorkflowUtil.getAssociatedTasksForSandbox(AVMUtil.getStoreName(node.getPath()));
- return getAssociatedTasksForNode(node, tasks);
+ return AVMWorkflowUtil.getAssociatedTasksForNode(node, tasks);
}
}
diff --git a/source/java/org/alfresco/web/bean/wcm/DeleteSandboxDialog.java b/source/java/org/alfresco/web/bean/wcm/DeleteSandboxDialog.java
index fe188d1962..2e71855d61 100644
--- a/source/java/org/alfresco/web/bean/wcm/DeleteSandboxDialog.java
+++ b/source/java/org/alfresco/web/bean/wcm/DeleteSandboxDialog.java
@@ -90,7 +90,7 @@ public class DeleteSandboxDialog extends BaseDialogBean
if (username != null)
{
Node website = this.avmBrowseBean.getWebsite();
- getWebProjectService().uninviteWebUser(website.getNodeRef(), username);
+ getWebProjectService().uninviteWebUser(website.getNodeRef(), username, true);
String wpStoreId = getWebProjectService().getWebProject(website.getNodeRef()).getStoreId();
String mainStore = AVMUtil.buildUserMainStoreName(wpStoreId, username);
diff --git a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java
index cf4c7ef603..fb3fb752ff 100644
--- a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java
+++ b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java
@@ -114,7 +114,7 @@ public class InviteWebsiteUsersWizard extends BaseInviteUsersWizard
selectedInvitees.put(userRole.getAuthority(), userRole.getRole());
}
- getWebProjectService().inviteWebUsersGroups(this.getNode().getNodeRef(), selectedInvitees);
+ getWebProjectService().inviteWebUsersGroups(this.getNode().getNodeRef(), selectedInvitees, true);
return outcome;
}
diff --git a/source/java/org/alfresco/web/bean/wcm/LinkValidationDialog.java b/source/java/org/alfresco/web/bean/wcm/LinkValidationDialog.java
index a9545d103d..ddbeff1b55 100644
--- a/source/java/org/alfresco/web/bean/wcm/LinkValidationDialog.java
+++ b/source/java/org/alfresco/web/bean/wcm/LinkValidationDialog.java
@@ -38,7 +38,7 @@ import org.alfresco.linkvalidation.LinkValidationAction;
import org.alfresco.linkvalidation.LinkValidationReport;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
-import org.alfresco.sandbox.SandboxConstants;
+import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMService;
@@ -129,8 +129,7 @@ public class LinkValidationDialog extends BaseDialogBean
SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN) != null)
{
String pattern = Application.getMessage(context, "link_validaton_dialog_title_user");
- String user = this.store.substring(
- this.store.indexOf(AVMUtil.STORE_SEPARATOR)+AVMUtil.STORE_SEPARATOR.length());
+ String user = AVMUtil.getUserName(this.store);
this.title = MessageFormat.format(pattern,
new Object[] {user});
}
diff --git a/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java b/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java
index dd27ee07f3..372529aa24 100644
--- a/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java
+++ b/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java
@@ -24,29 +24,13 @@
*/
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.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.avmsync.AVMDifference;
-import org.alfresco.service.cmr.avmsync.AVMSyncService;
-import org.alfresco.service.cmr.workflow.WorkflowTask;
-import org.alfresco.util.NameMatcher;
-import org.alfresco.util.Pair;
-import org.alfresco.util.VirtServerUtils;
+import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.web.app.Application;
-import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
@@ -62,39 +46,22 @@ public class RevertAllDialog extends BaseDialogBean
private static final String MSG_REVERTALL_SUCCESS = "revertall_success";
protected AVMBrowseBean avmBrowseBean;
-
- transient private AVMService avmService;
- transient private AVMSyncService avmSyncService;
- transient private ActionService actionService;
-
- transient private NameMatcher nameMatcher;
+ transient private SandboxService sbService;
- // 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;
-
-
- /**
- * @param avmService the avmService to set
- */
- public void setAvmService(AVMService avmService)
+ public void setSandboxService(SandboxService sbService)
{
- this.avmService = avmService;
+ this.sbService = sbService;
}
-
-
- protected AVMService getAvmService()
+
+ protected SandboxService getSandboxService()
{
- if (this.avmService == null)
+ if (this.sbService == null)
{
- this.avmService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMService();
+ this.sbService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSandboxService();
}
- return this.avmService;
+ return this.sbService;
}
-
/**
* @param avmBrowseBean The AVM BrowseBean to set
*/
@@ -103,104 +70,17 @@ public class RevertAllDialog extends BaseDialogBean
this.avmBrowseBean = avmBrowseBean;
}
- /**
- * @param avmSyncService The AVMSyncService to set.
- */
- public void setAvmSyncService(AVMSyncService avmSyncService)
- {
- this.avmSyncService = avmSyncService;
- }
-
- protected AVMSyncService getAvmSyncService()
- {
- if (this.avmSyncService == null)
- {
- this.avmSyncService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMSyncService();
- }
- return this.avmSyncService;
- }
-
- /**
- * @param actionService The actionService to set.
- */
- public void setActionService(ActionService actionService)
- {
- this.actionService = actionService;
- }
-
- protected ActionService getActionService()
- {
- if (this.actionService == null)
- {
- this.actionService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getActionService();
- }
- return this.actionService;
- }
-
- /**
- * @param nameMatcher The nameMatcher to set.
- */
- public void setNameMatcher(NameMatcher nameMatcher)
- {
- this.nameMatcher = nameMatcher;
- }
-
- /**
- * @return nameMatcher
- */
- protected NameMatcher getNameMatcher()
- {
- //check for null for cluster environment
- if (nameMatcher == null)
- {
- nameMatcher = (NameMatcher) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "globalPathExcluder");
- }
- return nameMatcher;
- }
-
-
/**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
*/
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
- String webapp = this.avmBrowseBean.getWebapp();
- String userStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getSandbox(), webapp);
- String stagingStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getStagingStore(), webapp);
-
- // calcluate the list of differences between the user store and the staging area
- List diffs = this.getAvmSyncService().compare(
- -1, userStore, -1, stagingStore, getNameMatcher());
-
- List> versionPaths = new ArrayList>();
-
- List tasks = null;
- for (AVMDifference diff : diffs)
- {
- AVMNodeDescriptor node = getAvmService().lookup(-1, diff.getSourcePath(), true);
- if (tasks == null)
- {
- tasks = AVMWorkflowUtil.getAssociatedTasksForSandbox(AVMUtil.getStoreName(diff.getSourcePath()));
- }
- if (AVMWorkflowUtil.getAssociatedTasksForNode(node, tasks).size() == 0)
- {
- String revertPath = diff.getSourcePath();
- versionPaths.add(new Pair(-1, revertPath) );
-
- if ( (this.virtUpdatePath == null) &&
- VirtServerUtils.requiresUpdateNotification(revertPath) )
- {
- this.virtUpdatePath = revertPath;
- }
- }
- }
-
- Map args = new HashMap(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_REVERTALL_SUCCESS), this.avmBrowseBean.getUsername());
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
@@ -208,22 +88,6 @@ public class RevertAllDialog 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
diff --git a/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java b/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java
index 7aeb466f4a..f8e2a3350a 100644
--- a/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java
+++ b/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java
@@ -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 selected = this.avmBrowseBean.getSelectedSandboxItems();
- List> versionPaths = new ArrayList>();
-
- List 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(-1, revertPath));
-
- if ( (this.virtUpdatePath == null) &&
- VirtServerUtils.requiresUpdateNotification(revertPath) )
- {
- this.virtUpdatePath = revertPath;
- }
- }
- }
-
- Map args = new HashMap(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
diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java
index e1f13619f8..26d1ebd9fb 100644
--- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java
+++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java
@@ -43,10 +43,8 @@ import org.alfresco.config.JNDIConstants;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.model.WCMWorkflowModel;
-import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
@@ -68,9 +66,9 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.ISO8601DateFormat;
import org.alfresco.util.NameMatcher;
-import org.alfresco.util.VirtServerUtils;
import org.alfresco.wcm.sandbox.SandboxFactory;
import org.alfresco.wcm.sandbox.SandboxInfo;
+import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.app.servlet.FacesHelper;
@@ -138,6 +136,7 @@ public class SubmitDialog extends BaseDialogBean
transient private AVMLockingService avmLockingService;
transient private FormsService formsService;
transient private SandboxFactory sandboxFactory;
+ transient private SandboxService sandboxService;
transient private NameMatcher nameMatcher;
@@ -260,6 +259,20 @@ public class SubmitDialog extends BaseDialogBean
}
return formsService;
}
+
+ public void setSandboxService(final SandboxService sandboxService)
+ {
+ this.sandboxService = sandboxService;
+ }
+
+ protected SandboxService getSandboxService()
+ {
+ if (sandboxService == null)
+ {
+ sandboxService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSandboxService();
+ }
+ return sandboxService;
+ }
// TODO - refactor ... push down into sandbox service (submit to workflow)
public void setSandboxFactory(final SandboxFactory sandboxFactory)
@@ -351,12 +364,6 @@ public class SubmitDialog extends BaseDialogBean
{
// if there's no workflow submit changes directly to staging
outcome = submitDirectToStaging(context);
-
- // force an update of the virt server if necessary
- if (this.virtUpdatePath != null)
- {
- AVMUtil.updateVServerWebapp(this.virtUpdatePath, true);
- }
}
}
finally
@@ -489,54 +496,20 @@ public class SubmitDialog extends BaseDialogBean
{
// direct submit to the staging area without workflow
List items = getSubmitItems();
-
- // construct diffs for selected items for submission
- final String sandboxPath = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getSandbox());
- final String stagingPath = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getStagingStore());
- final List diffs = new ArrayList(items.size());
- final String submitLabel = this.label;
- final String submitComment = this.comment;
- String storeId = this.avmBrowseBean.getWebProject().getStoreId();
+ List nodes = new ArrayList(items.size());
+
for (ItemWrapper wrapper : items)
{
- String srcPath = sandboxPath + wrapper.getPath();
- String destPath = stagingPath + wrapper.getPath();
- AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER);
- diffs.add(diff);
-
- // process the expiration date (if any)
- processExpirationDate(srcPath);
-
- // recursively remove locks from this item
- recursivelyRemoveLocks(storeId, -1, getAvmService().lookup(-1, srcPath, true), srcPath);
-
- // If nothing has required notifying the virtualization server
- // so far, check to see if destPath forces a notification
- // (e.g.: it might be a path to a jar file within WEB-INF/lib).
- if ( (this.virtUpdatePath == null) &&
- VirtServerUtils.requiresUpdateNotification( destPath ) )
- {
- this.virtUpdatePath = destPath;
- }
+ nodes.add(wrapper.getDescriptor());
}
- // write changes to layer so files are marked as modified
-
-
- // Submit is done as system as the staging store is read only
- // We could add support to runIgnoringStoreACls
- AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork