use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.
the class ExportCsvService method printObject.
private void printObject(CSVPrinter printer, ContentObjectRecord object) throws IOException {
// Vitals: object type, pid, title, path, label, depth
printer.print(object.getResourceType());
printer.print(object.getId());
printer.print(object.getTitle());
printer.print(object.getAncestorNames());
String label = object.getLabel();
if (label != null) {
printer.print(label);
} else {
printer.print("");
}
printer.print(object.getAncestorPathFacet().getHighestTier());
if (object.getStatus() != null) {
printer.print(object.getStatus().contains(MARKED_FOR_DELETION));
} else {
printer.print("");
}
// Dates: added, updated
Date added = object.getDateAdded();
if (added != null) {
printer.print(dateFormat.format(added));
} else {
printer.print("");
}
Date updated = object.getDateUpdated();
if (updated != null) {
printer.print(dateFormat.format(updated));
} else {
printer.print("");
}
// DATA_FILE info: mime type, checksum, file size
Datastream dataFileDatastream = object.getDatastreamObject(ORIGINAL_FILE.getId());
if (dataFileDatastream != null) {
printer.print(dataFileDatastream.getMimetype());
printer.print(dataFileDatastream.getChecksum().replace("urn:", ""));
Long filesize = dataFileDatastream.getFilesize();
// If we don't have a filesize for whatever reason, print a blank
if (filesize != null && filesize >= 0) {
printer.print(filesize);
} else {
printer.print("");
}
} else {
printer.print("");
printer.print("");
printer.print("");
}
// Container info: child count
Long childCount = object.getCountMap().get("child");
if (childCount != null && childCount > 0) {
printer.print(childCount.toString());
} else {
printer.print("");
}
// Description: does object have a MODS description?
List<String> contentStatus = object.getContentStatus();
if (contentStatus != null && contentStatus.contains(FacetConstants.CONTENT_NOT_DESCRIBED)) {
printer.print(FacetConstants.CONTENT_NOT_DESCRIBED);
} else if (contentStatus != null && contentStatus.contains(FacetConstants.CONTENT_DESCRIBED)) {
printer.print(FacetConstants.CONTENT_DESCRIBED);
} else {
printer.print("");
}
// Patron permissions
String computedPermissions = computePatronPermissions(object.getRoleGroup());
printer.print(computedPermissions);
// Is object embargoed
List<String> objStatus = object.getStatus();
printer.print(objStatus != null && objStatus.contains(FacetConstants.EMBARGOED));
printer.println();
}
use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.
the class RunEnhancementsService method createMessage.
private void createMessage(ContentObjectRecord metadata, String username, Boolean force) {
PID pid = metadata.getPid();
Datastream originalDs = metadata.getDatastreamObject(ORIGINAL_FILE.getId());
String resourceType = metadata.getResourceType();
PID originalPid = (ResourceType.File.equals(resourceType) && originalDs != null) ? DatastreamPids.getOriginalFilePid(pid) : pid;
Document msg = makeEnhancementOperationBody(username, originalPid, force);
messageSender.sendMessage(msg);
}
use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.
the class LorisContentService method createCanvas.
private Canvas createCanvas(String path, ContentObjectRecord briefObj) {
String title = getTitle(briefObj);
String uuid = jp2Pid(briefObj);
Canvas canvas = new Canvas(path, title);
if (StringUtils.isEmpty(uuid)) {
LOG.warn("No jp2 id was found for {}. IIIF canvas is empty.", briefObj.getId());
return canvas;
}
String canvasPath = URIUtil.join(basePath, "jp2Proxy", uuid, "jp2");
Datastream fileDs = briefObj.getDatastreamObject(DatastreamType.ORIGINAL_FILE.getId());
String extent = fileDs.getExtent();
if (extent != null && !extent.equals("")) {
String[] imgDimensions = extent.split("x");
canvas.setHeight(Integer.parseInt(imgDimensions[0]));
canvas.setWidth(Integer.parseInt(imgDimensions[1]));
}
canvas.addIIIFImage(canvasPath, ImageApiProfile.LEVEL_TWO);
ImageContent thumb = new ImageContent(URIUtil.join(basePath, "services", "api", "thumb", uuid, "large"));
canvas.addImage(thumb);
return canvas;
}
use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.
the class DatastreamUtil method getDatastreamUrl.
/**
* Returns a URL for retrieving a specific datastream of the provided object.
*
* @param metadata metadata record for object
* @param datastreamName name of datastream to return
* @return url for accessing the datastream.
*/
public static String getDatastreamUrl(ContentObjectRecord metadata, String datastreamName) {
// Prefer the matching datastream from this object over the same datastream with a different pid prefix
Datastream preferredDS = getPreferredDatastream(metadata, datastreamName);
if (preferredDS == null) {
return "";
}
StringBuilder url = new StringBuilder();
if (!isBlank(preferredDS.getExtension())) {
if (INDEXABLE_EXTENSIONS.contains(preferredDS.getExtension())) {
url.append("indexable");
}
}
url.append("content/");
if (isBlank(preferredDS.getOwner())) {
url.append(metadata.getId());
} else {
url.append(preferredDS.getOwner());
}
if (!ORIGINAL_FILE.getId().equals(preferredDS.getName())) {
url.append("/").append(preferredDS.getName());
}
return url.toString();
}
use of edu.unc.lib.boxc.search.api.models.Datastream in project box-c by UNC-Libraries.
the class ContentObjectSolrRecord method getDatastreamObject.
@Override
public Datastream getDatastreamObject(String datastreamName) {
if (datastreamName == null || this.datastreamObjects == null) {
return null;
}
String[] datastreamParts = datastreamName.split("/", 2);
String pid;
if (datastreamParts.length > 1) {
pid = datastreamParts[0];
if (pid.equals(getId())) {
pid = null;
}
datastreamName = datastreamParts[1];
} else {
pid = null;
}
for (Datastream datastream : this.datastreamObjects) {
if (datastream.equals(datastreamName) && (pid == null || pid.equals(datastream.getOwner()))) {
return datastream;
}
}
return null;
}
Aggregations