-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BXC-4712 update enhancements for thumbnails (#1793)
* BXC-4712 update enhancements for thumbnails * BXC-4712 remove unused constant * BXC-4712 adding new request and processors and updating thumbnail router * BXC-4712 update tsts and message senders * BXC-4712 fix router test * BXC-4712 remove unused variable * BXC-4712 cleanup * extra space removed * BXC-4712 make separate queues for importing thumbnails * BXC-4712 fix import thumbnail router test * BXC-4712 update URI to string * BXC-4712 update storage path to string * BXC-4712 update thumbnail datatream choice * BXC-4712 add datastream test * BXC-4712 a bit of cleanup * BXC-4712 working on datastream controller IT * BXC-4712 adjusting download image service * BXC-4712 set up test corpus datastreams correctly * BXC-4712 trigger indexing * BXC-4712 fix tests * BXC-4712 cleanup imports
- Loading branch information
1 parent
9852ed5
commit 1081c21
Showing
27 changed files
with
519 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
file:/tmp/boxc_test_storage/ | ||
file:/tmp/boxc_test_storage/ |
52 changes: 52 additions & 0 deletions
52
...-jms/src/main/java/edu/unc/lib/boxc/operations/jms/thumbnails/ImportThumbnailRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package edu.unc.lib.boxc.operations.jms.thumbnails; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import edu.unc.lib.boxc.auth.api.models.AgentPrincipals; | ||
import edu.unc.lib.boxc.auth.fcrepo.models.AgentPrincipalsImpl; | ||
|
||
import java.nio.file.Path; | ||
|
||
/** | ||
* Request object for importing an image as thumbnail for a collection, folder, or admin unit | ||
* | ||
* @author snluong | ||
*/ | ||
public class ImportThumbnailRequest { | ||
@JsonDeserialize(as = AgentPrincipalsImpl.class) | ||
private AgentPrincipals agent; | ||
private String mimetype; | ||
private Path storagePath; | ||
private String pidString; | ||
|
||
public String getPidString() { | ||
return pidString; | ||
} | ||
|
||
public void setPidString(String pidString) { | ||
this.pidString = pidString; | ||
} | ||
|
||
public AgentPrincipals getAgent() { | ||
return agent; | ||
} | ||
|
||
public void setAgent(AgentPrincipals agent) { | ||
this.agent = agent; | ||
} | ||
|
||
public String getMimetype() { | ||
return mimetype; | ||
} | ||
|
||
public void setMimetype(String mimetype) { | ||
this.mimetype = mimetype; | ||
} | ||
|
||
public Path getStoragePath() { | ||
return storagePath; | ||
} | ||
|
||
public void setStoragePath(Path storagePath) { | ||
this.storagePath = storagePath; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...edu/unc/lib/boxc/operations/jms/thumbnails/ImportThumbnailRequestSerializationHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package edu.unc.lib.boxc.operations.jms.thumbnails; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.ObjectReader; | ||
import com.fasterxml.jackson.databind.ObjectWriter; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Helper methods for serializing and deserializing import thumbnail requests | ||
* | ||
* @author snluong | ||
*/ | ||
public class ImportThumbnailRequestSerializationHelper { | ||
private static final ObjectWriter REQUEST_WRITER; | ||
private static final ObjectReader REQUEST_READER; | ||
static { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
REQUEST_WRITER = mapper.writerFor(ImportThumbnailRequest.class); | ||
REQUEST_READER = mapper.readerFor(ImportThumbnailRequest.class); | ||
} | ||
|
||
private ImportThumbnailRequestSerializationHelper() { | ||
} | ||
|
||
/** | ||
* Transform request into a JSON string | ||
* @param request | ||
* @return | ||
* @throws IOException | ||
*/ | ||
public static String toJson(ImportThumbnailRequest request) throws IOException { | ||
return REQUEST_WRITER.writeValueAsString(request); | ||
} | ||
|
||
/** | ||
* Transform JSON string to an ImportThumbnailRequest | ||
* @param json | ||
* @return | ||
* @throws IOException | ||
*/ | ||
public static ImportThumbnailRequest toRequest(String json) throws IOException { | ||
return REQUEST_READER.readValue(json); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...main/java/edu/unc/lib/boxc/services/camel/thumbnails/ImportThumbnailRequestProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package edu.unc.lib.boxc.services.camel.thumbnails; | ||
|
||
import edu.unc.lib.boxc.model.fcrepo.ids.PIDs; | ||
import edu.unc.lib.boxc.operations.jms.thumbnails.ImportThumbnailRequestSerializationHelper; | ||
import org.apache.camel.Exchange; | ||
import org.apache.camel.Processor; | ||
|
||
import java.io.IOException; | ||
|
||
import static edu.unc.lib.boxc.services.camel.util.CdrFcrepoHeaders.CdrBinaryMimeType; | ||
import static edu.unc.lib.boxc.services.camel.util.CdrFcrepoHeaders.CdrBinaryPath; | ||
import static org.fcrepo.camel.FcrepoHeaders.FCREPO_URI; | ||
|
||
/** | ||
* Processing requests to import images to use as a thumbnail for a non-work Repository object | ||
* | ||
* @author snluong | ||
*/ | ||
public class ImportThumbnailRequestProcessor implements Processor { | ||
@Override | ||
public void process(Exchange exchange) throws IOException { | ||
var in = exchange.getIn(); | ||
var request = ImportThumbnailRequestSerializationHelper.toRequest(in.getBody(String.class)); | ||
var mimetype = request.getMimetype(); | ||
var storagePath = request.getStoragePath(); | ||
var pidString = request.getPidString(); | ||
var repoPath = PIDs.get(pidString).getRepositoryPath(); | ||
|
||
in.setHeader(CdrBinaryPath, storagePath.toString()); | ||
in.setHeader(CdrBinaryMimeType, mimetype); | ||
in.setHeader(FCREPO_URI, repoPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.