Skip to content

Commit 49c0b96

Browse files
authored
Merge pull request #1744 from UNC-Libraries/bxc-4590
BXC-4590 - Skip Derivatives for icon files
2 parents 5de6bd7 + dbb5c2d commit 49c0b96

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

services-camel-app/src/main/java/edu/unc/lib/boxc/services/camel/images/ImageDerivativeProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class ImageDerivativeProcessor implements Processor {
2020

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

23-
private static final Pattern DISALLOWED_PATTERN = Pattern.compile(".*(vnd\\.fpx).*");
23+
private static final Pattern DISALLOWED_PATTERN = Pattern.compile(".*(vnd\\.fpx|x-icon).*");
2424

2525
/**
2626
* Returns true if the subject of the exchange is a binary which

services-camel-app/src/test/java/edu/unc/lib/boxc/services/camel/images/ImageEnhancementsRouterTest.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@
3636
import org.apache.camel.test.spring.CamelSpringTestSupport;
3737
import org.apache.commons.io.FileUtils;
3838
import org.junit.After;
39-
import org.junit.Before;
4039
import org.junit.Test;
4140
import org.springframework.context.support.AbstractApplicationContext;
4241
import org.springframework.context.support.ClassPathXmlApplicationContext;
4342

44-
import edu.unc.lib.boxc.services.camel.images.AddDerivativeProcessor;
45-
4643
public class ImageEnhancementsRouterTest extends CamelSpringTestSupport {
4744
private static final String EVENT_NS = "http://fedora.info/definitions/v4/event#";
4845
private static final String EVENT_TYPE = "org.fcrepo.jms.eventType";
@@ -423,6 +420,7 @@ public void testAccessCopyRouteForceFileExists() throws Exception {
423420
public void testAccessCopyRejection() throws Exception {
424421
createContext(accessCopyRoute);
425422

423+
when(addAccessCopyProcessor.needsRun(any())).thenReturn(true);
426424
getMockEndpoint("mock:process.enhancement.imageAccessCopy").expectedMessageCount(0);
427425

428426
Map<String, Object> headers = createEvent(fileID, eventTypes, "false");
@@ -438,6 +436,7 @@ public void testAccessCopyRejection() throws Exception {
438436
public void testAccessCopyDisallowedImageType() throws Exception {
439437
createContext(accessCopyRoute);
440438

439+
when(addAccessCopyProcessor.needsRun(any())).thenReturn(true);
441440
getMockEndpoint("mock:exec:/bin/sh").expectedMessageCount(0);
442441

443442
Map<String, Object> headers = createEvent(fileID, eventTypes, "false");
@@ -449,6 +448,23 @@ public void testAccessCopyDisallowedImageType() throws Exception {
449448
assertMockEndpointsSatisfied();
450449
}
451450

451+
@Test
452+
public void testAccessCopyIconFile() throws Exception {
453+
createContext(accessCopyRoute);
454+
455+
when(addAccessCopyProcessor.needsRun(any())).thenReturn(true);
456+
getMockEndpoint("mock:exec:/bin/sh").expectedMessageCount(0);
457+
458+
Map<String, Object> headers = createEvent(fileID, eventTypes, "false");
459+
headers.put(CdrBinaryMimeType, "image/x-icon");
460+
461+
template.sendBodyAndHeaders("", headers);
462+
463+
verify(addAccessCopyProcessor).needsRun(any(Exchange.class));
464+
verify(addAccessCopyProcessor, never()).process(any(Exchange.class));
465+
assertMockEndpointsSatisfied();
466+
}
467+
452468
private void createContext(String routeName) throws Exception {
453469
context.getRouteDefinition(routeName).adviceWith(context, new AdviceWithRouteBuilder() {
454470
@Override

0 commit comments

Comments
 (0)