diff --git a/source/java/org/alfresco/web/action/evaluator/WCMWorkflowDeletedEvaluator.java b/source/java/org/alfresco/web/action/evaluator/WCMWorkflowDeletedEvaluator.java index 20a2bbd9b1..9687a11538 100644 --- a/source/java/org/alfresco/web/action/evaluator/WCMWorkflowDeletedEvaluator.java +++ b/source/java/org/alfresco/web/action/evaluator/WCMWorkflowDeletedEvaluator.java @@ -33,7 +33,7 @@ import org.alfresco.util.Pair; import org.alfresco.web.action.ActionEvaluator; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; /** * UI Action Evaluator - return true if the node is not part of an in-progress WCM workflow. @@ -56,7 +56,7 @@ public class WCMWorkflowDeletedEvaluator implements ActionEvaluator // evaluate to true if we are within a workflow store (i.e. list of resources in the task // dialog) or not part of an already in-progress workflow - return (AVMConstants.isWorkflowStore(AVMConstants.getStoreName(path)) || + return (AVMUtil.isWorkflowStore(AVMUtil.getStoreName(path)) || avmService.hasAspect(version, path, AVMSubmittedAspect.ASPECT) == false); } } diff --git a/source/java/org/alfresco/web/action/evaluator/WCMWorkflowEvaluator.java b/source/java/org/alfresco/web/action/evaluator/WCMWorkflowEvaluator.java index a091f23c10..9dbd9d91b3 100644 --- a/source/java/org/alfresco/web/action/evaluator/WCMWorkflowEvaluator.java +++ b/source/java/org/alfresco/web/action/evaluator/WCMWorkflowEvaluator.java @@ -33,7 +33,7 @@ import org.alfresco.util.Pair; import org.alfresco.web.action.ActionEvaluator; import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; /** * UI Action Evaluator - return true if the node is not part of an in-progress WCM workflow. @@ -55,7 +55,7 @@ public class WCMWorkflowEvaluator implements ActionEvaluator // evaluate to true if we are not deleted and within a workflow store (i.e. list of resources // in the task dialog) or not part of an already in-progress workflow - return ((AVMConstants.isWorkflowStore(AVMConstants.getStoreName(path)) || + return ((AVMUtil.isWorkflowStore(AVMUtil.getStoreName(path)) || avmService.hasAspect(version, path, AVMSubmittedAspect.ASPECT) == false) && avmService.lookup(version, path) != null); } diff --git a/source/java/org/alfresco/web/bean/actions/handlers/CopyToWebProjectHandler.java b/source/java/org/alfresco/web/bean/actions/handlers/CopyToWebProjectHandler.java index c43686c3c6..cc26a92606 100644 --- a/source/java/org/alfresco/web/bean/actions/handlers/CopyToWebProjectHandler.java +++ b/source/java/org/alfresco/web/bean/actions/handlers/CopyToWebProjectHandler.java @@ -37,7 +37,7 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.util.Pair; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.WebProject; import org.alfresco.web.bean.wizard.IWizardBean; @@ -64,10 +64,10 @@ public class CopyToWebProjectHandler extends BaseActionHandler if (destNodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE)) { WebProject webProject = new WebProject(destNodeRef); - String storeName = AVMConstants.buildUserMainStoreName(webProject.getStoreId(), + String storeName = AVMUtil.buildUserMainStoreName(webProject.getStoreId(), Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName()); - String rootPath = AVMConstants.buildStoreWebappPath(storeName, AVMConstants.DIR_ROOT); + String rootPath = AVMUtil.buildStoreWebappPath(storeName, AVMUtil.DIR_ROOT); destNodeRef = AVMNodeConverter.ToNodeRef(-1, rootPath); } @@ -95,10 +95,10 @@ public class CopyToWebProjectHandler extends BaseActionHandler // get the destination path Pair avmNode = AVMNodeConverter.ToAVMVersionPath(dest); String avmPath = avmNode.getSecond(); - folder = avmPath.substring(avmPath.indexOf(AVMConstants.DIR_ROOT)+4); + folder = avmPath.substring(avmPath.indexOf(AVMUtil.DIR_ROOT)+4); // get the destination web project name - NodeRef webProjectNode = AVMConstants.getWebProjectNodeFromPath(avmPath); + NodeRef webProjectNode = AVMUtil.getWebProjectNodeFromPath(avmPath); webProject = Repository.getNameForNode( Repository.getServiceRegistry(context).getNodeService(), webProjectNode); } diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index cd14044a72..e0baa5c997 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -46,6 +46,7 @@ import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.actions.AVMRevertStoreAction; import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction; import org.alfresco.repo.domain.PropertyValue; +import org.alfresco.sandbox.SandboxConstants; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; @@ -277,7 +278,7 @@ public class AVMBrowseBean implements IContextListener summary.append(msg.getString(MSG_CREATED_BY)).append(": ") .append(store.getCreator()) .append("

"); - final int numUsers = this.getRelatedStoreNames(storeId, AVMConstants.PROP_SANDBOX_AUTHOR_MAIN).size(); + final int numUsers = this.getRelatedStoreNames(storeId, SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN).size(); summary.append(MessageFormat.format(msg.getString(MSG_WORKING_USERS), numUsers)); } @@ -295,7 +296,7 @@ public class AVMBrowseBean implements IContextListener */ private List getRelatedStoreNames(final String storeId, final QName... types) { - QName qn = QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + storeId + "%"); + QName qn = QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + storeId + "%"); final Map> relatedSandboxes = avmService.queryStoresPropertyKeys(qn); final List result = new LinkedList(); @@ -326,7 +327,7 @@ public class AVMBrowseBean implements IContextListener */ public String getStagingPreviewUrl() { - return AVMConstants.buildWebappUrl(getStagingStore(), getWebapp()); + return AVMUtil.buildWebappUrl(getStagingStore(), getWebapp()); } /** @@ -334,7 +335,7 @@ public class AVMBrowseBean implements IContextListener */ public String getSandboxPreviewUrl() { - return AVMConstants.buildWebappUrl(getSandbox(), getWebapp()); + return AVMUtil.buildWebappUrl(getSandbox(), getWebapp()); } /** @@ -460,7 +461,7 @@ public class AVMBrowseBean implements IContextListener { if (this.webapps == null) { - String path = AVMConstants.buildSandboxRootPath(getStagingStore()); + String path = AVMUtil.buildSandboxRootPath(getStagingStore()); Map folders = this.avmService.getDirectoryListing(-1, path); List webapps = new ArrayList(folders.size()); for (AVMNodeDescriptor node : folders.values()) @@ -597,7 +598,7 @@ public class AVMBrowseBean implements IContextListener { if (this.currentPath == null) { - this.currentPath = AVMConstants.buildStoreWebappPath(getSandbox(), getWebapp()); + this.currentPath = AVMUtil.buildStoreWebappPath(getSandbox(), getWebapp()); } return this.currentPath; } @@ -890,21 +891,21 @@ public class AVMBrowseBean implements IContextListener else { // calculate username and store name from specified path - String storeName = AVMConstants.getStoreName(path); - final String storeId = AVMConstants.getStoreId(storeName); - final String username = AVMConstants.getUserName(storeName); + String storeName = AVMUtil.getStoreName(path); + final String storeId = AVMUtil.getStoreId(storeName); + final String username = AVMUtil.getUserName(storeName); if (username == null) { - storeName = (AVMConstants.isPreviewStore(storeName) - ? AVMConstants.buildStagingPreviewStoreName(storeId) - : AVMConstants.buildStagingStoreName(storeId)); + storeName = (AVMUtil.isPreviewStore(storeName) + ? AVMUtil.buildStagingPreviewStoreName(storeId) + : AVMUtil.buildStagingStoreName(storeId)); setupSandboxActionImpl(storeName, null, false); } else { - storeName = (AVMConstants.isPreviewStore(storeName) - ? AVMConstants.buildUserPreviewStoreName(storeId, username) - : AVMConstants.buildUserMainStoreName(storeId, username)); + storeName = (AVMUtil.isPreviewStore(storeName) + ? AVMUtil.buildUserPreviewStoreName(storeId, username) + : AVMUtil.buildUserMainStoreName(storeId, username)); setupSandboxActionImpl(storeName, username, false); } @@ -943,8 +944,8 @@ public class AVMBrowseBean implements IContextListener } // update the specified webapp in the store - String webappPath = AVMConstants.buildStoreWebappPath(store, getWebapp()); - AVMConstants.updateVServerWebapp(webappPath, true); + String webappPath = AVMUtil.buildStoreWebappPath(store, getWebapp()); + AVMUtil.updateVServerWebapp(webappPath, true); } /** @@ -979,7 +980,7 @@ public class AVMBrowseBean implements IContextListener if ( VirtServerUtils.requiresUpdateNotification( path ) ) { - AVMConstants.updateVServerWebapp(path, true); + AVMUtil.updateVServerWebapp(path, true); } @@ -1015,7 +1016,7 @@ public class AVMBrowseBean implements IContextListener tx = Repository.getUserTransaction(context, false); tx.begin(); - String sandboxPath = AVMConstants.buildSandboxRootPath( sandbox ); + String sandboxPath = AVMUtil.buildSandboxRootPath( sandbox ); List diffs = this.avmSyncService.compare( @@ -1036,7 +1037,7 @@ public class AVMBrowseBean implements IContextListener { if ( VirtServerUtils.requiresUpdateNotification( diff.getSourcePath()) ) { - AVMConstants.updateVServerWebapp(diff.getSourcePath() , true); + AVMUtil.updateVServerWebapp(diff.getSourcePath() , true); break; } } @@ -1180,7 +1181,7 @@ public class AVMBrowseBean implements IContextListener @Override public String toString() { - if (AVMConstants.buildSandboxRootPath(getSandbox()).equals(path)) + if (AVMUtil.buildSandboxRootPath(getSandbox()).equals(path)) { // don't display the 'root' webapps path as this will confuse users // instead display which sandbox we are in diff --git a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java index ccea987d33..6ebe8dbe0f 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMEditBean.java @@ -354,9 +354,9 @@ public class AVMEditBean if (this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) { // reset the preview layer - String storeName = AVMConstants.getStoreName(avmPath); - storeName = AVMConstants.getCorrespondingPreviewStoreName(storeName); - final String path = AVMConstants.buildStoreRootPath(storeName); + String storeName = AVMUtil.getStoreName(avmPath); + storeName = AVMUtil.getCorrespondingPreviewStoreName(storeName); + final String path = AVMUtil.buildStoreRootPath(storeName); if (LOGGER.isDebugEnabled()) LOGGER.debug("reseting layer " + path); @@ -407,7 +407,7 @@ public class AVMEditBean if (node != null) { // Possibly notify virt server - AVMConstants.updateVServerWebapp(node.getPath(), false); + AVMUtil.updateVServerWebapp(node.getPath(), false); resetState(); outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME; @@ -463,14 +463,14 @@ public class AVMEditBean { final String path = AVMNodeConverter.ToAVMVersionPath(uploadedFile).getSecond(); diffList.add(new AVMDifference(-1, path, - -1, AVMConstants.getCorrespondingPathInMainStore(path), + -1, AVMUtil.getCorrespondingPathInMainStore(path), AVMDifference.NEWER)); } this.avmSyncService.update(diffList, null, true, true, true, true, null, null); } // Possibly notify virt server - AVMConstants.updateVServerWebapp(avmNode.getPath(), false); + AVMUtil.updateVServerWebapp(avmNode.getPath(), false); resetState(); @@ -520,7 +520,7 @@ public class AVMEditBean this.regenerateRenditions(); } // Possibly notify virt server - AVMConstants.updateVServerWebapp(node.getPath(), false); + AVMUtil.updateVServerWebapp(node.getPath(), false); // clear action context resetState(); diff --git a/source/java/org/alfresco/web/bean/wcm/AVMNode.java b/source/java/org/alfresco/web/bean/wcm/AVMNode.java index 7057530dd1..3b13c5fc8a 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMNode.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMNode.java @@ -67,8 +67,8 @@ public class AVMNode extends Node implements Map final ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance()); final String dns = - AVMConstants.lookupStoreDNS(AVMConstants.getStoreName(node.getPath())); - return AVMConstants.buildAssetUrl(AVMConstants.getSandboxRelativePath(node.getPath()), + AVMUtil.lookupStoreDNS(AVMUtil.getStoreName(node.getPath())); + return AVMUtil.buildAssetUrl(AVMUtil.getSandboxRelativePath(node.getPath()), config.getWCMDomain(), config.getWCMPort(), dns); @@ -85,7 +85,7 @@ public class AVMNode extends Node implements Map return null; } String s = node.getPath(); - s = AVMConstants.getSandboxRelativePath(s); + s = AVMUtil.getSandboxRelativePath(s); final Path result = new Path(); final String[] parts = s.split("/"); for (int i = 1; i < parts.length; i++) diff --git a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java b/source/java/org/alfresco/web/bean/wcm/AVMUtil.java similarity index 87% rename from source/java/org/alfresco/web/bean/wcm/AVMConstants.java rename to source/java/org/alfresco/web/bean/wcm/AVMUtil.java index c94d60e67d..050db79227 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMUtil.java @@ -38,6 +38,7 @@ 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.sandbox.SandboxConstants; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.avm.AVMNotFoundException; import org.alfresco.service.cmr.avm.AVMService; @@ -57,7 +58,7 @@ import org.alfresco.web.config.ClientConfigElement; * @author Ariel Backenroth * @author Kevin Roast */ -public final class AVMConstants +public final class AVMUtil { ///////////////////////////////////////////////////////////////////////////// @@ -68,7 +69,7 @@ public final class AVMConstants @Override protected Pattern pattern() { - return AVMConstants.SANDBOX_RELATIVE_PATH_PATTERN; + return AVMUtil.SANDBOX_RELATIVE_PATH_PATTERN; } }, WEBAPP_RELATIVE @@ -76,7 +77,7 @@ public final class AVMConstants @Override protected Pattern pattern() { - return AVMConstants.WEBAPP_RELATIVE_PATH_PATTERN; + return AVMUtil.WEBAPP_RELATIVE_PATH_PATTERN; } }; @@ -88,7 +89,7 @@ public final class AVMConstants /** * Private constructor */ - private AVMConstants() + private AVMUtil() { } @@ -118,7 +119,7 @@ public final class AVMConstants */ public static boolean isPreviewStore(final String storeName) { - return storeName.endsWith(AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW); + return storeName.endsWith(AVMUtil.STORE_SEPARATOR + AVMUtil.STORE_PREVIEW); } /** @@ -130,9 +131,9 @@ public final class AVMConstants */ public static boolean isWorkflowStore(String storeName) { - if (AVMConstants.isPreviewStore(storeName)) + if (AVMUtil.isPreviewStore(storeName)) { - storeName = AVMConstants.getCorrespondingMainStoreName(storeName); + storeName = AVMUtil.getCorrespondingMainStoreName(storeName); } return storeName.indexOf(STORE_SEPARATOR + STORE_WORKFLOW) != -1; @@ -147,11 +148,11 @@ public final class AVMConstants */ public static boolean isUserStore(String storeName) { - if (AVMConstants.isPreviewStore(storeName)) + if (AVMUtil.isPreviewStore(storeName)) { - storeName = AVMConstants.getCorrespondingMainStoreName(storeName); + storeName = AVMUtil.getCorrespondingMainStoreName(storeName); } - return storeName.indexOf(AVMConstants.STORE_SEPARATOR) != -1; + return storeName.indexOf(AVMUtil.STORE_SEPARATOR) != -1; } /** @@ -163,14 +164,14 @@ public final class AVMConstants */ public static String getUserName(String storeName) { - if (AVMConstants.isPreviewStore(storeName)) + if (AVMUtil.isPreviewStore(storeName)) { - storeName = AVMConstants.getCorrespondingMainStoreName(storeName); + storeName = AVMUtil.getCorrespondingMainStoreName(storeName); } - final int index = storeName.indexOf(AVMConstants.STORE_SEPARATOR); + final int index = storeName.indexOf(AVMUtil.STORE_SEPARATOR); return (index == -1 ? null - : storeName.substring(index + AVMConstants.STORE_SEPARATOR.length())); + : storeName.substring(index + AVMUtil.STORE_SEPARATOR.length())); } /** @@ -182,7 +183,7 @@ public final class AVMConstants */ public static String getStoreId(final String storeName) { - final int index = storeName.indexOf(AVMConstants.STORE_SEPARATOR); + final int index = storeName.indexOf(AVMUtil.STORE_SEPARATOR); return (index == -1 ? storeName : storeName.substring(0, index)); @@ -199,13 +200,13 @@ public final class AVMConstants */ public static String getCorrespondingMainStoreName(final String storeName) { - if (!AVMConstants.isPreviewStore(storeName)) + if (!AVMUtil.isPreviewStore(storeName)) { throw new IllegalArgumentException("store " + storeName + " is not a preview store"); } return storeName.substring(0, (storeName.length() - - (AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW).length())); + (AVMUtil.STORE_SEPARATOR + AVMUtil.STORE_PREVIEW).length())); } /** @@ -219,11 +220,11 @@ public final class AVMConstants */ public static String getCorrespondingPreviewStoreName(final String storeName) { - if (AVMConstants.isPreviewStore(storeName)) + if (AVMUtil.isPreviewStore(storeName)) { throw new IllegalArgumentException("store " + storeName + " is already a preview store"); } - return storeName + AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW; + return storeName + AVMUtil.STORE_SEPARATOR + AVMUtil.STORE_PREVIEW; } /** @@ -238,9 +239,9 @@ public final class AVMConstants */ public static String getCorrespondingPathInMainStore(final String avmPath) { - String storeName = AVMConstants.getStoreName(avmPath); - storeName = AVMConstants.getCorrespondingMainStoreName(storeName); - return AVMConstants.getCorrespondingPath(avmPath, storeName); + String storeName = AVMUtil.getStoreName(avmPath); + storeName = AVMUtil.getCorrespondingMainStoreName(storeName); + return AVMUtil.getCorrespondingPath(avmPath, storeName); } /** @@ -255,9 +256,9 @@ public final class AVMConstants */ public static String getCorrespondingPathInPreviewStore(final String avmPath) { - String storeName = AVMConstants.getStoreName(avmPath); - storeName = AVMConstants.getCorrespondingPreviewStoreName(storeName); - return AVMConstants.getCorrespondingPath(avmPath, storeName); + String storeName = AVMUtil.getStoreName(avmPath); + storeName = AVMUtil.getCorrespondingPreviewStoreName(storeName); + return AVMUtil.getCorrespondingPath(avmPath, storeName); } /** @@ -270,7 +271,7 @@ public final class AVMConstants */ public static String getCorrespondingPath(final String avmPath, final String otherStore) { - return (otherStore + ':' + AVMConstants.getStoreRelativePath(avmPath)); + return (otherStore + ':' + AVMUtil.getStoreRelativePath(avmPath)); } /** @@ -467,8 +468,8 @@ public final class AVMConstants */ public static String buildStagingPreviewStoreName(final String storeId) { - return (AVMConstants.buildStagingStoreName(storeId) + - AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW); + return (AVMUtil.buildStagingStoreName(storeId) + + AVMUtil.STORE_SEPARATOR + AVMUtil.STORE_PREVIEW); } /** @@ -486,7 +487,7 @@ public final class AVMConstants { throw new IllegalArgumentException("Username is mandatory."); } - return (AVMConstants.buildStagingStoreName(storeId) + AVMConstants.STORE_SEPARATOR + + return (AVMUtil.buildStagingStoreName(storeId) + AVMUtil.STORE_SEPARATOR + username); } @@ -501,8 +502,8 @@ public final class AVMConstants public static String buildUserPreviewStoreName(final String storeId, final String username) { - return (AVMConstants.buildUserMainStoreName(storeId, username) + - AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW); + return (AVMUtil.buildUserMainStoreName(storeId, username) + + AVMUtil.STORE_SEPARATOR + AVMUtil.STORE_PREVIEW); } /** @@ -520,7 +521,7 @@ public final class AVMConstants { throw new IllegalArgumentException("workflowId is mandatory."); } - return (AVMConstants.buildStagingStoreName(storeId) + AVMConstants.STORE_SEPARATOR + + return (AVMUtil.buildStagingStoreName(storeId) + AVMUtil.STORE_SEPARATOR + workflowId); } @@ -535,8 +536,8 @@ public final class AVMConstants public static String buildWorkflowPreviewStoreName(final String storeId, final String workflowId) { - return (AVMConstants.buildWorkflowMainStoreName(storeId, workflowId) + - AVMConstants.STORE_SEPARATOR + AVMConstants.STORE_PREVIEW); + return (AVMUtil.buildWorkflowMainStoreName(storeId, workflowId) + + AVMUtil.STORE_SEPARATOR + AVMUtil.STORE_PREVIEW); } /** @@ -564,7 +565,7 @@ public final class AVMConstants */ public static String buildSandboxRootPath(final String storeName) { - return AVMConstants.buildStoreRootPath(storeName) + '/' + JNDIConstants.DIR_DEFAULT_APPBASE; + return AVMUtil.buildStoreRootPath(storeName) + '/' + JNDIConstants.DIR_DEFAULT_APPBASE; } /** @@ -581,7 +582,7 @@ public final class AVMConstants { throw new IllegalArgumentException("Webapp name is mandatory."); } - return AVMConstants.buildSandboxRootPath(storeName) + '/' + webapp; + return AVMUtil.buildSandboxRootPath(storeName) + '/' + webapp; } public static String buildStoreUrl(String store) @@ -607,8 +608,8 @@ public final class AVMConstants { throw new IllegalArgumentException("AVM path is mandatory."); } - return AVMConstants.buildWebappUrl(AVMConstants.getStoreName(avmPath), - AVMConstants.getWebapp(avmPath)); + return AVMUtil.buildWebappUrl(AVMUtil.getStoreName(avmPath), + AVMUtil.getWebapp(avmPath)); } public static String buildWebappUrl(final String store, final String webapp) @@ -633,7 +634,7 @@ public final class AVMConstants { throw new IllegalArgumentException("expected exactly one ':' in " + avmPath); } - return AVMConstants.buildAssetUrl(s[0], s[1]); + return AVMUtil.buildAssetUrl(s[0], s[1]); } public static String buildAssetUrl(String store, String assetPath) @@ -689,9 +690,9 @@ public final class AVMConstants Repository.getServiceRegistry(FacesContext.getCurrentInstance()); final AVMService avmService = serviceRegistry.getAVMService(); final Map props = - avmService.queryStorePropertyKey(store, QName.createQName(null, PROP_DNS + '%')); + avmService.queryStorePropertyKey(store, QName.createQName(null, SandboxConstants.PROP_DNS + '%')); return (props.size() == 1 - ? props.keySet().iterator().next().getLocalName().substring(PROP_DNS.length()) + ? props.keySet().iterator().next().getLocalName().substring(SandboxConstants.PROP_DNS.length()) : null); } @@ -818,8 +819,8 @@ public final class AVMConstants */ public static NodeRef getWebProjectNodeFromPath(final String absoluteAVMPath) { - String storeName = AVMConstants.getStoreName(absoluteAVMPath); - String storeId = AVMConstants.getStoreId(storeName); + String storeName = AVMUtil.getStoreName(absoluteAVMPath); + String storeId = AVMUtil.getStoreId(storeName); return getWebProjectNodeFromStore(storeId); } @@ -920,7 +921,7 @@ public final class AVMConstants { path = path.substring(0, webappIndex); } - final VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry(); + final VirtServerRegistry vServerRegistry = AVMUtil.getVirtServerRegistry(); vServerRegistry.updateAllWebapps(-1, path, true); } } @@ -943,7 +944,7 @@ public final class AVMConstants { path = path.substring(0, webappIndex); } - final VirtServerRegistry vServerRegistry = AVMConstants.getVirtServerRegistry(); + final VirtServerRegistry vServerRegistry = AVMUtil.getVirtServerRegistry(); vServerRegistry.removeAllWebapps(-1, path, true); } } @@ -980,21 +981,8 @@ public final class AVMConstants // Note: this webapp is mapped to the URL path "" public final static String DIR_ROOT = "ROOT"; - // system property keys for sandbox identification and DNS virtualisation mapping - public final static String PROP_BACKGROUND_LAYER = ".background-layer."; - public final static String PROP_SANDBOXID = ".sandbox-id."; - public final static String PROP_DNS = ".dns."; - public final static String PROP_SANDBOX_STORE_PREFIX = ".sandbox.store."; - public final static QName PROP_WEB_PROJECT_NODE_REF = QName.createQName(null, ".web_project.noderef"); - 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"; + public final static String SPACE_ICON_WEBSITE = "space-icon-website"; + public final static QName PROP_WEB_PROJECT_NODE_REF = QName.createQName(null, ".web_project.noderef"); // web user role permissions public final static String ROLE_CONTENT_MANAGER = "ContentManager"; diff --git a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java index a6e090db4c..3c90ac53d0 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMWorkflowUtil.java @@ -97,13 +97,13 @@ public class AVMWorkflowUtil extends WorkflowUtil { // create package paths (layered to user sandbox area as target) final String workflowMainStoreName = sandboxInfo.getMainStoreName(); - final String packagesPath = AVMConstants.buildStoreRootPath(workflowMainStoreName); + final String packagesPath = AVMUtil.buildStoreRootPath(workflowMainStoreName); final List diffs = new ArrayList(srcPaths.size()); for (final String srcPath : srcPaths) { diffs.add(new AVMDifference(-1, srcPath, - -1, AVMConstants.getCorrespondingPath(srcPath, workflowMainStoreName), + -1, AVMUtil.getCorrespondingPath(srcPath, workflowMainStoreName), AVMDifference.NEWER)); avmSubmittedAspect.markSubmitted(-1, srcPath, path.instance.id); } diff --git a/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java b/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java index d1aa7410f1..bccfd7814b 100644 --- a/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java @@ -137,7 +137,7 @@ public class AddAvmContentDialog extends AddContentDialog logger.debug("Reloading virtualisation server on path: " + this.path); } - AVMConstants.updateVServerWebapp(this.path, false); + AVMUtil.updateVServerWebapp(this.path, false); return outcome; } diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java index a7946f19fd..c92dd66048 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java @@ -200,9 +200,9 @@ public class CreateWebContentWizard extends BaseContentWizard } // reset the preview layer - String storeName = AVMConstants.getStoreName(this.avmBrowseBean.getCurrentPath()); - storeName = AVMConstants.getCorrespondingPreviewStoreName(storeName); - final String path = AVMConstants.buildStoreRootPath(storeName); + String storeName = AVMUtil.getStoreName(this.avmBrowseBean.getCurrentPath()); + storeName = AVMUtil.getCorrespondingPreviewStoreName(storeName); + final String path = AVMUtil.buildStoreRootPath(storeName); if (LOGGER.isDebugEnabled()) LOGGER.debug("reseting layer " + path); this.avmSyncService.resetLayer(path); @@ -285,13 +285,13 @@ public class CreateWebContentWizard extends BaseContentWizard final List diffList = new ArrayList(1 + this.renditions.size() + uploadedFiles.length); diffList.add(new AVMDifference(-1, this.createdPath, - -1, AVMConstants.getCorrespondingPathInMainStore(this.createdPath), + -1, AVMUtil.getCorrespondingPathInMainStore(this.createdPath), AVMDifference.NEWER)); for (Rendition rendition : this.renditions) { final String path = rendition.getPath(); diffList.add(new AVMDifference(-1, path, - -1, AVMConstants.getCorrespondingPathInMainStore(path), + -1, AVMUtil.getCorrespondingPathInMainStore(path), AVMDifference.NEWER)); } @@ -299,7 +299,7 @@ public class CreateWebContentWizard extends BaseContentWizard { final String path = AVMNodeConverter.ToAVMVersionPath(uploadedFile).getSecond(); diffList.add(new AVMDifference(-1, path, - -1, AVMConstants.getCorrespondingPathInMainStore(path), + -1, AVMUtil.getCorrespondingPathInMainStore(path), AVMDifference.NEWER)); } @@ -354,20 +354,20 @@ public class CreateWebContentWizard extends BaseContentWizard // collect diffs for form data instance and all renditions for (Rendition rendition : this.getRenditions()) { - srcPaths.add(AVMConstants.getCorrespondingPath(rendition.getPath(), sandboxName)); + srcPaths.add(AVMUtil.getCorrespondingPath(rendition.getPath(), sandboxName)); } for (NodeRef uploadedFile : uploadedFiles) { final String uploadPath = AVMNodeConverter.ToAVMVersionPath(uploadedFile).getSecond(); - srcPaths.add(AVMConstants.getCorrespondingPath(uploadPath, sandboxName)); + srcPaths.add(AVMUtil.getCorrespondingPath(uploadPath, sandboxName)); } - srcPaths.add(AVMConstants.getCorrespondingPath(this.formInstanceData.getPath(), sandboxName)); + srcPaths.add(AVMUtil.getCorrespondingPath(this.formInstanceData.getPath(), sandboxName)); } else { // diff for txt or html content - srcPaths.add(AVMConstants.getCorrespondingPath(this.createdPath, sandboxName)); + srcPaths.add(AVMUtil.getCorrespondingPath(this.createdPath, sandboxName)); } if (LOGGER.isDebugEnabled()) @@ -399,7 +399,7 @@ public class CreateWebContentWizard extends BaseContentWizard MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null ? this.formInstanceData.getName() : this.getFileName()); - parameters.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMConstants.buildStoreRootPath(sandboxName)); + parameters.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMUtil.buildStoreRootPath(sandboxName)); // update start task with submit parameters this.workflowService.updateTask(startTask.id, parameters, null, null); @@ -424,7 +424,7 @@ public class CreateWebContentWizard extends BaseContentWizard protected String doPostCommitProcessing(final FacesContext facesContext, final String outcome) { // reset all paths and structures to the main store - this.createdPath = AVMConstants.getCorrespondingPathInMainStore(this.createdPath); + this.createdPath = AVMUtil.getCorrespondingPathInMainStore(this.createdPath); if (LOGGER.isDebugEnabled()) LOGGER.debug("reset path " + this.createdPath + " to main store"); @@ -467,7 +467,7 @@ public class CreateWebContentWizard extends BaseContentWizard if (LOGGER.isDebugEnabled()) LOGGER.debug("saving file content to " + fileName); - final String cwd = AVMConstants.getCorrespondingPathInPreviewStore(this.avmBrowseBean.getCurrentPath()); + final String cwd = AVMUtil.getCorrespondingPathInPreviewStore(this.avmBrowseBean.getCurrentPath()); final Form form = (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) ? this.getForm() : null); @@ -487,7 +487,7 @@ public class CreateWebContentWizard extends BaseContentWizard if (LOGGER.isDebugEnabled()) LOGGER.debug("creating all directories in path " + path); - AVMConstants.makeAllDirectories(path); + AVMUtil.makeAllDirectories(path); if (LOGGER.isDebugEnabled()) LOGGER.debug("creating file " + fileName + " in " + path); @@ -794,7 +794,7 @@ public class CreateWebContentWizard extends BaseContentWizard */ public String getPreviewSandboxUrl() { - return AVMConstants.buildWebappUrl(AVMConstants.getCorrespondingPreviewStoreName(this.avmBrowseBean.getSandbox()), + return AVMUtil.buildWebappUrl(AVMUtil.getCorrespondingPreviewStoreName(this.avmBrowseBean.getSandbox()), this.avmBrowseBean.getWebapp()); } diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebappDialog.java b/source/java/org/alfresco/web/bean/wcm/CreateWebappDialog.java index f7cc7deefe..287eabdecc 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebappDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebappDialog.java @@ -49,7 +49,7 @@ public class CreateWebappDialog extends CreateFolderDialog @Override protected String finishImpl(FacesContext context, String outcome) throws Exception { - final String parent = AVMConstants.buildSandboxRootPath(this.avmBrowseBean.getStagingStore()); + final String parent = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getStagingStore()); this.avmService.createDirectory(parent, this.name); final String path = AVMNodeConverter.ExtendAVMPath(parent, this.name); diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java index 55a9194d8b..fe7e95333a 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebsiteWizard.java @@ -53,6 +53,7 @@ import org.alfresco.service.cmr.workflow.WorkflowDefinition; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; +import org.alfresco.util.DNSNameMangler; import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.Application; import org.alfresco.web.app.servlet.FacesHelper; @@ -178,7 +179,7 @@ public class CreateWebsiteWizard extends BaseWizardBean // apply the uifacets aspect - icon, title and description props Map uiFacetsProps = new HashMap(4); - uiFacetsProps.put(ApplicationModel.PROP_ICON, AVMConstants.SPACE_ICON_WEBSITE); + uiFacetsProps.put(ApplicationModel.PROP_ICON, AVMUtil.SPACE_ICON_WEBSITE); uiFacetsProps.put(ContentModel.PROP_TITLE, this.title); uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, this.description); this.nodeService.addAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps); @@ -204,8 +205,8 @@ public class CreateWebsiteWizard extends BaseWizardBean this.sandboxInfo = SandboxFactory.createStagingSandbox(avmStore, nodeRef); // create the default webapp folder under the hidden system folders - final String stagingStore = AVMConstants.buildStagingStoreName(avmStore); - final String stagingStoreRoot = AVMConstants.buildSandboxRootPath(stagingStore); + final String stagingStore = AVMUtil.buildStagingStoreName(avmStore); + final String stagingStoreRoot = AVMUtil.buildSandboxRootPath(stagingStore); this.avmService.createDirectory(stagingStoreRoot, webapp); this.avmService.addAspect(AVMNodeConverter.ExtendAVMPath(stagingStoreRoot, webapp), WCMAppModel.ASPECT_WEBAPP); @@ -234,11 +235,11 @@ public class CreateWebsiteWizard extends BaseWizardBean { // update the virtualisation server with the default ROOT webapp path // performed after the main txn has committed successfully - String newStoreName = AVMConstants.buildStagingStoreName(sandboxInfo.getMainStoreName()); + String newStoreName = AVMUtil.buildStagingStoreName(sandboxInfo.getMainStoreName()); - String path = AVMConstants.buildStoreWebappPath(newStoreName, WEBAPP_DEFAULT); + String path = AVMUtil.buildStoreWebappPath(newStoreName, WEBAPP_DEFAULT); - AVMConstants.updateVServerWebapp(path, true); + AVMUtil.updateVServerWebapp(path, true); } return outcome; } @@ -497,7 +498,7 @@ public class CreateWebsiteWizard extends BaseWizardBean { String pattern = Application.getMessage(FacesContext.getCurrentInstance(), "deploy_to_help"); - String defaultPort = Integer.toString(AVMConstants.getRemoteRMIRegistryPort()); + String defaultPort = Integer.toString(AVMUtil.getRemoteRMIRegistryPort()); return MessageFormat.format(pattern, new Object[] {defaultPort}); } @@ -527,7 +528,7 @@ public class CreateWebsiteWizard extends BaseWizardBean if (foundCurrentUser == false) { buf.append(getInviteUsersWizard().buildLabelForUserAuthorityRole( - currentUser, AVMConstants.ROLE_CONTENT_MANAGER)); + currentUser, AVMUtil.ROLE_CONTENT_MANAGER)); } return buildSummary( @@ -557,7 +558,7 @@ public class CreateWebsiteWizard extends BaseWizardBean } if (foundCurrentUser == false) { - result.add(new UserWrapper(currentUser, AVMConstants.ROLE_CONTENT_MANAGER)); + result.add(new UserWrapper(currentUser, AVMUtil.ROLE_CONTENT_MANAGER)); } return result; } diff --git a/source/java/org/alfresco/web/bean/wcm/DNSNameMangler.java b/source/java/org/alfresco/web/bean/wcm/DNSNameMangler.java deleted file mode 100644 index 9dc4229a4c..0000000000 --- a/source/java/org/alfresco/web/bean/wcm/DNSNameMangler.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" */ - -package org.alfresco.web.bean.wcm; - -import java.util.regex.Pattern; - -import org.alfresco.util.GUID; - -/** - * Utility to convert sandbox store names into DNS save names. - * - * Host labels appear in the same order as transparent overlays - * are viewed (highest first). For example: - * - * The "preview" layer on the "alice" layer on the "mysite" layer - * within the domain www--sandbox.127-0-0-1.ip.alfrescodemo.net - * is encoded as: - * - * http://preview.alice.mysite.www--sandbox.127-0-0-1.ip.alfrescodemo.net - * - * Note that the "virtualization" domain config just refers to - * where the wildcard DNS entry begins. Here, both domains - * "127-0-0-1.ip.alfrescodemo.net" and "*.127-0-0-1.ip.alfrescodemo.net" - * resolve to 127.0.0.1, so effectively "127-0-0-1.ip.alfrescodemo.net" - * is the "virtualization domain". The "www--sandbox" part just - * delmits the end of the dns-name-mangled store. - * - * This manging scheme was also designed to be fully compatible with - * the future use of I18N-encoded DNS names; the relevant standard - * is IDNA ("Internationalizing Domain Names In Applications"). - * See RFC 3490 and 3492. - * - * @author Jon Cox - * @author Britt Park - * - */ -class DNSNameMangler -{ - // Component Separator. - private static final String SEPARATOR = "."; - - // DNS rules allow up to 255 chars, but limiting - // MAX_INTERNAL_DNS_NAME_LENGTH to less in order - // to provide plenty of extra room for: - // - // - // o The AVMUrlValve's end-of-info-bearing-part-of-DNS-name delimiter: - // (i.e.: ".www--sandbox"). For example: - // - // http://.www--sandbox:/ - // - // o Other AVMUrlValve args after "www--sandbox". For example: - // http://alice.mysite.www--sandbox.version--v44.:/ - // http://alice.mysite.www--sandbox.gmt--2006-12-31-23-59. - // ... - // - - private static final int MAX_INTERNAL_DNS_NAME_LENGTH = 150; - - // Regular expressions. - private static final Pattern RX_DNS_LEGAL = - Pattern.compile("[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]" + - "(?:\\.[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])*"); - - private static final Pattern RX_ILLEGAL_CHARS = - Pattern.compile("[^a-zA-Z0-9]"); - private static final Pattern RX_HYPHENS = - Pattern.compile("\\-+"); - private static final Pattern RX_LEADING_HYPHEN = - Pattern.compile("^\\-"); - private static final Pattern RX_TRAILING_HYPHEN = - Pattern.compile("\\-$"); - - /** - * Make a DNS readable name related to the components passed in. - * @param components The Strings from which to synthesize the DNS name. - * @return A Valid DNS name. - */ - static String MakeDNSName(String... components) - { - StringBuilder builder = new StringBuilder(); - - // Make domain name order the reverse - // of the file system ordering. - - for (int i = components.length - 1; i > 0; i--) - { - builder.append(MangleOne(components[i])); - builder.append(SEPARATOR); - } - builder.append(MangleOne(components[0])); - String result = builder.toString(); - - if ( (result.length() <= MAX_INTERNAL_DNS_NAME_LENGTH) && - RX_DNS_LEGAL.matcher(result).matches() - ) - { - return result; - } - - // Otherwise more drastic measures are needed. - result = components[0] + SEPARATOR + "guid-" + GUID.generate(); - result = MangleOne(result); - - if ( (result.length() <= MAX_INTERNAL_DNS_NAME_LENGTH) && - RX_DNS_LEGAL.matcher(result).matches() - ) - { - return result; - } - - // Finally this cannot fail. - return MangleOne("guid-" + GUID.generate()); - } - - /** - * Mangle one component of a DNS legal name. - * @param name The component. - * @return The mangled component. - */ - static String MangleOne(String name) - { - // Even if the name is IDNA-encoded, the result is never - // a string that contains chars outside of [a-zA-Z0-9-] - // Replace bad chars with "-", rather than throwing - // an error. - - name = RX_ILLEGAL_CHARS.matcher(name).replaceAll("-"); - - // While it's tempting to reserve "--" as our own - // mangling delimiter, IDNA has already clamed it. - // Therefore, doing something like this would be bad: - // - // name = RX_HYPHENS.matcher(name).replaceAll("-"); - // - // Any IDNA I18N-encoded host label ("xn--...") would - // be corrupted. - - // However, leading/trailing hyphens are always illegal, - // so we can still check for that: - - name = RX_LEADING_HYPHEN.matcher(name).replaceAll("x"); - name = RX_TRAILING_HYPHEN.matcher(name).replaceAll("x"); - - return name; - } -} diff --git a/source/java/org/alfresco/web/bean/wcm/DNSNameManglerTest.java b/source/java/org/alfresco/web/bean/wcm/DNSNameManglerTest.java deleted file mode 100644 index 176ceb17e7..0000000000 --- a/source/java/org/alfresco/web/bean/wcm/DNSNameManglerTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2005-2007 Alfresco Software Limited. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * As a special exception to the terms and conditions of version 2.0 of - * the GPL, you may redistribute this Program in connection with Free/Libre - * and Open Source Software ("FLOSS") applications as described in Alfresco's - * FLOSS exception. You should have recieved a copy of the text describing - * the FLOSS exception, and it is also available here: - * http://www.alfresco.com/legal/licensing" */ - -package org.alfresco.web.bean.wcm; - -import junit.framework.TestCase; - -/** - * Test the DNSNameMangler. - * @author britt - */ -public class DNSNameManglerTest extends TestCase -{ - /** - * Test it. - */ - public void testIt() - { - try - { - String mangled = DNSNameMangler.MakeDNSName("website", "britt", "main"); - System.out.println(mangled); - assertTrue(mangled.length() <= 59); - mangled = DNSNameMangler.MakeDNSName("website", "Foodle Dee dOO", "main"); - System.out.println(mangled); - assertTrue(mangled.length() <= 59); - mangled = DNSNameMangler.MakeDNSName("website-thinkl$", "winky_froo", "orkle"); - System.out.println(mangled); - assertTrue(mangled.length() <= 59); - mangled = DNSNameMangler.MakeDNSName("fork", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZZxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "winkle"); - System.out.println(mangled); - assertTrue(mangled.length() <= 59); - mangled = DNSNameMangler.MakeDNSName("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "Frederick", "preview"); - System.out.println(mangled); - assertTrue(mangled.length() <= 59); - } - catch (Exception e) - { - e.printStackTrace(System.err); - fail(); - } - } -} diff --git a/source/java/org/alfresco/web/bean/wcm/DeleteSandboxDialog.java b/source/java/org/alfresco/web/bean/wcm/DeleteSandboxDialog.java index 2c91121658..713d9520b8 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeleteSandboxDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/DeleteSandboxDialog.java @@ -98,8 +98,8 @@ public class DeleteSandboxDialog extends BaseDialogBean { // found the sandbox to remove String storeRoot = (String)website.getProperties().get(WCMAppModel.PROP_AVMSTORE); - String sandbox = AVMConstants.buildUserMainStoreName(storeRoot, username); - String path = AVMConstants.buildStoreWebappPath(sandbox, this.avmBrowseBean.getWebapp()); + String sandbox = AVMUtil.buildUserMainStoreName(storeRoot, username); + String path = AVMUtil.buildStoreWebappPath(sandbox, this.avmBrowseBean.getWebapp()); // Notify virtualisation server about removing this sandbox. // @@ -117,7 +117,7 @@ public class DeleteSandboxDialog extends BaseDialogBean // dependent order, so clients don't have to worry about // accessing a preview layer whose main layer has been torn // out from under it. - AVMConstants.removeVServerWebapp(path, true); + AVMUtil.removeVServerWebapp(path, true); // TODO: Use the .sandbox-id. property to delete all sandboxes, // rather than assume a sandbox always had a single preview @@ -127,7 +127,7 @@ public class DeleteSandboxDialog extends BaseDialogBean this.avmService.purgeStore(sandbox); // purge the user preview sandbox store from the system - sandbox = AVMConstants.buildUserPreviewStoreName(storeRoot, username); + sandbox = AVMUtil.buildUserPreviewStoreName(storeRoot, username); this.avmService.purgeStore(sandbox); // remove the association to this web project user meta-data diff --git a/source/java/org/alfresco/web/bean/wcm/DeleteWebsiteDialog.java b/source/java/org/alfresco/web/bean/wcm/DeleteWebsiteDialog.java index 8e6e3f95eb..7cf6b0c273 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeleteWebsiteDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/DeleteWebsiteDialog.java @@ -93,9 +93,9 @@ public class DeleteWebsiteDialog extends DeleteSpaceDialog // It does not matter what webapp name we give here, so "/ROOT" // is as sensible as anything else. It's all going away. - String sandbox = AVMConstants.buildStagingStoreName(storeRoot); - String path = AVMConstants.buildStoreWebappPath(sandbox, "/ROOT"); - AVMConstants.removeVServerWebapp(path, true); + String sandbox = AVMUtil.buildStagingStoreName(storeRoot); + String path = AVMUtil.buildStoreWebappPath(sandbox, "/ROOT"); + AVMUtil.removeVServerWebapp(path, true); // get the list of users who have a sandbox in the website @@ -106,15 +106,15 @@ public class DeleteWebsiteDialog extends DeleteSpaceDialog String username = (String)nodeService.getProperty(ref.getChildRef(), WCMAppModel.PROP_WEBUSERNAME); // delete the preview store for this user - deleteStore(AVMConstants.buildUserPreviewStoreName(storeRoot, username)); + deleteStore(AVMUtil.buildUserPreviewStoreName(storeRoot, username)); // delete the main store for this user - deleteStore(AVMConstants.buildUserMainStoreName(storeRoot, username)); + deleteStore(AVMUtil.buildUserMainStoreName(storeRoot, username)); } // remove the main staging and preview stores - deleteStore(AVMConstants.buildStagingPreviewStoreName(storeRoot)); - deleteStore(AVMConstants.buildStagingStoreName(storeRoot)); + deleteStore(AVMUtil.buildStagingPreviewStoreName(storeRoot)); + deleteStore(AVMUtil.buildStagingStoreName(storeRoot)); // use the super implementation to delete the node itself return super.finishImpl(context, outcome); diff --git a/source/java/org/alfresco/web/bean/wcm/DeploySnapshotDialog.java b/source/java/org/alfresco/web/bean/wcm/DeploySnapshotDialog.java index d0bbbb77e3..f414be0bc1 100644 --- a/source/java/org/alfresco/web/bean/wcm/DeploySnapshotDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/DeploySnapshotDialog.java @@ -74,7 +74,7 @@ public class DeploySnapshotDialog extends BaseDialogBean this.versionToDeploy = Integer.parseInt(parameters.get("version")); this.avmBrowseBean.getDeploymentMonitorIds().clear(); this.webProjectRef = this.avmBrowseBean.getWebsite().getNodeRef(); - String stagingStore = AVMConstants.buildSandboxRootPath(this.avmBrowseBean.getStagingStore()); + String stagingStore = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getStagingStore()); this.websiteRef = AVMNodeConverter.ToNodeRef(this.versionToDeploy, stagingStore); if (logger.isDebugEnabled()) @@ -152,14 +152,14 @@ public class DeploySnapshotDialog extends BaseDialogBean args.put(AVMDeploySnapshotAction.PARAM_WEBSITE, webProjectRef); args.put(AVMDeploySnapshotAction.PARAM_TARGET_SERVER, targetServer); args.put(AVMDeploySnapshotAction.PARAM_DEFAULT_RMI_PORT, - AVMConstants.getRemoteRMIRegistryPort()); + AVMUtil.getRemoteRMIRegistryPort()); args.put(AVMDeploySnapshotAction.PARAM_REMOTE_USERNAME, - AVMConstants.getRemoteDeploymentUsername()); + AVMUtil.getRemoteDeploymentUsername()); args.put(AVMDeploySnapshotAction.PARAM_REMOTE_PASSWORD, - AVMConstants.getRemoteDeploymentPassword()); + AVMUtil.getRemoteDeploymentPassword()); args.put(AVMDeploySnapshotAction.PARAM_CALLBACK, monitor); args.put(AVMDeploySnapshotAction.PARAM_DELAY, - AVMConstants.getRemoteDeploymentDelay()); + AVMUtil.getRemoteDeploymentDelay()); Action action = this.actionService.createAction(AVMDeploySnapshotAction.NAME, args); this.actionService.executeAction(action, this.websiteRef, false, true); } diff --git a/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java b/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java index 613052dc33..7bdf5fef41 100644 --- a/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/EditWebsiteWizard.java @@ -189,11 +189,11 @@ public class EditWebsiteWizard extends CreateWebsiteWizard // change/create the root webapp name for the website if (this.webapp != null && this.webapp.length() != 0) { - String stagingStore = AVMConstants.buildStagingStoreName(this.dnsName); - String webappPath = AVMConstants.buildStoreWebappPath(stagingStore, this.webapp); + String stagingStore = AVMUtil.buildStagingStoreName(this.dnsName); + String webappPath = AVMUtil.buildStoreWebappPath(stagingStore, this.webapp); if (this.avmService.lookup(-1, webappPath) == null) { - this.avmService.createDirectory(AVMConstants.buildSandboxRootPath(stagingStore), this.webapp); + this.avmService.createDirectory(AVMUtil.buildSandboxRootPath(stagingStore), this.webapp); } this.nodeService.setProperty(nodeRef, WCMAppModel.PROP_DEFAULTWEBAPP, this.webapp); } diff --git a/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java b/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java index c8c5f97c73..d6fc915159 100644 --- a/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java +++ b/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java @@ -131,7 +131,7 @@ public class FileDetailsBean extends AVMDetailsBean */ public String getPreviewUrl() { - return AVMConstants.buildAssetUrl(getAvmNode().getPath()); + return AVMUtil.buildAssetUrl(getAvmNode().getPath()); } /** diff --git a/source/java/org/alfresco/web/bean/wcm/FolderDetailsBean.java b/source/java/org/alfresco/web/bean/wcm/FolderDetailsBean.java index 34aad5ec78..20b4bc0e3e 100644 --- a/source/java/org/alfresco/web/bean/wcm/FolderDetailsBean.java +++ b/source/java/org/alfresco/web/bean/wcm/FolderDetailsBean.java @@ -61,7 +61,7 @@ public class FolderDetailsBean extends AVMDetailsBean */ public String getPreviewUrl() { - return AVMConstants.buildAssetUrl(getAvmNode().getPath()); + return AVMUtil.buildAssetUrl(getAvmNode().getPath()); } /** diff --git a/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java b/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java index 7b73ba6822..41a2654f76 100644 --- a/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java @@ -212,13 +212,13 @@ public class ImportWebsiteDialog // After a bulk import it's a good idea to snapshot the store this.avmService.createSnapshot( - AVMConstants.getStoreName(rootPath), + AVMUtil.getStoreName(rootPath), "Import of file: " + this.fileName, null); tx.commit(); // Reload virtualisation server as required - AVMConstants.updateVServerWebapp(rootPath, true); + AVMUtil.updateVServerWebapp(rootPath, true); UIContextService.getInstance(context).notifyBeans(); diff --git a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java index 34f7d164f9..83b475b650 100644 --- a/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/InviteWebsiteUsersWizard.java @@ -125,7 +125,7 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard { foundCurrentUser = true; } - if (AVMConstants.ROLE_CONTENT_MANAGER.equals(userRole.getRole())) + if (AVMUtil.ROLE_CONTENT_MANAGER.equals(userRole.getRole())) { this.managers.add(userAuth); } @@ -134,7 +134,7 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard if (foundCurrentUser == false) { - this.userGroupRoles.add(new UserGroupRole(currentUser, AVMConstants.ROLE_CONTENT_MANAGER, null)); + this.userGroupRoles.add(new UserGroupRole(currentUser, AVMUtil.ROLE_CONTENT_MANAGER, null)); this.managers.add(currentUser); } } @@ -146,7 +146,7 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard { for (String userAuth : findNestedUserAuthorities(userRole.getAuthority())) { - if (AVMConstants.ROLE_CONTENT_MANAGER.equals(userRole.getRole())) + if (AVMUtil.ROLE_CONTENT_MANAGER.equals(userRole.getRole())) { this.managers.add(userAuth); } @@ -161,7 +161,7 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard String username = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); String userrole = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE); - if (AVMConstants.ROLE_CONTENT_MANAGER.equals(userrole) && + if (AVMUtil.ROLE_CONTENT_MANAGER.equals(userrole) && this.managers.contains(username) == false) { this.managers.add(username); @@ -201,7 +201,7 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard // if this new user is a manager, we'll need to update the manager permissions applied // to each existing user sandbox - to ensure that new managers have access to them - managersUpdateRequired |= (AVMConstants.ROLE_CONTENT_MANAGER.equals(userRole.getRole())); + managersUpdateRequired |= (AVMUtil.ROLE_CONTENT_MANAGER.equals(userRole.getRole())); } } } @@ -238,13 +238,13 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard { for (SandboxInfo sandboxInfo : this.sandboxInfoList) { - String newlyInvitedStoreName = AVMConstants.buildStagingStoreName( + String newlyInvitedStoreName = AVMUtil.buildStagingStoreName( sandboxInfo.getMainStoreName()); - String path = AVMConstants.buildStoreWebappPath( + String path = AVMUtil.buildStoreWebappPath( newlyInvitedStoreName, this.avmBrowseBean.getWebapp()); - AVMConstants.updateVServerWebapp(path, true); + AVMUtil.updateVServerWebapp(path, true); } } return outcome; @@ -314,7 +314,7 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard if (isStandalone() == false && foundCurrentUser == false) { buf.append(buildLabelForUserAuthorityRole( - currentUser, AVMConstants.ROLE_CONTENT_MANAGER)); + currentUser, AVMUtil.ROLE_CONTENT_MANAGER)); } return buildSummary( diff --git a/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java b/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java index 910ebffbe0..cccaeaf3d0 100644 --- a/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/RevertAllDialog.java @@ -109,8 +109,8 @@ public class RevertAllDialog extends BaseDialogBean protected String finishImpl(FacesContext context, String outcome) throws Exception { String webapp = this.avmBrowseBean.getWebapp(); - String userStore = AVMConstants.buildStoreWebappPath(this.avmBrowseBean.getSandbox(), webapp); - String stagingStore = AVMConstants.buildStoreWebappPath(this.avmBrowseBean.getStagingStore(), webapp); + 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.avmSyncService.compare( @@ -155,7 +155,7 @@ public class RevertAllDialog extends BaseDialogBean // that update_path requires virt server notification. if (this.virtUpdatePath != null) { - AVMConstants.updateVServerWebapp(this.virtUpdatePath, true); + AVMUtil.updateVServerWebapp(this.virtUpdatePath, true); } return outcome; } diff --git a/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java b/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java index 28f15d1eeb..3c73c568b5 100644 --- a/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/RevertSelectedDialog.java @@ -132,7 +132,7 @@ public class RevertSelectedDialog extends BaseDialogBean // that update_path requires virt server notification. if (this.virtUpdatePath != null) { - AVMConstants.updateVServerWebapp(this.virtUpdatePath, true); + AVMUtil.updateVServerWebapp(this.virtUpdatePath, 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 b1eb3b2ff8..9edce7fa99 100644 --- a/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java +++ b/source/java/org/alfresco/web/bean/wcm/SandboxFactory.java @@ -32,6 +32,7 @@ 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.sandbox.SandboxConstants; import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; @@ -39,6 +40,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; +import org.alfresco.util.DNSNameMangler; import org.alfresco.web.bean.repository.Repository; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -82,7 +84,7 @@ public final class SandboxFactory final PermissionService permissionService = services.getPermissionService(); // create the 'staging' store for the website - final String stagingStoreName = AVMConstants.buildStagingStoreName(storeId); + final String stagingStoreName = AVMUtil.buildStagingStoreName(storeId); avmService.createStore(stagingStoreName); if (logger.isDebugEnabled()) logger.debug("Created staging sandbox store: " + stagingStoreName); @@ -90,18 +92,18 @@ public final class SandboxFactory // create the system directories 'www' and 'avm_webapps' avmService.createDirectory(stagingStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); // apply READ permissions for all users - NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(stagingStoreName)); + NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMUtil.buildStoreRootPath(stagingStoreName)); permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); - avmService.createDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), + avmService.createDirectory(AVMUtil.buildStoreRootPath(stagingStoreName), JNDIConstants.DIR_DEFAULT_APPBASE); // tag the store with the store type avmService.setStoreProperty(stagingStoreName, - AVMConstants.PROP_SANDBOX_STAGING_MAIN, + SandboxConstants.PROP_SANDBOX_STAGING_MAIN, new PropertyValue(DataTypeDefinition.TEXT, null)); avmService.setStoreProperty(stagingStoreName, - AVMConstants.PROP_WEB_PROJECT_NODE_REF, + AVMUtil.PROP_WEB_PROJECT_NODE_REF, new PropertyValue(DataTypeDefinition.NODE_REF, webProjectNodeRef)); // tag the store with the DNS name property @@ -112,23 +114,23 @@ public final class SandboxFactory // create the 'preview' store for the website - final String previewStoreName = AVMConstants.buildStagingPreviewStoreName(storeId); + final String previewStoreName = AVMUtil.buildStagingPreviewStoreName(storeId); avmService.createStore(previewStoreName); if (logger.isDebugEnabled()) logger.debug("Created staging preview sandbox store: " + previewStoreName + " above " + stagingStoreName); // create a layered directory pointing to 'www' in the staging area - avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), + avmService.createLayeredDirectory(AVMUtil.buildStoreRootPath(stagingStoreName), previewStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); // apply READ permissions for all users - dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(previewStoreName)); + dirRef = AVMNodeConverter.ToNodeRef(-1, AVMUtil.buildStoreRootPath(previewStoreName)); permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); // tag the store with the store type avmService.setStoreProperty(previewStoreName, - AVMConstants.PROP_SANDBOX_STAGING_PREVIEW, + SandboxConstants.PROP_SANDBOX_STAGING_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with the DNS name property @@ -142,7 +144,7 @@ public final class SandboxFactory // tag all related stores to indicate that they are part of a single sandbox - final QName sandboxIdProp = QName.createQName(AVMConstants.PROP_SANDBOXID + GUID.generate()); + final QName sandboxIdProp = QName.createQName(SandboxConstants.PROP_SANDBOXID + GUID.generate()); avmService.setStoreProperty(stagingStoreName, sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null)); @@ -188,8 +190,8 @@ public final class SandboxFactory final PermissionService permissionService = services.getPermissionService(); // create the user 'main' store - final String userStoreName = AVMConstants.buildUserMainStoreName(storeId, username); - final String previewStoreName = AVMConstants.buildUserPreviewStoreName(storeId, username); + final String userStoreName = AVMUtil.buildUserMainStoreName(storeId, username); + final String previewStoreName = AVMUtil.buildUserPreviewStoreName(storeId, username); if (avmService.getStore(userStoreName) != null) { @@ -201,39 +203,39 @@ public final class SandboxFactory } avmService.createStore(userStoreName); - final String stagingStoreName = AVMConstants.buildStagingStoreName(storeId); + final String stagingStoreName = AVMUtil.buildStagingStoreName(storeId); if (logger.isDebugEnabled()) logger.debug("Created user sandbox store: " + userStoreName + " above staging store " + stagingStoreName); // create a layered directory pointing to 'www' in the staging area - avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), + avmService.createLayeredDirectory(AVMUtil.buildStoreRootPath(stagingStoreName), userStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); - NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(userStoreName)); + NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMUtil.buildStoreRootPath(userStoreName)); // apply the user role permissions to the sandbox permissionService.setPermission(dirRef, username, role, true); permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); // apply the manager role permission for each manager in the web project for (String manager : managers) { - permissionService.setPermission(dirRef, manager, AVMConstants.ROLE_CONTENT_MANAGER, true); + permissionService.setPermission(dirRef, manager, AVMUtil.ROLE_CONTENT_MANAGER, true); } // tag the store with the store type avmService.setStoreProperty(userStoreName, - AVMConstants.PROP_SANDBOX_AUTHOR_MAIN, + SandboxConstants.PROP_SANDBOX_AUTHOR_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(userStoreName, - AVMConstants.PROP_WEBSITE_NAME, + SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(DataTypeDefinition.TEXT, storeId)); // tag the store, oddly enough, with its own store name for querying. avmService.setStoreProperty(userStoreName, - QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + userStoreName), + QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + userStoreName), new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with the DNS name property @@ -252,27 +254,27 @@ public final class SandboxFactory " above " + userStoreName); // create a layered directory pointing to 'www' in the user 'main' store - avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(userStoreName), + avmService.createLayeredDirectory(AVMUtil.buildStoreRootPath(userStoreName), previewStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); - dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(previewStoreName)); + dirRef = AVMNodeConverter.ToNodeRef(-1, AVMUtil.buildStoreRootPath(previewStoreName)); // apply the user role permissions to the sandbox permissionService.setPermission(dirRef, username, role, true); permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ, true); // apply the manager role permission for each manager in the web project for (String manager : managers) { - permissionService.setPermission(dirRef, manager, AVMConstants.ROLE_CONTENT_MANAGER, true); + permissionService.setPermission(dirRef, manager, AVMUtil.ROLE_CONTENT_MANAGER, true); } // tag the store with the store type avmService.setStoreProperty(previewStoreName, - AVMConstants.PROP_SANDBOX_AUTHOR_PREVIEW, + SandboxConstants.PROP_SANDBOX_AUTHOR_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with its own store name for querying. avmService.setStoreProperty(previewStoreName, - QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), + QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with the DNS name property @@ -290,7 +292,7 @@ public final class SandboxFactory // tag all related stores to indicate that they are part of a single sandbox - QName sandboxIdProp = QName.createQName(null, AVMConstants.PROP_SANDBOXID + GUID.generate()); + QName sandboxIdProp = QName.createQName(null, SandboxConstants.PROP_SANDBOXID + GUID.generate()); avmService.setStoreProperty(userStoreName, sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null)); @@ -324,36 +326,36 @@ public final class SandboxFactory final AVMService avmService = services.getAVMService(); final PermissionService permissionService = services.getPermissionService(); - final String stagingStoreName = AVMConstants.buildStagingStoreName(storeId); + final String stagingStoreName = AVMUtil.buildStagingStoreName(storeId); // create the user 'main' store - final String packageName = AVMConstants.STORE_WORKFLOW + "-" + GUID.generate(); + final String packageName = AVMUtil.STORE_WORKFLOW + "-" + GUID.generate(); final String mainStoreName = - AVMConstants.buildWorkflowMainStoreName(storeId, packageName); + AVMUtil.buildWorkflowMainStoreName(storeId, packageName); avmService.createStore(mainStoreName); if (logger.isDebugEnabled()) logger.debug("Created workflow sandbox store: " + mainStoreName); // create a layered directory pointing to 'www' in the staging area - avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName), + avmService.createLayeredDirectory(AVMUtil.buildStoreRootPath(stagingStoreName), mainStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); // tag the store with the store type avmService.setStoreProperty(mainStoreName, - AVMConstants.PROP_SANDBOX_WORKFLOW_MAIN, + SandboxConstants.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(mainStoreName, - AVMConstants.PROP_WEBSITE_NAME, + SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(DataTypeDefinition.TEXT, storeId)); // tag the store, oddly enough, with its own store name for querying. avmService.setStoreProperty(mainStoreName, - QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + mainStoreName), + QName.createQName(null, SandboxConstants.PROP_SANDBOX_STORE_PREFIX + mainStoreName), new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with the DNS name property @@ -368,25 +370,25 @@ public final class SandboxFactory // create the user 'preview' store final String previewStoreName = - AVMConstants.buildWorkflowPreviewStoreName(storeId, packageName); + AVMUtil.buildWorkflowPreviewStoreName(storeId, packageName); avmService.createStore(previewStoreName); if (logger.isDebugEnabled()) logger.debug("Created user sandbox preview store: " + previewStoreName); // create a layered directory pointing to 'www' in the user 'main' store - avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(mainStoreName), + avmService.createLayeredDirectory(AVMUtil.buildStoreRootPath(mainStoreName), previewStoreName + ":/", JNDIConstants.DIR_DEFAULT_WWW); // tag the store with the store type avmService.setStoreProperty(previewStoreName, - AVMConstants.PROP_SANDBOX_WORKFLOW_PREVIEW, + SandboxConstants.PROP_SANDBOX_WORKFLOW_PREVIEW, new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with its own store name for querying. avmService.setStoreProperty(previewStoreName, QName.createQName(null, - AVMConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), + SandboxConstants.PROP_SANDBOX_STORE_PREFIX + previewStoreName), new PropertyValue(DataTypeDefinition.TEXT, null)); // tag the store with the DNS name property @@ -405,7 +407,7 @@ public final class SandboxFactory // tag all related stores to indicate that they are part of a single sandbox - final QName sandboxIdProp = QName.createQName(AVMConstants.PROP_SANDBOXID + GUID.generate()); + final QName sandboxIdProp = QName.createQName(SandboxConstants.PROP_SANDBOXID + GUID.generate()); avmService.setStoreProperty(mainStoreName, sandboxIdProp, new PropertyValue(DataTypeDefinition.TEXT, null)); @@ -436,21 +438,21 @@ public final class SandboxFactory final ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance()); final PermissionService permissionService = services.getPermissionService(); - final String userStoreName = AVMConstants.buildUserMainStoreName(storeId, username); - final String previewStoreName = AVMConstants.buildUserPreviewStoreName(storeId, username); + final String userStoreName = AVMUtil.buildUserMainStoreName(storeId, username); + final String previewStoreName = AVMUtil.buildUserPreviewStoreName(storeId, username); // apply the manager role permission to the user main sandbox for each manager - NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(userStoreName)); + NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, AVMUtil.buildStoreRootPath(userStoreName)); for (String manager : managers) { - permissionService.setPermission(dirRef, manager, AVMConstants.ROLE_CONTENT_MANAGER, true); + permissionService.setPermission(dirRef, manager, AVMUtil.ROLE_CONTENT_MANAGER, true); } // apply the manager role permission to the user preview sandbox for each manager - dirRef = AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildStoreRootPath(previewStoreName)); + dirRef = AVMNodeConverter.ToNodeRef(-1, AVMUtil.buildStoreRootPath(previewStoreName)); for (String manager : managers) { - permissionService.setPermission(dirRef, manager, AVMConstants.ROLE_CONTENT_MANAGER, true); + permissionService.setPermission(dirRef, manager, AVMUtil.ROLE_CONTENT_MANAGER, true); } } @@ -462,9 +464,9 @@ public final class SandboxFactory */ private static void tagStoreDNSPath(AVMService avmService, String store, String... components) { - String path = AVMConstants.buildSandboxRootPath(store); + String path = AVMUtil.buildSandboxRootPath(store); // DNS name mangle the property name - can only contain value DNS characters! - String dnsProp = AVMConstants.PROP_DNS + DNSNameMangler.MakeDNSName(components); + String dnsProp = SandboxConstants.PROP_DNS + DNSNameMangler.MakeDNSName(components); avmService.setStoreProperty(store, QName.createQName(null, dnsProp), new PropertyValue(DataTypeDefinition.TEXT, path)); } @@ -499,7 +501,7 @@ public final class SandboxFactory String backgroundStore, int distance) { - String prop_key = AVMConstants.PROP_BACKGROUND_LAYER + backgroundStore; + String prop_key = SandboxConstants.PROP_BACKGROUND_LAYER + backgroundStore; avmService.setStoreProperty(store, QName.createQName(null, prop_key), new PropertyValue(DataTypeDefinition.INT, distance)); } diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java index e4172dd19d..23d8f3e6e6 100644 --- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java @@ -306,7 +306,7 @@ public class SubmitDialog extends BaseDialogBean // add submission parameters params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, getComment()); params.put(AVMWorkflowUtil.PROP_LABEL, getLabel()); - params.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMConstants.buildStoreRootPath(this.avmBrowseBean.getSandbox())); + params.put(AVMWorkflowUtil.PROP_FROM_PATH, AVMUtil.buildStoreRootPath(this.avmBrowseBean.getSandbox())); // update start task with submit parameters this.workflowService.updateTask(startTask.id, params, null, null); @@ -332,8 +332,8 @@ public class SubmitDialog extends BaseDialogBean List items = getSubmitItems(); // construct diffs for selected items for submission - String sandboxPath = AVMConstants.buildSandboxRootPath(this.avmBrowseBean.getSandbox()); - String stagingPath = AVMConstants.buildSandboxRootPath(this.avmBrowseBean.getStagingStore()); + String sandboxPath = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getSandbox()); + String stagingPath = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getStagingStore()); List diffs = new ArrayList(items.size()); for (ItemWrapper wrapper : items) @@ -379,7 +379,7 @@ public class SubmitDialog extends BaseDialogBean // // mysite:/www/avm_webapps/ROOT/WEB-INF/web.xml // mysite:/www/avm_webapps/ROOT/WEB-INF/lib/moo.jar - AVMConstants.updateVServerWebapp(this.virtUpdatePath, true); + AVMUtil.updateVServerWebapp(this.virtUpdatePath, true); } return outcome; } @@ -582,8 +582,8 @@ public class SubmitDialog extends BaseDialogBean if (this.avmBrowseBean.getAllItemsAction()) { String webapp = this.avmBrowseBean.getWebapp(); - String userStore = AVMConstants.buildStoreWebappPath(this.avmBrowseBean.getSandbox(), webapp); - String stagingStore = AVMConstants.buildStoreWebappPath(this.avmBrowseBean.getStagingStore(), webapp); + String userStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getSandbox(), webapp); + String stagingStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getStagingStore(), webapp); List diffs = this.avmSyncService.compare(-1, userStore, -1, stagingStore, nameMatcher); selected = new ArrayList(diffs.size()); for (AVMDifference diff : diffs) @@ -894,8 +894,8 @@ public class SubmitDialog extends BaseDialogBean public String getPreviewUrl() { ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance()); - String dns = AVMConstants.lookupStoreDNS(AVMConstants.getStoreName(descriptor.getPath())); - return AVMConstants.buildAssetUrl(AVMConstants.getSandboxRelativePath(descriptor.getPath()), + String dns = AVMUtil.lookupStoreDNS(AVMUtil.getStoreName(descriptor.getPath())); + return AVMUtil.buildAssetUrl(AVMUtil.getSandboxRelativePath(descriptor.getPath()), config.getWCMDomain(), config.getWCMPort(), dns); diff --git a/source/java/org/alfresco/web/bean/wcm/WebProject.java b/source/java/org/alfresco/web/bean/wcm/WebProject.java index 37b753f87f..47c215a5ed 100644 --- a/source/java/org/alfresco/web/bean/wcm/WebProject.java +++ b/source/java/org/alfresco/web/bean/wcm/WebProject.java @@ -173,11 +173,11 @@ public class WebProject public WebProject(final String avmPath) { - String stagingStore = AVMConstants.buildStagingStoreName(AVMConstants.getStoreId(AVMConstants.getStoreName(avmPath))); + String stagingStore = AVMUtil.buildStagingStoreName(AVMUtil.getStoreId(AVMUtil.getStoreName(avmPath))); final AVMService avmService = this.getServiceRegistry().getAVMService(); this.nodeRef = (NodeRef) avmService.getStoreProperty(stagingStore, - AVMConstants.PROP_WEB_PROJECT_NODE_REF).getValue(DataTypeDefinition.NODE_REF); + AVMUtil.PROP_WEB_PROJECT_NODE_REF).getValue(DataTypeDefinition.NODE_REF); } /** @@ -211,7 +211,7 @@ public class WebProject */ public String getStagingStore() { - return AVMConstants.buildStagingStoreName(this.getStoreId()); + return AVMUtil.buildStagingStoreName(this.getStoreId()); } /** @@ -269,7 +269,7 @@ public class WebProject final NodeRef userInfoRef = ref.getChildRef(); final String username = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); final String userrole = (String)nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE); - if (currentUser.equals(username) && AVMConstants.ROLE_CONTENT_MANAGER.equals(userrole)) + if (currentUser.equals(username) && AVMUtil.ROLE_CONTENT_MANAGER.equals(userrole)) { return true; } diff --git a/source/java/org/alfresco/web/forms/FormImpl.java b/source/java/org/alfresco/web/forms/FormImpl.java index b95222741d..f141f7af69 100644 --- a/source/java/org/alfresco/web/forms/FormImpl.java +++ b/source/java/org/alfresco/web/forms/FormImpl.java @@ -49,7 +49,7 @@ import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.AVMWorkflowUtil; import org.alfresco.web.forms.xforms.XFormsProcessor; import org.apache.commons.logging.Log; @@ -154,7 +154,7 @@ public class FormImpl root.put("xml", NodeModel.wrap(formInstanceData)); root.put("name", formInstanceDataName); root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME)); - root.put("cwd", AVMConstants.getWebappRelativePath(parentAVMPath)); + root.put("cwd", AVMUtil.getWebappRelativePath(parentAVMPath)); final TemplateService templateService = this.getServiceRegistry().getTemplateService(); @@ -182,9 +182,9 @@ public class FormImpl ":\n" + te.getMessage(), te); } - result = AVMConstants.buildPath(parentAVMPath, + result = AVMUtil.buildPath(parentAVMPath, result, - AVMConstants.PathRelation.SANDBOX_RELATIVE); + AVMUtil.PathRelation.SANDBOX_RELATIVE); LOGGER.debug("processed pattern " + outputPathPattern + " as " + result); return result; } diff --git a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java index 5d7a7e9cef..b8efb5c404 100644 --- a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java +++ b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java @@ -36,7 +36,7 @@ import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.*; import org.alfresco.service.namespace.QName; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.*; @@ -79,12 +79,12 @@ public class FormInstanceDataImpl public String getWebappRelativePath() { - return AVMConstants.getWebappRelativePath(this.getPath()); + return AVMUtil.getWebappRelativePath(this.getPath()); } public String getSandboxRelativePath() { - return AVMConstants.getSandboxRelativePath(this.getPath()); + return AVMUtil.getSandboxRelativePath(this.getPath()); } public String getPath() @@ -116,7 +116,7 @@ public class FormInstanceDataImpl public String getUrl() { - return AVMConstants.buildAssetUrl(this.getPath()); + return AVMUtil.buildAssetUrl(this.getPath()); } public List getRenditions() @@ -127,7 +127,7 @@ public class FormInstanceDataImpl final Collection renditionPaths = (pv == null ? Collections.EMPTY_LIST : pv.getCollection(DataTypeDefinition.TEXT)); - final String storeName = AVMConstants.getStoreName(this.getPath()); + final String storeName = AVMUtil.getStoreName(this.getPath()); final List result = new ArrayList(renditionPaths.size()); for (Serializable path : renditionPaths) { diff --git a/source/java/org/alfresco/web/forms/FormsService.java b/source/java/org/alfresco/web/forms/FormsService.java index f2ba623a94..df4833ba79 100644 --- a/source/java/org/alfresco/web/forms/FormsService.java +++ b/source/java/org/alfresco/web/forms/FormsService.java @@ -56,7 +56,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.QuickSort; import org.apache.commons.logging.Log; diff --git a/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java b/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java index aa0d6ba571..75a1b1b984 100644 --- a/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java +++ b/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java @@ -35,7 +35,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; diff --git a/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java b/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java index deb23f42c4..05c032f28a 100644 --- a/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java +++ b/source/java/org/alfresco/web/forms/RenderingEngineTemplateImpl.java @@ -57,7 +57,7 @@ import org.alfresco.service.namespace.*; import org.alfresco.service.cmr.remote.AVMRemote; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -186,9 +186,9 @@ public class RenderingEngineTemplateImpl final String webappName = (avmService.hasAspect(-1, - AVMConstants.getWebappPath(formInstanceDataAVMPath), + AVMUtil.getWebappPath(formInstanceDataAVMPath), WCMAppModel.ASPECT_WEBAPP) - ? AVMConstants.getWebapp(formInstanceDataAVMPath) + ? AVMUtil.getWebapp(formInstanceDataAVMPath) : null); root.put("webapp", webappName); @@ -211,7 +211,7 @@ public class RenderingEngineTemplateImpl root.put("xml", NodeModel.wrap(formInstanceDataDocument)); root.put("node", new TemplateNode(((FormInstanceDataImpl)formInstanceData).getNodeRef(), sr, null)); root.put("date", new SimpleDate(new Date(), SimpleDate.DATETIME)); - root.put("cwd", AVMConstants.getWebappRelativePath(currentAVMPath)); + root.put("cwd", AVMUtil.getWebappRelativePath(currentAVMPath)); final TemplateService templateService = sr.getTemplateService(); final String outputPathPattern = (FreeMarkerUtil.buildNamespaceDeclaration(formInstanceDataDocument) + this.getOutputPathPattern()); @@ -232,9 +232,9 @@ public class RenderingEngineTemplateImpl te); } - result = AVMConstants.buildPath(parentAVMPath, + result = AVMUtil.buildPath(parentAVMPath, result, - AVMConstants.PathRelation.SANDBOX_RELATIVE); + AVMUtil.PathRelation.SANDBOX_RELATIVE); LOGGER.debug("processed pattern " + outputPathPattern + " as " + result); return result; } @@ -257,7 +257,7 @@ public class RenderingEngineTemplateImpl if (!isRegenerate) { final String parentAVMPath = AVMNodeConverter.SplitBase(renditionAvmPath)[0]; - AVMConstants.makeAllDirectories(parentAVMPath); + AVMUtil.makeAllDirectories(parentAVMPath); avmService.createFile(parentAVMPath, AVMNodeConverter.SplitBase(renditionAvmPath)[1]); if (LOGGER.isDebugEnabled()) @@ -278,7 +278,7 @@ public class RenderingEngineTemplateImpl final Collection renditions = (pv == null ? new HashSet() : pv.getCollection(DataTypeDefinition.TEXT)); - renditions.add(AVMConstants.getStoreRelativePath(renditionAvmPath)); + renditions.add(AVMUtil.getStoreRelativePath(renditionAvmPath)); avmService.setNodeProperty(formInstanceData.getPath(), WCMAppModel.PROP_RENDITIONS, new PropertyValue(DataTypeDefinition.TEXT, @@ -317,7 +317,7 @@ public class RenderingEngineTemplateImpl new PropertyValue(DataTypeDefinition.TEXT, MessageFormat.format(bundle.getString("default_rendition_description"), this.getTitle(), - AVMConstants.getSandboxRelativePath(rendition.getPath())))); + AVMUtil.getSandboxRelativePath(rendition.getPath())))); props.put(WCMAppModel.PROP_PARENT_RENDERING_ENGINE_TEMPLATE, new PropertyValue(DataTypeDefinition.NODE_REF, this.nodeRef)); @@ -327,7 +327,7 @@ public class RenderingEngineTemplateImpl // extract a store relative path for the primary form instance data props.put(WCMAppModel.PROP_PRIMARY_FORM_INSTANCE_DATA, new PropertyValue(DataTypeDefinition.TEXT, - AVMConstants.getStoreRelativePath(formInstanceData.getPath()))); + AVMUtil.getStoreRelativePath(formInstanceData.getPath()))); final AVMService avmService = this.getServiceRegistry().getAVMService(); avmService.setNodeProperties(rendition.getPath(), props); @@ -344,8 +344,8 @@ public class RenderingEngineTemplateImpl final String formInstanceDataAvmPath = formInstanceData.getPath(); final String renditionAvmPath = rendition.getPath(); final String parentPath = AVMNodeConverter.SplitBase(formInstanceDataAvmPath)[0]; - final String sandboxUrl = AVMConstants.buildStoreUrl(formInstanceDataAvmPath); - final String webappUrl = AVMConstants.buildWebappUrl(formInstanceDataAvmPath); + final String sandboxUrl = AVMUtil.buildStoreUrl(formInstanceDataAvmPath); + final String webappUrl = AVMUtil.buildWebappUrl(formInstanceDataAvmPath); final HashMap model = new HashMap(); // add simple scalar parameters model.put(QName.createQName(NamespaceService.ALFRESCO_PREFIX, @@ -441,9 +441,9 @@ public class RenderingEngineTemplateImpl ". got a " + arguments[0].getClass().getName() + "."); } String path = (String)arguments[0]; - path = AVMConstants.buildPath(parentPath, + path = AVMUtil.buildPath(parentPath, path, - AVMConstants.PathRelation.WEBAPP_RELATIVE); + AVMUtil.PathRelation.WEBAPP_RELATIVE); LOGGER.debug("tpm_parseXMLDocument('" + path + "'), parentPath = " + parentPath); final Document d = fdf.parseXMLDocument(path); @@ -477,9 +477,9 @@ public class RenderingEngineTemplateImpl } String path = arguments.length == 2 ? (String)arguments[1] : ""; - path = AVMConstants.buildPath(parentPath, + path = AVMUtil.buildPath(parentPath, path, - AVMConstants.PathRelation.WEBAPP_RELATIVE); + AVMUtil.PathRelation.WEBAPP_RELATIVE); final String formName = (String)arguments[0]; LOGGER.debug("tpm_parseXMLDocuments('" + formName + "','" + path + "'), parentPath = " + parentPath); @@ -535,9 +535,9 @@ public class RenderingEngineTemplateImpl final String path = (String)arguments[0]; LOGGER.debug("tpm_getAVMPAth('" + path + "'), parentPath = " + parentPath); - return AVMConstants.buildPath(parentPath, + return AVMUtil.buildPath(parentPath, path, - AVMConstants.PathRelation.WEBAPP_RELATIVE); + AVMUtil.PathRelation.WEBAPP_RELATIVE); } }); diff --git a/source/java/org/alfresco/web/forms/RenditionImpl.java b/source/java/org/alfresco/web/forms/RenditionImpl.java index 8f42aca9ae..f792f02ddb 100644 --- a/source/java/org/alfresco/web/forms/RenditionImpl.java +++ b/source/java/org/alfresco/web/forms/RenditionImpl.java @@ -36,7 +36,7 @@ import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.ui.common.Utils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -83,12 +83,12 @@ public class RenditionImpl public String getWebappRelativePath() { - return AVMConstants.getWebappRelativePath(this.getPath()); + return AVMUtil.getWebappRelativePath(this.getPath()); } public String getSandboxRelativePath() { - return AVMConstants.getSandboxRelativePath(this.getPath()); + return AVMUtil.getSandboxRelativePath(this.getPath()); } public FormInstanceData getPrimaryFormInstanceData() @@ -139,7 +139,7 @@ public class RenditionImpl public String getUrl() { - return AVMConstants.buildAssetUrl(this.getPath()); + return AVMUtil.buildAssetUrl(this.getPath()); } public String getFileTypeImage() diff --git a/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java b/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java index c6bf9873ff..50521cdaaa 100644 --- a/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java +++ b/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java @@ -44,7 +44,7 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.forms.XMLUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java index c68348fe36..7aa9a976db 100644 --- a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java +++ b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java @@ -49,7 +49,7 @@ import org.alfresco.web.app.servlet.ajax.InvokeCommand; import org.alfresco.web.bean.FileUploadBean; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.wcm.AVMBrowseBean; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.AVMNode; import org.alfresco.web.forms.*; import org.alfresco.web.ui.common.Utils; @@ -462,10 +462,10 @@ public class XFormsBean else { final String previewStorePath = - AVMConstants.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath()); - currentPath = AVMConstants.buildPath(previewStorePath, + AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath()); + currentPath = AVMUtil.buildPath(previewStorePath, currentPath, - AVMConstants.PathRelation.WEBAPP_RELATIVE); + AVMUtil.PathRelation.WEBAPP_RELATIVE); } LOGGER.debug(this + ".getFilePickerData(" + currentPath + ")"); @@ -490,7 +490,7 @@ public class XFormsBean Element e = result.createElement("current-node"); e.setAttribute("avmPath", currentPath); e.setAttribute("webappRelativePath", - AVMConstants.getWebappRelativePath(currentPath)); + AVMUtil.getWebappRelativePath(currentPath)); e.setAttribute("type", "directory"); e.setAttribute("image", "/images/icons/space_small.gif"); filePickerDataElement.appendChild(e); @@ -501,7 +501,7 @@ public class XFormsBean e = result.createElement("child-node"); e.setAttribute("avmPath", entry.getValue().getPath()); e.setAttribute("webappRelativePath", - AVMConstants.getWebappRelativePath(entry.getValue().getPath())); + AVMUtil.getWebappRelativePath(entry.getValue().getPath())); e.setAttribute("type", entry.getValue().isDirectory() ? "directory" : "file"); e.setAttribute("image", (entry.getValue().isDirectory() ? "/images/icons/space_small.gif" @@ -552,10 +552,10 @@ public class XFormsBean else if (item.isFormField() && item.getFieldName().equals("currentPath")) { final String previewStorePath = - AVMConstants.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath()); - currentPath = AVMConstants.buildPath(previewStorePath, + AVMUtil.getCorrespondingPathInPreviewStore(this.getCurrentAVMPath()); + currentPath = AVMUtil.buildPath(previewStorePath, item.getString(), - AVMConstants.PathRelation.WEBAPP_RELATIVE); + AVMUtil.PathRelation.WEBAPP_RELATIVE); LOGGER.debug("currentPath is " + currentPath); } else @@ -692,8 +692,8 @@ public class XFormsBean } final String baseURI = (uri.charAt(0) == '/' - ? AVMConstants.buildStoreUrl(cwdAvmPath) - : AVMConstants.buildAssetUrl(cwdAvmPath)); + ? AVMUtil.buildStoreUrl(cwdAvmPath) + : AVMUtil.buildAssetUrl(cwdAvmPath)); LOGGER.debug("rewriting " + uri + " as " + (baseURI + uri)); includeEl.setAttribute("schemaLocation", baseURI + uri); diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java b/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java index d87b4fdc62..a70f0a72e6 100644 --- a/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java +++ b/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java @@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletRequest; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.web.bean.wcm.AVMBrowseBean; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.forms.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -173,7 +173,7 @@ public class XFormsProcessor append(JavaScriptUtils.javaScriptEscape(avmBrowseBean.getWebapp())). append("';\n"); js.append("alfresco.constants.AVM_WEBAPP_URL = '"). - append(JavaScriptUtils.javaScriptEscape(AVMConstants.buildWebappUrl(AVMConstants.getCorrespondingPreviewStoreName(avmBrowseBean.getSandbox()), + append(JavaScriptUtils.javaScriptEscape(AVMUtil.buildWebappUrl(AVMUtil.getCorrespondingPreviewStoreName(avmBrowseBean.getSandbox()), avmBrowseBean.getWebapp()))). append("';\n"); js.append("alfresco.xforms.constants.XFORMS_UI_DIV_ID = '"). diff --git a/source/java/org/alfresco/web/ui/repo/component/AbstractItemSelector.java b/source/java/org/alfresco/web/ui/repo/component/AbstractItemSelector.java index beb38b47ac..6f18c48454 100644 --- a/source/java/org/alfresco/web/ui/repo/component/AbstractItemSelector.java +++ b/source/java/org/alfresco/web/ui/repo/component/AbstractItemSelector.java @@ -49,7 +49,7 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.util.Pair; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.WebResources; import org.springframework.web.jsf.FacesContextUtils; @@ -382,7 +382,7 @@ public abstract class AbstractItemSelector extends UIInput { Pair avmNode = AVMNodeConverter.ToAVMVersionPath(value); String avmPath = avmNode.getSecond(); - label = avmPath.substring(avmPath.indexOf(AVMConstants.DIR_ROOT)+4); + label = avmPath.substring(avmPath.indexOf(AVMUtil.DIR_ROOT)+4); } else { diff --git a/source/java/org/alfresco/web/ui/repo/component/UIWebProjectFolderSelector.java b/source/java/org/alfresco/web/ui/repo/component/UIWebProjectFolderSelector.java index 23847faab3..40e12dcdd9 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UIWebProjectFolderSelector.java +++ b/source/java/org/alfresco/web/ui/repo/component/UIWebProjectFolderSelector.java @@ -44,7 +44,7 @@ import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.WebProject; import org.alfresco.web.ui.repo.WebResources; import org.apache.commons.logging.Log; @@ -79,7 +79,7 @@ public class UIWebProjectFolderSelector extends AbstractItemSelector if (this.navigationId != null && this.navigationId.startsWith("-1;")) { String rootPath = "-1;" + JNDIConstants.DIR_DEFAULT_WWW + ";" + JNDIConstants.DIR_DEFAULT_APPBASE + - ";" + AVMConstants.DIR_ROOT; + ";" + AVMUtil.DIR_ROOT; if (this.navigationId.equals(rootPath) == false) { @@ -123,13 +123,13 @@ public class UIWebProjectFolderSelector extends AbstractItemSelector { // get the root children for the sandbox of the current user WebProject webProject = new WebProject(new NodeRef(Repository.getStoreRef(), this.navigationId)); - this.avmStore = AVMConstants.buildUserMainStoreName(webProject.getStoreId(), + this.avmStore = AVMUtil.buildUserMainStoreName(webProject.getStoreId(), Application.getCurrentUser(context).getUserName()); if (logger.isDebugEnabled()) logger.debug("Getting children for store: " + this.avmStore); - String rootPath = AVMConstants.buildStoreWebappPath(this.avmStore, AVMConstants.DIR_ROOT); + String rootPath = AVMUtil.buildStoreWebappPath(this.avmStore, AVMUtil.DIR_ROOT); if (logger.isDebugEnabled()) logger.debug("Root path for store: "+ rootPath); @@ -163,7 +163,7 @@ public class UIWebProjectFolderSelector extends AbstractItemSelector // if they have AddChildren there is probably a sandbox but check to make // sure as it could have been deleted WebProject webProject = new WebProject(node); - String storeName = AVMConstants.buildUserMainStoreName(webProject.getStoreId(), + String storeName = AVMUtil.buildUserMainStoreName(webProject.getStoreId(), currentUserName); AVMStoreDescriptor storeDesc = avmService.getStore(storeName); if (storeDesc != null) diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java b/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java index 11184031ab..f909b9473d 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIDeployWebsite.java @@ -42,7 +42,7 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.bean.wcm.AVMConstants; +import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.DeploymentMonitor; import org.alfresco.web.ui.common.Utils; import org.apache.commons.logging.Log; @@ -343,7 +343,7 @@ public class UIDeployWebsite extends UIInput } // determine the polling frequency value - int pollFreq = AVMConstants.getRemoteDeploymentPollingFrequency() * 1000; + int pollFreq = AVMUtil.getRemoteDeploymentPollingFrequency() * 1000; // render the script to handle the progress monitoring out.write("