/** * Get the binary content of a datastream * * @param pid persistent identifier of the digital object * @param dsid datastream identifier * @return Binary blob * @throws RepositoryException */ @GET @Path("/{dsid}/content") public Response getDatastreamContent( @PathParam("pid") final String pid, @PathParam("dsid") final String dsid) throws RepositoryException { final Datastream ds = DatastreamService.getDatastream(pid, dsid); return ok(ds.getContent(), ds.getMimeType()).build(); }
/** * Get the datastream profile of a datastream * * @param pid persistent identifier of the digital object * @param dsid datastream identifier * @return 200 * @throws RepositoryException * @throws IOException * @throws TemplateException */ @GET @Path("/{dsid}") @Produces({TEXT_XML, APPLICATION_JSON}) public DatastreamProfile getDatastream( @PathParam("pid") final String pid, @PathParam("dsid") final String dsId) throws RepositoryException, IOException { logger.trace("Executing getDatastream() with dsId: " + dsId); Datastream ds = DatastreamService.getDatastream(pid, dsId); logger.debug("Retrieved dsNode: " + ds.getNode().getName()); return getDSProfile(ds); }
/** * Get previous version information for this datastream * * @param pid persistent identifier of the digital object * @param dsId datastream identifier * @return 200 * @throws RepositoryException * @throws IOException * @throws TemplateException */ @GET @Path("/{dsid}/versions") @Produces({TEXT_XML, APPLICATION_JSON}) // TODO implement this after deciding on a versioning model public DatastreamHistory getDatastreamHistory( @PathParam("pid") final String pid, @PathParam("dsid") final String dsId) throws RepositoryException, IOException { final Datastream ds = DatastreamService.getDatastream(pid, dsId); final DatastreamHistory dsHistory = new DatastreamHistory(singletonList(getDSProfile(ds))); dsHistory.dsID = dsId; dsHistory.pid = pid; return dsHistory; }
/** * Get the binary content of a datastream * * @param pathList * @return Binary blob * @throws RepositoryException */ @GET public Response getContent( @PathParam("path") List<PathSegment> pathList, @Context final Request request) throws RepositoryException { String path = toPath(pathList); final Datastream ds = datastreamService.getDatastream(path); final EntityTag etag = new EntityTag(ds.getContentDigest().toString()); final Date date = ds.getLastModifiedDate(); final Date roundedDate = new Date(); roundedDate.setTime(date.getTime() - date.getTime() % 1000); ResponseBuilder builder = request.evaluatePreconditions(roundedDate, etag); final CacheControl cc = new CacheControl(); cc.setMaxAge(0); cc.setMustRevalidate(true); if (builder == null) { builder = Response.ok(ds.getContent(), ds.getMimeType()); } return builder.cacheControl(cc).lastModified(date).tag(etag).build(); }