Skip to content

Commit

Permalink
BXC-4710 deleting THUMBNAIL_SMALL datastream type
Browse files Browse the repository at this point in the history
  • Loading branch information
sharonluong committed Sep 30, 2024
1 parent 58c972a commit 44cab13
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 161 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@
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;
Expand Down Expand Up @@ -699,22 +697,22 @@ public void folderObjectWithJP2Test() throws Exception {
@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();
File derivFile = derivDir.resolve("deriv.jp2").toFile();
FileUtils.write(derivFile, "content", "UTF-8");
long derivSize = 7l;

List<Derivative> derivs = Arrays.asList(new Derivative(THUMBNAIL_SMALL, derivFile));
List<Derivative> derivs = List.of(new Derivative(JP2_ACCESS_COPY, derivFile));
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(),
derivSize, JP2_ACCESS_COPY.getMimetype(), derivFile.getName(), null, null, null);

assertEquals(FILE_SIZE, (long) idb.getFilesizeSort());
assertEquals(FILE_SIZE + derivSize, (long) idb.getFilesizeTotal());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public enum DatastreamType {
ORIGINAL_FILE("original_file", null, null, DATA_FILE_FILESET, INTERNAL),
TECHNICAL_METADATA("techmd_fits", "text/xml", "xml", DATA_FILE_FILESET, INTERNAL),
TECHNICAL_METADATA_HISTORY("techmd_fits_history", "text/xml", "xml", DATA_FILE_FILESET, INTERNAL),
THUMBNAIL_SMALL("thumbnail_small", "image/png", "png", null, EXTERNAL),
THUMBNAIL_LARGE("thumbnail_large", "image/png", "png", null, EXTERNAL);

private final String id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
package edu.unc.lib.boxc.model.fcrepo.services;

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.THUMBNAIL_SMALL;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import edu.unc.lib.boxc.model.api.DatastreamType;
import edu.unc.lib.boxc.model.api.ids.PID;
import edu.unc.lib.boxc.model.fcrepo.ids.PIDs;
import edu.unc.lib.boxc.model.fcrepo.services.DerivativeService.Derivative;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import edu.unc.lib.boxc.model.api.DatastreamType;
import edu.unc.lib.boxc.model.api.ids.PID;
import edu.unc.lib.boxc.model.fcrepo.ids.PIDs;
import edu.unc.lib.boxc.model.fcrepo.services.DerivativeService;
import edu.unc.lib.boxc.model.fcrepo.services.DerivativeService.Derivative;
import static edu.unc.lib.boxc.model.api.DatastreamType.FULLTEXT_EXTRACTION;
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 org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

/**
*
Expand Down Expand Up @@ -56,48 +54,48 @@ public void init() throws Exception {

@Test
public void testGetDerivative() throws Exception {
File originalDerivFile = createDerivative(pid, THUMBNAIL_SMALL);
File originalDerivFile = createDerivative(pid, JP2_ACCESS_COPY);

Derivative deriv = derivativeService.getDerivative(pid, THUMBNAIL_SMALL);
Derivative deriv = derivativeService.getDerivative(pid, JP2_ACCESS_COPY);

assertEquals(originalDerivFile, deriv.getFile());
assertEquals(THUMBNAIL_SMALL, deriv.getType());
assertEquals(JP2_ACCESS_COPY, deriv.getType());
}

@Test
public void testGetDerivativeNotExist() throws Exception {
Derivative deriv = derivativeService.getDerivative(pid, THUMBNAIL_SMALL);
Derivative deriv = derivativeService.getDerivative(pid, JP2_ACCESS_COPY);

assertNull(deriv);
}

@Test
public void testGetDerivatives() throws Exception {
File originalDerivFile1 = createDerivative(pid, THUMBNAIL_SMALL);
File originalDerivFile1 = createDerivative(pid, FULLTEXT_EXTRACTION);
File originalDerivFil21 = createDerivative(pid, JP2_ACCESS_COPY);

List<Derivative> derivs = derivativeService.getDerivatives(pid);
assertEquals(2, derivs.size());

Derivative thumbDeriv = findDerivative(derivs, THUMBNAIL_SMALL);
Derivative textDeriv = findDerivative(derivs, FULLTEXT_EXTRACTION);
Derivative jp2Deriv = findDerivative(derivs, JP2_ACCESS_COPY);

assertNotNull(thumbDeriv);
assertNotNull(textDeriv);
assertNotNull(jp2Deriv);

assertEquals(originalDerivFile1, thumbDeriv.getFile());
assertEquals(originalDerivFile1, textDeriv.getFile());
assertEquals(originalDerivFil21, jp2Deriv.getFile());
}

@Test
public void testGetDerivativesIgnoreNonDerivatives() throws Exception {
File originalDerivFile1 = createDerivative(pid, THUMBNAIL_SMALL);
File originalDerivFile1 = createDerivative(pid, JP2_ACCESS_COPY);
createDerivative(pid, ORIGINAL_FILE);

List<Derivative> derivs = derivativeService.getDerivatives(pid);
assertEquals(1, derivs.size());

Derivative thumbDeriv = findDerivative(derivs, THUMBNAIL_SMALL);
Derivative thumbDeriv = findDerivative(derivs, JP2_ACCESS_COPY);
assertEquals(originalDerivFile1, thumbDeriv.getFile());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import java.util.HashSet;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;

/**
* @author lfarrell
Expand All @@ -16,21 +16,21 @@ public class QueryFilterFactoryTest {
@Test
public void NamedDatastreamFilterTest() {
var filter = QueryFilterFactory.createFilter(SearchFieldKey.DATASTREAM, DatastreamType.THUMBNAIL_LARGE);
assertTrue(filter instanceof NamedDatastreamFilter);
assertInstanceOf(NamedDatastreamFilter.class, filter);
}

@Test
public void MultipleDirectlyOwnedDatastreamsFilterTest() {
var datastreamTypes = new HashSet<DatastreamType>();
datastreamTypes.add(DatastreamType.THUMBNAIL_LARGE);
datastreamTypes.add(DatastreamType.THUMBNAIL_SMALL);
datastreamTypes.add(DatastreamType.JP2_ACCESS_COPY);
datastreamTypes.add(DatastreamType.FULLTEXT_EXTRACTION);
var filter = QueryFilterFactory.createFilter(SearchFieldKey.DATASTREAM, datastreamTypes);
assertTrue(filter instanceof MultipleDirectlyOwnedDatastreamsFilter);
assertInstanceOf(MultipleDirectlyOwnedDatastreamsFilter.class, filter);
}

@Test
public void HasPopulatedFieldFilterTest() {
var filter = QueryFilterFactory.createFilter(SearchFieldKey.STREAMING_TYPE);
assertTrue(filter instanceof HasPopulatedFieldFilter);
assertInstanceOf(HasPopulatedFieldFilter.class, filter);
}
}
20 changes: 0 additions & 20 deletions services-camel-app/src/main/webapp/WEB-INF/service-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,6 @@
<property name="titleRetrievalService" ref="titleRetrievalService" />
<property name="memberOrderService" ref="memberOrderService" />
</bean>

<bean id="addSmallThumbnailProcessor" class="edu.unc.lib.boxc.services.camel.images.AddDerivativeProcessor">
<constructor-arg value="#{T(edu.unc.lib.boxc.model.api.DatastreamType).THUMBNAIL_SMALL.getExtension()}" />
<constructor-arg value="${cdr.enhancement.path.thumbnail.small}" />
</bean>

<bean id="addLargeThumbnailProcessor" class="edu.unc.lib.boxc.services.camel.images.AddDerivativeProcessor">
<constructor-arg value="#{T(edu.unc.lib.boxc.model.api.DatastreamType).THUMBNAIL_LARGE.getExtension()}" />
<constructor-arg value="${cdr.enhancement.path.thumbnail.large}" />
</bean>

<bean id="addAccessCopyProcessor" class="edu.unc.lib.boxc.services.camel.images.AddDerivativeProcessor">
<constructor-arg value="#{T(edu.unc.lib.boxc.model.api.DatastreamType).JP2_ACCESS_COPY.getExtension()}" />
Expand All @@ -244,16 +234,6 @@
<constructor-arg value="${sourceImages.dir}" />
</bean>

<bean id="destroySmallThumbnailProcessor" class="edu.unc.lib.boxc.services.camel.destroyDerivatives.DestroyDerivativesProcessor">
<constructor-arg value="#{T(edu.unc.lib.boxc.model.api.DatastreamType).THUMBNAIL_SMALL.getExtension()}" />
<constructor-arg value="${cdr.enhancement.path.thumbnail.small}" />
</bean>

<bean id="destroyLargeThumbnailProcessor" class="edu.unc.lib.boxc.services.camel.destroyDerivatives.DestroyDerivativesProcessor">
<constructor-arg value="#{T(edu.unc.lib.boxc.model.api.DatastreamType).THUMBNAIL_LARGE.getExtension()}" />
<constructor-arg value="${cdr.enhancement.path.thumbnail.large}" />
</bean>

<bean id="destroyAccessCopyProcessor" class="edu.unc.lib.boxc.services.camel.destroyDerivatives.DestroyDerivativesProcessor">
<constructor-arg value="#{T(edu.unc.lib.boxc.model.api.DatastreamType).JP2_ACCESS_COPY.getExtension()}" />
<constructor-arg value="${cdr.enhancement.path.jp2}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export const briefObjectData = {
}
],
datastream: [
"thumbnail_small|image/png|fc77a9be-b49d-4f4e-b656-1644c9e964fc.png|png|6768|||",
"thumbnail_large|image/png|fc77a9be-b49d-4f4e-b656-1644c9e964fc.png|png|23535|||",
"event_log|application/n-triples|event_log.nt|nt|8206|urn:sha1:54fe67d57b965651e813eea1777c7f0332253168||",
"md_descriptive_history|text/xml|||916|urn:sha1:efb4f2b6226d2932229f0e2b89128ec9a651de71||",
"md_descriptive|text/xml|md_descriptive.xml|xml|283|urn:sha1:97f7dbdb806f724f9301445820ff1e0c9691cd6b||"
Expand Down
2 changes: 0 additions & 2 deletions static/js/vue-cdr-access/tests/fixtures/recordListFixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export const records_list = [
"datastream": [
"techmd_fits|text\/xml|aaa66f91-4870-4937-b7ba-06b015959e4f.xml|xml|5480|urn:sha1:82c71472051b8279a0fbaa537a340c57e3d842f6|aaa66f91-4870-4937-b7ba-06b015959e4f",
"original_file|image\/png|Screen+Shot+2018-10-17+at+3.02.53+PM.png|png|232738|urn:md5:f5397b230bb5dfa4d53f57ad35514405|aaa66f91-4870-4937-b7ba-06b015959e4f",
"thumbnail_small|image\/png|aaa66f91-4870-4937-b7ba-06b015959e4f.png|png|2454||aaa66f91-4870-4937-b7ba-06b015959e4f",
"thumbnail_large|image\/png|aaa66f91-4870-4937-b7ba-06b015959e4f.png|png|5892||aaa66f91-4870-4937-b7ba-06b015959e4f"
],
"fileDesc": [
"Portable Network Graphics"
Expand Down
2 changes: 0 additions & 2 deletions static/js/vue-cdr-access/tests/unit/aggregateRecord.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ const record = {
"original_file|image/jpeg|bee1.jpg|jpg|69481|urn:sha1:87d7bed6cb33c87c589cfcdc2a2ce6110712fabb|4053adf7-7bdc-4c9c-8769-8cc5da4ce81d|607x1024",
"techmd_fits|text/xml|techmd_fits.xml|xml|7013|urn:sha1:0c4a500c73146214d5fa08f278c0cdaadede79d0|4053adf7-7bdc-4c9c-8769-8cc5da4ce81d|",
"jp2|image/jp2|4053adf7-7bdc-4c9c-8769-8cc5da4ce81d.jp2|jp2|415163||4053adf7-7bdc-4c9c-8769-8cc5da4ce81d|",
"thumbnail_small|image/png|4053adf7-7bdc-4c9c-8769-8cc5da4ce81d.png|png|4802||4053adf7-7bdc-4c9c-8769-8cc5da4ce81d|",
"thumbnail_large|image/png|4053adf7-7bdc-4c9c-8769-8cc5da4ce81d.png|png|16336||4053adf7-7bdc-4c9c-8769-8cc5da4ce81d|",
"event_log|application/n-triples|event_log.nt|nt|4504|urn:sha1:b15940ee90b0f6d2b3ab1639eb7a266e54b621f2||",
"md_descriptive|text/xml|md_descriptive.xml|xml|459|urn:sha1:17e8dec55960ac14f100541993793dc8da231788||",
"md_descriptive_history|text/xml|||4976|urn:sha1:35e4b19ea3c58148c607b6537cc9af510406700c||"
Expand Down
2 changes: 0 additions & 2 deletions static/js/vue-cdr-access/tests/unit/collectionRecord.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const recordData = {
}
],
datastream: [
"thumbnail_small|image/png|fc77a9be-b49d-4f4e-b656-1644c9e964fc.png|png|6768|||",
"thumbnail_large|image/png|fc77a9be-b49d-4f4e-b656-1644c9e964fc.png|png|23535|||",
"event_log|application/n-triples|event_log.nt|nt|8206|urn:sha1:54fe67d57b965651e813eea1777c7f0332253168||",
"md_descriptive_history|text/xml|||916|urn:sha1:efb4f2b6226d2932229f0e2b89128ec9a651de71||",
"md_descriptive|text/xml|md_descriptive.xml|xml|283|urn:sha1:97f7dbdb806f724f9301445820ff1e0c9691cd6b||"
Expand Down
6 changes: 0 additions & 6 deletions static/js/vue-cdr-access/tests/unit/fileRecord.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ const record = {
"techmd_fits|text/xml|techmd_fits.xml|xml|4709|urn:sha1:5b0eabd749222a7c0bcdb92002be9fe3eff60128||",
"original_file|image/jpeg|beez||694904|urn:sha1:0d48dadb5d61ae0d41b4998280a3c39577a2f94a||2048x1536",
"jp2|image/jp2|4db695c0-5fd5-4abf-9248-2e115d43f57d.jp2|jp2|2189901|||",
"thumbnail_small|image/png|4db695c0-5fd5-4abf-9248-2e115d43f57d.png|png|6768|||",
"thumbnail_large|image/png|4db695c0-5fd5-4abf-9248-2e115d43f57d.png|png|23535|||",
"event_log|application/n-triples|event_log.nt|nt|4334|urn:sha1:aabf004766f954db4ac4ab9aa0a115bb10b708b4||"
],
parentCollectionId: "fc77a9be-b49d-4f4e-b656-1644c9e964fc",
Expand Down Expand Up @@ -166,8 +164,6 @@ const record = {
"original_file|image/jpeg|bee1.jpg|jpg|69481|urn:sha1:87d7bed6cb33c87c589cfcdc2a2ce6110712fabb||607x1024",
"techmd_fits|text/xml|techmd_fits.xml|xml|7013|urn:sha1:0c4a500c73146214d5fa08f278c0cdaadede79d0||",
"jp2|image/jp2|4053adf7-7bdc-4c9c-8769-8cc5da4ce81d.jp2|jp2|415163|||",
"thumbnail_small|image/png|4053adf7-7bdc-4c9c-8769-8cc5da4ce81d.png|png|4802|||",
"thumbnail_large|image/png|4053adf7-7bdc-4c9c-8769-8cc5da4ce81d.png|png|16336|||",
"event_log|application/n-triples|event_log.nt|nt|5852|urn:sha1:8d80f0de467fa650d4bc8568d4a958e5ced85f96||"
],
parentCollectionId: "fc77a9be-b49d-4f4e-b656-1644c9e964fc",
Expand Down Expand Up @@ -273,8 +269,6 @@ const record = {
"techmd_fits|text/xml|techmd_fits.xml|xml|4709|urn:sha1:5b0eabd749222a7c0bcdb92002be9fe3eff60128||",
"original_file|image/jpeg|beez||694904|urn:sha1:0d48dadb5d61ae0d41b4998280a3c39577a2f94a||2048x1536",
"jp2|image/jp2|4db695c0-5fd5-4abf-9248-2e115d43f57d.jp2|jp2|2189901|||",
"thumbnail_small|image/png|4db695c0-5fd5-4abf-9248-2e115d43f57d.png|png|6768|||",
"thumbnail_large|image/png|4db695c0-5fd5-4abf-9248-2e115d43f57d.png|png|23535|||",
"event_log|application/n-triples|event_log.nt|nt|4334|urn:sha1:aabf004766f954db4ac4ab9aa0a115bb10b708b4||"
],
parentCollectionId: "fc77a9be-b49d-4f4e-b656-1644c9e964fc",
Expand Down
Loading

0 comments on commit 44cab13

Please sign in to comment.