Class ConfigurationServiceImpl
java.lang.Object
org.craftercms.studio.impl.v2.service.configuration.ConfigurationServiceImpl
- All Implemented Interfaces:
ConfigurationService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBuilds the key for a given fileorg.dom4j.Document
getConfigurationAsDocument
(String siteId, String module, String path, String environment) Get configuration as DOM document for given parametersgetConfigurationAsString
(String siteId, String module, String path, String environment) Get configuration as string for given parametersgetConfigurationHistory
(String siteId, String module, String path, String environment) Get configuration history for given parametersorg.dom4j.Document
Get configuration from global repository as DocumentGet configuration from global repository as StringGet global role mappings configurationorg.apache.commons.configuration2.HierarchicalConfiguration
<?> Reads a configuration file using Apache Commons Configurationorg.springframework.core.io.Resource
Get a file from a plugingetRoleMappings
(String siteId) Get role mappings configuration for given sitegetTranslationConfiguration
(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 Configurationorg.apache.commons.configuration2.HierarchicalConfiguration
<?> getXmlConfiguration
(String siteId, String module, String path) Reads a configuration for the current environment, or fallback to the default environment if the file is missingvoid
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 filelegacyGetConfiguration
(String site, String path) This method holds logic for API 1, can be deleted when API 1 get configuration is removedvoid
makeBlobStoresReadOnly
(String siteId) Update blob stores configuration to make all blobStores read-onlyvoid
setConfigurationServiceInternal
(ConfigurationService configurationServiceInternal) 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 repoMethods 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
-
Constructor Details
-
ConfigurationServiceImpl
public ConfigurationServiceImpl()
-
-
Method Details
-
setConfigurationServiceInternal
-
getRoleMappings
public Map<NormalizedGroup,List<NormalizedRole>> 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:
ServiceLayerException
-
getGlobalRoleMappings
public Map<NormalizedGroup,List<NormalizedRole>> getGlobalRoleMappings() throws ServiceLayerExceptionDescription copied from interface:ConfigurationService
Get global role mappings configuration- Specified by:
getGlobalRoleMappings
in interfaceConfigurationService
- Returns:
- role mappings configuration
- Throws:
ServiceLayerException
-
getConfigurationAsString
public String getConfigurationAsString(String siteId, String module, String path, String environment) throws ContentNotFoundException 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
- Throws:
ContentNotFoundException
- if there is any issue reading the file from the repository
-
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
-
getXmlConfiguration
public org.apache.commons.configuration2.HierarchicalConfiguration<?> getXmlConfiguration(String siteId, String module, String path) throws ConfigurationException Description copied from interface:ConfigurationService
Reads a configuration for the current environment, or fallback to the default environment if the file is missing- Specified by:
getXmlConfiguration
in interfaceConfigurationService
- Parameters:
siteId
- the id of the sitemodule
- the modulepath
- 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
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
- Throws:
ContentNotFoundException
- if there is any issue reading the file from the repository
-
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 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
-
getConfigurationHistory
public ConfigurationHistory getConfigurationHistory(String siteId, String module, String path, String environment) throws ServiceLayerException 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:
ServiceLayerException
-
writeGlobalConfiguration
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
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
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
Description copied from interface:ConfigurationService
Invalidates all objects for a given site- Specified by:
invalidateConfiguration
in interfaceConfigurationService
- Parameters:
siteId
- the id of the site
-
makeBlobStoresReadOnly
Description copied from interface:ConfigurationService
Update blob stores configuration to make all blobStores read-only- Specified by:
makeBlobStoresReadOnly
in interfaceConfigurationService
- Parameters:
siteId
- the id of the site- Throws:
ServiceLayerException
- if an error occurs while reading or writing the configuration
-
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
-