diff --git a/config/alfresco/application-context-highlevel.xml b/config/alfresco/application-context-highlevel.xml index 6658d19a0d..3d71d7c776 100644 --- a/config/alfresco/application-context-highlevel.xml +++ b/config/alfresco/application-context-highlevel.xml @@ -39,6 +39,7 @@ + diff --git a/config/alfresco/client/config/repo-clients-apps.properties b/config/alfresco/client/config/repo-clients-apps.properties new file mode 100644 index 0000000000..fff40c330a --- /dev/null +++ b/config/alfresco/client/config/repo-clients-apps.properties @@ -0,0 +1,4 @@ +# registry of clients that are able to email + +repo.client-app.sfs.templateAssetsUrl=http://localhost:8082/sfs +repo.client-app.sfs.sharedLinkBaseUrl=http://localhost:8082/sfs/s \ No newline at end of file diff --git a/config/alfresco/quickshare-services-context.xml b/config/alfresco/quickshare-services-context.xml index 7fd06e8b76..ed5c1552e4 100644 --- a/config/alfresco/quickshare-services-context.xml +++ b/config/alfresco/quickshare-services-context.xml @@ -34,7 +34,7 @@ - org.alfresco.service.cmr.quickshare.QuickShareService + org.alfresco.service.cmr.quickshare.QuickShareService @@ -51,19 +51,6 @@ - - - - classpath*:alfresco/quickshare/quickshare-clients.properties - - - - - - - - - @@ -80,7 +67,7 @@ - + diff --git a/config/alfresco/quickshare/quickshare-clients.properties b/config/alfresco/quickshare/quickshare-clients.properties deleted file mode 100644 index 9187b8072f..0000000000 --- a/config/alfresco/quickshare/quickshare-clients.properties +++ /dev/null @@ -1,4 +0,0 @@ -# registry of clients that are able to email shared links - -quickshare.client.sfs.sharedLinkBaseUrl=http://localhost:8082/sfs/s -quickshare.client.sfs.templateAssetsUrl=http://localhost:8082/sfs diff --git a/config/alfresco/repo-clients-apps-context.xml b/config/alfresco/repo-clients-apps-context.xml new file mode 100644 index 0000000000..b39b4c033f --- /dev/null +++ b/config/alfresco/repo-clients-apps-context.xml @@ -0,0 +1,18 @@ + + + + + + + + + classpath*:alfresco/client/config/repo-clients-apps.properties + + + + + + + + + \ No newline at end of file diff --git a/source/java/org/alfresco/repo/quickshare/ClientAppConfig.java b/source/java/org/alfresco/repo/client/config/ClientAppConfig.java similarity index 65% rename from source/java/org/alfresco/repo/quickshare/ClientAppConfig.java rename to source/java/org/alfresco/repo/client/config/ClientAppConfig.java index 3c5f81934f..e6bc8fae75 100644 --- a/source/java/org/alfresco/repo/quickshare/ClientAppConfig.java +++ b/source/java/org/alfresco/repo/client/config/ClientAppConfig.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2017 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -24,7 +24,7 @@ * #L% */ -package org.alfresco.repo.quickshare; +package org.alfresco.repo.client.config; import org.alfresco.util.PropertyCheck; import org.apache.commons.lang.StringUtils; @@ -45,13 +45,24 @@ import java.util.concurrent.ConcurrentMap; /** * This class picks up all the loaded properties passed to it and uses a naming * convention to isolate the client's name and the related values. - * So, if a new client (e.g. MyClientName) is required to send a shared-link email, then the following + *

+ * The naming convention must confirm to the following: + *

+ * repo.client-app.{@literal .} + *

+ * Also, the client-name or property name ({@literal }) must not contain a dot {@literal ('.')} + *

+ * Note also, that any property without a value is ignored and the client will not be registered + * if all the properties of that client have no values. + *

+ * So, if a new client (e.g. MyClientName) is required to send a shared-link email and the service or the API requires, + * for example, sharedLinkBaseUrl and templateAssetsUrl properties, then the following * needs to be put into a properties file. *

    - *
  • quickshare.client.MyClientName.sharedLinkBaseUrl=http://localhost:8080/MyClientName/s
  • - *
  • quickshare.client.MyClientName.templateAssetsUrl=http://localhost:8080/MyClientName/assets
  • + *
  • repo.client-app.MyClientName.sharedLinkBaseUrl=http://localhost:8080/MyClientName/s
  • + *
  • repo.client-app.MyClientName.templateAssetsUrl=http://localhost:8080/MyClientName/assets
  • *
- * The default property file is alfresco/quickshare/quickshare-clients.properties which + * The default property file is alfresco/client/config/repo-clients-apps.properties which * could be overridden (or add new clients) by alfresco-global properties file. * * @author Jamal Kaabi-Mofrad @@ -60,8 +71,7 @@ public class ClientAppConfig extends AbstractLifecycleBean { private static final Log logger = LogFactory.getLog(ClientAppConfig.class); - public static final String PREFIX = "quickshare.client."; - public static final String PROP_SHARED_LINK_BASE_URL = "sharedLinkBaseUrl"; + public static final String PREFIX = "repo.client-app."; public static final String PROP_TEMPLATE_ASSETS_URL = "templateAssetsUrl"; private Properties defaultProperties; @@ -111,12 +121,15 @@ public class ClientAppConfig extends AbstractLifecycleBean protected void onBootstrap(ApplicationEvent event) { Map mergedProperties = getAndMergeProperties(); - Set clientsNames = processPropertyKeys(mergedProperties); - clients.putAll(processClients(clientsNames, mergedProperties)); + + Set clientsNames = new HashSet<>(); + Set propsNames = new HashSet<>(); + processPropertyKeys(mergedProperties, clientsNames, propsNames); + clients.putAll(processClients(clientsNames, propsNames, mergedProperties)); if (logger.isDebugEnabled()) { - logger.debug("All bootstrapped quickShare clients: " + clients); + logger.debug("All bootstrapped repo clients apps: " + clients); } } @@ -130,11 +143,11 @@ public class ClientAppConfig extends AbstractLifecycleBean * Processes the property's key and extracts the clients' names. * * @param allProps the merged properties - * @return a set of clients' names + * @param clientsNames a set of strings which will be populated with client names + * @param propsNames a set of strings which will be populated with properties names (i.e.the property after the client name) */ - protected Set processPropertyKeys(Map allProps) + protected void processPropertyKeys(Map allProps, Set clientsNames, Set propsNames) { - Set clientsNames = new HashSet<>(); for (String key : allProps.keySet()) { String propKey = key; @@ -157,13 +170,15 @@ public class ClientAppConfig extends AbstractLifecycleBean } String clientName = propKey.substring(0, clientNameControlDot); String propName = propKey.substring((clientNameControlDot + 1)); - if (PROP_SHARED_LINK_BASE_URL.equals(propName) || PROP_TEMPLATE_ASSETS_URL.equals(propName)) + // the property name (the property after the client name) must not contain a '.' + if (propName.indexOf('.') == -1) { clientsNames.add(clientName); + propsNames.add(propName); } else { - logMalformedPropertyKey(key); + logMalformedPropertyKey(key, "The property name " + propName + " must not contain a '.'"); } } else @@ -171,7 +186,6 @@ public class ClientAppConfig extends AbstractLifecycleBean logMalformedPropertyKey(propKey); } } - return clientsNames; } /** @@ -179,32 +193,51 @@ public class ClientAppConfig extends AbstractLifecycleBean * a map of {@code ClientApp} with the client's name as the key. * * @param clientsNames the processed clients' names + * @param propsNames the processed properties names * @param allProps the merged properties * @return a map of {@code ClientApp} with the client's name as the key. */ - protected Map processClients(Set clientsNames, Map allProps) + protected Map processClients(Set clientsNames, Set propsNames, Map allProps) { Map clientApps = new HashMap<>(clientsNames.size()); - for (String name : clientsNames) + for (String clientName : clientsNames) { - String propKey = getPropertyKey(name, PROP_SHARED_LINK_BASE_URL); - String sharedLinkBaseUrl = allProps.get(propKey); - if (isValidString(sharedLinkBaseUrl)) + Map config = new HashMap<>(); + String templateAssetsUrl = null; + for (String propName : propsNames) { - logInvalidPropertyValue(propKey, sharedLinkBaseUrl); - continue; - } + String propKey = getPropertyKey(clientName, propName); + if (!allProps.containsKey(propKey)) + { + // if the constructed property key does not exist, skip this iteration. + continue; + } - propKey = getPropertyKey(name, PROP_TEMPLATE_ASSETS_URL); - String templateAssetsUrl = allProps.get(propKey); - if (isValidString(templateAssetsUrl)) + String propValue = allProps.get(propKey); + + if (StringUtils.isEmpty(propValue)) + { + logInvalidPropertyValue(propKey, propValue); + continue; + } + + if (PROP_TEMPLATE_ASSETS_URL.equals(propName)) + { + templateAssetsUrl = propValue; + } + else + { + config.put(propName, propValue); + } + } + if (StringUtils.isEmpty(templateAssetsUrl) && config.isEmpty()) { - logInvalidPropertyValue(propKey, templateAssetsUrl); + logger.warn("Client-app [" + clientName + "] can not be registered as it needs at least one property with a valid value."); continue; } // As the required values are valid, create the client data - ClientApp client = new ClientApp(name, sharedLinkBaseUrl, templateAssetsUrl); - clientApps.put(name, client); + ClientApp client = new ClientApp(clientName, templateAssetsUrl, config); + clientApps.put(clientName, client); } return clientApps; } @@ -227,7 +260,7 @@ public class ClientAppConfig extends AbstractLifecycleBean { String value = globalProperties.getProperty(propKey); // before overriding the key, validate the property value - if (isValidString(value)) + if (StringUtils.isEmpty(value)) { logInvalidPropertyValue(propKey, value); continue; @@ -239,14 +272,20 @@ public class ClientAppConfig extends AbstractLifecycleBean return allProperties; } + private void logMalformedPropertyKey(String propName, String reason) + { + reason = (StringUtils.isBlank(reason)) ? "" : " " + reason; + logger.warn("Ignoring client app config (malformed property key) [" + propName + "]." + reason); + } + private void logMalformedPropertyKey(String propName) { - logger.warn("Ignoring quickShare client (malformed property key): " + propName); + logMalformedPropertyKey(propName, null); } private void logInvalidPropertyValue(String propName, String propValue) { - logger.warn("Ignoring quickShare client (invalid value) [" + propValue + "] for the property:" + propName); + logger.warn("Ignoring client app config (invalid value) [" + propValue + "] for the property:" + propName); } private String getPropertyKey(String clientName, String clientProp) @@ -254,22 +293,17 @@ public class ClientAppConfig extends AbstractLifecycleBean return PREFIX + clientName + '.' + clientProp; } - private boolean isValidString(String str) - { - return StringUtils.isEmpty(str); - } - public static class ClientApp { private final String name; - private final String sharedLinkBaseUrl; private final String templateAssetsUrl; + private final Map properties; - public ClientApp(String name, String sharedLinkBaseUrl, String templateAssetsUrl) + public ClientApp(String name, String templateAssetsUrl, Map properties) { this.name = name; - this.sharedLinkBaseUrl = sharedLinkBaseUrl; this.templateAssetsUrl = templateAssetsUrl; + this.properties = new HashMap<>(properties); } public String getName() @@ -277,16 +311,21 @@ public class ClientAppConfig extends AbstractLifecycleBean return name; } - public String getSharedLinkBaseUrl() - { - return sharedLinkBaseUrl; - } - public String getTemplateAssetsUrl() { return templateAssetsUrl; } + public Map getProperties() + { + return Collections.unmodifiableMap(properties); + } + + public String getProperty(String propName) + { + return properties.get(propName); + } + @Override public boolean equals(Object o) { @@ -314,8 +353,8 @@ public class ClientAppConfig extends AbstractLifecycleBean { final StringBuilder sb = new StringBuilder(250); sb.append("ClientApp [name=").append(name) - .append(", sharedLinkBaseUrl=").append(sharedLinkBaseUrl) .append(", templateAssetsUrl=").append(templateAssetsUrl) + .append(", properties=").append(properties) .append(']'); return sb.toString(); } diff --git a/source/java/org/alfresco/repo/quickshare/QuickShareServiceImpl.java b/source/java/org/alfresco/repo/quickshare/QuickShareServiceImpl.java index eb9a796dc2..1711076ece 100644 --- a/source/java/org/alfresco/repo/quickshare/QuickShareServiceImpl.java +++ b/source/java/org/alfresco/repo/quickshare/QuickShareServiceImpl.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2017 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -44,6 +44,7 @@ import org.alfresco.model.QuickShareModel; import org.alfresco.repo.Client; import org.alfresco.repo.Client.ClientType; import org.alfresco.repo.action.executer.MailActionExecuter; +import org.alfresco.repo.client.config.ClientAppConfig; import org.alfresco.repo.copy.CopyBehaviourCallback; import org.alfresco.repo.copy.CopyDetails; import org.alfresco.repo.copy.CopyServicePolicies; @@ -54,7 +55,7 @@ import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.quickshare.ClientAppConfig.ClientApp; +import org.alfresco.repo.client.config.ClientAppConfig.ClientApp; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; import org.alfresco.repo.security.permissions.AccessDeniedException; @@ -125,6 +126,7 @@ public class QuickShareServiceImpl implements QuickShareService, static final String ATTR_KEY_SHAREDIDS_ROOT = ".sharedIds"; + private static final String CONFIG_SHARED_LINK_BASE_URL = "sharedLinkBaseUrl"; private static final String FTL_SHARED_NODE_URL = "shared_node_url"; private static final String FTL_SHARED_NODE_NAME = "shared_node_name"; private static final String FTL_SENDER_MESSAGE = "sender_message"; @@ -914,11 +916,12 @@ public class QuickShareServiceImpl implements QuickShareService, Map templateModel = new HashMap<>(6); templateModel.put(FTL_SENDER_FIRST_NAME, senderFirstName); templateModel.put(FTL_SENDER_LAST_NAME, senderLastName); - final String sharedNodeUrl = getUrl(clientApp.getSharedLinkBaseUrl()) + '/' + emailRequest.getSharedId(); + final String sharedNodeUrl = getUrl(clientApp.getProperty(CONFIG_SHARED_LINK_BASE_URL), CONFIG_SHARED_LINK_BASE_URL) + + '/' + emailRequest.getSharedId(); templateModel.put(FTL_SHARED_NODE_URL, sharedNodeUrl); templateModel.put(FTL_SHARED_NODE_NAME, emailRequest.getSharedNodeName()); templateModel.put(FTL_SENDER_MESSAGE, emailRequest.getSenderMessage()); - String templateAssetsUrl = getUrl(clientApp.getTemplateAssetsUrl()); + final String templateAssetsUrl = getUrl(clientApp.getTemplateAssetsUrl(), ClientAppConfig.PROP_TEMPLATE_ASSETS_URL); templateModel.put(FTL_TEMPLATE_ASSETS_URL, templateAssetsUrl); // Set the email details @@ -999,8 +1002,13 @@ public class QuickShareServiceImpl implements QuickShareService, return nodeService.getProperty(parent, ContentModel.PROP_NAME).toString(); } - private String getUrl(String url) + private String getUrl(String url, String propName) { + if (url == null) + { + logger.warn("URL for the property [" + propName + "] is not configured."); + return ""; + } if (url.endsWith("/")) { return url.substring(0, url.length() - 1); diff --git a/source/test-java/org/alfresco/Repository01TestSuite.java b/source/test-java/org/alfresco/Repository01TestSuite.java index 10e800c9f6..8b1077dcab 100644 --- a/source/test-java/org/alfresco/Repository01TestSuite.java +++ b/source/test-java/org/alfresco/Repository01TestSuite.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2017 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -269,7 +269,7 @@ public class Repository01TestSuite extends TestSuite static void tests40(TestSuite suite) { - suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.quickshare.ClientAppConfigTest.class)); + suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.client.config.ClientAppConfigTest.class)); suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.quickshare.QuickShareServiceIntegrationTest.class)); suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.rating.RatingServiceIntegrationTest.class)); suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.remotecredentials.RemoteCredentialsServicesTest.class)); diff --git a/source/test-java/org/alfresco/repo/quickshare/ClientAppConfigTest.java b/source/test-java/org/alfresco/repo/client/config/ClientAppConfigTest.java similarity index 61% rename from source/test-java/org/alfresco/repo/quickshare/ClientAppConfigTest.java rename to source/test-java/org/alfresco/repo/client/config/ClientAppConfigTest.java index ac2c1b9790..256290950a 100644 --- a/source/test-java/org/alfresco/repo/quickshare/ClientAppConfigTest.java +++ b/source/test-java/org/alfresco/repo/client/config/ClientAppConfigTest.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2017 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -24,18 +24,20 @@ * #L% */ -package org.alfresco.repo.quickshare; +package org.alfresco.repo.client.config; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; -import org.alfresco.repo.quickshare.ClientAppConfig.ClientApp; +import org.alfresco.repo.client.config.ClientAppConfig.ClientApp; import org.alfresco.util.ApplicationContextHelper; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; +import java.util.Collections; import java.util.Map; /** @@ -51,10 +53,10 @@ public class ClientAppConfigTest @BeforeClass public static void setUp() throws Exception { - context = new ClassPathXmlApplicationContext(new String[] { "classpath:org/alfresco/repo/quickshare/test-quickshare-clients-context.xml" }, + context = new ClassPathXmlApplicationContext(new String[] { "classpath:org/alfresco/repo/client/config/test-repo-clients-apps-context.xml" }, ApplicationContextHelper.getApplicationContext()); - clientAppConfig = context.getBean("quickShareClientsConfigTest", ClientAppConfig.class); + clientAppConfig = context.getBean("clientAppConfigTest", ClientAppConfig.class); } @@ -69,33 +71,54 @@ public class ClientAppConfigTest { Map clients = clientAppConfig.getClients(); assertNotNull(clients); - assertEquals("Incorrect number of clients", 3, clients.size()); + assertEquals("Incorrect number of clients", 4, clients.size()); - // loaded from org/alfresco/repo/quickshare/test-quickshare-clients-config.properties + // loaded from org/alfresco/repo/client/config/test-repo-clients-apps.properties ClientApp client1 = clientAppConfig.getClient("test-client1"); assertNotNull(client1); assertEquals("test-client1", client1.getName()); - assertEquals("http://localhost:8081/test-client1/o", client1.getSharedLinkBaseUrl()); + assertEquals("http://localhost:8081/test-client1/o", client1.getProperty("sharedLinkBaseUrl")); assertEquals("http://localhost:8081/test-client1", client1.getTemplateAssetsUrl()); - // loaded from org/alfresco/repo/quickshare/test-quickshare-clients-config.properties and overridden by - // org/alfresco/repo/quickshare/test-global-properties.properties + // loaded from org/alfresco/repo/client/config/test-repo-clients-apps.properties and overridden by + // org/alfresco/repo/client/config/test-global-properties.properties ClientApp client2 = clientAppConfig.getClient("test-client2"); assertNotNull(client2); assertEquals("test-client2", client2.getName()); - assertEquals("https://127.0.0.1:8082/test-client2/t", client2.getSharedLinkBaseUrl()); + assertEquals("https://127.0.0.1:8082/test-client2/t", client2.getProperty("sharedLinkBaseUrl")); assertEquals("https://127.0.0.1:8082/test-client2", client2.getTemplateAssetsUrl()); - // loaded from org/alfresco/repo/quickshare/test-global-properties.properties + // loaded from org/alfresco/repo/client/config/test-global-properties.properties ClientApp client3 = clientAppConfig.getClient("test-client5"); assertNotNull(client3); assertEquals("test-client5", client3.getName()); - assertEquals("http://localhost:8085/test-client5/f", client3.getSharedLinkBaseUrl()); - assertEquals("http://localhost:8085/test-client5", client3.getTemplateAssetsUrl()); + assertEquals("http://localhost:8085/test-client5/f", client3.getProperty("myProp1")); + assertEquals("http://localhost:8085/test-client5", client3.getProperty("myProp2")); + assertEquals("test prop3", client3.getProperty("myProp3")); + assertEquals("test prop4", client3.getProperty("myProp4")); + assertEquals("test prop5", client3.getProperty("myProp5-with-hyphen")); + assertNull(client3.getTemplateAssetsUrl()); + + // loaded from org/alfresco/repo/client/config/test-global-properties.properties + ClientApp client4 = clientAppConfig.getClient("test-client11"); + assertNotNull(client4); + assertEquals("test-client11", client4.getName()); + assertEquals("http://localhost:8811/test-client11/t", client4.getProperty("myClientRequiredConfigUrl")); + assertNull(client4.getTemplateAssetsUrl()); + // Try to add a property into an unmodifiable map + try + { + client4.getProperties().put("newProperty"," test value"); + fail("Shouldn't be able to modify the client's processed properties."); + } + catch (UnsupportedOperationException ex) + { + // expected + } // Try to add a client into an unmodifiable map - ClientApp newClient = new ClientApp("testClient" + System.currentTimeMillis(), "http://localhost:8085/test-client/s", - "http://localhost:8085/testclient"); + ClientApp newClient = new ClientApp("testClient" + System.currentTimeMillis(), + "http://localhost:8085/testclient", Collections.singletonMap("sharedLinkBaseUrl", "http://localhost:8085/test-client/s")); try { clients.put(newClient.getName(), newClient); diff --git a/source/test-resources/org/alfresco/repo/client/config/test-global-properties.properties b/source/test-resources/org/alfresco/repo/client/config/test-global-properties.properties new file mode 100644 index 0000000000..84165342dc --- /dev/null +++ b/source/test-resources/org/alfresco/repo/client/config/test-global-properties.properties @@ -0,0 +1,38 @@ +# Simulate the alfresco global properties file + +# Override the default properties of client2 +repo.client-app.test-client2.sharedLinkBaseUrl=https://127.0.0.1:8082/test-client2/t +repo.client-app.test-client2.templateAssetsUrl=https://127.0.0.1:8082/test-client2 + +# Add a new client with a few properties +repo.client-app.test-client5.myProp1=http://localhost:8085/test-client5/f +repo.client-app.test-client5.myProp2=http://localhost:8085/test-client5 +repo.client-app.test-client5.myProp3=test prop3 +repo.client-app.test-client5.myProp4=test prop4 +repo.client-app.test-client5.myProp5-with-hyphen=test prop5 + +# Try to override the default properties of client1 with invalid values +repo.client-app.test-client1.sharedLinkBaseUrl= +repo.client-app.test-client1.templateAssetsUrl= + +# Invalid keys - undefined key structure +repo.client-app.invalid.test-client6.sharedLinkBaseUrl=http://localhost:8086/test-client6/s +repo.client-app.invalid.test-client6.templateAssetsUrl=http://localhost:8086/test-client6 + +# Invalid keys - undefined key structure +invalid.test-client7.sharedLinkBaseUrl=http://localhost:8087/test-client7/s +invalid.test-client7.templateAssetsUrl=http://localhost:8087/test-client7 + +# Invalid keys - undefined key structure +repo.client-app.test-client8.invalid.sharedLinkBaseUrl=http://localhost:8088/test-client8/e +repo.client-app.test-client8.invalid.templateAssetsUrl=http://localhost:8088/test-client8 + +# Invalid key - missing the property name after the dot +repo.client-app.test-client9.=http://localhost:8089/test-client9 + +# Invalid key - missing the property name +repo.client-app.test-client10=http://localhost:8810/test-client10 + +# Register a client with only one configuration +repo.client-app.test-client11.myClientRequiredConfigUrl=http://localhost:8811/test-client11/t + diff --git a/source/test-resources/org/alfresco/repo/quickshare/test-quickshare-clients-context.xml b/source/test-resources/org/alfresco/repo/client/config/test-repo-clients-apps-context.xml similarity index 54% rename from source/test-resources/org/alfresco/repo/quickshare/test-quickshare-clients-context.xml rename to source/test-resources/org/alfresco/repo/client/config/test-repo-clients-apps-context.xml index 445921f110..33bee589cb 100644 --- a/source/test-resources/org/alfresco/repo/quickshare/test-quickshare-clients-context.xml +++ b/source/test-resources/org/alfresco/repo/client/config/test-repo-clients-apps-context.xml @@ -3,10 +3,10 @@ - + - classpath*:org/alfresco/repo/quickshare/test-quickshare-clients-config.properties + classpath*:org/alfresco/repo/client/config/test-repo-clients-apps.properties @@ -14,13 +14,13 @@ - classpath*:org/alfresco/repo/quickshare/test-global-properties.properties + classpath*:org/alfresco/repo/client/config/test-global-properties.properties - - + + \ No newline at end of file diff --git a/source/test-resources/org/alfresco/repo/client/config/test-repo-clients-apps.properties b/source/test-resources/org/alfresco/repo/client/config/test-repo-clients-apps.properties new file mode 100644 index 0000000000..7d8fea7a6f --- /dev/null +++ b/source/test-resources/org/alfresco/repo/client/config/test-repo-clients-apps.properties @@ -0,0 +1,15 @@ +# registry of clients that are able to email shared links + +repo.client-app.test-client1.sharedLinkBaseUrl=http://localhost:8081/test-client1/o +repo.client-app.test-client1.templateAssetsUrl=http://localhost:8081/test-client1 + +repo.client-app.test-client2.sharedLinkBaseUrl=http://localhost:8082/test-client2/t +repo.client-app.test-client2.templateAssetsUrl=http://localhost:8082/test-client2 + +# Invalid keys - undefined key structure +invalid.test-client3.sharedLinkBaseUrl=http://localhost:8083/test-client3/s +invalid.test-client3.templateAssetsUrl=http://localhost:8083/test-client3 + +# Invalid values. As there are no values for this client, then is shouldn't be registered. +repo.client-app.test-client4.sharedLinkBaseUrl= +repo.client-app.test-client4.templateAssetsUrl= \ No newline at end of file diff --git a/source/test-resources/org/alfresco/repo/quickshare/test-global-properties.properties b/source/test-resources/org/alfresco/repo/quickshare/test-global-properties.properties deleted file mode 100644 index 5a6bbf5697..0000000000 --- a/source/test-resources/org/alfresco/repo/quickshare/test-global-properties.properties +++ /dev/null @@ -1,41 +0,0 @@ -# Simulate the alfresco global properties file - -# Override the default properties of client2 -quickshare.client.test-client2.sharedLinkBaseUrl=https://127.0.0.1:8082/test-client2/t -quickshare.client.test-client2.templateAssetsUrl=https://127.0.0.1:8082/test-client2 - -# Add a new client -quickshare.client.test-client5.sharedLinkBaseUrl=http://localhost:8085/test-client5/f -quickshare.client.test-client5.templateAssetsUrl=http://localhost:8085/test-client5 - -# Try to override the default properties of client1 with invalid values -quickshare.client.test-client1.sharedLinkBaseUrl= -quickshare.client.test-client1.templateAssetsUrl= - -# Invalid keys - undefined key structure -quickshare.client.invalid.test-client6.sharedLinkBaseUrl=http://localhost:8086/test-client6/s -quickshare.client.invalid.test-client6.templateAssetsUrl=http://localhost:8086/test-client6 - -# Invalid keys - undefined key structure -invalid.test-client7.sharedLinkBaseUrl=http://localhost:8087/test-client7/s -invalid.test-client7.templateAssetsUrl=http://localhost:8087/test-client7 - -# Invalid keys - undefined key structure -quickshare.client.test-client8.invalid.sharedLinkBaseUrl=http://localhost:8088/test-client8/e -quickshare.client.test-client8.invalid.templateAssetsUrl=http://localhost:8088/test-client8 - -# Invalid key - missing the required 'sharedLinkBaseUrl' and 'templateAssetsUrl' after the dot -quickshare.client.test-client9.=http://localhost:8089/test-client9 - -# Invalid key - missing the required 'sharedLinkBaseUrl' and 'templateAssetsUrl' -quickshare.client.test-client10=http://localhost:8810/test-client10 - -# Invalid keys - undefined 'sharedLink' and 'templateUrl' -quickshare.client.test-client11.sharedLink=http://localhost:8811/test-client11/e -quickshare.client.test-client11.templateUrl=http://localhost:8811/test-client11 - -# Invalid client config - missing the required 'templateAssetsUrl' config -quickshare.client.test-client12.sharedLinkBaseUrl=http://localhost:8812/test-client12/t - -# Invalid client config - missing the required 'sharedLinkBaseUrl' config -quickshare.client.test-client13.templateAssetsUrl=http://localhost:8812/test-client13 \ No newline at end of file diff --git a/source/test-resources/org/alfresco/repo/quickshare/test-quickshare-clients-config.properties b/source/test-resources/org/alfresco/repo/quickshare/test-quickshare-clients-config.properties deleted file mode 100644 index 406ff23d83..0000000000 --- a/source/test-resources/org/alfresco/repo/quickshare/test-quickshare-clients-config.properties +++ /dev/null @@ -1,15 +0,0 @@ -# registry of clients that are able to email shared links - -quickshare.client.test-client1.sharedLinkBaseUrl=http://localhost:8081/test-client1/o -quickshare.client.test-client1.templateAssetsUrl=http://localhost:8081/test-client1 - -quickshare.client.test-client2.sharedLinkBaseUrl=http://localhost:8082/test-client2/t -quickshare.client.test-client2.templateAssetsUrl=http://localhost:8082/test-client2 - -# Invalid keys - undefined key structure -invalid.test-client3.sharedLinkBaseUrl=http://localhost:8083/test-client3/s -invalid.test-client3.templateAssetsUrl=http://localhost:8083/test-client3 - -# Invalid values -quickshare.client.test-client4.sharedLinkBaseUrl= -quickshare.client.test-client4.templateAssetsUrl= \ No newline at end of file