Package org.ametys.web.skin
Class SkinDAO
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.web.skin.SkinDAO
-
- All Implemented Interfaces:
Component,Contextualizable,LogEnabled,Serviceable
public class SkinDAO extends AbstractLogEnabled implements Serviceable, Component, Contextualizable
DAO for manipulating skins
-
-
Field Summary
Fields Modifier and Type Field Description private static String__LICENCEprivate Context_contextprivate I18nUtils_i18nUtilsprotected ServiceManager_managerThe service manager instanceprivate SkinModelsManager_modelsManagerprivate SiteManager_siteManagerprivate SkinParameterTypeExtensionPoint_skinParameterTypeEPprivate SkinsManager_skinsManagerstatic StringROLEThe avalon role
-
Constructor Summary
Constructors Constructor Description SkinDAO()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_createConfigFile(SkinParametersModel model, Path skinDir, Map<String,Object> values)private Map<String,DefinitionAndValue>_getDefinitionAndValues(Map<String,Object> values, Collection<ElementDefinition> skinParameterDefinitions)private static Predicate<Path>_getModelFilter(Path skinDir)This filter accepts allFiles excepted CVS and SVN directories and root directory named "model"private Map<String,Object>_skin2JsonObject(String id, List<Site> skinSites)private List<Object>_skins2JsonObject(boolean includeAbstract)Map<String,Object>configureSkin(String skinName, Map<String,Object> values)Configure a skinvoidcontextualize(Context context)StringcopySkin(String skinId, String originalSkinId)Duplicate an existing skinStringdeleteSkin(String skinId)Delete a skinMap<String,Object>getSkin(String skinId)Retrieve informations on a skinMap<String,Object>getSkins(boolean includeAbstract)Retrieve the list of available skinsMap<String,Object>importSkin(String skinName, String tmpDirPath, Map<String,Object> values)This action receive a form with the "importfile" zip file as an exported skin.booleanisInUse(String skinId)Determines if a skin is currently used by one or more sitesCollection<DefinitionAndValue>readValues(Path skinDir, Collection<ElementDefinition> skinParameterDefinitions)Parse the values file and make a liaison with the definitions, to return a collection ofDefinitionAndValuevoidservice(ServiceManager manager)booleanskinExists(String skinId)Determines if a skin exists-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__LICENCE
private static final String __LICENCE
- See Also:
- Constant Field Values
-
_manager
protected ServiceManager _manager
The service manager instance
-
_skinsManager
private SkinsManager _skinsManager
-
_modelsManager
private SkinModelsManager _modelsManager
-
_siteManager
private SiteManager _siteManager
-
_i18nUtils
private I18nUtils _i18nUtils
-
_skinParameterTypeEP
private SkinParameterTypeExtensionPoint _skinParameterTypeEP
-
-
Constructor Detail
-
SkinDAO
public SkinDAO()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
getSkin
public Map<String,Object> getSkin(String skinId)
Retrieve informations on a skin- Parameters:
skinId- The skin id- Returns:
- the informations of a skin
-
skinExists
public boolean skinExists(String skinId) throws ProcessingException
Determines if a skin exists- Parameters:
skinId- The skin id- Returns:
- true if skin exists.
- Throws:
ProcessingException- if an error occurs
-
isInUse
public boolean isInUse(String skinId)
Determines if a skin is currently used by one or more sites- Parameters:
skinId- The skin id- Returns:
- true if skin is currently in use
-
getSkins
public Map<String,Object> getSkins(boolean includeAbstract)
Retrieve the list of available skins- Parameters:
includeAbstract- Should include abstract skins- Returns:
- a map of skins
-
_skins2JsonObject
private List<Object> _skins2JsonObject(boolean includeAbstract)
-
importSkin
public Map<String,Object> importSkin(String skinName, String tmpDirPath, Map<String,Object> values) throws TransformerConfigurationException, IOException, SAXException, ProcessingException
This action receive a form with the "importfile" zip file as an exported skin. Replace existing skin- Parameters:
skinName- The skin nametmpDirPath- The directory where the zip was uploadedvalues- the configuration's values. Can be empty.- Returns:
- The skin name
- Throws:
SAXException- if an error occurs during configuration file creationIOException- if an error occurs while manipulating filesTransformerConfigurationException- if an error occurs during configuration file creationProcessingException- error while parsing model
-
configureSkin
public Map<String,Object> configureSkin(String skinName, Map<String,Object> values) throws TransformerConfigurationException, IOException, SAXException, ProcessingException
Configure a skin- Parameters:
skinName- the skin namevalues- the configuration's values- Returns:
- A map with "errors" key that is a map <errorName> <errorMessage>
- Throws:
SAXException- if an error occurs during configuration file creationIOException- if an error occurs during configuration file creationTransformerConfigurationException- if an error occurs during configuration file creationProcessingException- error while parsing model
-
_getDefinitionAndValues
private Map<String,DefinitionAndValue> _getDefinitionAndValues(Map<String,Object> values, Collection<ElementDefinition> skinParameterDefinitions)
-
_createConfigFile
private void _createConfigFile(SkinParametersModel model, Path skinDir, Map<String,Object> values) throws IOException, SAXException, TransformerConfigurationException
-
copySkin
public String copySkin(String skinId, String originalSkinId) throws IOException
Duplicate an existing skin- Parameters:
skinId- The new skin idoriginalSkinId- The original skin id- Returns:
- An error message, or null if successful
- Throws:
IOException- if an I/O exception occurs during copy
-
_getModelFilter
private static final Predicate<Path> _getModelFilter(Path skinDir)
This filter accepts allFiles excepted CVS and SVN directories and root directory named "model"- Parameters:
skinDir- The model root directory- Returns:
- the filter
-
deleteSkin
public String deleteSkin(String skinId) throws IOException
Delete a skin- Parameters:
skinId- The skin id- Returns:
- the skin id
- Throws:
IOException- if an I/O exception occurs during deletion
-
readValues
public Collection<DefinitionAndValue> readValues(Path skinDir, Collection<ElementDefinition> skinParameterDefinitions) throws Exception
Parse the values file and make a liaison with the definitions, to return a collection ofDefinitionAndValue- Parameters:
skinDir- folder of the skinskinParameterDefinitions- the skin parameter definitions- Returns:
- a
CollectionofDefinitionAndValueusing flatDefinitions and the values found in skinDir - Throws:
Exception- Impossible to read the file
-
-