Package org.ametys.skinfactory.skins
Class SkinDAO
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.skinfactory.skins.SkinDAO
-
- All Implemented Interfaces:
Component,LogEnabled,Serviceable
public class SkinDAO extends AbstractLogEnabled implements Serviceable, Component
Component to interact with a skin
-
-
Field Summary
Fields Modifier and Type Field Description private static String__PROD_MODEprivate static String__WORK_MODEprivate static DateFormat_DATE_FORMATprivate ModelDesignsManager_designsManagerprivate I18nUtils_i18nUtilsprivate LanguagesManager_languageManagerprivate SkinLockManager_lockManagerprivate SkinModelsManager_modelsManagerprivate SiteManager_siteManagerprivate SkinFactoryComponent_skinFactoryManagerprivate SkinEditionHelper_skinHelperprivate SkinsManager_skinsManagerprivate UploadManager_uploadManagerprivate UserManager_userManagerprivate CurrentUserProvider_userProviderstatic StringSKIN_FACTORY_TOOL_IDConstant for skin editor tool id
-
Constructor Summary
Constructors Constructor Description SkinDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_copyFilesToPreserve(Path skinDir)private String_getDefaultLanguage(Path i18nFile)private String_getHash(Path skinDir)private Path_getUploadDir(Path tempDir, ImageParameter imgParam)private List<Object>_imageFiles2JsonObject(String imageDirPath, String libraryDirPath, Path file, String modelName, boolean deep)private boolean_isImage(Path file)private void_preserveFile(Path skinDir, Path fileToPreserve)private void_reapplyModel(Path skinDir, Path modelDir, String hash)private Map<String,Object>_uploadImages2JsonObject(Path uploadDir, String skinName, ImageParameter imageParam)Map<String,Object>affectDesign(String skinName, String designId)Affect a new design configurationMap<String,Object>changeModel(String modelName, String skinName, boolean useDefaults)Change the model of a skinprotected Map<String,Object>checkLock(Path skinDir)Determines the skin directory is locked.StringcheckManualCloseCondition(String skinId)Check the current save state of a skinMap<String,String>checkOpenCondition(String siteName)Check the conditions for opening the current skin of a siteMap<String,Object>getColors(String siteName)Get the colors of a model and its theme for a site.Map<String,Object>getCssStyleItems(String siteName)Get the css style items used by a siteMap<String,Object>getGalleryImages(String skinName, String paramId)Retrieve the list of images for the skin and parameterList<Object>getGalleryVariants(String skinName, String paramId)Retrieve the list of gallery variants available for the specified skin and parameterMap<String,Object>getLanguages(String siteName)Get the languages available on a siteMap<String,Object>getParametersValues(String siteName, List<String> paramIds)Get the parameters of the skin of a siteMap<String,Object>getSkinModelParameters(String modelName)Get the skin model's parametersList<Object>getThemeColors(String siteName)Retrieve the list of themes' colors for a siteMap<String,String>openSkin(String siteName, String mode)Open the skin of a site for editionMap<String,Object>restoreDefaults(String skinName)Restore the default parameters for a skinvoidservice(ServiceManager manager)Map<String,Object>updateColorTheme(String skinName, String themeId)Set the theme used by a skinMap<String,Object>updateParameter(String skinName, String lang, String parameterId, String value, boolean uploaded)Update a parameter of the skinMap<String,Object>uploadLocalImage(String uploadId, String fileName, String skinName, String parameterId)Upload a local image and set it as value for a image parameter-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
SKIN_FACTORY_TOOL_ID
public static final String SKIN_FACTORY_TOOL_ID
Constant for skin editor tool id- See Also:
- Constant Field Values
-
_DATE_FORMAT
private static final DateFormat _DATE_FORMAT
-
__WORK_MODE
private static final String __WORK_MODE
- See Also:
- Constant Field Values
-
__PROD_MODE
private static final String __PROD_MODE
- See Also:
- Constant Field Values
-
_userProvider
private CurrentUserProvider _userProvider
-
_i18nUtils
private I18nUtils _i18nUtils
-
_languageManager
private LanguagesManager _languageManager
-
_designsManager
private ModelDesignsManager _designsManager
-
_siteManager
private SiteManager _siteManager
-
_skinHelper
private SkinEditionHelper _skinHelper
-
_skinFactoryManager
private SkinFactoryComponent _skinFactoryManager
-
_lockManager
private SkinLockManager _lockManager
-
_modelsManager
private SkinModelsManager _modelsManager
-
_skinsManager
private SkinsManager _skinsManager
-
_userManager
private UserManager _userManager
-
_uploadManager
private UploadManager _uploadManager
-
-
Constructor Detail
-
SkinDAO
public SkinDAO()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
checkManualCloseCondition
public String checkManualCloseCondition(String skinId) throws IOException
Check the current save state of a skin- Parameters:
skinId- The skin id- Returns:
- The state message.
- Throws:
IOException- if an error occurs when manipulating files
-
checkOpenCondition
public Map<String,String> checkOpenCondition(String siteName) throws IOException
Check the conditions for opening the current skin of a site- Parameters:
siteName- The name of the site- Returns:
- The informations on the state of the site's skin
- Throws:
IOException- if an error occurs when manipulating files
-
checkLock
protected Map<String,Object> checkLock(Path skinDir) throws IOException
Determines the skin directory is locked. If no, the lock owner is set in JSON map request attribute- Parameters:
skinDir- The skin directory- Returns:
- information about the lock, or null if not locked
- Throws:
IOException- if an error occurs when manipulating files
-
affectDesign
public Map<String,Object> affectDesign(String skinName, String designId) throws IOException
Affect a new design configuration- Parameters:
skinName- The skin namedesignId- The design id- Returns:
- the information on the design, or the error.
- Throws:
IOException- if an error occurs when manipulating files
-
changeModel
public Map<String,Object> changeModel(String modelName, String skinName, boolean useDefaults) throws IOException, TransformerConfigurationException, SAXException
Change the model of a skin- Parameters:
modelName- The model nameskinName- The skin nameuseDefaults-trueto use default model parameters- Returns:
- The skin parameters, or the error informations.
- Throws:
IOException- if an error occurs when manipulating filesTransformerConfigurationException- if something goes wrong when generating the model fileSAXException- if an error occurs while saxing
-
getLanguages
public Map<String,Object> getLanguages(String siteName)
Get the languages available on a site- Parameters:
siteName- The site name- Returns:
- The languages informations
-
_getDefaultLanguage
private String _getDefaultLanguage(Path i18nFile)
-
getColors
public Map<String,Object> getColors(String siteName)
Get the colors of a model and its theme for a site.- Parameters:
siteName- The site name- Returns:
- The colors and theme informations.
-
getCssStyleItems
public Map<String,Object> getCssStyleItems(String siteName)
Get the css style items used by a site- Parameters:
siteName- The site name- Returns:
- The css style items.
-
getParametersValues
public Map<String,Object> getParametersValues(String siteName, List<String> paramIds)
Get the parameters of the skin of a site- Parameters:
siteName- The site nameparamIds- If not null, specify the ids of the parameters to retrieve- Returns:
- The parameters
-
openSkin
public Map<String,String> openSkin(String siteName, String mode) throws IOException
Open the skin of a site for edition- Parameters:
siteName- The site namemode- The open mode- Returns:
- The skin id, or an error message.
- Throws:
IOException- if an error occurs when manipulating files
-
_reapplyModel
private void _reapplyModel(Path skinDir, Path modelDir, String hash) throws IOException
- Throws:
IOException
-
_preserveFile
private void _preserveFile(Path skinDir, Path fileToPreserve) throws IOException
- Throws:
IOException
-
_copyFilesToPreserve
private void _copyFilesToPreserve(Path skinDir) throws IOException
- Throws:
IOException
-
restoreDefaults
public Map<String,Object> restoreDefaults(String skinName) throws IOException, TransformerConfigurationException, SAXException
Restore the default parameters for a skin- Parameters:
skinName- The skin name- Returns:
- The skin informations, or an error code.
- Throws:
IOException- if an error occurs when manipulating filesTransformerConfigurationException- if something goes wrong when generating the model fileSAXException- if an error occurs while saxing
-
updateColorTheme
public Map<String,Object> updateColorTheme(String skinName, String themeId) throws IOException
Set the theme used by a skin- Parameters:
skinName- The skin namethemeId- The theme id- Returns:
- The theme informations, or an error code.
- Throws:
IOException- if an error occurs when manipulating files
-
updateParameter
public Map<String,Object> updateParameter(String skinName, String lang, String parameterId, String value, boolean uploaded) throws IOException
Update a parameter of the skin- Parameters:
skinName- The skin namelang- The current languageparameterId- The parameter id to updatevalue- The new value for the parameteruploaded-trueif the file was uploaded- Returns:
- The skin parameters updated, or an error code.
- Throws:
IOException- if an error occurs when manipulating files
-
uploadLocalImage
public Map<String,Object> uploadLocalImage(String uploadId, String fileName, String skinName, String parameterId) throws IOException
Upload a local image and set it as value for a image parameter- Parameters:
uploadId- The upload identifierfileName- The name of uploaded fileskinName- The skin nameparameterId- The parameter id to update- Returns:
- The skin parameters updated, or an error code.
- Throws:
IOException- if an error occurs when manipulating files
-
getGalleryImages
public Map<String,Object> getGalleryImages(String skinName, String paramId) throws IOException
Retrieve the list of images for the skin and parameter- Parameters:
skinName- The skin nameparamId- The parameter id- Returns:
- The map of images informations
- Throws:
IOException- if an error occurs when manipulating files
-
_uploadImages2JsonObject
private Map<String,Object> _uploadImages2JsonObject(Path uploadDir, String skinName, ImageParameter imageParam) throws IOException
- Throws:
IOException
-
_imageFiles2JsonObject
private List<Object> _imageFiles2JsonObject(String imageDirPath, String libraryDirPath, Path file, String modelName, boolean deep) throws IOException
- Throws:
IOException
-
_getUploadDir
private Path _getUploadDir(Path tempDir, ImageParameter imgParam) throws IOException
- Throws:
IOException
-
getGalleryVariants
public List<Object> getGalleryVariants(String skinName, String paramId) throws IOException
Retrieve the list of gallery variants available for the specified skin and parameter- Parameters:
skinName- The skin nameparamId- The parameter id- Returns:
- The list of gallery variants
- Throws:
IOException- if an error occurs when manipulating files
-
getSkinModelParameters
public Map<String,Object> getSkinModelParameters(String modelName)
Get the skin model's parameters- Parameters:
modelName- The model name- Returns:
- The parameters
-
getThemeColors
public List<Object> getThemeColors(String siteName)
Retrieve the list of themes' colors for a site- Parameters:
siteName- The site name- Returns:
- The model's themes colors
-
-