@COPY public Message copy( @PathTranslated Path path, @Destination URI destinationUri, @Overwrite boolean overwrite) throws IOException { final Resource source = resolveResource(path); final Resource destination = resolveResource(Path.fromString(destinationUri.getPath())); if (destination.isLocked()) { return clientErrorLocked(); } if (source.exists()) { if (source.isCollection()) { // source exists if (destination.exists()) { // source exists and is a collection if (destination.isCollection()) { return (overwrite ? copyCollectionToCollection(source, destination, overwrite) : clientErrorPreconditionFailed()); } else { return (overwrite ? copyCollectionToResource(source, destination, overwrite) : clientErrorPreconditionFailed()); } } else { return (destination.parent().exists() ? copyCollectionToCollection(source, destination, false) : clientErrorPreconditionFailed()); } } else { if (destination.exists()) { // source exists if (destination.isCollection()) { // source exists, return (overwrite ? copyResourceToCollection(source, destination, overwrite) : clientErrorPreconditionFailed()); } else { return (overwrite ? copyResourceToResource(source, destination, overwrite) : clientErrorPreconditionFailed()); } } else { if (destination.parent().exists()) { return (overwrite ? clientErrorPreconditionFailed() : copyResourceToCollection(source, destination, overwrite)); } else { return clientErrorConflict(); } } } } else { return clientErrorNotFound(); } }
@PUT public Message put(@PathTranslated Path path, @Context Request request) throws IOException { final Resource resource = resolveResource(path); if (!resource.parent().exists()) { return clientErrorConflict(); } if (resource.exists() && resource.isCollection()) { return clientErrorMethodNotAllowed(); } ByteBuffer entity = request.buffer(); resource.put(entity); return successCreated(); }
@MKCOL public Message mkcol(@PathTranslated Path path, @Context Request request) { final Resource resource = resolveResource(path); if (request.hasBody()) { return clientErrorUnsupportedMediaType(); } else { if (resource.exists()) { return clientErrorMethodNotAllowed(); } else { if (resource.parent().exists()) { return (resource.mkcol() ? successCreated() : serverErrorInternal()); } else { return clientErrorConflict(); } } } }