Skip to content

Commit

Permalink
Merge branch 'main' into boxctron-development
Browse files Browse the repository at this point in the history
  • Loading branch information
bbpennel committed Oct 11, 2024
2 parents 15a75b4 + f6c1bfe commit f99565b
Show file tree
Hide file tree
Showing 74 changed files with 1,059 additions and 1,189 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
- /var/solr/data/access/conf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class SetDatastreamFilter implements IndexDocumentFilter {
private DerivativeService derivativeService;
private TechnicalMetadataService technicalMetadataService;
private Jp2InfoService jp2InfoService;
private static final List<DatastreamType> 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+))?");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Datastream> 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) {
Expand Down Expand Up @@ -334,7 +348,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 All @@ -352,33 +367,6 @@ private void addDerivatives(List<Datastream> 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<Datastream> 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<Datastream> clearPreviousThumbnailDatastreams(List<Datastream> 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();
Expand Down
Loading

0 comments on commit f99565b

Please sign in to comment.