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 protected ServiceManager_managerThe service manager instancestatic StringROLEThe avalon role
-
Constructor Summary
Constructors Constructor Description SkinDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
_manager
protected ServiceManager _manager
The service manager instance
-
-
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
-
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
-
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
-
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
-
-