Package org.ametys.plugins.skincommons
Class SkinLockManager
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.skincommons.SkinLockManager
-
- All Implemented Interfaces:
Component,LogEnabled,Serviceable,ThreadSafe
public class SkinLockManager extends AbstractLogEnabled implements Component, ThreadSafe, Serviceable
Component to manage lock on skin directories.
-
-
Field Summary
Fields Modifier and Type Field Description private CurrentUserProvider_userProviderstatic StringROLEThe Avalon role name
-
Constructor Summary
Constructors Constructor Description SkinLockManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanWrite(Path file)Determines if the current user can write in skin directoryUserIdentitygetLockOwner(Path file)Get lock ownerStringgetLockTool(Path file)Get tool responsible for lockbooleanisLocked(Path file)Determines if the skin directory is lockedDatelastModified(Path file)Get the last modified datevoidservice(ServiceManager smanager)voidunlock(Path file)Remove lock filevoidupdateLockFile(Path file, String toolId)Create or update .lock file-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_userProvider
private CurrentUserProvider _userProvider
-
-
Constructor Detail
-
SkinLockManager
public SkinLockManager()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
canWrite
public boolean canWrite(Path file) throws IOException
Determines if the current user can write in skin directory- Parameters:
file- The skin directory- Returns:
trueif the skin directory is not locked by another user- Throws:
IOException- If an error occurred
-
updateLockFile
public void updateLockFile(Path file, String toolId) throws IOException
Create or update .lock file- Parameters:
file- The skin directorytoolId- The id of tool responsible for lock.- Throws:
IOException- If an error occurred
-
isLocked
public boolean isLocked(Path file)
Determines if the skin directory is locked- Parameters:
file- The skin directory- Returns:
trueif the skin directory is locked
-
getLockOwner
public UserIdentity getLockOwner(Path file) throws IOException
Get lock owner- Parameters:
file- The skin directory- Returns:
- The lock owner or null.
- Throws:
IOException- if an error occurs while manipulating files
-
getLockTool
public String getLockTool(Path file) throws IOException
Get tool responsible for lock- Parameters:
file- The skin directory- Returns:
- The tool responsible for lock or
null - Throws:
IOException- if an error occurs while manipulating files
-
lastModified
public Date lastModified(Path file) throws IOException
Get the last modified date- Parameters:
file- The skin directory- Returns:
- the last modified date
- Throws:
IOException- if an error occurs while manipulating files
-
-