Package org.alfresco.repo.client.config
Class ClientAppConfig
- java.lang.Object
-
- org.springframework.extensions.surf.util.AbstractLifecycleBean
-
- org.alfresco.repo.client.config.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.AbstractLifecycleBeanThis 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
- Author:
- Jamal Kaabi-Mofrad
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClientAppConfig.ClientApp
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPREFIXstatic java.lang.StringPROP_TEMPLATE_ASSETS_URL
-
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 ajava.util.Map.ClientAppConfig.ClientAppgetClient(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.voidinit()protected voidonBootstrap(org.springframework.context.ApplicationEvent event)protected voidonShutdown(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 ofClientAppwith the client's name as the key.protected voidprocessPropertyKeys(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.voidsetDefaultProperties(java.util.Properties defaultProperties)voidsetGlobalProperties(java.util.Properties globalProperties)
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
- See Also:
- Constant Field Values
-
PROP_TEMPLATE_ASSETS_URL
public static final java.lang.String PROP_TEMPLATE_ASSETS_URL
- See Also:
- Constant Field Values
-
-
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:
onBootstrapin classorg.springframework.extensions.surf.util.AbstractLifecycleBean
-
onShutdown
protected void onShutdown(org.springframework.context.ApplicationEvent event)
- Specified by:
onShutdownin classorg.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 propertiesclientsNames- a set of strings which will be populated with client namespropsNames- 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 ofClientAppwith the client's name as the key.- Parameters:
clientsNames- the processed clients' namespropsNames- the processed properties namesallProps- the merged properties- Returns:
- a map of
ClientAppwith 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 ajava.util.Map.
-
-