Partially applied patch from ETHREEOH-2145 to resolve combining issue in JSF client config

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14510 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2009-06-03 09:44:15 +00:00
parent 35d40aa9cf
commit 67971c3851
6 changed files with 83 additions and 16 deletions

View File

@@ -91,7 +91,7 @@
<!-- Domain suffix appended to the CIFS URL host name --> <!-- Domain suffix appended to the CIFS URL host name -->
<!-- <!--
<cifs-url-suffix>.alfresco.org<cifs-url-suffix> <cifs-url-suffix>.alfresco.org</cifs-url-suffix>
--> -->
<!-- Breadcrumb mode, can be either 'path' or 'location' --> <!-- Breadcrumb mode, can be either 'path' or 'location' -->

View File

@@ -24,6 +24,7 @@
*/ */
package org.alfresco.web.config; package org.alfresco.web.config;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
@@ -80,7 +81,7 @@ public class ClientConfigElement extends ConfigElementAdapter
private int minUsernameLength = 2; private int minUsernameLength = 2;
private int minPasswordLength = 3; private int minPasswordLength = 3;
private String breadcrumbMode = BREADCRUMB_PATH; private String breadcrumbMode = BREADCRUMB_PATH;
private String cifsURLSuffix; private String cifsURLSuffix = null;
private boolean languageSelect = true; private boolean languageSelect = true;
private boolean zeroByteFileUploads = true; private boolean zeroByteFileUploads = true;
private boolean userGroupAdmin = true; private boolean userGroupAdmin = true;
@@ -160,6 +161,38 @@ public class ClientConfigElement extends ConfigElementAdapter
combinedElement.setHomeSpacePermission(newElement.getHomeSpacePermission()); 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<QName> newAttrs = newElement.getSimpleSearchAdditionalAttributes();
List<QName> combinedAttrs = new ArrayList<QName>(
this.simpleSearchAdditionalAttributes.size() + newAttrs.size());
combinedAttrs.addAll(this.simpleSearchAdditionalAttributes);
combinedAttrs.addAll(newAttrs);
combinedElement.setSimpleSearchAdditionalAttributes(combinedAttrs);
}
}
// override default values if they have changed // override default values if they have changed
if (newElement.getDefaultHomeSpacePath() != null && if (newElement.getDefaultHomeSpacePath() != null &&
newElement.getDefaultHomeSpacePath().equals(combinedElement.getDefaultHomeSpacePath()) == false) newElement.getDefaultHomeSpacePath().equals(combinedElement.getDefaultHomeSpacePath()) == false)
@@ -234,12 +267,6 @@ public class ClientConfigElement extends ConfigElementAdapter
combinedElement.setAllowGuestConfig(newElement.getAllowGuestConfig()); combinedElement.setAllowGuestConfig(newElement.getAllowGuestConfig());
} }
if (newElement.getSimpleSearchAdditionalAttributes() != null &&
newElement.getSimpleSearchAdditionalAttributes().equals(combinedElement.getSimpleSearchAdditionalAttributes()) == false)
{
combinedElement.setSimpleSearchAdditionalAttributes(newElement.getSimpleSearchAdditionalAttributes());
}
if (newElement.getMinUsernameLength() != combinedElement.getMinUsernameLength()) if (newElement.getMinUsernameLength() != combinedElement.getMinUsernameLength())
{ {
combinedElement.setMinUsernameLength(newElement.getMinUsernameLength()); combinedElement.setMinUsernameLength(newElement.getMinUsernameLength());
@@ -250,12 +277,6 @@ public class ClientConfigElement extends ConfigElementAdapter
combinedElement.setMinPasswordLength(newElement.getMinPasswordLength()); combinedElement.setMinPasswordLength(newElement.getMinPasswordLength());
} }
if ( newElement.getCifsURLSuffix() != null &&
newElement.getCifsURLSuffix().equals(combinedElement.getCifsURLSuffix()) == false)
{
combinedElement.setCifsURLSuffix(newElement.getCifsURLSuffix());
}
if (newElement.getBreadcrumbMode() != null && if (newElement.getBreadcrumbMode() != null &&
newElement.getBreadcrumbMode().equals(combinedElement.getBreadcrumbMode()) == false) newElement.getBreadcrumbMode().equals(combinedElement.getBreadcrumbMode()) == false)
{ {

View File

@@ -33,6 +33,7 @@ import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigException; import org.alfresco.config.ConfigException;
import org.alfresco.config.xml.XMLConfigService; import org.alfresco.config.xml.XMLConfigService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.BaseTest; import org.alfresco.util.BaseTest;
import org.alfresco.web.config.ActionsConfigElement.ActionDefinition; import org.alfresco.web.config.ActionsConfigElement.ActionDefinition;
import org.alfresco.web.config.ActionsConfigElement.ActionGroup; import org.alfresco.web.config.ActionsConfigElement.ActionGroup;
@@ -321,6 +322,10 @@ public class WebClientConfigTest extends BaseTest
assertEquals("recent spaces", 1, clientConfig.getRecentSpacesItems()); assertEquals("recent spaces", 1, clientConfig.getRecentSpacesItems());
assertEquals("search minimum", 10, clientConfig.getSearchMinimum()); assertEquals("search minimum", 10, clientConfig.getSearchMinimum());
assertFalse("shelf visible", clientConfig.isShelfVisible()); assertFalse("shelf visible", clientConfig.isShelfVisible());
List<QName> 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("number of items in new_group group", 1, actions.size());
assertEquals("action", "custom_action", actions.get(0)); 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<QName> attrs = clientConfig.getSimpleSearchAdditionalAttributes();
assertNotNull("Expecting a list of search attributes", attrs);
assertEquals("Expecting 2 search attributes", 2, attrs.size());
}
} }

View File

@@ -0,0 +1,10 @@
<alfresco-config>
<!-- Test for ETHREEOH-2145 where having an empty client config element wipes out -->
<!-- existing values -->
<config>
<client>
</client>
</config>
</alfresco-config>

View File

@@ -29,6 +29,12 @@
<!-- the from address to use when sending emails from the client --> <!-- the from address to use when sending emails from the client -->
<from-email-address>me@somewhere.com</from-email-address> <from-email-address>me@somewhere.com</from-email-address>
<!-- add some more search attributes -->
<simple-search-additional-attributes>
<qname>attr3</qname>
<qname>attr4</qname>
</simple-search-additional-attributes>
</client> </client>
</config> </config>

View File

@@ -45,8 +45,12 @@
<!-- can be: http|webdav|cifs --> <!-- can be: http|webdav|cifs -->
<edit-link-type>http</edit-link-type> <edit-link-type>http</edit-link-type>
<!-- the from address to use when sending emails from the client --> <cifs-url-suffix>.alfresco.org</cifs-url-suffix>
<from-email-address>alfresco@alfresco.org</from-email-address>
<simple-search-additional-attributes>
<qname>attr1</qname>
<qname>attr2</qname>
</simple-search-additional-attributes>
</client> </client>
<actions> <actions>