示例#1
0
  /**
   * 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();
  }
示例#2
0
 /**
  * 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);
 }
示例#3
0
  /**
   * 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();
  }
示例#4
0
 private DatastreamProfile getDSProfile(Datastream ds) throws RepositoryException, IOException {
   logger.trace("Executing getDSProfile() with node: " + ds.getDsId());
   final DatastreamProfile dsProfile = new DatastreamProfile();
   dsProfile.dsID = ds.getDsId();
   dsProfile.pid = ds.getObject().getName();
   logger.trace("Retrieved datastream " + ds.getDsId() + "'s parent: " + dsProfile.pid);
   dsProfile.dsLabel = ds.getLabel();
   logger.trace("Retrieved datastream " + ds.getDsId() + "'s label: " + ds.getLabel());
   dsProfile.dsState = A;
   dsProfile.dsMIME = ds.getMimeType();
   dsProfile.dsSize = getNodePropertySize(ds.getNode()) + ds.getContentSize();
   dsProfile.dsCreateDate = ds.getNode().getProperty("jcr:created").getString();
   return dsProfile;
 }