Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,13 +28,15 @@ | |
import javax.jcr.RepositoryException; | ||
import javax.jcr.Session; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.ws.rs.DELETE; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.HeaderParam; | ||
import javax.ws.rs.OPTIONS; | ||
import javax.ws.rs.PUT; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.WebApplicationException; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.PathSegment; | ||
|
@@ -104,7 +106,7 @@ public Response options(@PathParam("path") final List<PathSegment> pathList, | |
|
||
|
||
private void addOptionsHttpHeaders(final HttpServletResponse servletResponse) { | ||
servletResponse.addHeader("Allow", "HEAD,GET,PUT,OPTIONS"); | ||
servletResponse.addHeader("Allow", "HEAD,GET,PUT,DELETE,OPTIONS"); | ||
} | ||
|
||
/** | ||
|
@@ -206,4 +208,29 @@ public Response getContent(@PathParam("path") final List<PathSegment> pathList, | |
} | ||
} | ||
|
||
/** | ||
* Delete the binary content and the parent object | ||
*/ | ||
@DELETE | ||
@Timed | ||
public Response deleteContent(@PathParam("path") final List<PathSegment> pathList, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
barmintor
via email
Contributor
|
||
@Context final Request request, | ||
@Context final HttpServletResponse servletResponse) throws RepositoryException { | ||
|
||
try { | ||
final String path = toPath(pathList); | ||
|
||
final Datastream ds = datastreamService.getDatastream(session, path); | ||
evaluateRequestPreconditions(request, servletResponse, ds, session); | ||
|
||
nodeService.deleteObject(session, path); | ||
session.save(); | ||
return noContent().build(); | ||
} catch (final WebApplicationException ex) { | ||
return (Response)ex.getResponse(); | ||
} finally { | ||
session.logout(); | ||
} | ||
} | ||
|
||
} |
This method really bothers me looking at it as a REST API, but makes us conform to LDP. LDP wants us, when we delete a binary resource, to also delete the parent resource.
The only alternative I came up with (and have @azaroth42 puzzling over) is inverting our
fcr:content
paradigm. As is, if you create a binary resource in fcrepo4, you create two (REST) resources, e.g./a/b/c
and/a/b/c/fcr:content
.Instead, we could invert this and when you create the binary resource you create:
/a/b/c
, which if you retrieve it you get the bytestream, and/a/b/c/fcr:metadata
(or whatever) which describes the bytestreamThis would make the REST relationship a little nicer, but would be a ton of work.
@ajs6f @barmintor @escowles ?