From 21a73db5bda34f4976b37a42d24dae562eff94b7 Mon Sep 17 00:00:00 2001 From: Jon Cox Date: Mon, 25 Dec 2006 02:07:46 +0000 Subject: [PATCH] Fixed up paths a bit more so that now you get files paths like this: mysite--guest--preview/HEAD/DATA/www/avm_webapps/ROOT/WEB-INF/... and: mysite--guest--preview/VERSION/v1/DATA/www/avm_webapps/ROOT/WEB-INF/... rather than: mysite--guest--preview/HEAD/DATA/appBase/avm_webapps/ROOT/WEB-INF/... and: mysite--guest--preview/VERSION/v1/DATA/appBase/avm_webapps/ROOT/WEB-INF/... The reason for this is that the actual "appliation base" is and always has been "avm_webapps"; the original reason for making the *parent* of this dir called appBase had do do with the fact that you can have diffrent app bases for different virtual hosts. However, in the end it causes way more confusion than it was ever worth, so it's gone now. The reason for all the modified files is that people were hard-coding values in many different places, and/or defining their own constants for something that was needed at a higher level. As a temporary measure (I hope), I've defined some rather ugly-looking constants in JNDIConstants.java, and have used them everywhere: DIR_DEFAULT_WWW = "www" DIR_DEFAULT_APPBASE = "avm_webapps" The reason for calling the parent of the new application base "www" is that will be the default place that www-centric stuff happens (therefore, it's also the level at which the overlays take place). Ultimately, I'd like to turn these into spring configs, and bring back support for multiple AVMHost nodes within the same Tomcat... but it's not a priority at the moment. Please don't hard-code any dirs named "appBase" as the root level dir in a repo -- it's now "www", and will change again to a function call later when/if virtual AVMHosts come back. Keeping them as constants also helps them to be easier to find when overhauling things. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4696 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/web/bean/wcm/AVMConstants.java | 48 ++++++++++--------- .../alfresco/web/bean/wcm/SandboxFactory.java | 32 ++++++------- .../alfresco/web/bean/wcm/SubmitDialog.java | 3 +- ...ervletContextFormDataFunctionsAdapter.java | 8 ++-- 4 files changed, 47 insertions(+), 44 deletions(-) diff --git a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java index ab4a805ef4..f407840a9c 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java @@ -23,11 +23,12 @@ import java.util.regex.Pattern; import javax.faces.context.FacesContext; +import org.alfresco.config.JNDIConstants; import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.service.ServiceRegistry; 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; @@ -283,12 +284,12 @@ public final class AVMConstants { throw new IllegalArgumentException("Store name is mandatory."); } - return storeName + ":/" + DIR_APPBASE; + return storeName + ":/" + JNDIConstants.DIR_DEFAULT_WWW; } public static String buildSandboxRootPath(final String storeName) { - return AVMConstants.buildStoreRootPath(storeName) + '/' + DIR_WEBAPPS; + return AVMConstants.buildStoreRootPath(storeName) + '/' + JNDIConstants.DIR_DEFAULT_APPBASE; } public static String buildStoreWebappPath(final String storeName, String webapp) @@ -367,9 +368,9 @@ public final class AVMConstants { throw new IllegalArgumentException("Asset path is mandatory."); } - if (assetPath.startsWith('/' + DIR_APPBASE + '/' + DIR_WEBAPPS)) + if (assetPath.startsWith( '/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + JNDIConstants.DIR_DEFAULT_APPBASE )) { - assetPath = assetPath.substring(('/' + DIR_APPBASE + '/' + DIR_WEBAPPS).length()); + assetPath = assetPath.substring(('/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + JNDIConstants.DIR_DEFAULT_APPBASE ).length()); } if (assetPath.startsWith('/' + DIR_ROOT)) { @@ -541,7 +542,11 @@ public final class AVMConstants if (force || requiresVServerUpdate(path)) { VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry(); - int webappIndex = path.indexOf('/', path.indexOf(DIR_WEBAPPS) + DIR_WEBAPPS.length() + 1); + + int webappIndex = path.indexOf( '/', + path.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE) + + JNDIConstants.DIR_DEFAULT_APPBASE.length() + 1); + if (webappIndex != -1) { path = path.substring(0, webappIndex); @@ -562,7 +567,9 @@ public final class AVMConstants { VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry(); - int webappIndex = path.indexOf('/', path.indexOf(DIR_WEBAPPS) + DIR_WEBAPPS.length() + 1); + int webappIndex = path.indexOf( '/', path.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE) + + JNDIConstants.DIR_DEFAULT_APPBASE.length() + 1); + if (webappIndex != -1) { path = path.substring(0, webappIndex); @@ -586,14 +593,6 @@ public final class AVMConstants public final static String STORE_WORKFLOW = "workflow"; private final static String STORE_PREVIEW = "preview"; - // system directories at the top level of an AVM website - // - // TODO: The virtualization server should get these two parameters - // from the Alfresco webapp at registration time. - // - public final static String DIR_APPBASE = "appBase"; - public final static String DIR_WEBAPPS = "avm_webapps"; - // servlet default webapp // Note: this webapp is mapped to the URL path "" public final static String DIR_ROOT = "ROOT"; @@ -629,15 +628,18 @@ public final class AVMConstants private final static Pattern STORE_RELATIVE_PATH_PATTERN = Pattern.compile("[^:]+:(.+)"); private final static Pattern WEBAPP_RELATIVE_PATH_PATTERN = - Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE + - "/" + AVMConstants.DIR_WEBAPPS + "/([^/]+))(.*)"); + Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW + + "/" + JNDIConstants.DIR_DEFAULT_APPBASE + "/([^/]+))(.*)"); private final static Pattern SANDBOX_RELATIVE_PATH_PATTERN = - Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE + - "/" + AVMConstants.DIR_WEBAPPS + ")(.*)"); + 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( - ".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS + - "/.*/WEB-INF/((classes/.*)|(lib/.*)|(web.xml))", - Pattern.CASE_INSENSITIVE); + 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 + ); } diff --git a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java index c641c5d3a6..edc68bd457 100644 --- a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java +++ b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java @@ -20,15 +20,15 @@ import java.util.List; import java.util.Map; import javax.faces.context.FacesContext; - +import org.alfresco.config.JNDIConstants; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.domain.PropertyValue; -import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.QName; +import org.alfresco.service.ServiceRegistry; import org.alfresco.util.GUID; import org.alfresco.web.bean.repository.Repository; import org.apache.commons.logging.Log; @@ -79,15 +79,15 @@ public final class SandboxFactory if (logger.isDebugEnabled()) logger.debug("Created staging sandbox store: " + stagingStoreName); - // create the system directories 'appBase' and 'avm_webapps' - avmService.createDirectory(stagingStoreName + ":/", AVMConstants.DIR_APPBASE); + // create the system directories 'www' and 'avm_webapps' + avmService.createDirectory(stagingStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(stagingStoreName)); for (String manager : managers) { permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true); } avmService.createDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), - AVMConstants.DIR_WEBAPPS); + JNDIConstants.DIR_DEFAULT_APPBASE); // tag the store with the store type avmService.setStoreProperty(stagingStoreName, @@ -108,11 +108,11 @@ public final class SandboxFactory logger.debug("Created staging preview sandbox store: " + previewStoreName + " above " + stagingStoreName); - // create a layered directory pointing to 'appBase' in the staging area + // create a layered directory pointing to 'www' in the staging area avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), previewStoreName + ":/", - AVMConstants.DIR_APPBASE); + JNDIConstants.DIR_DEFAULT_WWW); dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(previewStoreName)); for (String manager : managers) { @@ -191,10 +191,10 @@ public final class SandboxFactory logger.debug("Created user sandbox store: " + userStoreName + " above staging store " + stagingStoreName); - // create a layered directory pointing to 'appBase' in the staging area + // create a layered directory pointing to 'www' in the staging area avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), userStoreName + ":/", - AVMConstants.DIR_APPBASE); + JNDIConstants.DIR_DEFAULT_WWW); NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(userStoreName)); permissionService.setPermission(dirRef, username, role, true); for (String manager : managers) @@ -233,10 +233,10 @@ public final class SandboxFactory logger.debug("Created user preview sandbox store: " + previewStoreName + " above " + userStoreName); - // create a layered directory pointing to 'appBase' in the user 'main' store + // create a layered directory pointing to 'www' in the user 'main' store avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(userStoreName), previewStoreName + ":/", - AVMConstants.DIR_APPBASE); + JNDIConstants.DIR_DEFAULT_WWW); dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(previewStoreName)); permissionService.setPermission(dirRef, username, role, true); for (String manager : managers) @@ -312,10 +312,10 @@ public final class SandboxFactory if (logger.isDebugEnabled()) logger.debug("Created workflow sandbox store: " + workflowMainStoreName); - // create a layered directory pointing to 'appBase' in the staging area + // create a layered directory pointing to 'www' in the staging area avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), workflowMainStoreName + ":/", - AVMConstants.DIR_APPBASE); + JNDIConstants.DIR_DEFAULT_WWW); // tag the store with the store type avmService.setStoreProperty(workflowMainStoreName, @@ -347,10 +347,10 @@ public final class SandboxFactory if (logger.isDebugEnabled()) logger.debug("Created user sandbox preview store: " + workflowPreviewStoreName); - // create a layered directory pointing to 'appBase' in the user 'main' store + // create a layered directory pointing to 'www' in the user 'main' store avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(workflowMainStoreName), workflowPreviewStoreName + ":/", - AVMConstants.DIR_APPBASE); + JNDIConstants.DIR_DEFAULT_WWW); // tag the store with the store type avmService.setStoreProperty(workflowPreviewStoreName, @@ -389,7 +389,7 @@ public final class SandboxFactory /** * Tag a named store with a DNS path meta-data attribute. - * The DNS meta-data attribute is set to the system path 'store:/appBase/avm_webapps' + * The DNS meta-data attribute is set to the system path 'store:/www/avm_webapps' * * @param store Name of the store to tag */ diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java index 6c4a13d03a..ca38ad0b62 100644 --- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java @@ -30,6 +30,7 @@ import java.util.regex.Pattern; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; +import org.alfresco.config.JNDIConstants; import org.alfresco.model.ContentModel; import org.alfresco.model.WCMAppModel; import org.alfresco.repo.avm.AVMDAOs; @@ -720,7 +721,7 @@ public class SubmitDialog extends BaseDialogBean */ public class ItemWrapper { - private static final String rootPath = '/' + AVMConstants.DIR_WEBAPPS; + private static final String rootPath = '/' + JNDIConstants.DIR_DEFAULT_APPBASE; private AVMNodeDescriptor descriptor; public ItemWrapper(AVMNodeDescriptor descriptor) diff --git a/source/java/org/alfresco/web/forms/ServletContextFormDataFunctionsAdapter.java b/source/java/org/alfresco/web/forms/ServletContextFormDataFunctionsAdapter.java index 42ab1a9e89..f1f3c9790e 100644 --- a/source/java/org/alfresco/web/forms/ServletContextFormDataFunctionsAdapter.java +++ b/source/java/org/alfresco/web/forms/ServletContextFormDataFunctionsAdapter.java @@ -37,12 +37,12 @@ public class ServletContextFormDataFunctionsAdapter private String toAVMPath(String path) { - // The real_path will look somethign like this: - // /alfresco.avm/avm.alfresco.localhost/$-1$alfreco-guest-main:/appBase/avm_webapps/my_webapp + // The real_path will look something like this: + // /alfresco.avm/avm.alfresco.localhost/$-1$alfreco-guest-main:/www/avm_webapps/my_webapp path = this.servletContext.getRealPath(path); // The avm_path to the root of the context will look something like this: - // alfreco-guest-main:/appBase/avm_webapps/my_webapp + // alfreco-guest-main:/www/avm_webapps/my_webapp path = path.substring(path.indexOf('$', path.indexOf('$') + 1) + 1); path = path.replace('\\','/'); return path; @@ -62,4 +62,4 @@ public class ServletContextFormDataFunctionsAdapter { return super.parseXMLDocuments(formName, this.toAVMPath(path)); } -} \ No newline at end of file +}