Open source, commercial support.

Efficient deleting

Community provided content
Register
New page Edit

When a user deletes a collection (ie a folder) Milton will, by default, check each resource individually to see if its locked, and then delete each item individually.

This can sometimes be inefficient and slow. So as of 1.5.4 milton supports a pluggable service ( com.bradmcevoy.http.DeleteHelper) which you can implement to make this more efficient. This class will be used whenever a resource is deleted, which can be a result of a MOVE or COPY operation.

public interface DeleteHelper {
    /**
     * Check if the resource or any child resources are locked or otherwise not
     * deletable
     *
     * @param req
     * @param r
     * @return
     */
    boolean isLockedOut(Request req, Resource r);

    /**
     * Delete the resource and any child resources
     *
     * @param r
     */
    void delete(DeletableResource r) throws NotAuthorizedException, ConflictException, BadRequestException;
}

By implementing this interface you can check locks in batch and delete in batch (eg using a single SQL statement).

However, be aware that many client applications will delete each resource individually anway.