Search in sources :

Example 1 with DeletableCollectionResource

use of io.milton.resource.DeletableCollectionResource in project lobcder by skoulouzis.

the class DeleteHelperImpl method isLockedOut.

@Override
public boolean isLockedOut(Request req, Resource r) throws NotAuthorizedException, BadRequestException {
    if (r instanceof DeletableCollectionResource) {
        DeletableCollectionResource dcr = (DeletableCollectionResource) r;
        boolean locked = dcr.isLockedOutRecursive(req);
        if (locked && log.isInfoEnabled()) {
            log.info("isLocked, as reported by DeletableCollectionResource: " + dcr.getName());
        }
        return locked;
    } else if (r instanceof CollectionResource) {
        CollectionResource col = (CollectionResource) r;
        List<Resource> list = new ArrayList<Resource>();
        list.addAll(col.getChildren());
        for (Resource rChild : list) {
            if (rChild instanceof DeletableResource) {
                DeletableResource rChildDel = (DeletableResource) rChild;
                if (isLockedOut(req, rChildDel)) {
                    if (log.isInfoEnabled()) {
                        log.info("isLocked: " + rChild.getName() + " type:" + rChild.getClass());
                    }
                    return true;
                }
            } else {
                if (log.isInfoEnabled()) {
                    log.info("a child resource is not deletable: " + rChild.getName() + " type: " + rChild.getClass());
                }
                return true;
            }
        }
        return false;
    } else {
        boolean locked = handlerHelper.isLockedOut(req, r);
        if (locked && log.isInfoEnabled()) {
            log.info("isLocked, as reported by handlerHelper on resource: " + r.getName());
        }
        return locked;
    }
}
Also used : CollectionResource(io.milton.resource.CollectionResource) DeletableCollectionResource(io.milton.resource.DeletableCollectionResource) DeletableCollectionResource(io.milton.resource.DeletableCollectionResource) DeletableResource(io.milton.resource.DeletableResource) CollectionResource(io.milton.resource.CollectionResource) Resource(io.milton.resource.Resource) DeletableCollectionResource(io.milton.resource.DeletableCollectionResource) ArrayList(java.util.ArrayList) List(java.util.List) DeletableResource(io.milton.resource.DeletableResource)

Aggregations

CollectionResource (io.milton.resource.CollectionResource)1 DeletableCollectionResource (io.milton.resource.DeletableCollectionResource)1 DeletableResource (io.milton.resource.DeletableResource)1 Resource (io.milton.resource.Resource)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1