diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 96b1019306..5ffce68264 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -19,7 +19,7 @@ jobs:
ports:
- 46380:6379
fedora:
- image: fcrepo/fcrepo:5.1.1
+ image: fcrepo/fcrepo:5.1.1-multiplatform
ports:
- 48085:8080
volumes:
@@ -38,7 +38,7 @@ jobs:
- name: Get Container ID of fedora service
id: get_container_id
run: |
- CONTAINER_ID=$(docker ps --format "{{.ID}}" -f "ancestor=fcrepo/fcrepo:5.1.1")
+ CONTAINER_ID=$(docker ps --format "{{.ID}}" -f "ancestor=fcrepo/fcrepo:5.1.1-multiplatform")
echo "CONTAINER_ID=$CONTAINER_ID" >> $GITHUB_ENV
- name: Restart fedora now that the repository has been checked out so config files are available
run: docker restart ${{ env.CONTAINER_ID }}
diff --git a/auth-api/src/main/java/edu/unc/lib/boxc/auth/api/services/DatastreamPermissionUtil.java b/auth-api/src/main/java/edu/unc/lib/boxc/auth/api/services/DatastreamPermissionUtil.java
index 81a72d3da0..5c1aa25431 100644
--- a/auth-api/src/main/java/edu/unc/lib/boxc/auth/api/services/DatastreamPermissionUtil.java
+++ b/auth-api/src/main/java/edu/unc/lib/boxc/auth/api/services/DatastreamPermissionUtil.java
@@ -30,8 +30,6 @@ public class DatastreamPermissionUtil {
DS_PERMISSION_MAP.put(DatastreamType.ORIGINAL_FILE, Permission.viewOriginal);
DS_PERMISSION_MAP.put(DatastreamType.TECHNICAL_METADATA, Permission.viewHidden);
DS_PERMISSION_MAP.put(DatastreamType.TECHNICAL_METADATA_HISTORY, Permission.viewHidden);
- DS_PERMISSION_MAP.put(DatastreamType.THUMBNAIL_SMALL, Permission.viewAccessCopies);
- DS_PERMISSION_MAP.put(DatastreamType.THUMBNAIL_LARGE, Permission.viewAccessCopies);
}
private DatastreamPermissionUtil() {
diff --git a/docker-compose.yml b/docker-compose.yml
index c54da4f291..06ea2ba4e4 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -2,7 +2,7 @@ version: '3.7'
services:
fedora:
- image: fcrepo/fcrepo:5.1.1
+ image: fcrepo/fcrepo:5.1.1-multiplatform
ports:
- "48085:8080"
volumes:
@@ -27,8 +27,8 @@ services:
ports:
- "48983:8983"
volumes:
- - ./etc/solr-config:/solr_config/config
+ - ./etc/solr-config:/var/solr/data/access/conf
command:
- solr-precreate
- access
- - /solr_config/config
\ No newline at end of file
+ - /var/solr/data/access/conf
\ No newline at end of file
diff --git a/indexing-solr/src/main/java/edu/unc/lib/boxc/indexing/solr/filter/SetDatastreamFilter.java b/indexing-solr/src/main/java/edu/unc/lib/boxc/indexing/solr/filter/SetDatastreamFilter.java
index e2b2772c3c..9b2440d3bf 100644
--- a/indexing-solr/src/main/java/edu/unc/lib/boxc/indexing/solr/filter/SetDatastreamFilter.java
+++ b/indexing-solr/src/main/java/edu/unc/lib/boxc/indexing/solr/filter/SetDatastreamFilter.java
@@ -55,7 +55,7 @@ public class SetDatastreamFilter implements IndexDocumentFilter {
private DerivativeService derivativeService;
private TechnicalMetadataService technicalMetadataService;
private Jp2InfoService jp2InfoService;
- private static final List THUMBNAIL_DS_TYPES = Arrays.asList(DatastreamType.THUMBNAIL_SMALL, DatastreamType.THUMBNAIL_LARGE);
+
// Check for hours, minutes, seconds. Plus a check for optional milliseconds separated from seconds
// by a "." or a ":" via a non-capturing block followed by a capture group for the milliseconds.
private final Pattern TIMING_REGEX = Pattern.compile("(\\d+):(\\d+):(\\d+)(?:[.:](\\d+))?");
@@ -87,7 +87,7 @@ public void filter(DocumentIndexingPackage dip) throws IndexingException {
}
if (contentObj instanceof WorkObject) {
- addThumbnailDerivatives((WorkObject) contentObj, datastreams);
+ addThumbnailDerivative((WorkObject) contentObj, datastreams);
}
// Add in metadata datastreams
@@ -288,6 +288,20 @@ private boolean needsExtent(String name, String mimetype) {
|| mimetype.startsWith("audio"));
}
+ /**
+ * Used to selectively add the JP2 thumbnail datastream
+ *
+ * @param workObject the work object with the thumbnail relation
+ * @param datastreams work object's datastreams to add thumbnail streams to
+ */
+ private void addThumbnailDerivative(WorkObject workObject, List datastreams) {
+ FileObject thumbnailObject = workObject.getThumbnailObject();
+
+ if (thumbnailObject != null) {
+ addDerivatives(datastreams, thumbnailObject.getPid(), true, List.of(JP2_ACCESS_COPY));
+ }
+ }
+
private String getFirstChecksum(Resource resc) {
Statement prop = resc.getProperty(Premis.hasMessageDigest);
if (prop == null) {
@@ -334,7 +348,8 @@ private long getFilesize(FileObject fileObject, List datastreams) th
}
private void addDerivatives(List dsList, PID pid, boolean ownedByOtherObject, List 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)) {
@@ -352,33 +367,6 @@ private void addDerivatives(List dsList, PID pid, boolean ownedByOth
});
}
- /**
- * Used to selectively add only thumbnail datastreams
- *
- * @param workObject the work object with the thumbnail relation
- * @param datastreams work object's datastreams to add thumbnail streams to
- */
- private void addThumbnailDerivatives(WorkObject workObject, List datastreams) {
- FileObject thumbnailObject = workObject.getThumbnailObject();
-
- if (thumbnailObject != null) {
- var updatedDatastreams = clearPreviousThumbnailDatastreams(datastreams);
- addDerivatives(updatedDatastreams, thumbnailObject.getPid(), true, THUMBNAIL_DS_TYPES);
- }
- }
-
- /**
- * There may be thumbnail streams from the primary object, so we'll clear those
- * before adding the assigned thumbnail datastreams
- *
- * @param datastreams full list of datastreams to index for the work object
- * @return modified list of datastreams without thumbnail datastreams
- */
- private List clearPreviousThumbnailDatastreams(List datastreams) {
- datastreams.removeIf(ds -> THUMBNAIL_DS_TYPES.contains(DatastreamType.getByIdentifier(ds.getName())));
- return datastreams;
- }
-
private DatastreamImpl createDatastream(DerivativeService.Derivative derivative, String owner, String extent) {
DatastreamType type = derivative.getType();
String name = type.getId();
diff --git a/indexing-solr/src/test/java/edu/unc/lib/boxc/indexing/solr/filter/SetDatastreamFilterTest.java b/indexing-solr/src/test/java/edu/unc/lib/boxc/indexing/solr/filter/SetDatastreamFilterTest.java
index 8e84ece0ae..5fc205886d 100644
--- a/indexing-solr/src/test/java/edu/unc/lib/boxc/indexing/solr/filter/SetDatastreamFilterTest.java
+++ b/indexing-solr/src/test/java/edu/unc/lib/boxc/indexing/solr/filter/SetDatastreamFilterTest.java
@@ -48,12 +48,9 @@
import static edu.unc.lib.boxc.model.api.DatastreamType.JP2_ACCESS_COPY;
import static edu.unc.lib.boxc.model.api.DatastreamType.ORIGINAL_FILE;
import static edu.unc.lib.boxc.model.api.DatastreamType.TECHNICAL_METADATA;
-import static edu.unc.lib.boxc.model.api.DatastreamType.THUMBNAIL_LARGE;
-import static edu.unc.lib.boxc.model.api.DatastreamType.THUMBNAIL_SMALL;
import static edu.unc.lib.boxc.model.fcrepo.ids.DatastreamPids.getOriginalFilePid;
import static org.apache.jena.rdf.model.ResourceFactory.createResource;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -83,11 +80,8 @@ public class SetDatastreamFilterTest {
private static final String FILE2_DIGEST = "urn:sha1:afbf62faf8a82d00969e0d4d965d62a45bb8c69b";
private static final long FILE2_SIZE = 7231l;
- private static final String FILE3_MIMETYPE = "image/png";
- private static final String FILE3_NAME = "image.png";
- private static final String FILE3_DIGEST = "urn:sha1:280f5922b6487c39d6d01a5a8e93bfa07b8f1740";
- private static final long FILE3_SIZE = 17136l;
- private static final String FILE3_EXTENT = "375x250";
+ private static final String PNG_MIMETYPE = "image/png";
+ private static final String IMAGE_EXTENT = "375x250";
private static final String FILE_MP3_MIMETYPE = "audio/mpeg";
private static final String FILE_MP3_NAME = "audio.mp3";
@@ -123,6 +117,8 @@ public class SetDatastreamFilterTest {
private static final String PREMIS_DIGEST = "urn:sha1:da39a3ee5e6b4b0d3255bfef95601890afd80709";
private static final long PREMIS_SIZE = 893l;
+ private static final long JP2_SIZE = 11;
+
private AutoCloseable closeable;
@TempDir
@@ -201,12 +197,7 @@ public void fileObjectMultipleBinariesTest() throws Exception {
fileResource(TECHNICAL_METADATA.getId(), FILE2_SIZE, FILE2_MIMETYPE, FILE2_NAME, FILE2_DIGEST));
when(binObj2.getBinaryStream()).thenReturn(getClass().getResourceAsStream("/datastream/techmd.xml"));
- BinaryObject binObj3 = mock(BinaryObject.class);
- when(binObj3.getPid()).thenReturn(PIDs.get(pid.getId() + "/" + THUMBNAIL_LARGE.getId()));
- when(binObj3.getResource()).thenReturn(
- fileResource(THUMBNAIL_LARGE.getId(), FILE3_SIZE, FILE3_MIMETYPE, FILE3_NAME, FILE3_DIGEST));
-
- when(fileObj.getBinaryObjects()).thenReturn(Arrays.asList(binObj, binObj2, binObj3));
+ when(fileObj.getBinaryObjects()).thenReturn(Arrays.asList(binObj, binObj2));
dip.setContentObject(fileObj);
filter.filter(dip);
@@ -215,17 +206,15 @@ public void fileObjectMultipleBinariesTest() throws Exception {
FILE_SIZE, FILE_MIMETYPE, FILE_NAME, FILE_DIGEST, null, null);
assertContainsDatastream(idb.getDatastream(), TECHNICAL_METADATA.getId(),
FILE2_SIZE, FILE2_MIMETYPE, FILE2_NAME, FILE2_DIGEST, null, null);
- assertContainsDatastream(idb.getDatastream(), THUMBNAIL_LARGE.getId(),
- FILE3_SIZE, FILE3_MIMETYPE, FILE3_NAME, FILE3_DIGEST, null, null);
assertEquals(FILE_SIZE, (long) idb.getFilesizeSort());
- assertEquals(FILE_SIZE + FILE2_SIZE + FILE3_SIZE, (long) idb.getFilesizeTotal());
+ assertEquals(FILE_SIZE + FILE2_SIZE, (long) idb.getFilesizeTotal());
}
@Test
public void fileObjectImageBinaryTest() throws Exception {
when(binObj.getResource()).thenReturn(
- fileResource(ORIGINAL_FILE.getId(), FILE_SIZE, FILE3_MIMETYPE, "test.png", FILE_DIGEST));
+ fileResource(ORIGINAL_FILE.getId(), FILE_SIZE, PNG_MIMETYPE, "test.png", FILE_DIGEST));
BinaryObject binObj2 = mock(BinaryObject.class);
when(binObj2.getPid()).thenReturn(DatastreamPids.getTechnicalMetadataPid(pid));
@@ -233,32 +222,26 @@ public void fileObjectImageBinaryTest() throws Exception {
fileResource(TECHNICAL_METADATA.getId(), FILE2_SIZE, FILE2_MIMETYPE, FILE2_NAME, FILE2_DIGEST));
when(binObj2.getBinaryStream()).thenReturn(getClass().getResourceAsStream("/datastream/techmd.xml"));
- BinaryObject binObj3 = mock(BinaryObject.class);
- when(binObj3.getPid()).thenReturn(PIDs.get(pid.getId() + "/" + JP2_ACCESS_COPY.getId()));
- when(binObj3.getResource()).thenReturn(
- fileResource(THUMBNAIL_LARGE.getId(), FILE3_SIZE, JP2_ACCESS_COPY.getMimetype(),
- JP2_ACCESS_COPY.getDefaultFilename(), FILE3_DIGEST));
+ List derivs = makeJP2Derivative();
+ var pid = PIDs.get(PID_STRING);
+ when(derivativeService.getDerivatives(pid)).thenReturn(derivs);
- BinaryObject binObj4 = mock(BinaryObject.class);
- when(binObj4.getPid()).thenReturn(PIDs.get(pid.getId() + "/" + THUMBNAIL_LARGE.getId()));
- when(binObj4.getResource()).thenReturn(
- fileResource(THUMBNAIL_LARGE.getId(), FILE3_SIZE, FILE3_MIMETYPE, FILE3_NAME, FILE3_DIGEST));
- when(fileObj.getBinaryObjects()).thenReturn(Arrays.asList(binObj, binObj2, binObj3, binObj4));
+ when(fileObj.getBinaryObjects()).thenReturn(Arrays.asList(binObj, binObj2));
dip.setContentObject(fileObj);
filter.filter(dip);
assertContainsDatastream(idb.getDatastream(), ORIGINAL_FILE.getId(),
- FILE_SIZE, FILE3_MIMETYPE, "test.png", FILE_DIGEST, null, FILE3_EXTENT);
+ FILE_SIZE, PNG_MIMETYPE, "test.png", FILE_DIGEST, null, IMAGE_EXTENT);
assertContainsDatastream(idb.getDatastream(), TECHNICAL_METADATA.getId(),
FILE2_SIZE, FILE2_MIMETYPE, FILE2_NAME, FILE2_DIGEST, null, null);
- assertContainsDatastream(idb.getDatastream(), THUMBNAIL_LARGE.getId(),
- FILE3_SIZE, FILE3_MIMETYPE, FILE3_NAME, FILE3_DIGEST, null, null);
+ assertContainsDatastream(idb.getDatastream(), JP2_ACCESS_COPY.getId(),
+ JP2_SIZE, JP2_ACCESS_COPY.getMimetype(), "access.jp2", null, null, null);
assertEquals(FILE_SIZE, (long) idb.getFilesizeSort());
// JP2 and thumbnail set to same size
- assertEquals(FILE_SIZE + FILE2_SIZE + (FILE3_SIZE * 2), (long) idb.getFilesizeTotal());
+ assertEquals(FILE_SIZE + FILE2_SIZE + JP2_SIZE, (long) idb.getFilesizeTotal());
}
@Test
@@ -465,7 +448,7 @@ public void fileObjectVideoNoHeightWidthBinaryTest() throws Exception {
@Test
public void fileObjectImageBinaryNoDimensionsTest() throws Exception {
when(binObj.getResource()).thenReturn(
- fileResource(ORIGINAL_FILE.getId(), FILE_SIZE, FILE3_MIMETYPE, "test.png", FILE_DIGEST));
+ fileResource(ORIGINAL_FILE.getId(), FILE_SIZE, PNG_MIMETYPE, "test.png", FILE_DIGEST));
BinaryObject binObj2 = mock(BinaryObject.class);
when(binObj2.getPid()).thenReturn(DatastreamPids.getTechnicalMetadataPid(pid));
@@ -479,7 +462,7 @@ public void fileObjectImageBinaryNoDimensionsTest() throws Exception {
filter.filter(dip);
assertContainsDatastream(idb.getDatastream(), ORIGINAL_FILE.getId(),
- FILE_SIZE, FILE3_MIMETYPE, "test.png", FILE_DIGEST, null, null);
+ FILE_SIZE, PNG_MIMETYPE, "test.png", FILE_DIGEST, null, null);
assertContainsDatastream(idb.getDatastream(), TECHNICAL_METADATA.getId(),
FILE2_SIZE, FILE2_MIMETYPE, FILE2_NAME, FILE2_DIGEST, null, null);
@@ -491,7 +474,7 @@ public void fileObjectImageBinaryNoDimensionsTest() throws Exception {
@Test
public void fileObjectImageBinaryWithJp2DimensionsTest() throws Exception {
when(binObj.getResource()).thenReturn(
- fileResource(ORIGINAL_FILE.getId(), FILE_SIZE, FILE3_MIMETYPE, "test.png", FILE_DIGEST));
+ fileResource(ORIGINAL_FILE.getId(), FILE_SIZE, PNG_MIMETYPE, "test.png", FILE_DIGEST));
BinaryObject binObj2 = mock(BinaryObject.class);
when(binObj2.getPid()).thenReturn(DatastreamPids.getTechnicalMetadataPid(pid));
@@ -504,18 +487,7 @@ public void fileObjectImageBinaryWithJp2DimensionsTest() throws Exception {
when(fileObj.getBinaryObjects()).thenReturn(Arrays.asList(binObj, binObj2));
dip.setContentObject(fileObj);
- File smallFile = derivDir.resolve("small.png").toFile();
- FileUtils.write(smallFile, "content", "UTF-8");
-
- File largeFile = derivDir.resolve("large.png").toFile();
- FileUtils.write(largeFile, "large content", "UTF-8");
-
- File jp2File = derivDir.resolve("access.jp2").toFile();
- FileUtils.write(jp2File, "jp2 content", "UTF-8");
-
- List derivs = Arrays.asList(new Derivative(THUMBNAIL_SMALL, smallFile),
- new Derivative(THUMBNAIL_LARGE, largeFile),
- new Derivative(JP2_ACCESS_COPY, jp2File));
+ List derivs = makeJP2Derivative();
when(derivativeService.getDerivatives(filePid)).thenReturn(derivs);
var mockJp2InfoService = mock(Jp2InfoService.class);
@@ -525,11 +497,11 @@ public void fileObjectImageBinaryWithJp2DimensionsTest() throws Exception {
filter.filter(dip);
assertContainsDatastream(idb.getDatastream(), ORIGINAL_FILE.getId(),
- FILE_SIZE, FILE3_MIMETYPE, "test.png", FILE_DIGEST, null, FILE3_EXTENT);
+ FILE_SIZE, PNG_MIMETYPE, "test.png", FILE_DIGEST, null, IMAGE_EXTENT);
assertContainsDatastream(idb.getDatastream(), TECHNICAL_METADATA.getId(),
FILE2_SIZE, FILE2_MIMETYPE, FILE2_NAME, FILE2_DIGEST, null, null);
assertContainsDatastream(idb.getDatastream(), JP2_ACCESS_COPY.getId(),
- 11, JP2_ACCESS_COPY.getMimetype(), "access.jp2", null, null, "1000x600");
+ JP2_SIZE, JP2_ACCESS_COPY.getMimetype(), "access.jp2", null, null, "1000x600");
assertEquals(FILE_SIZE, (long) idb.getFilesizeSort());
}
@@ -604,7 +576,7 @@ public void workObjectTest() throws Exception {
}
@Test
- public void workObjectWithoutPrimaryObjectTest() throws Exception {
+ public void workObjectWithoutPrimaryObjectTest() {
WorkObject workObj = mock(WorkObject.class);
dip.setContentObject(workObj);
@@ -625,7 +597,8 @@ public void workObjectWithThumbnailNoPrimaryObjectTest() throws Exception {
PID filePid = PIDs.get(fileId);
when(fileObj.getPid()).thenReturn(filePid);
when(binObj.getPid()).thenReturn(getOriginalFilePid(filePid));
- setUpDerivatives(filePid);
+ var derivs = makeJP2Derivative();
+ when(derivativeService.getDerivatives(filePid)).thenReturn(derivs);
dip.setContentObject(workObj);
filter.filter(dip);
@@ -633,7 +606,9 @@ public void workObjectWithThumbnailNoPrimaryObjectTest() throws Exception {
assertNotNull(idb.getDatastream());
assertNull(idb.getFilesizeSort());
assertNotNull(idb.getFilesizeTotal());
- assertThumbnailDatastreams(fileId);
+
+ assertContainsDatastream(idb.getDatastream(), JP2_ACCESS_COPY.getId(),
+ JP2_SIZE, JP2_ACCESS_COPY.getMimetype(), "access.jp2", null, fileId, null);
}
@Test
@@ -649,7 +624,6 @@ public void workObjectTestWithPrimaryAndThumbnailObjects() throws Exception {
PID filePid = PIDs.get(fileId);
when(fileObj.getPid()).thenReturn(filePid);
when(binObj.getPid()).thenReturn(getOriginalFilePid(filePid));
- setUpDerivatives(filePid);
// set up thumbnail file object
FileObject thumbnailObj = mock(FileObject.class);
@@ -657,13 +631,13 @@ public void workObjectTestWithPrimaryAndThumbnailObjects() throws Exception {
String thumbnailId = "066ed112-f548-479e-ab4b-bf1aad40d678";
PID thumbnailPid = PIDs.get(thumbnailId);
when(thumbnailObj.getPid()).thenReturn(thumbnailPid);
- setUpDerivatives(thumbnailPid);
+ var derivs = makeJP2Derivative();
+ when(derivativeService.getDerivatives(thumbnailPid)).thenReturn(derivs);
filter.filter(dip);
assertContainsDatastream(idb.getDatastream(), ORIGINAL_FILE.getId(),
FILE_SIZE, FILE_MIMETYPE, FILE_NAME, FILE_DIGEST, fileId, null);
- assertThumbnailDatastreams(thumbnailId);
assertContainsMetadataDatastreams(idb.getDatastream());
// Sort size is based off primary object's size
@@ -671,10 +645,8 @@ public void workObjectTestWithPrimaryAndThumbnailObjects() throws Exception {
// Work has no datastreams of its own
assertEquals(FILE2_SIZE + MODS_SIZE + PREMIS_SIZE, (long) idb.getFilesizeTotal());
- assertDoesNotContainDatastream(idb.getDatastream(), THUMBNAIL_SMALL.getId(),
- 7l, THUMBNAIL_SMALL.getMimetype(), "small.png", null, fileId, null);
- assertDoesNotContainDatastream(idb.getDatastream(), THUMBNAIL_LARGE.getId(),
- 13l, THUMBNAIL_LARGE.getMimetype(), "large.png", null, fileId, null);
+ assertContainsDatastream(idb.getDatastream(), JP2_ACCESS_COPY.getId(),
+ JP2_SIZE, JP2_ACCESS_COPY.getMimetype(), "access.jp2", null, thumbnailId, null);
}
@Test
@@ -691,28 +663,40 @@ public void folderObjectWithMetadataTest() throws Exception {
assertEquals(FILE2_SIZE + MODS_SIZE + PREMIS_SIZE, (long) idb.getFilesizeTotal());
}
+ @Test
+ public void folderObjectWithJP2Test() throws Exception {
+ FolderObject folderObj = mock(FolderObject.class);
+ when(folderObj.getPid()).thenReturn(pid);
+
+ List derivs = makeJP2Derivative();
+ when(derivativeService.getDerivatives(pid)).thenReturn(derivs);
+
+ dip.setContentObject(folderObj);
+
+ filter.filter(dip);
+
+ assertContainsDatastream(idb.getDatastream(), JP2_ACCESS_COPY.getId(),
+ JP2_SIZE, JP2_ACCESS_COPY.getMimetype(), "access.jp2", null, null, null);
+ }
+
@Test
public void fileObjectWithDerivativeTest() throws Exception {
when(fileObj.getPid()).thenReturn(pid);
- when(fileObj.getBinaryObjects()).thenReturn(Arrays.asList(binObj));
+ when(fileObj.getBinaryObjects()).thenReturn(List.of(binObj));
dip.setContentObject(fileObj);
- File derivFile = derivDir.resolve("deriv.png").toFile();
- FileUtils.write(derivFile, "content", "UTF-8");
- long derivSize = 7l;
-
- List derivs = Arrays.asList(new Derivative(THUMBNAIL_SMALL, derivFile));
+ List derivs = makeJP2Derivative();
when(derivativeService.getDerivatives(pid)).thenReturn(derivs);
filter.filter(dip);
assertContainsDatastream(idb.getDatastream(), ORIGINAL_FILE.getId(),
FILE_SIZE, FILE_MIMETYPE, FILE_NAME, FILE_DIGEST, null, null);
- assertContainsDatastream(idb.getDatastream(), THUMBNAIL_SMALL.getId(),
- derivSize, THUMBNAIL_SMALL.getMimetype(), derivFile.getName(), null, null, null);
+ assertContainsDatastream(idb.getDatastream(), JP2_ACCESS_COPY.getId(),
+ JP2_SIZE, JP2_ACCESS_COPY.getMimetype(), "access.jp2", null, null, null);
assertEquals(FILE_SIZE, (long) idb.getFilesizeSort());
- assertEquals(FILE_SIZE + derivSize, (long) idb.getFilesizeTotal());
+ assertEquals(FILE_SIZE + JP2_SIZE, (long) idb.getFilesizeTotal());
}
@Test
@@ -751,17 +735,6 @@ private void assertContainsDatastream(List values, String name, long fil
assertTrue(values.contains(joined), "Did not contain datastream " + name);
}
- private void assertDoesNotContainDatastream(List values, String name, long filesize, String mimetype,
- String filename, String digest, String owner, String extent) {
- String extension = filename.substring(filename.lastIndexOf('.') + 1);
- List
+
+
+
diff --git a/web-common/src/main/java/edu/unc/lib/boxc/web/common/services/DerivativeContentService.java b/web-common/src/main/java/edu/unc/lib/boxc/web/common/services/DerivativeContentService.java
index f1c6651e28..010a865bf4 100644
--- a/web-common/src/main/java/edu/unc/lib/boxc/web/common/services/DerivativeContentService.java
+++ b/web-common/src/main/java/edu/unc/lib/boxc/web/common/services/DerivativeContentService.java
@@ -86,29 +86,6 @@ public void streamData(PID pid, String dsName, AccessGroupSet principals, boolea
IOUtils.copy(new FileInputStream(derivFile), outStream, BUFFER_SIZE);
}
- /**
- * Returns a response entity consisting of the derivative stream used for thumbnails
- * @param pid PID of the repository object
- * @param dsName datastream name
- * @return
- * @throws FileNotFoundException
- */
- public ResponseEntity
streamThumbnail(PID pid, String dsName) throws FileNotFoundException {
- var datastreamType = getType(dsName);
- Derivative derivative = getDerivative(pid, dsName, datastreamType);
-
- var file = derivative.getFile();
- var filename = file.getName();
- var input = new FileInputStream(file);
- InputStreamResource resource = new InputStreamResource(input);
- return ResponseEntity.ok()
- .header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=" + filename)
- .contentLength(file.length())
- .contentType(MediaType.IMAGE_PNG)
- .body(resource);
-
- }
-
private DatastreamType getType(String dsName) {
DatastreamType derivType = getByIdentifier(dsName);
if (derivType == null || !listDerivativeTypes().contains(derivType)) {
diff --git a/web-common/src/main/java/edu/unc/lib/boxc/web/common/utils/DatastreamUtil.java b/web-common/src/main/java/edu/unc/lib/boxc/web/common/utils/DatastreamUtil.java
index 6ffd8b89b8..5ba6695bf8 100644
--- a/web-common/src/main/java/edu/unc/lib/boxc/web/common/utils/DatastreamUtil.java
+++ b/web-common/src/main/java/edu/unc/lib/boxc/web/common/utils/DatastreamUtil.java
@@ -131,7 +131,7 @@ public static Datastream getPreferredDatastream(ContentObjectRecord metadata, St
*/
public static String getThumbnailOwnerId(ContentObjectRecord metadata) {
// Prefer the matching derivative from this object
- Datastream preferredDS = getPreferredDatastream(metadata, DatastreamType.THUMBNAIL_LARGE.getId());
+ Datastream preferredDS = getPreferredDatastream(metadata, DatastreamType.JP2_ACCESS_COPY.getId());
// Ensure that this item has the appropriate thumbnail
if (preferredDS == null) {
diff --git a/web-common/src/test/java/edu/unc/lib/boxc/web/common/services/AccessCopiesServiceTest.java b/web-common/src/test/java/edu/unc/lib/boxc/web/common/services/AccessCopiesServiceTest.java
index 2203762a56..8735914cef 100644
--- a/web-common/src/test/java/edu/unc/lib/boxc/web/common/services/AccessCopiesServiceTest.java
+++ b/web-common/src/test/java/edu/unc/lib/boxc/web/common/services/AccessCopiesServiceTest.java
@@ -30,6 +30,7 @@
import java.util.UUID;
import static edu.unc.lib.boxc.auth.api.Permission.viewOriginal;
+import static edu.unc.lib.boxc.model.api.DatastreamType.JP2_ACCESS_COPY;
import static edu.unc.lib.boxc.model.api.DatastreamType.ORIGINAL_FILE;
import static edu.unc.lib.boxc.model.api.DatastreamType.TECHNICAL_METADATA;
import static edu.unc.lib.boxc.web.common.services.AccessCopiesService.AUDIO_MIMETYPE_REGEX;
@@ -154,11 +155,11 @@ private ContentObjectSolrRecord createPdfObject(ResourceType resourceType) {
private ContentObjectSolrRecord createImgObject(ResourceType resourceType) {
var mdObjectImg = new ContentObjectSolrRecord();
mdObjectImg.setResourceType(resourceType.name());
- mdObjectImg.setId(UUID.randomUUID().toString());
- List imgDatastreams = Arrays.asList(
+ var id = UUID.randomUUID().toString();
+ mdObjectImg.setId(id);
+ List imgDatastreams = List.of(
ORIGINAL_FILE.getId() + "|image/png|file.png|png|766|urn:sha1:checksum|",
- DatastreamType.THUMBNAIL_LARGE.getId() + "|image/png|thumb|png|55||",
- DatastreamType.JP2_ACCESS_COPY.getId() + "|image/jp2|thumb|jp2|555||");
+ JP2_ACCESS_COPY.getId() + "|image/jp2|bunny.jp2|jp2|||" + id + "|1200x1200");
mdObjectImg.setFileFormatCategory(Collections.singletonList(ContentCategory.image.getDisplayName()));
mdObjectImg.setFileFormatType(Collections.singletonList("image/png"));
mdObjectImg.setDatastream(imgDatastreams);
@@ -292,9 +293,8 @@ public void getThumbnailIdNoPrimaryMultipleImages() {
var mdObjectImg2 = new ContentObjectSolrRecord();
mdObjectImg2.setResourceType(ResourceType.File.name());
mdObjectImg2.setId(UUID.randomUUID().toString());
- var imgDatastreams = Arrays.asList(
- ORIGINAL_FILE.getId() + "|image/jpg|file2.png|png|555|urn:sha1:checksum|",
- DatastreamType.THUMBNAIL_LARGE.getId() + "|image/png|thumb|png|55||");
+ var imgDatastreams = List.of(
+ ORIGINAL_FILE.getId() + "|image/jpg|file2.png|png|555|urn:sha1:checksum|");
mdObjectImg2.setFileFormatCategory(Collections.singletonList(ContentCategory.image.getDisplayName()));
mdObjectImg2.setFileFormatType(Collections.singletonList("png"));
mdObjectImg2.setDatastream(imgDatastreams);
diff --git a/web-common/src/test/java/edu/unc/lib/boxc/web/common/services/DerivativeContentServiceTest.java b/web-common/src/test/java/edu/unc/lib/boxc/web/common/services/DerivativeContentServiceTest.java
index e739758dee..7ca07f2dde 100644
--- a/web-common/src/test/java/edu/unc/lib/boxc/web/common/services/DerivativeContentServiceTest.java
+++ b/web-common/src/test/java/edu/unc/lib/boxc/web/common/services/DerivativeContentServiceTest.java
@@ -44,18 +44,4 @@ public void init() {
void closeService() throws Exception {
closeable.close();
}
-
- @Test
- public void testStreamThumbnail() throws FileNotFoundException {
- var pid = makePid();
- var datastreamType = DatastreamType.THUMBNAIL_SMALL;
- var file = new File("src/test/resources/tokki.jpg");
- var derivative = new DerivativeService.Derivative(datastreamType, file);
- when(derivativeService.getDerivative(eq(pid), eq(datastreamType))).thenReturn(derivative);
-
- var respEntity = derivativeContentService.streamThumbnail(pid, "thumbnail_small");
- assertEquals(HttpStatus.OK, respEntity.getStatusCode());
- assertEquals("inline; filename=\"tokki.jpg\"", respEntity.getHeaders().getContentDisposition().toString());
- assertEquals(MediaType.IMAGE_PNG, respEntity.getHeaders().getContentType());
- }
}
diff --git a/web-common/src/test/java/edu/unc/lib/boxc/web/common/utils/DatastreamUtilTest.java b/web-common/src/test/java/edu/unc/lib/boxc/web/common/utils/DatastreamUtilTest.java
index 7ef1d075fc..7d3f0bdc0e 100644
--- a/web-common/src/test/java/edu/unc/lib/boxc/web/common/utils/DatastreamUtilTest.java
+++ b/web-common/src/test/java/edu/unc/lib/boxc/web/common/utils/DatastreamUtilTest.java
@@ -1,24 +1,20 @@
package edu.unc.lib.boxc.web.common.utils;
+import edu.unc.lib.boxc.model.api.ids.PID;
+import edu.unc.lib.boxc.search.solr.models.ContentObjectSolrRecord;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static edu.unc.lib.boxc.model.api.DatastreamType.JP2_ACCESS_COPY;
import static edu.unc.lib.boxc.model.api.DatastreamType.ORIGINAL_FILE;
import static edu.unc.lib.boxc.model.api.DatastreamType.TECHNICAL_METADATA;
-import static edu.unc.lib.boxc.model.api.DatastreamType.THUMBNAIL_LARGE;
-import static edu.unc.lib.boxc.model.api.DatastreamType.THUMBNAIL_SMALL;
import static edu.unc.lib.boxc.model.fcrepo.test.TestHelper.makePid;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import edu.unc.lib.boxc.model.api.ids.PID;
-import edu.unc.lib.boxc.search.solr.models.ContentObjectSolrRecord;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
/**
*
* @author bbpennel
@@ -31,9 +27,6 @@ public class DatastreamUtilTest {
private final static String ORIGINAL_DS = ORIGINAL_FILE.getId() + "|image/jpg|image|jpg|555||";
private final static String ORIGINAL_INDEXABLE = ORIGINAL_FILE.getId() + "|application/pdf|doc.pdf|pdf|5555||";
private final static String FITS_DS = TECHNICAL_METADATA.getId() + "|text/xml|fits.xml|xml|5555||";
- private final static String THUMB_SMALL_DS = THUMBNAIL_SMALL.getId() + "|image/png|small|png|3333||";
- private final static String THUMB_LARGE_DS = THUMBNAIL_LARGE.getId() + "|image/png|small|png|10000||";
- private final static List EMPTY_LIST = Collections.emptyList();
@BeforeEach
public void setup() {
@@ -76,28 +69,31 @@ public void testGetDatastreamUrl() {
@Test
public void testConstructThumbnailSmall() {
PID pid = makePid();
+ var id = pid.getId();
ContentObjectSolrRecord mdObj = new ContentObjectSolrRecord();
- mdObj.setId(pid.getId());
- mdObj.setDatastream(asList(ORIGINAL_DS, THUMB_SMALL_DS, THUMB_LARGE_DS));
-
- var id = DatastreamUtil.getThumbnailOwnerId(mdObj);
- assertEquals(pid.getId(), id);
- var url = DatastreamUtil.constructThumbnailUrl(id, "small");
- assertEquals(ENDPOINT_URL + "thumb/" + pid.getId() + "/small", url);
+ mdObj.setId(id);
+ var jp2Datastream = JP2_ACCESS_COPY.getId() + "|image/jp2|bunny.jp2|jp2|||" + id + "|1200x1200";
+ mdObj.setDatastream(asList(ORIGINAL_DS, jp2Datastream));
+
+ var ownerId = DatastreamUtil.getThumbnailOwnerId(mdObj);
+ assertEquals(id, ownerId);
+ var url = DatastreamUtil.constructThumbnailUrl(ownerId, "small");
+ assertEquals(ENDPOINT_URL + "thumb/" + ownerId + "/small", url);
}
@Test
public void testConstructThumbnailUrlForPrimaryObject() {
PID primaryObjPid = makePid();
+ var primaryObjId = primaryObjPid.getId();
PID pid = makePid();
ContentObjectSolrRecord mdObj = new ContentObjectSolrRecord();
mdObj.setId(pid.getId());
- mdObj.setDatastream(asList(ORIGINAL_DS,
- THUMB_SMALL_DS + primaryObjPid.getId(), THUMB_LARGE_DS + primaryObjPid.getId()));
+ var jp2Datastream = JP2_ACCESS_COPY.getId() + "|image/jp2|bunny.jp2|jp2|||" + primaryObjId + "|1200x1200";
+ mdObj.setDatastream(asList(ORIGINAL_DS, jp2Datastream));
var id = DatastreamUtil.getThumbnailOwnerId(mdObj);
- assertEquals(primaryObjPid.getId(), id);
+ assertEquals(primaryObjId, id);
var url = DatastreamUtil.constructThumbnailUrl(id, "large");
assertEquals(ENDPOINT_URL + "thumb/" + primaryObjPid.getId() + "/large", url);
}
@@ -107,7 +103,7 @@ public void testGetThumbnailUrlNoThumbs() {
PID pid = makePid();
ContentObjectSolrRecord mdObj = new ContentObjectSolrRecord();
mdObj.setId(pid.getId());
- mdObj.setDatastream(asList(ORIGINAL_DS));
+ mdObj.setDatastream(List.of(ORIGINAL_DS));
var id = DatastreamUtil.getThumbnailOwnerId(mdObj);
assertNull(id);
diff --git a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/DownloadImageService.java b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/DownloadImageService.java
index 58a411e5fd..88dda0dacf 100644
--- a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/DownloadImageService.java
+++ b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/DownloadImageService.java
@@ -103,8 +103,12 @@ public String getDownloadFilename(ContentObjectRecord contentObjectRecord, Strin
}
private Datastream getDatastream(ContentObjectRecord contentObjectRecord) {
- var id = DatastreamType.ORIGINAL_FILE.getId();
- return contentObjectRecord.getDatastreamObject(id);
+ var originalFileDatastream = contentObjectRecord.getDatastreamObject(
+ DatastreamType.ORIGINAL_FILE.getId());
+ if (originalFileDatastream == null) {
+ return contentObjectRecord.getDatastreamObject(DatastreamType.JP2_ACCESS_COPY.getId());
+ }
+ return originalFileDatastream;
}
/**
diff --git a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/ImportThumbnailService.java b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/ImportThumbnailService.java
index f4fc5c66e5..47b61c8bac 100644
--- a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/ImportThumbnailService.java
+++ b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/ImportThumbnailService.java
@@ -1,11 +1,14 @@
package edu.unc.lib.boxc.web.services.processing;
-import static edu.unc.lib.boxc.model.api.ids.RepositoryPathConstants.HASHED_PATH_DEPTH;
-import static edu.unc.lib.boxc.model.api.ids.RepositoryPathConstants.HASHED_PATH_SIZE;
-import static edu.unc.lib.boxc.model.fcrepo.ids.RepositoryPaths.idToPath;
-import static edu.unc.lib.boxc.operations.jms.RunEnhancementsMessageHelpers.makeEnhancementOperationBody;
-import static org.apache.commons.io.FileUtils.copyInputStreamToFile;
-import static org.apache.commons.lang3.StringUtils.containsIgnoreCase;
+import edu.unc.lib.boxc.auth.api.Permission;
+import edu.unc.lib.boxc.auth.api.models.AgentPrincipals;
+import edu.unc.lib.boxc.auth.api.services.AccessControlService;
+import edu.unc.lib.boxc.model.api.ids.PID;
+import edu.unc.lib.boxc.model.fcrepo.ids.PIDs;
+import edu.unc.lib.boxc.operations.jms.thumbnails.ImportThumbnailRequest;
+import edu.unc.lib.boxc.operations.jms.thumbnails.ThumbnailRequestSender;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -13,16 +16,11 @@
import java.nio.file.Path;
import java.nio.file.Paths;
-import org.jdom2.Document;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import edu.unc.lib.boxc.auth.api.Permission;
-import edu.unc.lib.boxc.auth.api.models.AgentPrincipals;
-import edu.unc.lib.boxc.auth.api.services.AccessControlService;
-import edu.unc.lib.boxc.model.api.ids.PID;
-import edu.unc.lib.boxc.model.fcrepo.ids.PIDs;
-import edu.unc.lib.boxc.operations.jms.MessageSender;
+import static edu.unc.lib.boxc.model.api.ids.RepositoryPathConstants.HASHED_PATH_DEPTH;
+import static edu.unc.lib.boxc.model.api.ids.RepositoryPathConstants.HASHED_PATH_SIZE;
+import static edu.unc.lib.boxc.model.fcrepo.ids.RepositoryPaths.idToPath;
+import static org.apache.commons.io.FileUtils.copyInputStreamToFile;
+import static org.apache.commons.lang3.StringUtils.containsIgnoreCase;
/**
* Service to process requests to add/update display thumbnail objects
@@ -35,7 +33,7 @@ public class ImportThumbnailService {
private String sourceImagesDir;
private Path storagePath;
private AccessControlService aclService;
- private MessageSender messageSender;
+ private ThumbnailRequestSender messageSender;
public void init() {
storagePath = Paths.get(sourceImagesDir);
@@ -57,8 +55,13 @@ public void run(InputStream importStream, AgentPrincipals agent, String uuid, St
File finalLocation = storagePath.resolve(thumbnailBasePath).resolve(uuid).toFile();
copyInputStreamToFile(importStream, finalLocation);
- Document msg = makeEnhancementOperationBody(agent.getUsername(), pid, true);
- messageSender.sendMessage(msg);
+ var request = new ImportThumbnailRequest();
+ request.setAgent(agent);
+ request.setMimetype(mimeType);
+ request.setPidString(uuid);
+ request.setStoragePath(finalLocation.toPath());
+
+ messageSender.sendToImportQueue(request);
log.info("Job to to add thumbnail to object {} has been queued by {}",
uuid, agent.getUsername());
@@ -68,7 +71,7 @@ public void setAclService(AccessControlService aclService) {
this.aclService = aclService;
}
- public void setMessageSender(MessageSender messageSender) {
+ public void setMessageSender(ThumbnailRequestSender messageSender) {
this.messageSender = messageSender;
}
diff --git a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/RunEnhancementsRequest.java b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/RunEnhancementsRequest.java
new file mode 100644
index 0000000000..8509f57825
--- /dev/null
+++ b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/RunEnhancementsRequest.java
@@ -0,0 +1,47 @@
+package edu.unc.lib.boxc.web.services.processing;
+
+import edu.unc.lib.boxc.auth.api.models.AgentPrincipals;
+
+import java.util.List;
+
+/**
+ * @author bbpennel
+ */
+public class RunEnhancementsRequest {
+ private List pids;
+ private boolean force;
+ private AgentPrincipals agent;
+ private boolean recursive;
+
+ public List getPids() {
+ return pids;
+ }
+
+ public boolean isForce() {
+ return force;
+ }
+
+ public void setPids(List pids) {
+ this.pids = pids;
+ }
+
+ public void setForce(boolean force) {
+ this.force = force;
+ }
+
+ public AgentPrincipals getAgent() {
+ return agent;
+ }
+
+ public void setAgent(AgentPrincipals agent) {
+ this.agent = agent;
+ }
+
+ public boolean isRecursive() {
+ return recursive;
+ }
+
+ public void setRecursive(boolean recursive) {
+ this.recursive = recursive;
+ }
+}
diff --git a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/RunEnhancementsService.java b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/RunEnhancementsService.java
index 4b3fff5064..7f032a09a6 100644
--- a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/RunEnhancementsService.java
+++ b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/processing/RunEnhancementsService.java
@@ -6,12 +6,12 @@
import java.util.Arrays;
import java.util.List;
+import edu.unc.lib.boxc.auth.api.models.AgentPrincipals;
import org.jdom2.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import edu.unc.lib.boxc.auth.api.Permission;
-import edu.unc.lib.boxc.auth.api.models.AgentPrincipals;
import edu.unc.lib.boxc.auth.api.services.AccessControlService;
import edu.unc.lib.boxc.common.metrics.TimerFactory;
import edu.unc.lib.boxc.model.api.ResourceType;
@@ -41,7 +41,7 @@ public class RunEnhancementsService {
private static final Logger LOG = LoggerFactory.getLogger(RunEnhancementsService.class);
private static final Timer timer = TimerFactory.createTimerForClass(RunEnhancementsService.class);
- private final List resultsFieldList = Arrays.asList(
+ private static final List RESULTS_FIELD_LIST = Arrays.asList(
SearchFieldKey.DATASTREAM.name(), SearchFieldKey.ID.name(),
SearchFieldKey.RESOURCE_TYPE.name());
@@ -57,61 +57,70 @@ public class RunEnhancementsService {
* Service to take a list of pids searches for file objects which are in the list of pids
* or children of those objects and run enhancements on.
*
- * @param agent security principals of the agent making request.
- * @param objectPids List of pids to run enhancements on
- * @param force whether enhancements should run if derivatives are already present
+ * @param request Request to run enhancements
*/
- public void run(AgentPrincipals agent, List objectPids, boolean force) {
- try (Timer.Context context = timer.time()) {
+ public void run(RunEnhancementsRequest request) {
+ try (Timer.Context ignored = timer.time()) {
+ var agent = request.getAgent();
+ var objectPids = request.getPids();
+ var force = request.isForce();
+ var recursive = request.isRecursive();
for (String objectPid : objectPids) {
PID pid = PIDs.get(objectPid);
aclService.assertHasAccess("User does not have permission to run enhancements",
pid, agent.getPrincipals(), Permission.runEnhancements);
- LOG.debug("sending solr update message for {} of type runEnhancements", pid);
-
- if (!(repositoryObjectLoader.getRepositoryObject(pid) instanceof FileObject)) {
- SearchState searchState = new SearchState();
- searchState.addFacet(new GenericFacet(SearchFieldKey.RESOURCE_TYPE, ResourceType.File.name()));
- searchState.setResultFields(resultsFieldList);
- searchState.setRowsPerPage(1000);
- searchState.setIgnoreMaxRows(true);
-
- SearchRequest searchRequest = new SearchRequest();
- searchRequest.setAccessGroups(agent.getPrincipals());
- searchRequest.setSearchState(searchState);
- searchRequest.setRootPid(pid);
- searchRequest.setApplyCutoffs(false);
-
- // Page through results for requests to run enhancements of large folders
- long totalResults = -1;
- int count = 0;
- do {
- SearchResultResponse resultResponse = queryLayer.performSearch(searchRequest);
- if (totalResults == -1) {
- totalResults = resultResponse.getResultCount();
- LOG.debug("Found {} items to queue for enhancement run", totalResults);
- // Add the root container itself
- ContentObjectRecord rootContainer = resultResponse.getSelectedContainer();
- createMessage(rootContainer, agent.getUsername(), force);
- }
- for (ContentObjectRecord metadata : resultResponse.getResultList()) {
- createMessage(metadata, agent.getUsername(), force);
- count++;
- }
- LOG.debug("Queued {} out of {} items for enhancements", count, totalResults);
- } while(count < totalResults);
+ if (recursive && !(repositoryObjectLoader.getRepositoryObject(pid) instanceof FileObject)) {
+ LOG.debug("Queueing object and children for enhancements: {}", pid);
+ recursiveEnhancements(pid, agent, force);
} else {
- LOG.debug("Queueing a file object for enhancements: {}", pid);
- SimpleIdRequest searchRequest = new SimpleIdRequest(pid, agent.getPrincipals());
- ContentObjectRecord metadata = queryLayer.getObjectById(searchRequest);
- createMessage(metadata, agent.getUsername(), force);
+ LOG.debug("Queueing object for enhancements: {}", pid);
+ shallowEnhancements(pid, agent, force);
}
}
}
}
+ private void recursiveEnhancements(PID pid, AgentPrincipals agent, Boolean force) {
+ SearchState searchState = new SearchState();
+ searchState.addFacet(new GenericFacet(SearchFieldKey.RESOURCE_TYPE, ResourceType.File.name()));
+ searchState.setResultFields(RESULTS_FIELD_LIST);
+ searchState.setRowsPerPage(1000);
+ searchState.setIgnoreMaxRows(true);
+
+ SearchRequest searchRequest = new SearchRequest();
+ searchRequest.setAccessGroups(agent.getPrincipals());
+ searchRequest.setSearchState(searchState);
+ searchRequest.setRootPid(pid);
+ searchRequest.setApplyCutoffs(false);
+
+ // Page through results for requests to run enhancements of large folders
+ long totalResults = -1;
+ int count = 0;
+ do {
+ SearchResultResponse resultResponse = queryLayer.performSearch(searchRequest);
+ if (totalResults == -1) {
+ totalResults = resultResponse.getResultCount();
+ LOG.debug("Found {} items to queue for enhancement run", totalResults);
+ // Add the root container itself
+ ContentObjectRecord rootContainer = resultResponse.getSelectedContainer();
+ createMessage(rootContainer, agent.getUsername(), force);
+ }
+ for (ContentObjectRecord metadata : resultResponse.getResultList()) {
+ createMessage(metadata, agent.getUsername(), force);
+ count++;
+ }
+ LOG.debug("Queued {} out of {} items for enhancements", count, totalResults);
+ } while(count < totalResults);
+ }
+
+ private void shallowEnhancements(PID pid, AgentPrincipals agent, Boolean force) {
+ SimpleIdRequest searchRequest = new SimpleIdRequest(pid, agent.getPrincipals());
+ ContentObjectRecord metadata = queryLayer.getObjectById(searchRequest);
+ createMessage(metadata, agent.getUsername(), force);
+ }
+
public void setAclService(AccessControlService aclService) {
this.aclService = aclService;
}
diff --git a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/rest/DatastreamController.java b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/rest/DatastreamController.java
index a120054935..f0fa637460 100644
--- a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/rest/DatastreamController.java
+++ b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/rest/DatastreamController.java
@@ -154,16 +154,7 @@ public ResponseEntity 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);
diff --git a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/rest/RunEnhancementsController.java b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/rest/RunEnhancementsController.java
index c6e7643788..8e1b47424e 100644
--- a/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/rest/RunEnhancementsController.java
+++ b/web-services-app/src/main/java/edu/unc/lib/boxc/web/services/rest/RunEnhancementsController.java
@@ -3,9 +3,9 @@
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
+import edu.unc.lib.boxc.web.services.processing.RunEnhancementsRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,9 +37,10 @@ public class RunEnhancementsController {
@PostMapping(value = "runEnhancements", produces = APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity