@Test public void testGetDissemination_RemoteNotFound() throws Exception { final DigitalObjectHandler pageObject = new DigitalObjectHandler(robject, null); DefaultDisseminationHandler handler = new DefaultDisseminationHandler("unknownDatastreamId", pageObject); try { Response response = handler.getDissemination(null); fail(robject.getPid()); } catch (DigitalObjectNotFoundException ex) { assertEquals(robject.getPid(), ex.getPid()); } }
@Override public Response getDissemination(Request httpRequest) throws DigitalObjectException, DigitalObjectNotFoundException { String pid = fobject.getPid(); if (dsId == null) { return Response.ok(fobject.asText(), MediaType.TEXT_XML_TYPE) .header("Content-Disposition", "inline; filename=\"" + pid + ".xml\"") .build(); } if (fobject instanceof LocalObject) { LocalObject lobject = (LocalObject) fobject; BinaryEditor loader = BinaryEditor.dissemination(lobject, dsId); if (loader == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, null, null); } File entity = loader.read(); if (entity == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, "no content", null); } Date lastModification = new Date(loader.getLastModified()); ResponseBuilder evaluatePreconditions = httpRequest == null ? null : httpRequest.evaluatePreconditions(lastModification); if (evaluatePreconditions != null) { return evaluatePreconditions.build(); } return Response.ok(entity, loader.getProfile().getDsMIME()) .header("Content-Disposition", "inline; filename=\"" + entity.getName() + '"') .lastModified(lastModification) .build(); } else if (fobject instanceof RemoteObject) { RemoteObject remote = (RemoteObject) fobject; return getResponse(remote, dsId); } throw new IllegalStateException("unsupported: " + fobject.getClass()); }
DefaultDisseminationHandler implements DisseminationHandler { @Override public Response getDissemination(Request httpRequest) throws DigitalObjectException, DigitalObjectNotFoundException { String pid = fobject.getPid(); if (dsId == null) { return Response.ok(fobject.asText(), MediaType.TEXT_XML_TYPE) .header("Content-Disposition", "inline; filename=\"" + pid + ".xml\"") .build(); } if (fobject instanceof LocalObject) { LocalObject lobject = (LocalObject) fobject; BinaryEditor loader = BinaryEditor.dissemination(lobject, dsId); if (loader == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, null, null); } File entity = loader.read(); if (entity == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, "no content", null); } Date lastModification = new Date(loader.getLastModified()); ResponseBuilder evaluatePreconditions = httpRequest == null ? null : httpRequest.evaluatePreconditions(lastModification); if (evaluatePreconditions != null) { return evaluatePreconditions.build(); } return Response.ok(entity, loader.getProfile().getDsMIME()) .header("Content-Disposition", "inline; filename=\"" + entity.getName() + '"') .lastModified(lastModification) .build(); } else if (fobject instanceof RemoteObject) { RemoteObject remote = (RemoteObject) fobject; return getResponse(remote, dsId); } throw new IllegalStateException("unsupported: " + fobject.getClass()); } }
DefaultDisseminationHandler implements DisseminationHandler { @Override public Response getDissemination(Request httpRequest) throws DigitalObjectException, DigitalObjectNotFoundException { String pid = fobject.getPid(); if (dsId == null) { return Response.ok(fobject.asText(), MediaType.TEXT_XML_TYPE) .header("Content-Disposition", "inline; filename=\"" + pid + ".xml\"") .build(); } if (fobject instanceof LocalObject) { LocalObject lobject = (LocalObject) fobject; BinaryEditor loader = BinaryEditor.dissemination(lobject, dsId); if (loader == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, null, null); } File entity = loader.read(); if (entity == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, "no content", null); } Date lastModification = new Date(loader.getLastModified()); ResponseBuilder evaluatePreconditions = httpRequest == null ? null : httpRequest.evaluatePreconditions(lastModification); if (evaluatePreconditions != null) { return evaluatePreconditions.build(); } return Response.ok(entity, loader.getProfile().getDsMIME()) .header("Content-Disposition", "inline; filename=\"" + entity.getName() + '"') .lastModified(lastModification) .build(); } else if (fobject instanceof RemoteObject) { RemoteObject remote = (RemoteObject) fobject; return getResponse(remote, dsId); } throw new IllegalStateException("unsupported: " + fobject.getClass()); } DefaultDisseminationHandler(String dsId, DigitalObjectHandler handler); }
DefaultDisseminationHandler implements DisseminationHandler { @Override public Response getDissemination(Request httpRequest) throws DigitalObjectException, DigitalObjectNotFoundException { String pid = fobject.getPid(); if (dsId == null) { return Response.ok(fobject.asText(), MediaType.TEXT_XML_TYPE) .header("Content-Disposition", "inline; filename=\"" + pid + ".xml\"") .build(); } if (fobject instanceof LocalObject) { LocalObject lobject = (LocalObject) fobject; BinaryEditor loader = BinaryEditor.dissemination(lobject, dsId); if (loader == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, null, null); } File entity = loader.read(); if (entity == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, "no content", null); } Date lastModification = new Date(loader.getLastModified()); ResponseBuilder evaluatePreconditions = httpRequest == null ? null : httpRequest.evaluatePreconditions(lastModification); if (evaluatePreconditions != null) { return evaluatePreconditions.build(); } return Response.ok(entity, loader.getProfile().getDsMIME()) .header("Content-Disposition", "inline; filename=\"" + entity.getName() + '"') .lastModified(lastModification) .build(); } else if (fobject instanceof RemoteObject) { RemoteObject remote = (RemoteObject) fobject; return getResponse(remote, dsId); } throw new IllegalStateException("unsupported: " + fobject.getClass()); } DefaultDisseminationHandler(String dsId, DigitalObjectHandler handler); String getDsId(); DigitalObjectHandler getHandler(); @Override Response getDissemination(Request httpRequest); static Response getResponse(RemoteObject remote, String dsId); @Override void setDissemination(DisseminationInput input, String message); @Override void deleteDissemination(String message); void setRawDissemination(File contents, String filename, MediaType mime, String message); void setPreviewDissemination(File contents, String filename, MediaType mime, String message); void setIconAsDissemination(MediaType origMime, String dsLabel, String message); void setIconAsDissemination(String dsId, MediaType origMime, String dsLabel, String message); void setDsDissemination(String dsId, File contents, String filename, MediaType mime, String message); }
DefaultDisseminationHandler implements DisseminationHandler { @Override public Response getDissemination(Request httpRequest) throws DigitalObjectException, DigitalObjectNotFoundException { String pid = fobject.getPid(); if (dsId == null) { return Response.ok(fobject.asText(), MediaType.TEXT_XML_TYPE) .header("Content-Disposition", "inline; filename=\"" + pid + ".xml\"") .build(); } if (fobject instanceof LocalObject) { LocalObject lobject = (LocalObject) fobject; BinaryEditor loader = BinaryEditor.dissemination(lobject, dsId); if (loader == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, null, null); } File entity = loader.read(); if (entity == null) { throw new DigitalObjectNotFoundException(pid, null, dsId, "no content", null); } Date lastModification = new Date(loader.getLastModified()); ResponseBuilder evaluatePreconditions = httpRequest == null ? null : httpRequest.evaluatePreconditions(lastModification); if (evaluatePreconditions != null) { return evaluatePreconditions.build(); } return Response.ok(entity, loader.getProfile().getDsMIME()) .header("Content-Disposition", "inline; filename=\"" + entity.getName() + '"') .lastModified(lastModification) .build(); } else if (fobject instanceof RemoteObject) { RemoteObject remote = (RemoteObject) fobject; return getResponse(remote, dsId); } throw new IllegalStateException("unsupported: " + fobject.getClass()); } DefaultDisseminationHandler(String dsId, DigitalObjectHandler handler); String getDsId(); DigitalObjectHandler getHandler(); @Override Response getDissemination(Request httpRequest); static Response getResponse(RemoteObject remote, String dsId); @Override void setDissemination(DisseminationInput input, String message); @Override void deleteDissemination(String message); void setRawDissemination(File contents, String filename, MediaType mime, String message); void setPreviewDissemination(File contents, String filename, MediaType mime, String message); void setIconAsDissemination(MediaType origMime, String dsLabel, String message); void setIconAsDissemination(String dsId, MediaType origMime, String dsLabel, String message); void setDsDissemination(String dsId, File contents, String filename, MediaType mime, String message);  }