Skip to content

Commit

Permalink
BXC-4712 a bit of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sharonluong committed Sep 24, 2024
1 parent 7a644a0 commit d622795
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ private long getFilesize(FileObject fileObject, List<Datastream> datastreams) th
}

private void addDerivatives(List<Datastream> dsList, PID pid, boolean ownedByOtherObject, List<DatastreamType> types) {
derivativeService.getDerivatives(pid).forEach(deriv -> {
var derivatives = derivativeService.getDerivatives(pid);
derivatives.forEach(deriv -> {
DatastreamType type = deriv.getType();
// only add derivatives of types listed
if ((types != null) && !types.contains(type)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ public void folderObjectWithJP2Test() throws Exception {
FolderObject folderObj = mock(FolderObject.class);
when(folderObj.getPid()).thenReturn(pid);

File file = derivDir.resolve("small.png").toFile();
File file = derivDir.resolve("small.jp2").toFile();
FileUtils.write(file, "content", "UTF-8");
List<Derivative> derivs = List.of(new Derivative(JP2_ACCESS_COPY, file));
when(derivativeService.getDerivatives(pid)).thenReturn(derivs);
Expand All @@ -706,7 +706,7 @@ public void folderObjectWithJP2Test() throws Exception {
filter.filter(dip);

assertContainsDatastream(idb.getDatastream(), JP2_ACCESS_COPY.getId(),
7l, JP2_ACCESS_COPY.getMimetype(), "small.png", null, PID_STRING, null);
7l, JP2_ACCESS_COPY.getMimetype(), "small.jp2", null, null, null);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Map<String, String> validateOptions(Map<String, String> options) {
}

protected void addThumbnail(ContentObject object) throws IOException {
var derivativePath = derivativeService.getDerivativePath(object.getPid(), DatastreamType.THUMBNAIL_LARGE);
var derivativePath = derivativeService.getDerivativePath(object.getPid(), DatastreamType.JP2_ACCESS_COPY);
FileUtils.write(derivativePath.toFile(), "image", "UTF-8");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,7 @@ public ResponseEntity<InputStreamResource> getThumbnail(@PathVariable("pid") Str
throw new ResourceNotFoundException("The requested object either does not exist or is not accessible");
}

if (ResourceType.Folder.name().equals(objRecord.getResourceType()) ||
ResourceType.Collection.name().equals(objRecord.getResourceType()) ||
ResourceType.AdminUnit.name().equals(objRecord.getResourceType())) {
String thumbName = "thumbnail_" + size.toLowerCase().trim();
try {
return derivativeContentService.streamThumbnail(pid, thumbName);
} catch (IOException e) {
log.error("Error streaming thumbnail for {}", pid);
}
} else if (ResourceType.Work.name().equals(objRecord.getResourceType())) {
if (ResourceType.Work.name().equals(objRecord.getResourceType())) {
var thumbId = accessCopiesService.getThumbnailId(objRecord, principals, true);
if (thumbId != null) {
pid = PIDs.get(thumbId);
Expand Down

0 comments on commit d622795

Please sign in to comment.