From 89e06d4afdb4e592d636794ef08ed240803035a8 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Tue, 2 Jan 2007 12:24:23 +0000 Subject: [PATCH] . Fixed bug in Create Form Wizard - you can now create Forms again for a website. . Code cleanup and added missing javadocs for some methods in AVMConstants git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4705 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/web/bean/wcm/AVMBrowseBean.java | 9 +- .../alfresco/web/bean/wcm/AVMConstants.java | 149 ++++++++++++++---- .../web/bean/wcm/CreateFormWizard.java | 2 +- .../alfresco/web/bean/wcm/SandboxFactory.java | 12 +- 4 files changed, 130 insertions(+), 42 deletions(-) diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index 6516b4096c..38e667ba97 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -33,7 +33,6 @@ import javax.faces.event.ActionEvent; import javax.faces.model.SelectItem; import javax.transaction.UserTransaction; -import org.alfresco.model.WCMAppModel; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.actions.AVMRevertStoreAction; import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction; @@ -43,12 +42,9 @@ 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.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.namespace.QName; -import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.util.Pair; import org.alfresco.web.app.Application; import org.alfresco.web.app.context.IContextListener; @@ -802,17 +798,16 @@ public class AVMBrowseBean implements IContextListener String storeName = AVMConstants.getStoreName(path); final String storeId = AVMConstants.getStoreId(storeName); final String username = AVMConstants.getUserName(storeName); - final boolean preview = AVMConstants.isPreviewStore(storeName); if (username == null) { - storeName = (preview + storeName = (AVMConstants.isPreviewStore(storeName) ? AVMConstants.buildStagingPreviewStoreName(storeId) : AVMConstants.buildStagingStoreName(storeId)); setupSandboxActionImpl(storeName, null, false); } else { - storeName = (preview + storeName = (AVMConstants.isPreviewStore(storeName) ? AVMConstants.buildUserPreviewStoreName(storeId, username) : AVMConstants.buildUserMainStoreName(storeId, username)); setupSandboxActionImpl(storeName, username, false); diff --git a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java index 59bab2f60b..3f669924e7 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java @@ -28,11 +28,10 @@ import org.alfresco.config.JNDIConstants; import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.avm.AVMNotFoundException; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.namespace.QName; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.util.ParameterCheck; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.config.ClientConfigElement; @@ -40,6 +39,8 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.jsf.FacesContextUtils; /** + * Helper methods and constants related to AVM directories, paths and store name manipulation. + * * @author Ariel Backenroth * @author Kevin Roast */ @@ -81,7 +82,8 @@ public final class AVMConstants /** * Extracts the store name from the avmpath * - * @param avmPath an absolute avm pth + * @param avmPath an absolute avm path + * * @return the store name */ public static String getStoreName(final String avmPath) @@ -98,6 +100,7 @@ public final class AVMConstants * Indicates whether the store name describes a preview store. * * @param storeName the store name + * * @return true if the store is a preview store, false otherwise. */ public static boolean isPreviewStore(final String storeName) @@ -105,6 +108,13 @@ public final class AVMConstants return storeName.endsWith(AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW); } + /** + * Indicates whether the store name describes a workflow store. + * + * @param storeName the store name + * + * @return true if the store is a workflow store, false otherwise. + */ public static boolean isWorkflowStore(String storeName) { if (AVMConstants.isPreviewStore(storeName)) @@ -119,6 +129,7 @@ public final class AVMConstants * Indicates whether the store name describes a user store. * * @param storeName the store name + * * @return true if the store is a user store, false otherwise. */ public static boolean isUserStore(String storeName) @@ -134,6 +145,7 @@ public final class AVMConstants * Extracts the username from the store name. * * @param storeName the store name + * * @return the username associated or null if this is a staging store. */ public static String getUserName(String storeName) @@ -152,6 +164,7 @@ public final class AVMConstants * Extracts the store id from the store name. * * @param storeName the store name. + * * @return the store id. */ public static String getStoreId(final String storeName) @@ -166,7 +179,9 @@ public final class AVMConstants * Returns the corresponding main store name if this is a preview store name. * * @param storeName the preview store name. + * * @return the corresponding main store name. + * * @exception IllegalArgumentException if this is not a preview store name. */ public static String getCorrespondingMainStoreName(final String storeName) @@ -184,7 +199,9 @@ public final class AVMConstants * Returns the corresponding preview store name if this is a main store name. * * @param storeName the main store name. + * * @return the corresponding preview store name. + * * @exception IllegalArgumentException if this is not a main store name. */ public static String getCorrespondingPreviewStoreName(final String storeName) @@ -201,7 +218,9 @@ public final class AVMConstants * a main store. * * @param avmPath an avm path within the main store. + * * @return the corresponding path within the preview store. + * * @exception IllegalArgumentException if this is not a path within the preview store. */ public static String getCorrespondingPathInMainStore(final String avmPath) @@ -216,7 +235,9 @@ public final class AVMConstants * a main store. * * @param avmPath an avm path within the main store. + * * @return the corresponding path within the preview store. + * * @exception IllegalArgumentException if this is not a path within the preview store. */ public static String getCorrespondingPathInPreviewStore(final String avmPath) @@ -226,11 +247,26 @@ public final class AVMConstants return AVMConstants.getCorrespondingPath(avmPath, storeName); } + /** + * Returns the corresponding path in the store provided. + * + * @param avmPath an avm path + * @param otherStore the other store to return the corresponding path for + * + * @return the corresponding path within the supplied store + */ public static String getCorrespondingPath(final String avmPath, final String otherStore) { return (otherStore + ':' + AVMConstants.getStoreRelativePath(avmPath)); } + /** + * Returns the main staging store name for the specified store id. + * + * @param storeId store id to build staging store name for + * + * @return main staging store name for the specified store id + */ public static String buildStagingStoreName(final String storeId) { if (storeId == null || storeId.length() == 0) @@ -240,14 +276,29 @@ public final class AVMConstants return storeId; } + /** + * Returns the preview store name for the specified store id. + * + * @param storeId store id to build preview store name for + * + * @return preview store name for the specified store id + */ public static String buildStagingPreviewStoreName(final String storeId) { return (AVMConstants.buildStagingStoreName(storeId) + AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW); } + /** + * Returns the main store name for a specific username. + * + * @param storeId store id to build user store name for + * @param username of the user to build store name for + * + * @return the main store for the specified user and store id + */ public static String buildUserMainStoreName(final String storeId, - final String username) + final String username) { if (username == null || username.length() == 0) { @@ -257,15 +308,31 @@ public final class AVMConstants username); } + /** + * Returns the preview store name for a specific username. + * + * @param storeId store id to build user preview store name for + * @param username of the user to build preview store name for + * + * @return the preview store for the specified user and store id + */ public static String buildUserPreviewStoreName(final String storeId, - final String username) + final String username) { return (AVMConstants.buildUserMainStoreName(storeId, username) + AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW); } + /** + * Returns the store name for a specific workflow Id. + * + * @param storeId store id to build workflow store name for + * @param workflowId of the user to build workflow store name for + * + * @return the store for the specified workflow and store ids + */ public static String buildWorkflowMainStoreName(final String storeId, - final String workflowId) + final String workflowId) { if (workflowId == null || workflowId.length() == 0) { @@ -275,13 +342,28 @@ public final class AVMConstants workflowId); } + /** + * Returns the preview store name for a specific workflow Id. + * + * @param storeId store id to build preview workflow store name for + * @param workflowId of the user to build preview workflow store name for + * + * @return the store for the specified preview workflow and store ids + */ public static String buildWorkflowPreviewStoreName(final String storeId, - final String workflowId) + final String workflowId) { return (AVMConstants.buildWorkflowMainStoreName(storeId, workflowId) + AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW); } + /** + * Returns the root path for the specified store name + * + * @param storeName store to build root path for + * + * @return root path for the specified store name + */ public static String buildStoreRootPath(final String storeName) { if (storeName == null || storeName.length() == 0) @@ -291,11 +373,26 @@ public final class AVMConstants return storeName + ":/" + JNDIConstants.DIR_DEFAULT_WWW; } + /** + * Returns the root path for the specified sandbox name + * + * @param storeName store to build root sandbox path for + * + * @return root sandbox path for the specified store name + */ public static String buildSandboxRootPath(final String storeName) { return AVMConstants.buildStoreRootPath(storeName) + '/' + JNDIConstants.DIR_DEFAULT_APPBASE; } + /** + * Returns the root webapp path for the specified store and webapp name + * + * @param storeName store to build root webapp path for + * @param webapp webapp folder name + * + * @return the root webapp path for the specified store and webapp name + */ public static String buildStoreWebappPath(final String storeName, String webapp) { if (webapp == null || webapp.length() == 0) @@ -421,8 +518,7 @@ public final class AVMConstants final PathRelation relation) { String parent = parentAVMPath; - if (path == null || path.length() == 0 || - ".".equals(path) || "./".equals(path)) + if (path == null || path.length() == 0 || ".".equals(path) || "./".equals(path)) { return parent; } @@ -627,12 +723,13 @@ public final class AVMConstants return (VirtServerRegistry)ac.getBean(BEAN_VIRT_SERVER_REGISTRY); } + // Component Separator. private static final String STORE_SEPARATOR = "--"; // names of the stores representing the layers for an AVM website //XXXarielb this should be private - public final static String STORE_WORKFLOW = "workflow"; + /*package*/ final static String STORE_WORKFLOW = "workflow"; private final static String STORE_PREVIEW = "preview"; // servlet default webapp @@ -641,22 +738,16 @@ public final class AVMConstants // system property keys for sandbox identification and DNS virtualisation mapping public final static String PROP_SANDBOXID = ".sandbox-id."; - public final static QName PROP_SANDBOX_STAGING_MAIN = - QName.createQName(null, ".sandbox.staging.main"); - public final static QName PROP_SANDBOX_STAGING_PREVIEW = - QName.createQName(null, ".sandbox.staging.preview"); - public final static QName PROP_SANDBOX_AUTHOR_MAIN = - QName.createQName(null, ".sandbox.author.main"); - public final static QName PROP_SANDBOX_AUTHOR_PREVIEW = - QName.createQName(null, ".sandbox.author.preview"); - public final static QName PROP_SANDBOX_WORKFLOW_MAIN = - QName.createQName(null, ".sandbox.workflow.main"); - public final static QName PROP_SANDBOX_WORKFLOW_PREVIEW = - QName.createQName(null, ".sandbox.workflow.preview"); public final static String PROP_DNS = ".dns."; - public final static QName PROP_WEBSITE_NAME = - QName.createQName(null, ".website.name"); public final static String PROP_SANDBOX_STORE_PREFIX = ".sandbox.store."; + public final static QName PROP_SANDBOX_STAGING_MAIN = QName.createQName(null, ".sandbox.staging.main"); + public final static QName PROP_SANDBOX_STAGING_PREVIEW = QName.createQName(null, ".sandbox.staging.preview"); + public final static QName PROP_SANDBOX_AUTHOR_MAIN = QName.createQName(null, ".sandbox.author.main"); + public final static QName PROP_SANDBOX_AUTHOR_PREVIEW = QName.createQName(null, ".sandbox.author.preview"); + public final static QName PROP_SANDBOX_WORKFLOW_MAIN = QName.createQName(null, ".sandbox.workflow.main"); + public final static QName PROP_SANDBOX_WORKFLOW_PREVIEW = QName.createQName(null, ".sandbox.workflow.preview"); + public final static QName PROP_WEBSITE_NAME = QName.createQName(null, ".website.name"); + public final static String SPACE_ICON_WEBSITE = "space-icon-website"; // virtualisation server MBean registry @@ -669,17 +760,19 @@ public final class AVMConstants // pattern for absolute AVM Path private final static Pattern STORE_RELATIVE_PATH_PATTERN = Pattern.compile("[^:]+:(.+)"); + private final static Pattern WEBAPP_RELATIVE_PATH_PATTERN = Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW + "/" + JNDIConstants.DIR_DEFAULT_APPBASE + "/([^/]+))(.*)"); + private final static Pattern SANDBOX_RELATIVE_PATH_PATTERN = Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW + "/" + JNDIConstants.DIR_DEFAULT_APPBASE + ")(.*)"); // patterns for WEB-INF files that require virtualisation server reload private final static Pattern WEB_INF_PATH_PATTERN = - Pattern.compile(".*:/" + JNDIConstants.DIR_DEFAULT_WWW + - "/" + JNDIConstants.DIR_DEFAULT_APPBASE + "/" + - ".*/WEB-INF/((classes/.*)|(lib/.*)|(web.xml))", - Pattern.CASE_INSENSITIVE); + Pattern.compile(".*:/" + JNDIConstants.DIR_DEFAULT_WWW + + "/" + JNDIConstants.DIR_DEFAULT_APPBASE + "/" + + ".*/WEB-INF/((classes/.*)|(lib/.*)|(web.xml))", + Pattern.CASE_INSENSITIVE); } diff --git a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java index e84a17e7a6..61b2de966d 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java @@ -256,7 +256,7 @@ public class CreateFormWizard if (this.applyDefaultWorkflow) { props.clear(); - props.put(WCMAppModel.PROP_WORKFLOW_NAME, this.getDefaultWorkflowName()); + props.put(WCMAppModel.PROP_WORKFLOW_NAME, this.getDefaultWorkflowName()[0]); this.nodeService.createNode(folderInfo.getNodeRef(), WCMAppModel.ASSOC_FORM_WORKFLOW_DEFAULTS, WCMAppModel.ASSOC_FORM_WORKFLOW_DEFAULTS, diff --git a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java index da213313e6..38961629c0 100644 --- a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java +++ b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java @@ -153,7 +153,7 @@ public final class SandboxFactory * Create a user sandbox for the named store. * * A user sandbox is comprised of two stores, the first - * named 'storename---username' layered over the staging store with a preview store + * named 'storename--username' layered over the staging store with a preview store * named 'storename--username--preview' layered over the main store. * * Various store meta-data properties are set including: @@ -230,7 +230,7 @@ public final class SandboxFactory // snapshot the store avmService.createSnapshot(userStoreName, null, null); - + // create the user 'preview' store avmService.createStore(previewStoreName); if (logger.isDebugEnabled()) @@ -263,8 +263,8 @@ public final class SandboxFactory // snapshot the store avmService.createSnapshot(previewStoreName, null, null); - - + + // tag all related stores to indicate that they are part of a single sandbox QName sandboxIdProp = QName.createQName(null, AVMConstants.PROP_SANDBOXID + GUID.generate()); avmService.setStoreProperty(userStoreName, @@ -273,7 +273,7 @@ public final class SandboxFactory avmService.setStoreProperty(previewStoreName, sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null)); - + if (logger.isDebugEnabled()) { dumpStoreProperties(avmService, userStoreName); @@ -286,7 +286,7 @@ public final class SandboxFactory * Create a user sandbox for the named store. * * A user sandbox is comprised of two stores, the first - * named 'storename---username' layered over the staging store with a preview store + * named 'storename--username' layered over the staging store with a preview store * named 'storename--username--preview' layered over the main store. * * Various store meta-data properties are set including: