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.
-
-
Constructor Summary
Constructors Constructor Description SkinLockManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canWrite(Path file)
Determines if the current user can write in skin directoryUserIdentity
getLockOwner(Path file)
Get lock ownerString
getLockTool(Path file)
Get tool responsible for lockboolean
isLocked(Path file)
Determines if the skin directory is lockedDate
lastModified(Path file)
Get the last modified datevoid
service(ServiceManager smanager)
void
unlock(Path file)
Remove lock filevoid
updateLockFile(Path file, String toolId)
Create or update .lock file-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Constructor Detail
-
SkinLockManager
public SkinLockManager()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in 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:
true
if 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:
true
if 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
-
-