This module is view-only. You do not have an enrolement for this module.

Deleting files and folders

The webdav method for deleting resources is, surprise surprise, DELETE. And its supported in milton with the DeletableResource interface:

void delete() throws NotAuthorizedException, ConflictException, BadRequestException;

Implement DELETE for PlanetResource as follows:

public class PlanetResource extends AbstractResource implements GetableResource, ReplaceableResource, MoveableResource, CopyableResource, DeletableResource{

    private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(PlanetResource.class);
    private final SolarSystemResource parent;
    private final Planet planet;

    public PlanetResource(SolarSystemResource parent, Planet planet) {
        this.parent = parent;
        this.planet = planet;
    }

    @Override
    public void delete() throws NotAuthorizedException, ConflictException, BadRequestException {
        parent.getSolarSystem().getPlanets().remove(planet);
    }

Pretty simple, huh?