Class ConfigurationServiceImpl
- java.lang.Object
-
- org.craftercms.studio.impl.v2.service.configuration.ConfigurationServiceImpl
-
- All Implemented Interfaces:
ConfigurationService
public class ConfigurationServiceImpl extends Object implements ConfigurationService
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_KEY_TRANSLATION_DEFAULT_LOCALE
static String
CONFIG_KEY_TRANSLATION_LOCALES
static String
PLACEHOLDER_ID
static String
PLACEHOLDER_NAME
static String
PLACEHOLDER_TYPE
-
Constructor Summary
Constructors Constructor Description ConfigurationServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getCacheKey(String siteId, String module, String path, String environment, String suffix)
Builds the key for a given fileorg.dom4j.Document
getConfigurationAsDocument(String siteId, String module, String path, String environment)
Get configuration as DOM document for given parametersString
getConfigurationAsString(String siteId, String module, String path, String environment)
Get configuration as string for given parametersConfigurationHistory
getConfigurationHistory(String siteId, String module, String path, String environment)
Get configuration history for given parametersContentRepository
getContentRepository()
org.dom4j.Document
getGlobalConfigurationAsDocument(String path)
Get configuration from global repository as DocumentString
getGlobalConfigurationAsString(String path)
Get configuration from global repository as StringMap<String,List<String>>
getGlobalRoleMappings()
Get global role mappings configurationorg.apache.commons.configuration2.HierarchicalConfiguration<?>
getGlobalXmlConfiguration(String path)
Reads a configuration file using Apache Commons ConfigurationItemServiceInternal
getItemServiceInternal()
org.springframework.core.io.Resource
getPluginFile(String siteId, String pluginId, String type, String name, String filename)
Get a a file from a pluginMap<String,List<String>>
getRoleMappings(String siteId)
Get role mappings configuration for given siteTranslationConfiguration
getTranslationConfiguration(String siteId)
Get the translation configuration for a given siteorg.apache.commons.configuration2.HierarchicalConfiguration<?>
getXmlConfiguration(String siteId, String path)
Reads a configuration file using Apache Commons Configurationprotected void
invalidateCache(String key)
void
invalidateConfiguration(String siteId)
Invalidates all objects for a given sitevoid
invalidateConfiguration(String siteId, String path)
Invalidates the cache for the given filevoid
invalidateConfiguration(String siteId, String module, String path, String environment)
Invalidates the cache for the given fileMap<String,Object>
legacyGetConfiguration(String site, String path)
This method holds logic for API 1, can be deleted when API 1 get configuration is removedvoid
setAuditServiceInternal(AuditServiceInternal auditServiceInternal)
void
setCacheInvalidators(List<CacheInvalidator<String,Object>> cacheInvalidators)
void
setConfigurationCache(com.google.common.cache.Cache<String,Object> configurationCache)
void
setConfigurationReader(org.craftercms.commons.config.EncryptionAwareConfigurationReader configurationReader)
void
setContentRepository(ContentRepository contentRepository)
void
setContentService(ContentService contentService)
void
setDependencyService(DependencyService dependencyService)
void
setEventService(EventService eventService)
void
setItemServiceInternal(ItemServiceInternal itemServiceInternal)
void
setSecurityService(SecurityService securityService)
void
setServicesConfig(ServicesConfig servicesConfig)
void
setSiteService(SiteService siteService)
void
setStudioConfiguration(StudioConfiguration studioConfiguration)
void
setTranslationConfig(String translationConfig)
protected InputStream
validate(InputStream content, String filename)
void
writeConfiguration(String siteId, String module, String path, String environment, InputStream content)
Write configuration file for given parametersvoid
writeGlobalConfiguration(String path, InputStream content)
Write configuration file within global repo-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.craftercms.studio.api.v2.service.config.ConfigurationService
getCacheKey
-
-
-
-
Field Detail
-
PLACEHOLDER_TYPE
public static final String PLACEHOLDER_TYPE
- See Also:
- Constant Field Values
-
PLACEHOLDER_NAME
public static final String PLACEHOLDER_NAME
- See Also:
- Constant Field Values
-
PLACEHOLDER_ID
public static final String PLACEHOLDER_ID
- See Also:
- Constant Field Values
-
CONFIG_KEY_TRANSLATION_DEFAULT_LOCALE
public static final String CONFIG_KEY_TRANSLATION_DEFAULT_LOCALE
- See Also:
- Constant Field Values
-
CONFIG_KEY_TRANSLATION_LOCALES
public static final String CONFIG_KEY_TRANSLATION_LOCALES
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRoleMappings
public Map<String,List<String>> getRoleMappings(String siteId) throws ServiceLayerException
Description copied from interface:ConfigurationService
Get role mappings configuration for given site- Specified by:
getRoleMappings
in interfaceConfigurationService
- Parameters:
siteId
- Site id to use- Returns:
- role mappings configuration
- Throws:
ConfigurationException
- configuration errorServiceLayerException
-
getGlobalRoleMappings
public Map<String,List<String>> getGlobalRoleMappings() throws ServiceLayerException
Description copied from interface:ConfigurationService
Get global role mappings configuration- Specified by:
getGlobalRoleMappings
in interfaceConfigurationService
- Returns:
- role mappings configuration
- Throws:
ConfigurationException
- configuration errorServiceLayerException
-
getConfigurationAsString
public String getConfigurationAsString(String siteId, String module, String path, String environment)
Description copied from interface:ConfigurationService
Get configuration as string for given parameters- Specified by:
getConfigurationAsString
in interfaceConfigurationService
- Parameters:
siteId
- site id to usemodule
- CrafterCMS modulepath
- path of configuration fileenvironment
- environment to use. if empty using default- Returns:
- String content of configuration file
-
getConfigurationAsDocument
public org.dom4j.Document getConfigurationAsDocument(String siteId, String module, String path, String environment) throws ServiceLayerException
Description copied from interface:ConfigurationService
Get configuration as DOM document for given parameters- Specified by:
getConfigurationAsDocument
in interfaceConfigurationService
- Parameters:
siteId
- site id to usemodule
- CrafterCMS modulepath
- path of configuration fileenvironment
- environment to use. if empty using default- Returns:
- DOM document representing configuration file
- Throws:
ServiceLayerException
- if there is any error loading the configuration
-
getXmlConfiguration
public org.apache.commons.configuration2.HierarchicalConfiguration<?> getXmlConfiguration(String siteId, String path) throws ConfigurationException
Description copied from interface:ConfigurationService
Reads a configuration file using Apache Commons Configuration- Specified by:
getXmlConfiguration
in interfaceConfigurationService
- Parameters:
siteId
- the id of the sitepath
- the path of the file- Returns:
- the configuration object
- Throws:
ConfigurationException
- if there is any error reading or parsing the file
-
getGlobalXmlConfiguration
public org.apache.commons.configuration2.HierarchicalConfiguration<?> getGlobalXmlConfiguration(String path) throws ConfigurationException
Description copied from interface:ConfigurationService
Reads a configuration file using Apache Commons Configuration- Specified by:
getGlobalXmlConfiguration
in interfaceConfigurationService
- Parameters:
path
- the path of the file- Returns:
- the configuration object
- Throws:
ConfigurationException
- if there is any error reading or parsing the file
-
getGlobalConfigurationAsDocument
public org.dom4j.Document getGlobalConfigurationAsDocument(String path) throws ServiceLayerException
Description copied from interface:ConfigurationService
Get configuration from global repository as Document- Specified by:
getGlobalConfigurationAsDocument
in interfaceConfigurationService
- Parameters:
path
- path of the configuration file- Returns:
- the Document
- Throws:
ServiceLayerException
- if there is any error reading the configuration
-
getGlobalConfigurationAsString
public String getGlobalConfigurationAsString(String path)
Description copied from interface:ConfigurationService
Get configuration from global repository as String- Specified by:
getGlobalConfigurationAsString
in interfaceConfigurationService
- Parameters:
path
- path of configuration file- Returns:
- String content of configuration file
-
writeConfiguration
public void writeConfiguration(String siteId, String module, String path, String environment, InputStream content) throws ServiceLayerException, UserNotFoundException
Description copied from interface:ConfigurationService
Write configuration file for given parameters- Specified by:
writeConfiguration
in interfaceConfigurationService
- Parameters:
siteId
- site id to usemodule
- CrafterCMS modulepath
- path where to store configuration fileenvironment
- environment to use. if empty using defaultcontent
- content of configuration file- Throws:
ServiceLayerException
- general service errorUserNotFoundException
-
getCacheKey
public String getCacheKey(String siteId, String module, String path, String environment, String suffix)
Description copied from interface:ConfigurationService
Builds the key for a given file- Specified by:
getCacheKey
in interfaceConfigurationService
- Parameters:
siteId
- the id of the sitemodule
- the module of the filepath
- the path of the fileenvironment
- the environment of the filesuffix
- the suffix for the cache key- Returns:
- the key for the file
-
getPluginFile
public org.springframework.core.io.Resource getPluginFile(String siteId, String pluginId, String type, String name, String filename) throws ContentNotFoundException
Description copied from interface:ConfigurationService
Get a a file from a plugin- Specified by:
getPluginFile
in interfaceConfigurationService
- Parameters:
siteId
- the id of sitepluginId
- the id of the plugintype
- the type of pluginname
- the name of the pluginfilename
- the path and name of the file- Returns:
- the file as a resource
- Throws:
ContentNotFoundException
- if there is any issue reading the file from the repository
-
validate
protected InputStream validate(InputStream content, String filename) throws ServiceLayerException
- Throws:
ServiceLayerException
-
getConfigurationHistory
public ConfigurationHistory getConfigurationHistory(String siteId, String module, String path, String environment) throws SiteNotFoundException, ContentNotFoundException
Description copied from interface:ConfigurationService
Get configuration history for given parameters- Specified by:
getConfigurationHistory
in interfaceConfigurationService
- Parameters:
siteId
- site id to usemodule
- CrafterCMS modulepath
- path of configuration fileenvironment
- environment to use. if empty using default- Returns:
- configuration history
- Throws:
SiteNotFoundException
ContentNotFoundException
-
writeGlobalConfiguration
public void writeGlobalConfiguration(String path, InputStream content) throws ServiceLayerException
Description copied from interface:ConfigurationService
Write configuration file within global repo- Specified by:
writeGlobalConfiguration
in interfaceConfigurationService
- Parameters:
path
- path of configuration filecontent
- content of configuration file- Throws:
ServiceLayerException
- general service error
-
getTranslationConfiguration
public TranslationConfiguration getTranslationConfiguration(String siteId) throws ServiceLayerException
Description copied from interface:ConfigurationService
Get the translation configuration for a given site- Specified by:
getTranslationConfiguration
in interfaceConfigurationService
- Parameters:
siteId
- the id of the site- Returns:
- the translation configuration
- Throws:
ServiceLayerException
- general service error
-
invalidateConfiguration
public void invalidateConfiguration(String siteId, String path)
Description copied from interface:ConfigurationService
Invalidates the cache for the given file- Specified by:
invalidateConfiguration
in interfaceConfigurationService
- Parameters:
siteId
- the id of the sitepath
- the path of the file
-
invalidateConfiguration
public void invalidateConfiguration(String siteId, String module, String path, String environment)
Description copied from interface:ConfigurationService
Invalidates the cache for the given file- Specified by:
invalidateConfiguration
in interfaceConfigurationService
- Parameters:
siteId
- the id of the sitemodule
- the module of the filepath
- the path of the fileenvironment
- the environment of the file
-
invalidateConfiguration
public void invalidateConfiguration(String siteId)
Description copied from interface:ConfigurationService
Invalidates all objects for a given site- Specified by:
invalidateConfiguration
in interfaceConfigurationService
- Parameters:
siteId
- the id of the site
-
invalidateCache
protected void invalidateCache(String key)
-
legacyGetConfiguration
public Map<String,Object> legacyGetConfiguration(String site, String path) throws ServiceLayerException
Description copied from interface:ConfigurationService
This method holds logic for API 1, can be deleted when API 1 get configuration is removed- Specified by:
legacyGetConfiguration
in interfaceConfigurationService
- Throws:
ServiceLayerException
-
setContentService
public void setContentService(ContentService contentService)
-
setStudioConfiguration
public void setStudioConfiguration(StudioConfiguration studioConfiguration)
-
setAuditServiceInternal
public void setAuditServiceInternal(AuditServiceInternal auditServiceInternal)
-
setSiteService
public void setSiteService(SiteService siteService)
-
setSecurityService
public void setSecurityService(SecurityService securityService)
-
setServicesConfig
public void setServicesConfig(ServicesConfig servicesConfig)
-
setEventService
public void setEventService(EventService eventService)
-
setConfigurationReader
public void setConfigurationReader(org.craftercms.commons.config.EncryptionAwareConfigurationReader configurationReader)
-
setTranslationConfig
public void setTranslationConfig(String translationConfig)
-
getItemServiceInternal
public ItemServiceInternal getItemServiceInternal()
-
setItemServiceInternal
public void setItemServiceInternal(ItemServiceInternal itemServiceInternal)
-
setConfigurationCache
public void setConfigurationCache(com.google.common.cache.Cache<String,Object> configurationCache)
-
getContentRepository
public ContentRepository getContentRepository()
-
setContentRepository
public void setContentRepository(ContentRepository contentRepository)
-
setCacheInvalidators
public void setCacheInvalidators(List<CacheInvalidator<String,Object>> cacheInvalidators)
-
setDependencyService
public void setDependencyService(DependencyService dependencyService)
-
-