use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.
the class CdrEventToSolrUpdateProcessorTest method addPidListElement.
private void addPidListElement(Element parentEl, String elementName, List<PID> pids) {
if (pids != null && pids.size() > 0) {
Element listEl = new Element("subjects", CDR_MESSAGE_NS);
parentEl.addContent(listEl);
for (PID pid : pids) {
listEl.addContent(new Element("pid", CDR_MESSAGE_NS).setText(pid.getId()));
}
}
}
use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.
the class FedoraContentControllerIT method testInvalidDatastream.
@Test
public void testInvalidDatastream() throws Exception {
PID filePid = makePid();
repositoryObjectFactory.createFileObject(filePid, null);
// Verify administrative datastream retrievable
MvcResult result = mvc.perform(get("/content/" + filePid.getId() + "/some_ds")).andExpect(status().isNotFound()).andReturn();
MockHttpServletResponse response = result.getResponse();
assertEquals("Must not return file content", "", response.getContentAsString());
}
use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.
the class LorisContentController method getSequence.
/**
* Handles requests for IIIF sequences
* @param id
* @param datastream
* @param response
* @return
*/
@GetMapping(value = "/jp2Proxy/{id}/{datastream}/sequence/normal", produces = APPLICATION_JSON_VALUE)
@ResponseBody
public String getSequence(@PathVariable("id") String id, @PathVariable("datastream") String datastream, HttpServletRequest request, HttpServletResponse response) throws JsonProcessingException {
PID pid = PIDs.get(id);
// Check if the user is allowed to view this object's manifest
if (this.hasAccess(pid, datastream)) {
List<ContentObjectRecord> briefObjs = getDatastreams(pid);
response.addHeader("Access-Control-Allow-Origin", "*");
return lorisContentService.getSequence(request, briefObjs);
} else {
LOG.debug("Manifest access was forbidden to {} for user {}", id, GroupsThreadStore.getUsername());
response.setStatus(HttpStatus.FORBIDDEN.value());
}
return "";
}
use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.
the class LorisContentController method getCanvas.
/**
* Handles requests for IIIF canvases
* @param id
* @param datastream
* @param response
* @return
*/
@GetMapping(value = "/jp2Proxy/{id}/{datastream}", produces = APPLICATION_JSON_VALUE)
@ResponseBody
public String getCanvas(@PathVariable("id") String id, @PathVariable("datastream") String datastream, HttpServletRequest request, HttpServletResponse response) throws JsonProcessingException {
PID pid = PIDs.get(id);
// Check if the user is allowed to view this object's manifest
if (this.hasAccess(pid, datastream)) {
SimpleIdRequest idRequest = new SimpleIdRequest(pid, GroupsThreadStore.getAgentPrincipals().getPrincipals());
ContentObjectRecord briefObj = queryLayer.getObjectById(idRequest);
response.addHeader("Access-Control-Allow-Origin", "*");
return lorisContentService.getCanvas(request, briefObj);
} else {
LOG.debug("Manifest access was forbidden to {} for user {}", id, GroupsThreadStore.getUsername());
response.setStatus(HttpStatus.FORBIDDEN.value());
}
return "";
}
use of edu.unc.lib.boxc.model.api.ids.PID in project box-c by UNC-Libraries.
the class LorisContentController method getRegion.
/**
* Handles requests for individual region tiles.
* @param id
* @param datastream
* @param region
* @param size
* @param rotation
* @param qualityFormat
* @param response
*/
@GetMapping("/jp2Proxy/{id}/{datastream}/{region}/{size}/{rotation}/{qualityFormat:.+}")
public void getRegion(@PathVariable("id") String id, @PathVariable("datastream") String datastream, @PathVariable("region") String region, @PathVariable("size") String size, @PathVariable("rotation") String rotation, @PathVariable("qualityFormat") String qualityFormat, HttpServletResponse response) {
PID pid = PIDs.get(id);
// Check if the user is allowed to view this object
if (this.hasAccess(pid, datastream)) {
try {
String[] qualityFormatArray = qualityFormat.split("\\.");
String quality = qualityFormatArray[0];
String format = qualityFormatArray[1];
response.addHeader("Access-Control-Allow-Origin", "*");
lorisContentService.streamJP2(id, region, size, rotation, quality, format, datastream, response.getOutputStream(), response);
} catch (IOException e) {
LOG.error("Error retrieving streaming JP2 content for {}", id, e);
}
} else {
LOG.debug("Access was forbidden to {} for user {}", id, GroupsThreadStore.getUsername());
response.setStatus(HttpStatus.FORBIDDEN.value());
}
}
Aggregations