diff --git a/config/alfresco/web-client-config.xml b/config/alfresco/web-client-config.xml index f85fb9cabd..a76591bfee 100644 --- a/config/alfresco/web-client-config.xml +++ b/config/alfresco/web-client-config.xml @@ -91,7 +91,7 @@ diff --git a/source/java/org/alfresco/web/config/ClientConfigElement.java b/source/java/org/alfresco/web/config/ClientConfigElement.java index 33d837e6c0..778ca24542 100644 --- a/source/java/org/alfresco/web/config/ClientConfigElement.java +++ b/source/java/org/alfresco/web/config/ClientConfigElement.java @@ -24,6 +24,7 @@ */ package org.alfresco.web.config; +import java.util.ArrayList; import java.util.List; import javax.faces.context.FacesContext; @@ -80,7 +81,7 @@ public class ClientConfigElement extends ConfigElementAdapter private int minUsernameLength = 2; private int minPasswordLength = 3; private String breadcrumbMode = BREADCRUMB_PATH; - private String cifsURLSuffix; + private String cifsURLSuffix = null; private boolean languageSelect = true; private boolean zeroByteFileUploads = true; private boolean userGroupAdmin = true; @@ -160,6 +161,38 @@ public class ClientConfigElement extends ConfigElementAdapter combinedElement.setHomeSpacePermission(newElement.getHomeSpacePermission()); } + if (newElement.getCifsURLSuffix() == null) + { + combinedElement.setCifsURLSuffix(this.cifsURLSuffix); + } + else + { + combinedElement.setCifsURLSuffix(newElement.getCifsURLSuffix()); + } + + if (newElement.getSimpleSearchAdditionalAttributes() == null) + { + combinedElement.setSimpleSearchAdditionalAttributes(this.simpleSearchAdditionalAttributes); + } + else + { + if (this.simpleSearchAdditionalAttributes == null) + { + // there aren't any existing attributes so just use the new set + combinedElement.setSimpleSearchAdditionalAttributes(newElement.getSimpleSearchAdditionalAttributes()); + } + else + { + // get the current list and add the additional attributes to it + List newAttrs = newElement.getSimpleSearchAdditionalAttributes(); + List combinedAttrs = new ArrayList( + this.simpleSearchAdditionalAttributes.size() + newAttrs.size()); + combinedAttrs.addAll(this.simpleSearchAdditionalAttributes); + combinedAttrs.addAll(newAttrs); + combinedElement.setSimpleSearchAdditionalAttributes(combinedAttrs); + } + } + // override default values if they have changed if (newElement.getDefaultHomeSpacePath() != null && newElement.getDefaultHomeSpacePath().equals(combinedElement.getDefaultHomeSpacePath()) == false) @@ -234,12 +267,6 @@ public class ClientConfigElement extends ConfigElementAdapter combinedElement.setAllowGuestConfig(newElement.getAllowGuestConfig()); } - if (newElement.getSimpleSearchAdditionalAttributes() != null && - newElement.getSimpleSearchAdditionalAttributes().equals(combinedElement.getSimpleSearchAdditionalAttributes()) == false) - { - combinedElement.setSimpleSearchAdditionalAttributes(newElement.getSimpleSearchAdditionalAttributes()); - } - if (newElement.getMinUsernameLength() != combinedElement.getMinUsernameLength()) { combinedElement.setMinUsernameLength(newElement.getMinUsernameLength()); @@ -250,12 +277,6 @@ public class ClientConfigElement extends ConfigElementAdapter combinedElement.setMinPasswordLength(newElement.getMinPasswordLength()); } - if ( newElement.getCifsURLSuffix() != null && - newElement.getCifsURLSuffix().equals(combinedElement.getCifsURLSuffix()) == false) - { - combinedElement.setCifsURLSuffix(newElement.getCifsURLSuffix()); - } - if (newElement.getBreadcrumbMode() != null && newElement.getBreadcrumbMode().equals(combinedElement.getBreadcrumbMode()) == false) { diff --git a/source/java/org/alfresco/web/config/WebClientConfigTest.java b/source/java/org/alfresco/web/config/WebClientConfigTest.java index cccb6f9efb..730d32516d 100644 --- a/source/java/org/alfresco/web/config/WebClientConfigTest.java +++ b/source/java/org/alfresco/web/config/WebClientConfigTest.java @@ -33,6 +33,7 @@ import org.alfresco.config.Config; import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigException; import org.alfresco.config.xml.XMLConfigService; +import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseTest; import org.alfresco.web.config.ActionsConfigElement.ActionDefinition; import org.alfresco.web.config.ActionsConfigElement.ActionGroup; @@ -321,6 +322,10 @@ public class WebClientConfigTest extends BaseTest assertEquals("recent spaces", 1, clientConfig.getRecentSpacesItems()); assertEquals("search minimum", 10, clientConfig.getSearchMinimum()); assertFalse("shelf visible", clientConfig.isShelfVisible()); + + List attrs = clientConfig.getSimpleSearchAdditionalAttributes(); + assertNotNull("Expecting a list of search attributes", attrs); + assertEquals("Expecting 4 search attributes", 4, attrs.size()); } /** @@ -895,4 +900,25 @@ public class WebClientConfigTest extends BaseTest assertEquals("number of items in new_group group", 1, actions.size()); assertEquals("action", "custom_action", actions.get(0)); } + + public void testETHREEOH2145() + { + XMLConfigService svc = initXMLConfigService("test-config.xml", "test-config-e30-2145.xml"); + + // get the "client" config from global config section + Config cfg = svc.getGlobalConfig(); + assertNotNull("cfg should not be null", cfg); + ClientConfigElement clientConfig = (ClientConfigElement)cfg.getConfigElement("client"); + assertNotNull("clientConfig should not be null", clientConfig); + + assertEquals("from-email-address", "alfresco@alfresco.org", clientConfig.getFromEmailAddress()); + assertEquals("cifs-url-suffix", ".alfresco.org", clientConfig.getCifsURLSuffix()); + assertEquals("edit-link-type", "http", clientConfig.getEditLinkType()); + assertEquals("error-page", "/jsp/error.jsp", clientConfig.getErrorPage()); + assertEquals("home-space-permission", "Consumer", clientConfig.getHomeSpacePermission()); + + List attrs = clientConfig.getSimpleSearchAdditionalAttributes(); + assertNotNull("Expecting a list of search attributes", attrs); + assertEquals("Expecting 2 search attributes", 2, attrs.size()); + } } diff --git a/source/test-resources/test-config-e30-2145.xml b/source/test-resources/test-config-e30-2145.xml new file mode 100644 index 0000000000..940ef22171 --- /dev/null +++ b/source/test-resources/test-config-e30-2145.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/source/test-resources/test-config-override.xml b/source/test-resources/test-config-override.xml index 83e2efa3f2..0a3d184648 100644 --- a/source/test-resources/test-config-override.xml +++ b/source/test-resources/test-config-override.xml @@ -29,6 +29,12 @@ me@somewhere.com + + + + attr3 + attr4 + diff --git a/source/test-resources/test-config.xml b/source/test-resources/test-config.xml index aad877a482..180dadc940 100644 --- a/source/test-resources/test-config.xml +++ b/source/test-resources/test-config.xml @@ -45,8 +45,12 @@ http - - alfresco@alfresco.org + .alfresco.org + + + attr1 + attr2 +