Package nl.info.webdav.locking
Class LockedObject
java.lang.Object
nl.info.webdav.locking.LockedObject
a helper class for ResourceLocks, represents the Locks
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LockedObject[]children of that lockprotected booleanweather the lock is exclusive or not.protected longDescribing the timeout of a locked object (ms)protected intDescribing the depth of a locked collection.protected String[]owner of the lock.protected LockedObjectprotected Stringweather the lock is a write or read lock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(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"getID()Gets the LockID (locktoken) for the LockedObjectintGets the depth of the lockString[]getOwner()Gets the owners for the LockedObjectgetPath()Gets the path for the LockedObjectlongGets the timeout for the LockedObjectgetType()Gets the type of the lockbooleanReturn true if the lock has expired.booleanGets the exclusivity for the LockedObjectbooleanisShared()Gets the exclusivity for the LockedObjectvoidrefreshTimeout(int timeout) Sets a new timeout for the LockedObjectvoiddeletes this Lock object.voidremoveLockedObjectOwner(String owner) tries to remove the owner from the lockvoiddeletes this Lock object.voidsetExclusive(boolean exclusive) Sets the exclusivity for the LockedObject
-
Field Details
-
_lockDepth
protected int _lockDepthDescribing the depth of a locked collection. If the locked resource is not a collection, depth is 0 / doesn't matter. -
_expiresAt
protected long _expiresAtDescribing the timeout of a locked object (ms) -
_owner
owner of the lock. shared locks can have multiple owners. is null if no owner is present -
_children
children of that lock -
_parent
-
_exclusive
protected boolean _exclusiveweather the lock is exclusive or not. if owner=null the exclusive value doesn't matter -
_type
weather the lock is a write or read lock
-
-
Constructor Details
-
LockedObject
- Parameters:
resourceLocks- the resourceLocks where locks are storedpath- the path to the locked objectisTemporary- indicates if the LockedObject should be temporary or not
-
-
Method Details
-
addLockedObjectOwner
adds a new owner to a lock- Parameters:
owner- string that represents the owner- Returns:
- true if the owner was added, false otherwise
-
removeLockedObjectOwner
tries to remove the owner from the lock- Parameters:
owner- string that represents the owner
-
addChild
adds a new child lock to this lock- Parameters:
newChild- new child
-
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
Gets the LockID (locktoken) for the LockedObject- Returns:
- locktoken
-
getOwner
Gets the owners for the LockedObject- Returns:
- owners
-
getPath
Gets the path for the LockedObject- Returns:
- path
-
setExclusive
public void setExclusive(boolean exclusive) Sets the exclusivity for the LockedObject- Parameters:
exclusive-
-
isExclusive
public boolean isExclusive()Gets the exclusivity for the LockedObject- Returns:
- exclusivity
-
getType
Gets the type of the lock- Returns:
- type
-
getLockDepth
public int getLockDepth()Gets the depth of the lock- Returns:
- depth
-