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 SummaryFields 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 SummaryConstructors Constructor Description SkinDAO()
 - 
Method SummaryAll 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.AbstractLogEnabledenableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
- 
 
- 
- 
- 
Field Detail- 
__LICENCEprivate static final String __LICENCE - See Also:
- Constant Field Values
 
 - 
_managerprotected ServiceManager _manager The service manager instance
 - 
_skinsManagerprivate SkinsManager _skinsManager 
 - 
_modelsManagerprivate SkinModelsManager _modelsManager 
 - 
_siteManagerprivate SiteManager _siteManager 
 - 
_i18nUtilsprivate I18nUtils _i18nUtils 
 - 
_skinParameterTypeEPprivate SkinParameterTypeExtensionPoint _skinParameterTypeEP 
 
- 
 - 
Constructor Detail- 
SkinDAOpublic SkinDAO() 
 
- 
 - 
Method Detail- 
servicepublic void service(ServiceManager manager) throws ServiceException - Specified by:
- servicein interface- Serviceable
- Throws:
- ServiceException
 
 - 
contextualizepublic void contextualize(Context context) throws ContextException - Specified by:
- contextualizein interface- Contextualizable
- Throws:
- ContextException
 
 - 
getSkinpublic Map<String,Object> getSkin(String skinId) Retrieve informations on a skin- Parameters:
- skinId- The skin id
- Returns:
- the informations of a skin
 
 - 
skinExistspublic 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
 
 - 
isInUsepublic 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
 
 - 
getSkinspublic Map<String,Object> getSkins(boolean includeAbstract) Retrieve the list of available skins- Parameters:
- includeAbstract- Should include abstract skins
- Returns:
- a map of skins
 
 - 
_skins2JsonObjectprivate List<Object> _skins2JsonObject(boolean includeAbstract) 
 - 
importSkinpublic 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 name
- tmpDirPath- The directory where the zip was uploaded
- values- the configuration's values. Can be empty.
- Returns:
- The skin name
- Throws:
- SAXException- if an error occurs during configuration file creation
- IOException- if an error occurs while manipulating files
- TransformerConfigurationException- if an error occurs during configuration file creation
- ProcessingException- error while parsing model
 
 - 
configureSkinpublic Map<String,Object> configureSkin(String skinName, Map<String,Object> values) throws TransformerConfigurationException, IOException, SAXException, ProcessingException Configure a skin- Parameters:
- skinName- the skin name
- values- 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 creation
- IOException- if an error occurs during configuration file creation
- TransformerConfigurationException- if an error occurs during configuration file creation
- ProcessingException- error while parsing model
 
 - 
_getDefinitionAndValuesprivate Map<String,DefinitionAndValue> _getDefinitionAndValues(Map<String,Object> values, Collection<ElementDefinition> skinParameterDefinitions) 
 - 
_createConfigFileprivate void _createConfigFile(SkinParametersModel model, Path skinDir, Map<String,Object> values) throws IOException, SAXException, TransformerConfigurationException 
 - 
copySkinpublic String copySkin(String skinId, String originalSkinId) throws IOException Duplicate an existing skin- Parameters:
- skinId- The new skin id
- originalSkinId- The original skin id
- Returns:
- An error message, or null if successful
- Throws:
- IOException- if an I/O exception occurs during copy
 
 - 
_getModelFilterprivate 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
 
 - 
deleteSkinpublic 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
 
 - 
readValuespublic 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 skin
- skinParameterDefinitions- the skin parameter definitions
- Returns:
- a CollectionofDefinitionAndValueusing flatDefinitions and the values found in skinDir
- Throws:
- Exception- Impossible to read the file
 
 
- 
 
-