Class ClientAppConfig

  • All Implemented Interfaces:
    java.util.EventListener, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener

    public class ClientAppConfig
    extends org.springframework.extensions.surf.util.AbstractLifecycleBean
    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.

    The naming convention must confirm to the following:

    repo.client-app.<client-name>.<propertyName>

    Also, the client-name or property name (<propertyName>) must not contain a dot ('.')

    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.

    • 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/client/config/repo-clients-apps.properties which could be overridden (or add new clients) by alfresco-global properties file.
    Author:
    Jamal Kaabi-Mofrad
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PREFIX  
      static java.lang.String PROP_TEMPLATE_ASSETS_URL  
      • Fields inherited from class org.springframework.extensions.surf.util.AbstractLifecycleBean

        log
    • Constructor Summary

      Constructors 
      Constructor Description
      ClientAppConfig()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.util.Map<java.lang.String,​java.lang.String> getAndMergeProperties()
      Converts and merges the given Java properties into a java.util.Map.
      ClientAppConfig.ClientApp getClient​(java.lang.String name)
      Returns the named client or null if no client exists with the given name.
      java.util.Map<java.lang.String,​ClientAppConfig.ClientApp> getClients()
      Returns an unmodifiable view of the clients map.
      void init()  
      protected void onBootstrap​(org.springframework.context.ApplicationEvent event)  
      protected void onShutdown​(org.springframework.context.ApplicationEvent event)  
      protected java.util.Map<java.lang.String,​ClientAppConfig.ClientApp> processClients​(java.util.Set<java.lang.String> clientsNames, java.util.Set<java.lang.String> propsNames, java.util.Map<java.lang.String,​java.lang.String> allProps)
      Processes the given properties and if the properties' values are valid, creates a map of ClientApp with the client's name as the key.
      protected void processPropertyKeys​(java.util.Map<java.lang.String,​java.lang.String> allProps, java.util.Set<java.lang.String> clientsNames, java.util.Set<java.lang.String> propsNames)
      Processes the property's key and extracts the clients' names.
      void setDefaultProperties​(java.util.Properties defaultProperties)  
      void setGlobalProperties​(java.util.Properties globalProperties)  
      • Methods inherited from class org.springframework.extensions.surf.util.AbstractLifecycleBean

        getApplicationContext, onApplicationEvent, setApplicationContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClientAppConfig

        public ClientAppConfig()
    • Method Detail

      • setDefaultProperties

        public void setDefaultProperties​(java.util.Properties defaultProperties)
      • setGlobalProperties

        public void setGlobalProperties​(java.util.Properties globalProperties)
      • init

        public void init()
      • getClients

        public java.util.Map<java.lang.String,​ClientAppConfig.ClientApp> getClients()
        Returns an unmodifiable view of the clients map. Never null.
      • getClient

        public ClientAppConfig.ClientApp getClient​(java.lang.String name)
        Returns the named client or null if no client exists with the given name.
        Parameters:
        name - the name of the client to retrieve
      • onBootstrap

        protected void onBootstrap​(org.springframework.context.ApplicationEvent event)
        Specified by:
        onBootstrap in class org.springframework.extensions.surf.util.AbstractLifecycleBean
      • onShutdown

        protected void onShutdown​(org.springframework.context.ApplicationEvent event)
        Specified by:
        onShutdown in class org.springframework.extensions.surf.util.AbstractLifecycleBean
      • processPropertyKeys

        protected void processPropertyKeys​(java.util.Map<java.lang.String,​java.lang.String> allProps,
                                           java.util.Set<java.lang.String> clientsNames,
                                           java.util.Set<java.lang.String> propsNames)
        Processes the property's key and extracts the clients' names.
        Parameters:
        allProps - the merged properties
        clientsNames - a set of strings which will be populated with client names
        propsNames - a set of strings which will be populated with properties names (i.e.the property after the client name)
      • processClients

        protected java.util.Map<java.lang.String,​ClientAppConfig.ClientApp> processClients​(java.util.Set<java.lang.String> clientsNames,
                                                                                                 java.util.Set<java.lang.String> propsNames,
                                                                                                 java.util.Map<java.lang.String,​java.lang.String> allProps)
        Processes the given properties and if the properties' values are valid, creates a map of ClientApp with the client's name as the key.
        Parameters:
        clientsNames - the processed clients' names
        propsNames - the processed properties names
        allProps - the merged properties
        Returns:
        a map of ClientApp with the client's name as the key.
      • getAndMergeProperties

        protected java.util.Map<java.lang.String,​java.lang.String> getAndMergeProperties()
        Converts and merges the given Java properties into a java.util.Map.