Package org.drjekyll.webdav.locking
Class LockedObject
- java.lang.Object
-
- org.drjekyll.webdav.locking.LockedObject
-
public class LockedObject extends Object
a helper class for ResourceLocks, represents the Locks- Author:
- re
-
-
Constructor Summary
Constructors Constructor Description LockedObject(ResourceLocks resLocks, String path, boolean temporary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(LockedObject newChild)adds a new child lock to this lockbooleanaddLockedObjectOwner(String owner)adds a new owner to a lockbooleancheckLocks(boolean exclusive, int depth)checks if a lock of the given exclusivity can be placed, only considering children up to "depth"LockedObject[]getChildren()children of that locklonggetExpiresAt()Describing the timeout of a locked object (ms)StringgetID()Gets the LockID (locktoken) for the LockedObjectintgetLockDepth()Describing the depth of a locked collection.String[]getOwner()owner of the lock.LockedObjectgetParent()StringgetPath()Gets the path for the LockedObjectlonggetTimeoutMillis()Gets the timeout for the LockedObjectStringgetType()weather the lock is a write or read lock Gets the type of the lockbooleanhasExpired()Return true if the lock has expired.booleanisExclusive()weather the lock is exclusive or not.booleanisShared()Gets the exclusivity for the LockedObjectvoidrefreshTimeout(int timeout)Sets a new timeout for the LockedObjectvoidremoveLockedObject()deletes this Lock object.voidremoveLockedObjectOwner(String owner)tries to remove the owner from the lockvoidremoveTempLockedObject()deletes this Lock object.voidsetChildren(LockedObject[] children)voidsetExclusive(boolean exclusive)Sets the exclusivity for the LockedObjectvoidsetExpiresAt(long expiresAt)voidsetLockDepth(int lockDepth)voidsetOwner(String[] owner)voidsetParent(LockedObject parent)voidsetType(String type)
-
-
-
Constructor Detail
-
LockedObject
public LockedObject(ResourceLocks resLocks, String path, boolean temporary)
- Parameters:
resLocks- the resourceLocks where locks are storedpath- the path to the locked objecttemporary- indicates if the LockedObject should be temporary or not
-
-
Method Detail
-
addLockedObjectOwner
public boolean addLockedObjectOwner(String owner)
adds a new owner to a lock- Parameters:
owner- string that represents the owner- Returns:
- true if the owner was added, false otherwise
-
getOwner
public String[] getOwner()
owner of the lock. shared locks can have multiple owners. is null if no owner is present Gets the owners for the LockedObject- Returns:
- owners
-
setOwner
public void setOwner(String[] owner)
-
removeLockedObjectOwner
public void removeLockedObjectOwner(String owner)
tries to remove the owner from the lock- Parameters:
owner- string that represents the owner
-
addChild
public void addChild(LockedObject newChild)
adds a new child lock to this lock- Parameters:
newChild- new child
-
getChildren
public LockedObject[] getChildren()
children of that lock
-
setChildren
public void setChildren(LockedObject[] children)
-
removeLockedObject
public void removeLockedObject()
deletes this Lock object. assumes that it has no children and no owners (does not check this itself)
-
removeTempLockedObject
public void removeTempLockedObject()
deletes this Lock object. assumes that it has no children and no owners (does not check this itself)
-
checkLocks
public boolean checkLocks(boolean exclusive, int depth)checks if a lock of the given exclusivity can be placed, only considering children up to "depth"- Parameters:
exclusive- wheather the new lock should be exclusivedepth- the depth to which should be checked- Returns:
- true if the lock can be placed
-
refreshTimeout
public void refreshTimeout(int timeout)
Sets a new timeout for the LockedObject- Parameters:
timeout-
-
getTimeoutMillis
public long getTimeoutMillis()
Gets the timeout for the LockedObject- Returns:
- timeout
-
hasExpired
public boolean hasExpired()
Return true if the lock has expired.- Returns:
- true if timeout has passed
-
getID
public String getID()
Gets the LockID (locktoken) for the LockedObject- Returns:
- locktoken
-
getPath
public String getPath()
Gets the path for the LockedObject- Returns:
- path
-
isExclusive
public boolean isExclusive()
weather the lock is exclusive or not. if owner=null the exclusive value doesn't matter Gets the exclusivity for the LockedObject- Returns:
- exclusivity
-
setExclusive
public void setExclusive(boolean exclusive)
Sets the exclusivity for the LockedObject- Parameters:
exclusive-
-
isShared
public boolean isShared()
Gets the exclusivity for the LockedObject- Returns:
- exclusivity
-
getType
public String getType()
weather the lock is a write or read lock Gets the type of the lock- Returns:
- type
-
setType
public void setType(String type)
-
getLockDepth
public int getLockDepth()
Describing the depth of a locked collection. If the locked resource is not a collection, depth is 0 / doesn't matter. Gets the depth of the lock- Returns:
- depth
-
setLockDepth
public void setLockDepth(int lockDepth)
-
getExpiresAt
public long getExpiresAt()
Describing the timeout of a locked object (ms)
-
setExpiresAt
public void setExpiresAt(long expiresAt)
-
getParent
public LockedObject getParent()
-
setParent
public void setParent(LockedObject parent)
-
-