diff --git a/config/alfresco/web-client-config-wcm-actions.xml b/config/alfresco/web-client-config-wcm-actions.xml index 027e8fc1a3..2da8058c52 100644 --- a/config/alfresco/web-client-config-wcm-actions.xml +++ b/config/alfresco/web-client-config-wcm-actions.xml @@ -79,7 +79,7 @@ submit /images/icons/submit.gif - #{AVMBrowseBean.setupSubmitNodeAction} + #{AVMBrowseBean.setupContentAction} dialog:submitSandboxItems #{actionContext.path} diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index af9d0ba552..1cfb6d4d28 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -405,7 +405,7 @@ public class AVMBrowseBean implements IContextListener } /** - * @return Returns the sandbox. + * @return Returns the current sandbox context. */ public String getSandbox() { @@ -413,7 +413,7 @@ public class AVMBrowseBean implements IContextListener } /** - * @param sandbox The sandbox to set. + * @param sandbox The sandbox to set. */ public void setSandbox(String sandbox) { @@ -421,7 +421,7 @@ public class AVMBrowseBean implements IContextListener } /** - * @return Returns the username. + * @return Returns the current username context. */ public String getUsername() { @@ -429,7 +429,7 @@ public class AVMBrowseBean implements IContextListener } /** - * @param username The username to set. + * @param username The username to set. */ public void setUsername(String username) { @@ -792,7 +792,7 @@ public class AVMBrowseBean implements IContextListener String store = params.get("store"); String username = params.get("username"); - setupSandboxActionImpl(store, username); + setupSandboxActionImpl(store, username, true); } /** @@ -800,8 +800,9 @@ public class AVMBrowseBean implements IContextListener * * @param store The store name for the action * @param username The authority pertinent to the action (null for staging store actions) + * @param reset True to reset the current path and AVM action node context */ - private void setupSandboxActionImpl(String store, String username) + private void setupSandboxActionImpl(String store, String username, boolean reset) { // can be null if it's the staging store - i.e. not a user specific store setUsername(username); @@ -818,14 +819,15 @@ public class AVMBrowseBean implements IContextListener (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE))); } - this.sandboxTitle = null; - // update UI state ready for return to the previous screen - this.location = null; - setCurrentPath(null); - setAvmActionNode(null); - - this.submitAll = false; + if (reset == true) + { + this.sandboxTitle = null; + this.location = null; + setCurrentPath(null); + setAvmActionNode(null); + this.submitAll = false; + } } /** @@ -849,6 +851,14 @@ public class AVMBrowseBean implements IContextListener { if (logger.isDebugEnabled()) logger.debug("Setup content action for path: " + path); + + // calculate username and store name from specified path + String[] parts = path.split("[-:]"); + String storename = parts[0]; + String username = parts[1]; + setupSandboxActionImpl(AVMConstants.buildAVMUserMainStoreName(storename, username), username, false); + + // setup the action node AVMNodeDescriptor node = avmService.lookup(-1, path, true); setAVMActionNodeDescriptor(node); } @@ -864,20 +874,6 @@ public class AVMBrowseBean implements IContextListener } } - /** - * Submit a node from a user sandbox into the staging area sandbox via worklfow - */ - public void setupSubmitNodeAction(ActionEvent event) - { - // extract store and username from the path to this node - String path = getPathFromEventArgs(event); - String[] parts = path.split("[-:]"); - String storename = parts[0]; - String username = parts[1]; - setupSandboxActionImpl(AVMConstants.buildAVMUserMainStoreName(storename, username), username); - setupContentAction(path, true); - } - /** * Submit all nodes from user sandbox into the staging area sandbox via workflow */ diff --git a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java index 4b04e75aa8..1490214a93 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java @@ -23,6 +23,7 @@ import java.util.regex.Pattern; import javax.faces.context.FacesContext; +import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.repo.domain.PropertyValue; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.namespace.QName; @@ -30,6 +31,7 @@ import org.alfresco.util.ParameterCheck; import org.alfresco.web.app.Application; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.config.ClientConfigElement; +import org.springframework.web.jsf.FacesContextUtils; /** * @author Kevin Roast @@ -260,6 +262,33 @@ public final class AVMConstants return m.matches() && m.group(1).length() != 0 ? m.group(1) : "/"; } + /** + * @param path Path to match against + * + * @return true if the path should require a virtualisation server reload, false otherwise + */ + public static boolean requiresServerReload(String path) + { + if (path == null || path.length() == 0) + { + throw new IllegalArgumentException("Path value is mandatory."); + } + + return webinfPathPattern.matcher(path).matches(); + } + + public static void reloadServerOnPath(String path, boolean force) + { + if (force || requiresServerReload(path)) + { + VirtServerRegistry vServerRegistry = (VirtServerRegistry)FacesContextUtils.getRequiredWebApplicationContext( + FacesContext.getCurrentInstance()).getBean(BEAN_VIRT_SERVER_REGISTRY); + int webappindex = path.indexOf('/', path.indexOf(DIR_WEBAPPS) + DIR_WEBAPPS.length() + 1); + vServerRegistry.webappUpdated(-1, path.substring(0, webappindex)); + } + } + + // names of the stores representing the layers for an AVM website public final static String STORE_STAGING = "-staging"; public final static String STORE_MAIN = "-main"; @@ -283,14 +312,26 @@ public final class AVMConstants public final static String PROP_SANDBOX_STORE_PREFIX = ".sandbox.store."; public final static String SPACE_ICON_WEBSITE = "space-icon-website"; + // virtualisation server MBean registry + private static final String BEAN_VIRT_SERVER_REGISTRY = "VirtServerRegistry"; + // URLs for preview of sandboxes and assets private final static String PREVIEW_SANDBOX_URL = "http://www-{0}.{1}:{2}"; private final static String PREVIEW_ASSET_URL = "http://www-{0}.{1}:{2}{3}"; - // patter for absolute AVM Path + // pattern for absolute AVM Path private final static Pattern absoluteAVMPath = Pattern.compile( "([^:]+:/" + AVMConstants.DIR_APPBASE + "/[^/]+/[^/]+).*"); private final static Pattern webappRelativePath = Pattern.compile( - "[^:]+:/" + AVMConstants.DIR_APPBASE + - "/" + AVMConstants.DIR_WEBAPPS + "/[^/]+(.*)"); + "[^:]+:/" + AVMConstants.DIR_APPBASE + + "/" + AVMConstants.DIR_WEBAPPS + "/[^/]+(.*)"); + + // patterns for WEB-INF files that require virtualisation server reload + private final static Pattern webinfPathPattern = Pattern.compile( + ".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS + "/.*/WEB-INF/(classes/.*)|(lib/.*)|(web.xml)", + Pattern.CASE_INSENSITIVE); + //private final static Pattern webinfLibPattern = Pattern.compile( + // ".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS + "/.*/WEB-INF/lib/.*"); + //private final static Pattern webinfWebXmlPattern = Pattern.compile( + // ".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS + "/.*/WEB-INF/web.xml"); } diff --git a/source/java/org/alfresco/web/config/ClientConfigElement.java b/source/java/org/alfresco/web/config/ClientConfigElement.java index c9cdf44ec1..97f86a45cf 100644 --- a/source/java/org/alfresco/web/config/ClientConfigElement.java +++ b/source/java/org/alfresco/web/config/ClientConfigElement.java @@ -456,9 +456,10 @@ public class ClientConfigElement extends ConfigElementAdapter if (iValue == null) { iValue = DEFAULT_VSERVER_PORT; - logger.warn("Virtualisation Server not started - reverting to default port: " + value); + logger.warn("Virtualisation Server not started - reverting to default port: " + iValue); } - this.wcmPort.put(iValue.toString()); + value = iValue.toString(); + this.wcmPort.put(value); } return value; }