Package org.ametys.skinfactory
Class SkinFactoryComponent
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.skinfactory.SkinFactoryComponent
-
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
,ThreadSafe
public class SkinFactoryComponent extends AbstractLogEnabled implements Component, ThreadSafe, Serviceable
Manager for skin parameters
-
-
Field Summary
Fields Modifier and Type Field Description private static Pattern
__I18N_CATALOG_LANGUAGE
private Map<String,String>
_modelsHash
private SkinModelsManager
_modelsManager
private Map<String,Map<String,AbstractSkinParameter>>
_modelsParameters
private SourceResolver
_resolver
static Pattern
CSS_PARAM_PATTERN
Pattern for CSS parameters.static Pattern
I18N_PARAM_PATTERN
Pattern for i18n text parameters.static String
ROLE
Avalon rolestatic Pattern
TXT_PARAM_PATTERN
Pattern for text parameters.
-
Constructor Summary
Constructors Constructor Description SkinFactoryComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private I18nizableText
_configureI18nizableText(Configuration configuration, String modelName)
private void
_configureImage(Path imageFile, ImageParameter param, String modelName)
private void
_configureVariant(Path variantFile, VariantParameter param, String modelName)
private void
_findImagesParameters(Path modelDir, Path imagesDir, Path file, Map<String,ImageParameter> params, String modelName)
private void
_findVariantsParameters(Path variantsDir, Map<String,VariantParameter> params, String modelName)
private String
_getCatalogLanguage(String string, String fileName)
private Map<String,CSSParameter>
_getCSSParameters(Path modelDir, String modelName)
private Map<String,String>
_getI18nOtherDefaultValues(Path defaultCatalog, String i18nKey)
private Map<String,I18nizableTextParameter>
_getI18nTextParameters(Path modelDir, String modelName)
private Map<String,ImageParameter>
_getImageParameters(Path modelDir, String modelName)
private Map<String,TextParameter>
_getTextParameters(Path modelDir, String modelName)
private Object
_getValue(SkinModel model, AbstractSkinParameter param, Map<String,Object> values, Map<String,String> defaultValues)
private Map<String,VariantParameter>
_getVariantParameters(Path modelDir, String modelName)
private List<Variant>
_getVariantValues(Path variant, String modelName)
private List<Path>
_listFiles(Path file, String extension)
private void
_parseCSSFile(Map<String,CSSParameter> cssParams, String modelName, Path cssFile)
private Map<String,I18nizableTextParameter>
_parseI18nFile(String skinName, Path i18nFile)
private I18nizableText
_parseI18nizableText(String label, String modelName)
private Map<String,TextParameter>
_parseXSLFile(String skinName, Path xslFile)
void
applyColorTheme(String modelName, Path skinDir)
Apply new color themevoid
applyModelParameters(String modelName, Path skinDir)
Apply model parameters in given skinvoid
applyModelParameters(String modelName, Path skinDir, Map<String,Object> values)
Apply model parameters in given skinvoid
applyParameter(AbstractSkinParameter parameter, Path skinDir, String modelName, Object value, String lang)
Apply parametervoid
clearModelsParametersCache()
Remove all model parameters from cacheString
getColorTheme(Path skinDir)
Get the current themeAbstractSkinParameter
getModelParamater(String modelName, String paramId)
Get the skin parameter of the given modelMap<String,AbstractSkinParameter>
getModelParameters(String modelName)
Get the skin parameters of a modelObject
getParameterValue(Path skinDir, String modelName, String id)
Get the parameter's valueMap<String,Object>
getParameterValues(Path skinDir, String modelName)
Get all parameters' valuesMap<String,Object>
getParameterValues(Path skinDir, String modelName, List<String> ids)
Get the parameters' valuesboolean
isModelUpToDate(String modelName)
Determines if the model was changedboolean
saveColorTheme(Path skinDir, String themeId)
Modify the color themeboolean
saveParameter(Path skinDir, String id, Object value)
Modify a skin parameter's valueboolean
saveParameters(Path skinDir, Map<String,Object> parameters)
Save skin parametersvoid
service(ServiceManager smanager)
void
updateHash(Path xmlFile, String hash)
Update hash-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
CSS_PARAM_PATTERN
public static final Pattern CSS_PARAM_PATTERN
Pattern for CSS parameters. E.g: color: #EEEEEE /* AMETYS("myuniqueid", "Label", DESCRIPTION_I18N_KEY) *\/;
-
I18N_PARAM_PATTERN
public static final Pattern I18N_PARAM_PATTERN
Pattern for i18n text parameters. E.g: <message key="SKIN_TITLE">Ametys, Web Java Open Source CMS<!-- Ametys("text.i18n.site.title", "Titre du site") --></message>
-
TXT_PARAM_PATTERN
public static final Pattern TXT_PARAM_PATTERN
Pattern for text parameters. E.g: <xsl:variable name="foo">test<!-- Ametys("variable.foo", "Foo", "Foo") --></xsl:variable>
-
__I18N_CATALOG_LANGUAGE
private static final Pattern __I18N_CATALOG_LANGUAGE
-
_modelsParameters
private final Map<String,Map<String,AbstractSkinParameter>> _modelsParameters
-
_modelsHash
private final Map<String,String> _modelsHash
-
_modelsManager
private SkinModelsManager _modelsManager
-
_resolver
private SourceResolver _resolver
-
-
Constructor Detail
-
SkinFactoryComponent
public SkinFactoryComponent()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
clearModelsParametersCache
public void clearModelsParametersCache()
Remove all model parameters from cache
-
getModelParamater
public AbstractSkinParameter getModelParamater(String modelName, String paramId)
Get the skin parameter of the given model- Parameters:
modelName
- The model nameparamId
- The id of the parameter- Returns:
- The skin parameter or
null
if it doesn't exist
-
isModelUpToDate
public boolean isModelUpToDate(String modelName)
Determines if the model was changed- Parameters:
modelName
- The model name- Returns:
true
if the model was changed
-
getModelParameters
public Map<String,AbstractSkinParameter> getModelParameters(String modelName)
Get the skin parameters of a model- Parameters:
modelName
- the model name- Returns:
- skin parameters in a List
-
_getVariantParameters
private Map<String,VariantParameter> _getVariantParameters(Path modelDir, String modelName) throws IOException
- Throws:
IOException
-
_findVariantsParameters
private void _findVariantsParameters(Path variantsDir, Map<String,VariantParameter> params, String modelName) throws IOException
- Throws:
IOException
-
_getVariantValues
private List<Variant> _getVariantValues(Path variant, String modelName)
-
_configureVariant
private void _configureVariant(Path variantFile, VariantParameter param, String modelName)
-
_getImageParameters
private Map<String,ImageParameter> _getImageParameters(Path modelDir, String modelName)
-
_findImagesParameters
private void _findImagesParameters(Path modelDir, Path imagesDir, Path file, Map<String,ImageParameter> params, String modelName)
-
_configureImage
private void _configureImage(Path imageFile, ImageParameter param, String modelName)
-
_getCSSParameters
private Map<String,CSSParameter> _getCSSParameters(Path modelDir, String modelName) throws IOException
- Throws:
IOException
-
_listFiles
private List<Path> _listFiles(Path file, String extension)
-
_parseCSSFile
private void _parseCSSFile(Map<String,CSSParameter> cssParams, String modelName, Path cssFile)
-
_getTextParameters
private Map<String,TextParameter> _getTextParameters(Path modelDir, String modelName)
-
_parseXSLFile
private Map<String,TextParameter> _parseXSLFile(String skinName, Path xslFile)
-
_getI18nTextParameters
private Map<String,I18nizableTextParameter> _getI18nTextParameters(Path modelDir, String modelName)
-
_parseI18nFile
private Map<String,I18nizableTextParameter> _parseI18nFile(String skinName, Path i18nFile)
-
_getCatalogLanguage
private String _getCatalogLanguage(String string, String fileName)
-
_getI18nOtherDefaultValues
private Map<String,String> _getI18nOtherDefaultValues(Path defaultCatalog, String i18nKey) throws IOException
- Throws:
IOException
-
_parseI18nizableText
private I18nizableText _parseI18nizableText(String label, String modelName)
-
getParameterValue
public Object getParameterValue(Path skinDir, String modelName, String id)
Get the parameter's value- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)modelName
- The model nameid
- The parameter id- Returns:
- The parameter's value
-
getParameterValues
public Map<String,Object> getParameterValues(Path skinDir, String modelName, List<String> ids)
Get the parameters' values- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)modelName
- The model nameids
- The parameters' id- Returns:
- The parameters' values
-
getColorTheme
public String getColorTheme(Path skinDir)
Get the current theme- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)- Returns:
- The current theme id
-
getParameterValues
public Map<String,Object> getParameterValues(Path skinDir, String modelName)
Get all parameters' values- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)modelName
- The model name- Returns:
- The all parameters' values
-
saveColorTheme
public boolean saveColorTheme(Path skinDir, String themeId)
Modify the color theme- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)themeId
- The id of the theme. Can be null to clear theme.- Returns:
true
is modification success
-
saveParameter
public boolean saveParameter(Path skinDir, String id, Object value)
Modify a skin parameter's value- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)id
- the id of the parametervalue
- the new value- Returns:
true
is modification success
-
saveParameters
public boolean saveParameters(Path skinDir, Map<String,Object> parameters)
Save skin parameters- Parameters:
skinDir
- The skin directory (could be in temp, work or skin)parameters
- The skins parameters to save- Returns:
true
is modification success
-
applyModelParameters
public void applyModelParameters(String modelName, Path skinDir)
Apply model parameters in given skin- Parameters:
modelName
- The model nameskinDir
- The skin directory (could be temp, work or skins)
-
applyModelParameters
public void applyModelParameters(String modelName, Path skinDir, Map<String,Object> values)
Apply model parameters in given skin- Parameters:
modelName
- The model nameskinDir
- The skin directoryvalues
- The values to set
-
_getValue
private Object _getValue(SkinModel model, AbstractSkinParameter param, Map<String,Object> values, Map<String,String> defaultValues)
-
updateHash
public void updateHash(Path xmlFile, String hash) throws IOException
Update hash- Parameters:
xmlFile
- the xmlFile
hash
- the new hash of the file- Throws:
IOException
- if an error occurs while manipulating the file
-
applyParameter
public void applyParameter(AbstractSkinParameter parameter, Path skinDir, String modelName, Object value, String lang)
Apply parameter- Parameters:
parameter
- the skin parameterskinDir
- the skin directory (could be temp, work or skins)modelName
- the model namevalue
- the parameter valuelang
- The language
-
applyColorTheme
public void applyColorTheme(String modelName, Path skinDir)
Apply new color theme- Parameters:
skinDir
- the skin directory (could be temp, work or skins)modelName
- the model name
-
_configureI18nizableText
private I18nizableText _configureI18nizableText(Configuration configuration, String modelName) throws ConfigurationException
- Throws:
ConfigurationException
-
-