Package org.ametys.web.skin
Class SkinModelsManager
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.web.skin.SkinModelsManager
-
- All Implemented Interfaces:
Initializable
,Component
,Contextualizable
,LogEnabled
,Serviceable
,ThreadSafe
public class SkinModelsManager extends AbstractLogEnabled implements ThreadSafe, Serviceable, Component, Contextualizable, Initializable
Manages the models of skin
-
-
Field Summary
Fields Modifier and Type Field Description protected Context
_cocoonContext
Cocoon contextprotected Context
_context
Avalon contextprotected Map<String,Path>
_externalSkinModels
The models declared as external: name of the models and file locationprotected ServiceManager
_manager
The avalon service managerprotected Map<Path,SkinModel>
_models
The set of templates classified by skinsprotected Map<String,Path>
_resourcesSkinModels
The models declared in jar filesprotected SkinsManager
_skinsManager
The sites managerprotected SourceResolver
_sourceResolver
The excalibur source resolverstatic String
ROLE
The avalon role name
-
Constructor Summary
Constructors Constructor Description SkinModelsManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contextualize(Context context)
void
generateModelFile(Path skinDir, String modelId)
Generates the model.xml file for the skinvoid
generateModelFile(Path skinDir, String modelId, String colorTheme)
Generates the model.xml file for the skinPath
getLocalModelsLocation()
Get the skins locationSkinModel
getModel(String id)
Get a modelString
getModelHash(String id)
Get hash from modelString
getModelOfSkin(Skin skin)
Get the id of model associated to a skinSet<String>
getModels()
Get the list of existing modelsvoid
initialize()
void
service(ServiceManager manager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_externalSkinModels
protected Map<String,Path> _externalSkinModels
The models declared as external: name of the models and file location
-
_resourcesSkinModels
protected Map<String,Path> _resourcesSkinModels
The models declared in jar files
-
_manager
protected ServiceManager _manager
The avalon service manager
-
_sourceResolver
protected SourceResolver _sourceResolver
The excalibur source resolver
-
_skinsManager
protected SkinsManager _skinsManager
The sites manager
-
_cocoonContext
protected Context _cocoonContext
Cocoon context
-
-
Constructor Detail
-
SkinModelsManager
public SkinModelsManager()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getModels
public Set<String> getModels()
Get the list of existing models- Returns:
- A set of model names. Can be null if there is an error.
-
getModel
public SkinModel getModel(String id)
Get a model- Parameters:
id
- The id of the model- Returns:
- The model or null if the model does not exists
-
getModelOfSkin
public String getModelOfSkin(Skin skin)
Get the id of model associated to a skin- Parameters:
skin
- The skin- Returns:
- The id of the model or
null
if there is no model for this skin
-
getModelHash
public String getModelHash(String id)
Get hash from model- Parameters:
id
- The id of the model- Returns:
- unique has
-
generateModelFile
public void generateModelFile(Path skinDir, String modelId, String colorTheme) throws IOException, SAXException, TransformerConfigurationException
Generates the model.xml file for the skin- Parameters:
skinDir
- The skin directorymodelId
- The model idcolorTheme
- The id of color theme. Can be null.- Throws:
IOException
- if an I/O exception occurs during generationSAXException
- if an error occurs during generationTransformerConfigurationException
- if an error occurs during generation
-
generateModelFile
public void generateModelFile(Path skinDir, String modelId) throws IOException, SAXException, TransformerConfigurationException
Generates the model.xml file for the skin- Parameters:
skinDir
- The skin directorymodelId
- The model id- Throws:
IOException
- if an I/O exception occurs during generationSAXException
- if an error occurs during generationTransformerConfigurationException
- if an error occurs during generation
-
getLocalModelsLocation
public Path getLocalModelsLocation()
Get the skins location- Returns:
- the skin location
-
-