Package org.ametys.plugins.skincommons
Class SkinEditionHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.skincommons.SkinEditionHelper
-
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
,ThreadSafe
public class SkinEditionHelper extends AbstractLogEnabled implements Component, ThreadSafe, Serviceable, Contextualizable
Helper for skin edition
-
-
Field Summary
Fields Modifier and Type Field Description protected Context
_cocoonContext
The cocoon contextprivate static DateFormat
_DATE_FORMAT
private XMLResourceBundleFactory
_i18nFactory
private PageElementCache
_inputDataCache
private SiteManager
_siteManager
private SkinsManager
_skinsManager
private PageElementCache
_zoneItemCache
static String
ROLE
The Avalon role name
-
Constructor Summary
Constructors Constructor Description SkinEditionHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private String
_getModel(Path skinDir)
private String
_getSkinId(Site site)
private void
_invalidateSkinCatalogue(Path skinDir, String skinName, String catalogLocation, String lang)
Invalidate catalog of the skinprivate void
_invalidateSkinCatalogues(Path skinDir, String skinName, String catalogLocation)
Invalidate all catalogs of the skinvoid
contextualize(Context context)
Path
createBackupFile(String skinName)
Create a backup file of the current skinvoid
deleteOldBackup(String skinName, int keepMax)
Remove the old backupboolean
deleteQuicklyDirectory(Path file)
Asynchronous file deletionPath
getBackupDirectory(String skinName, Date date)
Get the backup directory of skinString
getBackupDirectoryURI(String skinName, Date date)
Get the backup directory of skinFile
getRootBackupDirectory(String skinName)
Get the root backup directory of skinString
getRootBackupDirectoryURI(String skinName)
Get the root backup directory of skinPath
getSkinDirectory(String skinName)
Get the skin directory of skinString
getSkinModel(String skinName)
Get the model of the skinPath
getTempDirectory(String skinName)
Get the temp directory of skinString
getTempDirectoryURI(String skinName)
Get the temp directory of skinString
getTempModel(String skinName)
Get the model of temporary version of skinPath
getWorkDirectory(String skinName)
Get the work directory of skinString
getWorkDirectoryURI(String skinName)
Get the work directory of skinString
getWorkModel(String skinName)
Get the model of working version of skinvoid
invalidateCaches(String skinName)
Invalidate all caches relative to the modified skin.void
invalidateSkinCatalogue(String skinName, String lang)
Invalidate a catalog of the skin for a given languagevoid
invalidateSkinCatalogues(String skinName)
Invalidate all catalogs of the skinvoid
invalidateTempSkinCatalogue(String skinName, String lang)
Invalidate a catalog of the temporary skin for a given languagevoid
invalidateTempSkinCatalogues(String skinName)
Invalidate all catalogs of the temporary skinvoid
service(ServiceManager smanager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_DATE_FORMAT
private static final DateFormat _DATE_FORMAT
-
_cocoonContext
protected Context _cocoonContext
The cocoon context
-
_siteManager
private SiteManager _siteManager
-
_zoneItemCache
private PageElementCache _zoneItemCache
-
_inputDataCache
private PageElementCache _inputDataCache
-
_i18nFactory
private XMLResourceBundleFactory _i18nFactory
-
_skinsManager
private SkinsManager _skinsManager
-
-
Constructor Detail
-
SkinEditionHelper
public SkinEditionHelper()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
createBackupFile
public Path createBackupFile(String skinName) throws IOException
Create a backup file of the current skin- Parameters:
skinName
- The skin name- Returns:
- The created backup directory
- Throws:
IOException
- If an error occurred
-
deleteQuicklyDirectory
public boolean deleteQuicklyDirectory(Path file) throws IOException
Asynchronous file deletion- Parameters:
file
- The file to delete- Returns:
true
if the deletion succeeded- Throws:
IOException
- if an error occurs while manipulating files
-
deleteOldBackup
public void deleteOldBackup(String skinName, int keepMax) throws IOException
Remove the old backup- Parameters:
skinName
- The skin namekeepMax
- The max number of backup to keep- Throws:
IOException
- if an error occurs while manipulating files
-
invalidateCaches
public void invalidateCaches(String skinName) throws Exception
Invalidate all caches relative to the modified skin.- Parameters:
skinName
- the modified skin name.- Throws:
Exception
- if an error occurs.
-
_getSkinId
private String _getSkinId(Site site)
-
invalidateTempSkinCatalogues
public void invalidateTempSkinCatalogues(String skinName)
Invalidate all catalogs of the temporary skin- Parameters:
skinName
- The site name
-
invalidateTempSkinCatalogue
public void invalidateTempSkinCatalogue(String skinName, String lang)
Invalidate a catalog of the temporary skin for a given language- Parameters:
skinName
- The site namelang
- The language
-
invalidateSkinCatalogues
public void invalidateSkinCatalogues(String skinName)
Invalidate all catalogs of the skin- Parameters:
skinName
- The skin name
-
invalidateSkinCatalogue
public void invalidateSkinCatalogue(String skinName, String lang)
Invalidate a catalog of the skin for a given language- Parameters:
skinName
- The site namelang
- The language
-
_invalidateSkinCatalogues
private void _invalidateSkinCatalogues(Path skinDir, String skinName, String catalogLocation)
Invalidate all catalogs of the skin- Parameters:
skinDir
- The skin directoryskinName
- The skin namecatalogLocation
- the catalog location
-
_invalidateSkinCatalogue
private void _invalidateSkinCatalogue(Path skinDir, String skinName, String catalogLocation, String lang)
Invalidate catalog of the skin- Parameters:
skinDir
- The skin directoryskinName
- The site namecatalogLocation
- the catalog locationlang
- The language of catalog. Can be empty.
-
getTempDirectory
public Path getTempDirectory(String skinName)
Get the temp directory of skin- Parameters:
skinName
- The skin name- Returns:
- The temp directory
-
getWorkDirectory
public Path getWorkDirectory(String skinName)
Get the work directory of skin- Parameters:
skinName
- The skin name- Returns:
- The work directory
-
getBackupDirectory
public Path getBackupDirectory(String skinName, Date date)
Get the backup directory of skin- Parameters:
skinName
- The skin namedate
- The date- Returns:
- The backup directory
-
getRootBackupDirectory
public File getRootBackupDirectory(String skinName)
Get the root backup directory of skin- Parameters:
skinName
- The skin name- Returns:
- The root backup directory
-
getTempDirectoryURI
public String getTempDirectoryURI(String skinName)
Get the temp directory of skin- Parameters:
skinName
- The skin name- Returns:
- The temp directory URI
-
getWorkDirectoryURI
public String getWorkDirectoryURI(String skinName)
Get the work directory of skin- Parameters:
skinName
- The skin name- Returns:
- The work directory URI
-
getBackupDirectoryURI
public String getBackupDirectoryURI(String skinName, Date date)
Get the backup directory of skin- Parameters:
skinName
- The skin namedate
- The date- Returns:
- The backup directory URI
-
getRootBackupDirectoryURI
public String getRootBackupDirectoryURI(String skinName)
Get the root backup directory of skin- Parameters:
skinName
- The skin name- Returns:
- The root backup directory URI
-
getSkinDirectory
public Path getSkinDirectory(String skinName)
Get the skin directory of skin- Parameters:
skinName
- The skin name- Returns:
- The skin directory
-
getTempModel
public String getTempModel(String skinName)
Get the model of temporary version of skin- Parameters:
skinName
- The skin name- Returns:
- the model name
-
getWorkModel
public String getWorkModel(String skinName)
Get the model of working version of skin- Parameters:
skinName
- The skin name- Returns:
- the model name
-
getSkinModel
public String getSkinModel(String skinName)
Get the model of the skin- Parameters:
skinName
- skinName The skin name- Returns:
- The model name or
null
-
-