Skip to content

Commit

Permalink
Merge main into Zip files development (#1845)
Browse files Browse the repository at this point in the history
* Bxc 4734 thumbnail placeholder (#1830)

* BXC-4734 update for thumbnail placeholder usage

* BXC-4734 remove placeholder test from download image IT

* BXC-4734 change null to empty array

* BXC-4734 clean up code

* BXC-4734 update file extension

* Block jp2 processing for x-raw-panasonic. Add unit test (#1829)

* Bxc 4761 replace existing bug (#1832)

* BXC-4761 set force to true to force access copy regeneration

* BXC-4761 set to string true

* Bxc 4760 admin unit thumb (#1833)

* BXC-4760 excuse admin unit from permissions check

* BXC-4760 move method

* Display filesize on file objects

* Move file downloads into the files table (#1831)

* Move image download access into the files table

* Update tests and fix issues found by tests

* Fix issue with empty download column showing up, if there is no downloadable content

* Add translations back in and check dropdown urls, instead of text, as translations aren't in scope in the tests.

* Don't show modal if user is logged in

* Check for restricted content, not downloadable images, and pass the file's info into the restriction check instead of using the work's info.

* Fix display issue and modal tests

* Use login modal on file pages

* Don't show modal login if logging in doesn't grant further access.

* Fix layout of buttons on small screens and add "view" item back in for file records

* Display login button for folders and collections

* Fix button layout

* Fix button layout in the files table

* Fix issue with no valid download sizes, but user canViewOriginal

* Set default as logged in

* Check if JP2 exists and rename restrictedContent component

* block jp2 processing for image/vnd.microsoft.icon and add test (#1837)

* Fix merge of changes in restricted content into object actions

* Fixed bug when format field not present on brief record, which is always the case for containers. Fix nesting of briefObject within response objects in tests, since sometimes it was nested, double nested, or not nested. restrictedFiles now uses restrictedContent to DRY it up, and restrictedContent can now also deal with data being nested or not

* Only allow view button on files

* Fixes to spacing of restricted content sections

---------

Co-authored-by: sharonl <[email protected]>
Co-authored-by: lfarrell <[email protected]>
Co-authored-by: krwong <[email protected]>
  • Loading branch information
4 people authored Dec 3, 2024
1 parent c5815a9 commit a3f2ff2
Show file tree
Hide file tree
Showing 27 changed files with 13,934 additions and 16,085 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ public List<SolrInputDocument> populate() {
newDoc.addField("ancestorIds", makeAncestorIds(pid1, pid2));
newDoc.addField("ancestorPath", makeAncestorPath(pid1, pid2));
newDoc.addField("resourceType", ResourceType.Work.name());
imgDatastreams.set(0, imgDatastreams.get(0) + pid6File.getId());
imgDatastreams.set(1, imgDatastreams.get(1) + pid6File.getId());
newDoc.addField(SearchFieldKey.DATASTREAM.getSolrField(), imgDatastreams);
List<String> workDatastreams = Arrays.asList(
ORIGINAL_FILE.getId() + "|image/png|file.png|png|766|urn:sha1:checksum|" + pid6File.getId() + "|1200x1200",
DatastreamType.JP2_ACCESS_COPY.getId() + "|image/jp2|bunny.jp2|jp2|||" + pid6File.getId() + "|1200x1200");
newDoc.addField(SearchFieldKey.DATASTREAM.getSolrField(), workDatastreams);
newDoc.addField(SearchFieldKey.FILE_FORMAT_CATEGORY.getSolrField(), ContentCategory.image.getDisplayName());
newDoc.addField(SearchFieldKey.FILE_FORMAT_TYPE.getSolrField(), "png");
docs.add(newDoc);
Expand All @@ -152,6 +153,9 @@ public List<SolrInputDocument> populate() {
newDoc.addField("ancestorIds", makeAncestorIds(pid1, pid3));
newDoc.addField("ancestorPath", makeAncestorPath(pid1));
newDoc.addField("resourceType", "Collection");
List<String> collection2Datastream = List.of(
DatastreamType.JP2_ACCESS_COPY.getId() + "|image/jp2|bunny.jp2|jp2|||" + pid2.getId() + "|120x120");
newDoc.addField(SearchFieldKey.DATASTREAM.getSolrField(), collection2Datastream);
docs.add(newDoc);

return docs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static String getImageServiceId(String id) {
* @return
*/
public static String getImageServerEncodedId(String id) {
return URLEncoder.encode(getImageServiceId(id));
return URLEncoder.encode(getImageServiceId(id), StandardCharsets.UTF_8);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public DatastreamImpl(String datastream) {

@Override
public String toString() {
//DS name|mimetype|extension|filesize|checksum|owner|extent
//DS name|mimetype|filename|extension|filesize|checksum|owner|extent
StringBuilder sb = new StringBuilder();
if (name != null) {
sb.append(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class ImageDerivativeProcessor implements Processor {

private static final Pattern MIMETYPE_PATTERN = Pattern.compile("^(image.*$|application.*?(photoshop|psd)$)");

private static final Pattern DISALLOWED_PATTERN = Pattern.compile(".*(vnd\\.fpx|x-icon).*");
private static final Pattern DISALLOWED_PATTERN =
Pattern.compile(".*(vnd\\.fpx|x-icon|x-raw-panasonic|vnd\\.microsoft\\.icon).*");

/**
* Returns true if the subject of the exchange is a binary which
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public void process(Exchange exchange) throws IOException {
in.setHeader(CdrBinaryPath, storagePath.toString());
in.setHeader(CdrBinaryMimeType, mimetype);
in.setHeader(FCREPO_URI, repoPath);
// force access copy regeneration when importing a thumbnail
in.setHeader("force", "true");
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package edu.unc.lib.boxc.services.camel.images;

import edu.unc.lib.boxc.services.camel.util.CdrFcrepoHeaders;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.openMocks;

/**
* @author bbpennel
*/
public class ImageDerivativeProcessorTest {
@Mock
private Exchange exchange;
@Mock
private Message messageIn;
private AutoCloseable closeable;
private ImageDerivativeProcessor processor;

@BeforeEach
public void init() {
closeable = openMocks(this);

when(exchange.getIn()).thenReturn(messageIn);
when(messageIn.getHeader(CdrFcrepoHeaders.CdrBinaryPath)).thenReturn("path/to/binary");

processor = new ImageDerivativeProcessor();
}

@AfterEach
public void close() throws Exception {
closeable.close();
}

@Test
public void testAllowedImageTypePanasonicRaw() {
when(messageIn.getHeader(CdrFcrepoHeaders.CdrBinaryMimeType)).thenReturn("image/x-raw-panasonic");

assertFalse(ImageDerivativeProcessor.allowedImageType(exchange));
}

@Test
public void testAllowedImageTypePanasonicRw2() {
when(messageIn.getHeader(CdrFcrepoHeaders.CdrBinaryMimeType)).thenReturn("image/x-panasonic-rw2");

assertTrue(ImageDerivativeProcessor.allowedImageType(exchange));
}

@Test
public void testAllowedImageTypeIcon() {
when(messageIn.getHeader(CdrFcrepoHeaders.CdrBinaryMimeType)).thenReturn("image/x-icon");

assertFalse(ImageDerivativeProcessor.allowedImageType(exchange));
}

@Test
public void testAllowedImageTypeJpeg() {
when(messageIn.getHeader(CdrFcrepoHeaders.CdrBinaryMimeType)).thenReturn("image/jpeg");

assertTrue(ImageDerivativeProcessor.allowedImageType(exchange));
}

@Test
public void testAllowedImageTypePhotoshop() {
when(messageIn.getHeader(CdrFcrepoHeaders.CdrBinaryMimeType)).thenReturn("application/photoshop");

assertTrue(ImageDerivativeProcessor.allowedImageType(exchange));
}

@Test
public void testAllowedImageTypeMicrosoft() {
when(messageIn.getHeader(CdrFcrepoHeaders.CdrBinaryMimeType)).thenReturn("image/vnd.microsoft.icon");

assertFalse(ImageDerivativeProcessor.allowedImageType(exchange));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void testImportThumbnail() throws IOException {
verify(message).setHeader(FCREPO_URI, pid.getRepositoryPath());
verify(message).setHeader(CdrBinaryMimeType, mimetype);
verify(message).setHeader(CdrBinaryPath, path.toString());
verify(message).setHeader("force", "true");
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion static/css/sass/cdr_ui_styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,6 @@ table.dataTable {
.restricted-access {
border: 1px solid;
border-radius: 5px;
padding: 15px;

.button {
text-align: left;
Expand Down Expand Up @@ -1092,6 +1091,7 @@ a.navbar-item:hover {
}
}


.relateditem {
margin-left: 5px;
margin-right: 5px;
Expand Down
Loading

0 comments on commit a3f2ff2

Please sign in to comment.