From 2ebb1a5e08afc10c2d2c7fea64c8ea10106575d2 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Thu, 14 Dec 2006 11:19:34 +0000 Subject: [PATCH] . Website virtualisation server URL and Port are no longer managed by the web-client-config.xml - instead the values are retrieved dynamically from the VirtServerRegistryMBean. - Fall back values are used if no virtualisation server is running (with a warning output to the log) - Values are retrieved and cached for 10 seconds - so if the virtualisation server is started after the main Alfresco server then it will take up to 10 seconds for those values to be updated . Adding missing NameMatcher impl to compare() call in AVMBrowseBean git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4602 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/web-client-config.xml | 4 - .../alfresco/web/bean/wcm/AVMBrowseBean.java | 30 ++++--- .../alfresco/web/bean/wcm/AVMConstants.java | 4 +- .../web/config/ClientConfigElement.java | 88 ++++++++++--------- .../web/config/ClientElementReader.java | 14 --- source/web/WEB-INF/faces-config-beans.xml | 4 + 6 files changed, 72 insertions(+), 72 deletions(-) diff --git a/config/alfresco/web-client-config.xml b/config/alfresco/web-client-config.xml index 67a1835d17..1d34fb0afb 100644 --- a/config/alfresco/web-client-config.xml +++ b/config/alfresco/web-client-config.xml @@ -69,10 +69,6 @@ alfresco@alfresco.org - - - 127-0-0-1.ip.alfrescodemo.net - 8180 diff --git a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java index 7e2b7af66e..af9d0ba552 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMBrowseBean.java @@ -52,6 +52,7 @@ import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; +import org.alfresco.util.NameMatcher; import org.alfresco.util.Pair; import org.alfresco.web.app.Application; import org.alfresco.web.app.context.IContextListener; @@ -141,9 +142,6 @@ public class AVMBrowseBean implements IContextListener /** Current AVM Node action context */ private AVMNode avmNode = null; - private String wcmDomain; - private String wcmPort; - /** breadcrumb location */ private List location = null; @@ -175,7 +173,10 @@ public class AVMBrowseBean implements IContextListener protected AVMSyncService avmSyncService; /** Action service bean reference */ - protected ActionService actionService; + protected ActionService actionService; + + /** Global exclude name matcher */ + protected NameMatcher nameMatcher; /** @@ -184,10 +185,6 @@ public class AVMBrowseBean implements IContextListener public AVMBrowseBean() { UIContextService.getInstance(FacesContext.getCurrentInstance()).registerBean(this); - - ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance()); - this.wcmDomain = config.getWCMDomain(); - this.wcmPort = config.getWCMPort(); } @@ -287,6 +284,14 @@ public class AVMBrowseBean implements IContextListener this.actionService = actionService; } + /** + * @param nameMatcher The nameMatcher to set. + */ + public void setNameMatcher(NameMatcher nameMatcher) + { + this.nameMatcher = nameMatcher; + } + /** * Summary text for the staging store: * Created On: xx/yy/zz @@ -691,6 +696,9 @@ public class AVMBrowseBean implements IContextListener Map nodes = this.avmService.getDirectoryListing(-1, getCurrentPath()); this.files = new ArrayList(nodes.size()); this.folders = new ArrayList(nodes.size()); + ClientConfigElement config = Application.getClientConfig(context); + String wcmDomain = config.getWCMDomain(); + String wcmPort = config.getWCMPort(); for (String name : nodes.keySet()) { AVMNodeDescriptor avmRef = nodes.get(name); @@ -715,7 +723,7 @@ public class AVMBrowseBean implements IContextListener // common properties String assetPath = path.substring(rootPathIndex); - String previewUrl = AVMConstants.buildAVMAssetUrl(assetPath, this.wcmDomain, this.wcmPort, dns); + String previewUrl = AVMConstants.buildAVMAssetUrl(assetPath, wcmDomain, wcmPort, dns); node.getProperties().put("previewUrl", previewUrl); } @@ -939,8 +947,8 @@ public class AVMBrowseBean implements IContextListener tx.begin(); // calcluate the list of differences between the user store and the staging area - // TODO Need to pass the global exclude NameMatcher to the compare call. - List diffs = this.avmSyncService.compare(-1, store + ":/", -1, getStagingStore() + ":/", null); + List diffs = this.avmSyncService.compare( + -1, store + ":/", -1, getStagingStore() + ":/", this.nameMatcher); List> versionPaths = new ArrayList>(); for (AVMDifference diff : diffs) { diff --git a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java index be9a33e7c1..4b04e75aa8 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMConstants.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMConstants.java @@ -284,8 +284,8 @@ public final class AVMConstants public final static String SPACE_ICON_WEBSITE = "space-icon-website"; // URLs for preview of sandboxes and assets - private final static String PREVIEW_SANDBOX_URL = "http://www-{0}.avm.{1}:{2}"; - private final static String PREVIEW_ASSET_URL = "http://www-{0}.avm.{1}:{2}{3}"; + 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 private final static Pattern absoluteAVMPath = Pattern.compile( diff --git a/source/java/org/alfresco/web/config/ClientConfigElement.java b/source/java/org/alfresco/web/config/ClientConfigElement.java index 98d05c2d1f..c9cdf44ec1 100644 --- a/source/java/org/alfresco/web/config/ClientConfigElement.java +++ b/source/java/org/alfresco/web/config/ClientConfigElement.java @@ -16,8 +16,15 @@ */ package org.alfresco.web.config; +import javax.faces.context.FacesContext; + import org.alfresco.config.ConfigElement; import org.alfresco.config.element.ConfigElementAdapter; +import org.alfresco.mbeans.VirtServerRegistry; +import org.alfresco.repo.cache.ExpiringValueCache; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.web.jsf.FacesContextUtils; /** * Custom config element that represents config values for the client @@ -26,9 +33,16 @@ import org.alfresco.config.element.ConfigElementAdapter; */ public class ClientConfigElement extends ConfigElementAdapter { + private static Log logger = LogFactory.getLog(ClientConfigElement.class); + public static final String CONFIG_ELEMENT_ID = "client"; - private String fromEmailAddress = "alfresco@alfresco.org"; + private static final String BEAN_VIRT_SERVER_REGISTRY = "VirtServerRegistry"; + private static final String DEFAULT_VSERVER_IP = "avm.127-0-0-1.ip.alfrescodemo.net"; + private static final int DEFAULT_VSERVER_PORT = 8180; + private static final String DEFAULT_FROM_ADDRESS = "alfresco@alfresco.org"; + + private String fromEmailAddress = DEFAULT_FROM_ADDRESS; private String errorPage = null; private String loginPage = null; private int recentSpacesItems = 6; @@ -42,8 +56,8 @@ public class ClientConfigElement extends ConfigElementAdapter private String homeSpacePermission = null; private boolean ajaxEnabled = false; private String initialLocation = "myalfresco"; - private String wcmDomain = null; - private String wcmPort = null; + private ExpiringValueCache wcmDomain = new ExpiringValueCache(1000*10L); + private ExpiringValueCache wcmPort = new ExpiringValueCache(1000*10L); /** * Default Constructor @@ -165,24 +179,6 @@ public class ClientConfigElement extends ConfigElementAdapter combinedElement.setInitialLocation(newElement.getInitialLocation()); } - if (newElement.getWCMDomain() == null) - { - combinedElement.setWCMDomain(this.wcmDomain); - } - else - { - combinedElement.setWCMDomain(newElement.wcmDomain); - } - - if (newElement.getWCMPort() == null) - { - combinedElement.setWCMPort(this.wcmPort); - } - else - { - combinedElement.setWCMPort(newElement.wcmPort); - } - return combinedElement; } @@ -426,34 +422,44 @@ public class ClientConfigElement extends ConfigElementAdapter } /** - * @return Returns the WCM Domain. + * @return Returns the WCM Domain obtained from the Virtualisation Server registry. */ public String getWCMDomain() { - return this.wcmDomain; + String value = this.wcmDomain.get(); + if (value == null) + { + VirtServerRegistry vServerRegistry = (VirtServerRegistry)FacesContextUtils.getRequiredWebApplicationContext( + FacesContext.getCurrentInstance()).getBean(BEAN_VIRT_SERVER_REGISTRY); + value = vServerRegistry.getVirtServerFQDN(); + if (value == null) + { + value = DEFAULT_VSERVER_IP; + logger.warn("Virtualisation Server not started - reverting to default IP: " + value); + } + this.wcmDomain.put(value); + } + return value; } /** - * @param wcmDomain The WCM Domain to set. - */ - /*package*/ void setWCMDomain(String wcmDomain) - { - this.wcmDomain = wcmDomain; - } - - /** - * @return Returns the WCM Port. + * @return Returns the WCM Port obtained from the Virtualisation Server registry. */ public String getWCMPort() { - return this.wcmPort; - } - - /** - * @param wcmPort The WCM Port to set. - */ - /*package*/ void setWCMPort(String wcmPort) - { - this.wcmPort = wcmPort; + String value = this.wcmPort.get(); + if (value == null) + { + VirtServerRegistry vServerRegistry = (VirtServerRegistry)FacesContextUtils.getRequiredWebApplicationContext( + FacesContext.getCurrentInstance()).getBean(BEAN_VIRT_SERVER_REGISTRY); + Integer iValue = vServerRegistry.getVirtServerHttpPort(); + if (iValue == null) + { + iValue = DEFAULT_VSERVER_PORT; + logger.warn("Virtualisation Server not started - reverting to default port: " + value); + } + this.wcmPort.put(iValue.toString()); + } + return value; } } diff --git a/source/java/org/alfresco/web/config/ClientElementReader.java b/source/java/org/alfresco/web/config/ClientElementReader.java index 9b6d81e7ea..a66da1050c 100644 --- a/source/java/org/alfresco/web/config/ClientElementReader.java +++ b/source/java/org/alfresco/web/config/ClientElementReader.java @@ -42,8 +42,6 @@ public class ClientElementReader implements ConfigElementReader public static final String ELEMENT_SHELFVISIBLE = "shelf-visible"; public static final String ELEMENT_AJAX_ENABLED = "ajax-enabled"; public static final String ELEMENT_INITIALLOCATION = "initial-location"; - public static final String ELEMENT_WCM_DOMAIN = "wcm-domain"; - public static final String ELEMENT_WCM_PORT = "wcm-port"; /** * @see org.alfresco.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element) @@ -163,18 +161,6 @@ public class ClientElementReader implements ConfigElementReader { configElement.setInitialLocation(initialLocation.getTextTrim()); } - - // get the WCM domain and port - Element wcmDomain = element.element(ELEMENT_WCM_DOMAIN); - if (wcmDomain != null) - { - configElement.setWCMDomain(wcmDomain.getTextTrim()); - } - Element wcmPort = element.element(ELEMENT_WCM_PORT); - if (wcmPort != null) - { - configElement.setWCMPort(wcmPort.getTextTrim()); - } } return configElement; diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index a2f2fc3cf7..8c6c32b71c 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -2317,6 +2317,10 @@ workflowService #{WorkflowService} + + nameMatcher + #{globalPathExcluder} +