Skip to content

Commit

Permalink
Merge pull request #1823 from UNC-Libraries/BXC-4725-m4a-access
Browse files Browse the repository at this point in the history
BXC-4725 m4a derivatives for access
  • Loading branch information
bbpennel authored Oct 24, 2024
2 parents 09a5832 + ec967d1 commit e710900
Show file tree
Hide file tree
Showing 145 changed files with 10,287 additions and 6,551 deletions.
10 changes: 5 additions & 5 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 Expand Up @@ -86,11 +86,11 @@ jobs:
restore-keys: v1-npm-deps-

- run: npm --prefix static/js/vue-cdr-access install
- run: npm --prefix static/js/admin/vue-permissions-editor install
- run: npm --prefix static/js/admin/vue-cdr-admin install

- run: npm install -g jest-cli@29.0.3
- run: npm --prefix static/js/vue-cdr-access run test
- run: npm --prefix static/js/admin/vue-permissions-editor run test
- run: npm --prefix static/js/admin/vue-cdr-admin run test

- name: Report to CodeClimate
uses: paambaati/codeclimate-action@v3.0.0
Expand All @@ -103,7 +103,7 @@ jobs:
${{github.workspace}}/**/target/site/jacoco/jacoco.xml:jacoco
${{github.workspace}}/**/target/site/jacoco-it/jacoco.xml:jacoco
${{github.workspace}}/static/js/vue-cdr-access/coverage/lcov.info:lcov
${{github.workspace}}/static/js/admin/vue-permissions-editor/coverage/lcov.info:lcov
${{github.workspace}}/static/js/admin/vue-cdr-admin/coverage/lcov.info:lcov
- name: View fedora service logs
if: always()
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ static/js/cdr-access.js
static/css/cdr_access.css
static/css/cdr_vue_modal_styles.css
static/js/vue-access-index.js
static/js/vue-admin-index.js
static/js/vue-permissions-index.js
static/js/vue-cdr-access/.env
static/css/cdr-ui.css
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ build-admin-concat:
static/css/admin/fontawesome/all.min.css \
static/css/structure_browse.css \
static/css/cdr_vue_modal_styles.css \
static/js/admin/vue-permissions-editor/dist/assets/index.css \
static/js/admin/vue-cdr-admin/dist/assets/index.css \
> static/css/cdr_admin.css

ifneq ($(VERSION), "")
Expand All @@ -44,11 +44,11 @@ ifneq ($(VERSION), "")
endif

build-admin-npm:
# Build vue permissions application files
npm --prefix static/js/admin/vue-permissions-editor ci
npm --prefix static/js/admin/vue-permissions-editor run build
# Build vue admin application files
npm --prefix static/js/admin/vue-cdr-admin ci
npm --prefix static/js/admin/vue-cdr-admin run build

cp static/js/admin/vue-permissions-editor/dist/assets/vue-permissions-index.js static/js/vue-permissions-index.js
cp static/js/admin/vue-cdr-admin/dist/assets/vue-admin-index.js static/js/vue-admin-index.js

build-access-concat:
# Make sure file is empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,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
2 changes: 1 addition & 1 deletion etc/solr-config/access/conf/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
<field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
<!-- Descriptive Fields -->
<field name="title" type="sortableText" indexed="true" stored="true" required="true"/>
<!-- View behavior for UV -->
<!-- View behavior for Clover -->
<field name="viewBehavior" type="string" indexed="true" stored="true" />

<!-- Index fields -->
Expand Down
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 e710900

Please sign in to comment.