Package io.milton.resource
Interface DeletableCollectionResource
- All Superinterfaces:
CollectionResource,DeletableResource,Resource
An extension to DeletableResource and CollectionResource, this interface
adds a method to support efficient detection of child locks.
This interface ONLY needs to be implemented by those who need to improve
performance of deleting collections
In the case of deleting a collection resource it might be inefficient to
check for locks by recursively walking through the collection. By implementing
this interface you have the ability to use a more efficient approach
See HandlerHelper.isLockedOut for an example of checking for locks:
public boolean isLockedOut( Request inRequest, Resource inResource ) {
if( inResource == null || !( inResource instanceof LockableResource ) ) {
return false;
}
LockableResource lr = (LockableResource) inResource;
LockToken token = lr.getCurrentLock();
if( token != null ) {
Auth auth = inRequest.getAuthorization();
String lockedByUser = token.info.lockedByUser;
if( lockedByUser == null ) {
log.warn( "Resource is locked with a null user. Ignoring the lock" );
return false;
} else if( !lockedByUser.equals( auth.getUser() ) ) {
log.info( "fail: lock owned by: " + lockedByUser + " not by " + auth.getUser() );
String value = inRequest.getIfHeader();
if( value != null ) {
if( value.contains( "opaquelocktoken:" + token.tokenId + ">" ) ) {
log.info( "Contained valid token. so is unlocked" );
return false;
}
}
return true;
}
}
return false;
}
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisLockedOutRecursive(Request request) Check to see if this resource or any child resource are locked by someone other then the current user (as per the Authorisation property of the request)Methods inherited from interface io.milton.resource.CollectionResource
child, getChildrenMethods inherited from interface io.milton.resource.DeletableResource
deleteMethods inherited from interface io.milton.resource.Resource
authenticate, authorise, checkRedirect, getModifiedDate, getName, getRealm, getUniqueId
-
Method Details
-
isLockedOutRecursive
Check to see if this resource or any child resource are locked by someone other then the current user (as per the Authorisation property of the request)- Parameters:
request-- Returns:
- - true indicates that the DELETE request must not proceed because this resource or at least one child resource is locked by someone other then the current user
-