diff --git a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java index 778e5afe04..8d5d95867b 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java @@ -72,9 +72,9 @@ public class AVMWorkflowUtil extends WorkflowUtil final NodeService nodeService) { // create package paths (layered to user sandbox area as target) - final String packageName = SandboxFactory.createWorkflowSandbox(storeId); - final String workflowMainStoreName = - AVMConstants.buildWorkflowMainStoreName(storeId, packageName); + + SandboxInfo sandboxInfo = SandboxFactory.createWorkflowSandbox(storeId); + final String workflowMainStoreName = sandboxInfo.getMainStoreName(); final String packagesPath = AVMConstants.buildStoreRootPath(workflowMainStoreName); final List diffs = new ArrayList(srcPaths.size()); diff --git a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java index f7a8d257b3..5b5739a9b2 100644 --- a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java @@ -20,6 +20,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -150,14 +151,18 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard } // build the sandboxes now we have the manager list and complete user list + List sandboxInfoList = new LinkedList(); + for (UserGroupRole userRole : this.userGroupRoles) { String authority = userRole.getAuthority(); if (excludeUsers.contains(authority) == false) { - SandboxFactory.createUserSandbox( + SandboxInfo info = + SandboxFactory.createUserSandbox( getAvmStore(), this.managers, userRole.getAuthority(), userRole.getRole()); + sandboxInfoList.add( info ); } } @@ -179,12 +184,20 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard } } - // reload virtualisation server for the web project + // reload virtualisation server for webapp in this web project if (isStandalone()) { - String stagingStore = AVMConstants.buildStagingStoreName(getAvmStore()); - String path = AVMConstants.buildStoreWebappPath(stagingStore, this.avmBrowseBean.getWebapp()); - AVMConstants.updateVServerWebapp(path, true); + for (SandboxInfo sandboxInfo : sandboxInfoList ) + { + String newlyInvitedStoreName = + AVMConstants.buildStagingStoreName( sandboxInfo.getMainStoreName() ); + + String path = + AVMConstants.buildStoreWebappPath( newlyInvitedStoreName, + this.avmBrowseBean.getWebapp()); + + AVMConstants.updateVServerWebapp(path, true); + } } return outcome; diff --git a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java index edc68bd457..da213313e6 100644 --- a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java +++ b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java @@ -67,7 +67,7 @@ public final class SandboxFactory * @param storeId The store name to create the sandbox for * @param managers The list of authorities who have ContentManager role in the website */ - public static void createStagingSandbox(final String storeId, final List managers) + public static SandboxInfo createStagingSandbox(final String storeId, final List managers) { final ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance()); final AVMService avmService = services.getAVMService(); @@ -145,6 +145,8 @@ public final class SandboxFactory dumpStoreProperties(avmService, stagingStoreName); dumpStoreProperties(avmService, previewStoreName); } + + return new SandboxInfo( new String[] { stagingStoreName, previewStoreName } ); } /** @@ -164,25 +166,28 @@ public final class SandboxFactory * @param managers The list of authorities who have ContentManager role in the website * @param username Username of the user to create the sandbox for * @param role Role permission for the user + * @return Summary information regarding the sandbox */ - public static void createUserSandbox(final String storeId, - final List managers, - final String username, - final String role) + public static SandboxInfo createUserSandbox(final String storeId, + final List managers, + final String username, + final String role) { final ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance()); final AVMService avmService = services.getAVMService(); final PermissionService permissionService = services.getPermissionService(); // create the user 'main' store - final String userStoreName = AVMConstants.buildUserMainStoreName(storeId, username); + final String userStoreName = AVMConstants.buildUserMainStoreName(storeId, username); + final String previewStoreName = AVMConstants.buildUserPreviewStoreName(storeId, username); + if (avmService.getStore(userStoreName) != null) { if (logger.isDebugEnabled()) { logger.debug("Not creating as store already exists: " + userStoreName); } - return; + return new SandboxInfo( new String[] { userStoreName, previewStoreName } ); } avmService.createStore(userStoreName); @@ -227,7 +232,6 @@ public final class SandboxFactory // create the user 'preview' store - String previewStoreName = AVMConstants.buildUserPreviewStoreName(storeId, username); avmService.createStore(previewStoreName); if (logger.isDebugEnabled()) logger.debug("Created user preview sandbox store: " + previewStoreName + @@ -275,6 +279,7 @@ public final class SandboxFactory dumpStoreProperties(avmService, userStoreName); dumpStoreProperties(avmService, previewStoreName); } + return new SandboxInfo( new String[] { userStoreName, previewStoreName } ); } /** @@ -295,7 +300,7 @@ public final class SandboxFactory * @param username Username of the user to create the sandbox for * @param role Role permission for the user */ - public static String createWorkflowSandbox(final String storeId) + public static SandboxInfo createWorkflowSandbox(final String storeId) { final ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance()); final AVMService avmService = services.getAVMService(); @@ -305,86 +310,86 @@ public final class SandboxFactory // create the user 'main' store final String packageName = AVMConstants.STORE_WORKFLOW + "-" + GUID.generate(); - final String workflowMainStoreName = + final String mainStoreName = AVMConstants.buildWorkflowMainStoreName(storeId, packageName); - avmService.createStore(workflowMainStoreName); + avmService.createStore(mainStoreName); if (logger.isDebugEnabled()) - logger.debug("Created workflow sandbox store: " + workflowMainStoreName); + logger.debug("Created workflow sandbox store: " + mainStoreName); // create a layered directory pointing to 'www' in the staging area avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), - workflowMainStoreName + ":/", + mainStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); // tag the store with the store type - avmService.setStoreProperty(workflowMainStoreName, + avmService.setStoreProperty(mainStoreName, AVMConstants.PROP_SANDBOX_WORKFLOW_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with the base name of the website so that corresponding // staging areas can be found. - avmService.setStoreProperty(workflowMainStoreName, + avmService.setStoreProperty(mainStoreName, AVMConstants.PROP_WEBSITE_NAME, new PropertyValue(DataTypeDefinition.TEXT, storeId)); // tag the store, oddly enough, with its own store name for querying. // when will the madness end. - avmService.setStoreProperty(workflowMainStoreName, - QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + workflowMainStoreName), + avmService.setStoreProperty(mainStoreName, + QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + mainStoreName), new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with the DNS name property - tagStoreDNSPath(avmService, workflowMainStoreName, storeId, packageName); + tagStoreDNSPath(avmService, mainStoreName, storeId, packageName); // snapshot the store - avmService.createSnapshot(workflowMainStoreName, null, null); + avmService.createSnapshot(mainStoreName, null, null); // create the user 'preview' store - final String workflowPreviewStoreName = + final String previewStoreName = AVMConstants.buildWorkflowPreviewStoreName(storeId, packageName); - avmService.createStore(workflowPreviewStoreName); + avmService.createStore(previewStoreName); if (logger.isDebugEnabled()) - logger.debug("Created user sandbox preview store: " + workflowPreviewStoreName); + logger.debug("Created user sandbox preview store: " + previewStoreName); // create a layered directory pointing to 'www' in the user 'main' store - avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(workflowMainStoreName), - workflowPreviewStoreName + ":/", + avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(mainStoreName), + previewStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); // tag the store with the store type - avmService.setStoreProperty(workflowPreviewStoreName, + avmService.setStoreProperty(previewStoreName, AVMConstants.PROP_SANDBOX_WORKFLOW_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with its own store name for querying. - avmService.setStoreProperty(workflowPreviewStoreName, + avmService.setStoreProperty(previewStoreName, QName.createQName(null, - AVMConstants.PROP_SANDBOX_STORE_PREFIX + workflowPreviewStoreName), + AVMConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with the DNS name property - tagStoreDNSPath(avmService, workflowPreviewStoreName, storeId, packageName, "preview"); + tagStoreDNSPath(avmService, previewStoreName, storeId, packageName, "preview"); // snapshot the store - avmService.createSnapshot(workflowPreviewStoreName, null, null); + avmService.createSnapshot(previewStoreName, null, null); // tag all related stores to indicate that they are part of a single sandbox final QName sandboxIdProp = QName.createQName(AVMConstants.PROP_SANDBOXID + GUID.generate()); - avmService.setStoreProperty(workflowMainStoreName, + avmService.setStoreProperty(mainStoreName, sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null)); - avmService.setStoreProperty(workflowPreviewStoreName, + avmService.setStoreProperty(previewStoreName, sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null)); if (logger.isDebugEnabled()) { - dumpStoreProperties(avmService, workflowMainStoreName); - dumpStoreProperties(avmService, workflowPreviewStoreName); + dumpStoreProperties(avmService, mainStoreName); + dumpStoreProperties(avmService, previewStoreName); } - return packageName; + return new SandboxInfo( new String[] { mainStoreName, previewStoreName } ); } /** diff --git a/source/java/org/alfresco/web/bean/wcm/SandboxInfo.java b/source/java/org/alfresco/web/bean/wcm/SandboxInfo.java new file mode 100644 index 0000000000..4d021dc595 --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/SandboxInfo.java @@ -0,0 +1,50 @@ +/*----------------------------------------------------------------------------- +* Copyright 2007 Alfresco Inc. +* +* Licensed under the Mozilla Public License version 1.1 +* with a permitted attribution clause. You may obtain a +* copy of the License at: +* +* http://www.alfresco.org/legal/license.txt +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +* either express or implied. See the License for the specific +* language governing permissions and limitations under the +* License. +* +* +* Author Jon Cox +* File SandboxInfo.java +*----------------------------------------------------------------------------*/ + +package org.alfresco.web.bean.wcm; + +/** +* Provides information about a sandbox created by SandboxFactory. +*/ +public final class SandboxInfo +{ + String [] store_names_; + public SandboxInfo(String [] store_names) + { + store_names_ = store_names; + } + + /** + * A list of names of the stores within this sandbox. + * The "main" store should come first in this list; + * any other stores should appear in the order that + * they are overlaid on "main" (e.g.: any "preview" + * layers should come afterward, in "lowest first" order). + *

+ * Note: all sandboxes must have a "main" layer. + */ + public String [] getStoreNames() { return store_names_; } + + /** + * The name of the "main" store within this sandbox. + */ + public String getMainStoreName() { return store_names_[0]; } +}