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
This commit is contained in:
Jon Cox
2006-12-25 02:07:46 +00:00
parent df84dcde28
commit 21a73db5bd
4 changed files with 47 additions and 44 deletions

View File

@@ -23,11 +23,12 @@ import java.util.regex.Pattern;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import org.alfresco.config.JNDIConstants;
import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.mbeans.VirtServerRegistry;
import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.util.ParameterCheck; import org.alfresco.util.ParameterCheck;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
@@ -283,12 +284,12 @@ public final class AVMConstants
{ {
throw new IllegalArgumentException("Store name is mandatory."); throw new IllegalArgumentException("Store name is mandatory.");
} }
return storeName + ":/" + DIR_APPBASE; return storeName + ":/" + JNDIConstants.DIR_DEFAULT_WWW;
} }
public static String buildSandboxRootPath(final String storeName) 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) public static String buildStoreWebappPath(final String storeName, String webapp)
@@ -367,9 +368,9 @@ public final class AVMConstants
{ {
throw new IllegalArgumentException("Asset path is mandatory."); 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)) if (assetPath.startsWith('/' + DIR_ROOT))
{ {
@@ -541,7 +542,11 @@ public final class AVMConstants
if (force || requiresVServerUpdate(path)) if (force || requiresVServerUpdate(path))
{ {
VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry(); 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) if (webappIndex != -1)
{ {
path = path.substring(0, webappIndex); path = path.substring(0, webappIndex);
@@ -562,7 +567,9 @@ public final class AVMConstants
{ {
VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry(); 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) if (webappIndex != -1)
{ {
path = path.substring(0, webappIndex); path = path.substring(0, webappIndex);
@@ -586,14 +593,6 @@ public final class AVMConstants
public final static String STORE_WORKFLOW = "workflow"; public final static String STORE_WORKFLOW = "workflow";
private final static String STORE_PREVIEW = "preview"; 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 // servlet default webapp
// Note: this webapp is mapped to the URL path "" // Note: this webapp is mapped to the URL path ""
public final static String DIR_ROOT = "ROOT"; public final static String DIR_ROOT = "ROOT";
@@ -629,15 +628,18 @@ public final class AVMConstants
private final static Pattern STORE_RELATIVE_PATH_PATTERN = private final static Pattern STORE_RELATIVE_PATH_PATTERN =
Pattern.compile("[^:]+:(.+)"); Pattern.compile("[^:]+:(.+)");
private final static Pattern WEBAPP_RELATIVE_PATH_PATTERN = private final static Pattern WEBAPP_RELATIVE_PATH_PATTERN =
Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE + Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW +
"/" + AVMConstants.DIR_WEBAPPS + "/([^/]+))(.*)"); "/" + JNDIConstants.DIR_DEFAULT_APPBASE + "/([^/]+))(.*)");
private final static Pattern SANDBOX_RELATIVE_PATH_PATTERN = private final static Pattern SANDBOX_RELATIVE_PATH_PATTERN =
Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE + Pattern.compile("([^:]+:/" + JNDIConstants.DIR_DEFAULT_WWW +
"/" + AVMConstants.DIR_WEBAPPS + ")(.*)"); "/" + JNDIConstants.DIR_DEFAULT_APPBASE + ")(.*)");
// patterns for WEB-INF files that require virtualisation server reload // patterns for WEB-INF files that require virtualisation server reload
private final static Pattern WEB_INF_PATH_PATTERN = Pattern.compile( private final static Pattern WEB_INF_PATH_PATTERN =
".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS + Pattern.compile( ".*:/" +
"/.*/WEB-INF/((classes/.*)|(lib/.*)|(web.xml))", JNDIConstants.DIR_DEFAULT_WWW + "/" +
Pattern.CASE_INSENSITIVE); JNDIConstants.DIR_DEFAULT_APPBASE + "/" +
".*/WEB-INF/((classes/.*)|(lib/.*)|(web.xml))",
Pattern.CASE_INSENSITIVE
);
} }

View File

@@ -20,15 +20,15 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import org.alfresco.config.JNDIConstants;
import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.util.GUID; import org.alfresco.util.GUID;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -79,15 +79,15 @@ public final class SandboxFactory
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Created staging sandbox store: " + stagingStoreName); logger.debug("Created staging sandbox store: " + stagingStoreName);
// create the system directories 'appBase' and 'avm_webapps' // create the system directories 'www' and 'avm_webapps'
avmService.createDirectory(stagingStoreName + ":/", AVMConstants.DIR_APPBASE); avmService.createDirectory(stagingStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW);
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(stagingStoreName)); NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(stagingStoreName));
for (String manager : managers) for (String manager : managers)
{ {
permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true); permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
} }
avmService.createDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), avmService.createDirectory(AVMConstants.buildStoreRootPath(stagingStoreName),
AVMConstants.DIR_WEBAPPS); JNDIConstants.DIR_DEFAULT_APPBASE);
// tag the store with the store type // tag the store with the store type
avmService.setStoreProperty(stagingStoreName, avmService.setStoreProperty(stagingStoreName,
@@ -108,11 +108,11 @@ public final class SandboxFactory
logger.debug("Created staging preview sandbox store: " + previewStoreName + logger.debug("Created staging preview sandbox store: " + previewStoreName +
" above " + stagingStoreName); " 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), avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName),
previewStoreName + ":/", previewStoreName + ":/",
AVMConstants.DIR_APPBASE); JNDIConstants.DIR_DEFAULT_WWW);
dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(previewStoreName)); dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(previewStoreName));
for (String manager : managers) for (String manager : managers)
{ {
@@ -191,10 +191,10 @@ public final class SandboxFactory
logger.debug("Created user sandbox store: " + userStoreName + logger.debug("Created user sandbox store: " + userStoreName +
" above staging store " + stagingStoreName); " 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), avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName),
userStoreName + ":/", userStoreName + ":/",
AVMConstants.DIR_APPBASE); JNDIConstants.DIR_DEFAULT_WWW);
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(userStoreName)); NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(userStoreName));
permissionService.setPermission(dirRef, username, role, true); permissionService.setPermission(dirRef, username, role, true);
for (String manager : managers) for (String manager : managers)
@@ -233,10 +233,10 @@ public final class SandboxFactory
logger.debug("Created user preview sandbox store: " + previewStoreName + logger.debug("Created user preview sandbox store: " + previewStoreName +
" above " + userStoreName); " 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), avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(userStoreName),
previewStoreName + ":/", previewStoreName + ":/",
AVMConstants.DIR_APPBASE); JNDIConstants.DIR_DEFAULT_WWW);
dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(previewStoreName)); dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(previewStoreName));
permissionService.setPermission(dirRef, username, role, true); permissionService.setPermission(dirRef, username, role, true);
for (String manager : managers) for (String manager : managers)
@@ -312,10 +312,10 @@ public final class SandboxFactory
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Created workflow sandbox store: " + workflowMainStoreName); 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), avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName),
workflowMainStoreName + ":/", workflowMainStoreName + ":/",
AVMConstants.DIR_APPBASE); JNDIConstants.DIR_DEFAULT_WWW);
// tag the store with the store type // tag the store with the store type
avmService.setStoreProperty(workflowMainStoreName, avmService.setStoreProperty(workflowMainStoreName,
@@ -347,10 +347,10 @@ public final class SandboxFactory
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Created user sandbox preview store: " + workflowPreviewStoreName); 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), avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(workflowMainStoreName),
workflowPreviewStoreName + ":/", workflowPreviewStoreName + ":/",
AVMConstants.DIR_APPBASE); JNDIConstants.DIR_DEFAULT_WWW);
// tag the store with the store type // tag the store with the store type
avmService.setStoreProperty(workflowPreviewStoreName, avmService.setStoreProperty(workflowPreviewStoreName,
@@ -389,7 +389,7 @@ public final class SandboxFactory
/** /**
* Tag a named store with a DNS path meta-data attribute. * 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 * @param store Name of the store to tag
*/ */

View File

@@ -30,6 +30,7 @@ import java.util.regex.Pattern;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import org.alfresco.config.JNDIConstants;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMDAOs; import org.alfresco.repo.avm.AVMDAOs;
@@ -720,7 +721,7 @@ public class SubmitDialog extends BaseDialogBean
*/ */
public class ItemWrapper public class ItemWrapper
{ {
private static final String rootPath = '/' + AVMConstants.DIR_WEBAPPS; private static final String rootPath = '/' + JNDIConstants.DIR_DEFAULT_APPBASE;
private AVMNodeDescriptor descriptor; private AVMNodeDescriptor descriptor;
public ItemWrapper(AVMNodeDescriptor descriptor) public ItemWrapper(AVMNodeDescriptor descriptor)

View File

@@ -37,12 +37,12 @@ public class ServletContextFormDataFunctionsAdapter
private String toAVMPath(String path) private String toAVMPath(String path)
{ {
// The real_path will look somethign like this: // The real_path will look something like this:
// /alfresco.avm/avm.alfresco.localhost/$-1$alfreco-guest-main:/appBase/avm_webapps/my_webapp // /alfresco.avm/avm.alfresco.localhost/$-1$alfreco-guest-main:/www/avm_webapps/my_webapp
path = this.servletContext.getRealPath(path); path = this.servletContext.getRealPath(path);
// The avm_path to the root of the context will look something like this: // 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.substring(path.indexOf('$', path.indexOf('$') + 1) + 1);
path = path.replace('\\','/'); path = path.replace('\\','/');
return path; return path;