mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
Modified CLI and renamed packages.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.iiif.canvasdimension.service;
|
||||
package org.dspace.iiif;
|
||||
|
||||
import org.dspace.content.Bitstream;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.iiif.canvasdimension;
|
||||
package org.dspace.iiif;
|
||||
|
||||
import static org.dspace.iiif.canvasdimension.Util.checkDimensions;
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.iiif.canvasdimension.service.IIIFApiQueryService;
|
||||
import org.dspace.iiif.util.IIIFSharedUtils;
|
||||
|
||||
|
@@ -17,11 +17,11 @@ import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.MissingArgumentException;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.dspace.app.util.factory.UtilServiceFactory;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
@@ -62,9 +62,7 @@ public class CanvasDimensionCLI {
|
||||
int max2Process = Integer.MAX_VALUE;
|
||||
|
||||
String identifier = null;
|
||||
String typeString = null;
|
||||
String eperson = null;
|
||||
int dsoType = -1;
|
||||
|
||||
Context context = new Context();
|
||||
IIIFCanvasDimensionService canvasProcessor = IIIFCanvasDimensionServiceFactory.getInstance()
|
||||
@@ -75,8 +73,6 @@ public class CanvasDimensionCLI {
|
||||
Options options = new Options();
|
||||
options.addOption("i", "identifier", true,
|
||||
"process IIIF canvas dimensions for images belonging to this identifier");
|
||||
options.addOption("t", "type", true,
|
||||
"type: COMMUNITY, COLLECTION or ITEM\"");
|
||||
options.addOption("e", "eperson", true,
|
||||
"email of eperson setting the canvas dimensions");
|
||||
options.addOption("f", "force", false,
|
||||
@@ -116,9 +112,10 @@ public class CanvasDimensionCLI {
|
||||
help.printHelp("CanvasDimension processor\n", options);
|
||||
System.out
|
||||
.println("\nUUID example: iiif-canvas-dimensions -e user@email.org " +
|
||||
"-i 1086306d-8a51-43c3-98b9-c3b00f49105f -t COLLECTION");
|
||||
"-i 1086306d-8a51-43c3-98b9-c3b00f49105f");
|
||||
System.out
|
||||
.println("\nHandle example: iiif-canvas-dimensions -e user@email.org -i 123456/21");
|
||||
.println("\nHandle example: iiif-canvas-dimensions -e user@email.org " +
|
||||
"-i 123456789/12");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@@ -139,24 +136,6 @@ public class CanvasDimensionCLI {
|
||||
System.out.println("An identifier for a Community, Collection, or Item must be provided.");
|
||||
System.exit(1);
|
||||
}
|
||||
if (line.hasOption('t')) {
|
||||
typeString = line.getOptionValue('t');
|
||||
if ("ITEM".equalsIgnoreCase(typeString)) {
|
||||
dsoType = Constants.ITEM;
|
||||
} else if ("COLLECTION".equals(typeString)) {
|
||||
dsoType = Constants.COLLECTION;
|
||||
} else if ("COMMUNITY".equalsIgnoreCase(typeString)) {
|
||||
dsoType = Constants.COMMUNITY;
|
||||
}
|
||||
} else {
|
||||
// If the identifier is a handle dsoType is not required.
|
||||
if (identifier.indexOf('/') == -1) {
|
||||
HelpFormatter help = new HelpFormatter();
|
||||
help.printHelp("CanvasDimension processor\n", options);
|
||||
System.out.println("A DSpace type must be provided: COMMUNITY, COLLECTION or ITEM.");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
if (line.hasOption('m')) {
|
||||
max2Process = Integer.parseInt(line.getOptionValue('m'));
|
||||
if (max2Process <= 1) {
|
||||
@@ -185,17 +164,14 @@ public class CanvasDimensionCLI {
|
||||
DSpaceObject dso = null;
|
||||
if (identifier.indexOf('/') != -1) {
|
||||
dso = HandleServiceFactory.getInstance().getHandleService().resolveToObject(context, identifier);
|
||||
} else if (dsoType == Constants.COMMUNITY) {
|
||||
dso = ContentServiceFactory.getInstance().getCommunityService().find(context, UUID.fromString(identifier));
|
||||
} else if (dsoType == Constants.COLLECTION) {
|
||||
dso = ContentServiceFactory.getInstance().getCollectionService().find(context, UUID.fromString(identifier));
|
||||
} else if (dsoType == Constants.ITEM) {
|
||||
dso = ContentServiceFactory.getInstance().getItemService().find(context, UUID.fromString(identifier));
|
||||
} else {
|
||||
dso = UtilServiceFactory.getInstance().getDSpaceObjectUtils()
|
||||
.findDSpaceObject(context, UUID.fromString(identifier));
|
||||
}
|
||||
|
||||
if (dso == null) {
|
||||
throw new IllegalArgumentException("Cannot resolve "
|
||||
+ identifier + " to a DSpace object using type: " + typeString);
|
||||
+ identifier + " to a DSpace object.");
|
||||
}
|
||||
|
||||
EPerson user;
|
||||
|
@@ -31,7 +31,7 @@ import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.DSpaceObjectService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.iiif.canvasdimension.service.IIIFApiQueryService;
|
||||
import org.dspace.iiif.IIIFApiQueryService;
|
||||
import org.dspace.iiif.canvasdimension.service.IIIFCanvasDimensionService;
|
||||
import org.dspace.iiif.util.IIIFSharedUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.iiif;
|
||||
package org.dspace.iiif.consumer;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.iiif;
|
||||
package org.dspace.iiif.consumer;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.CacheManager;
|
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.iiif;
|
||||
package org.dspace.iiif.consumer;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
@@ -5,7 +5,7 @@
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.canvasdimension;
|
||||
package org.dspace.iiif.canvasdimension;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -97,7 +97,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
String handle = iiifItem.getHandle();
|
||||
execCanvasScriptHandle(handle);
|
||||
execCanvasScript(handle);
|
||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||
@@ -128,7 +128,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
String id = col1.getID().toString();
|
||||
execCanvasScript(id, "COLLECTION");
|
||||
execCanvasScript(id);
|
||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||
@@ -159,7 +159,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
String id = child1.getID().toString();
|
||||
execCanvasScript(id, "COMMUNITY");
|
||||
execCanvasScript(id);
|
||||
|
||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
@@ -191,7 +191,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
String handle = parentCommunity.getHandle();
|
||||
execCanvasScriptHandle(handle);
|
||||
execCanvasScript(handle);
|
||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||
@@ -235,7 +235,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
String id = parentCommunity.getID().toString();
|
||||
execCanvasScript(id, "COMMUNITY");
|
||||
execCanvasScript(id);
|
||||
|
||||
// All bitstreams should be updated with canvas metadata.
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
@@ -275,7 +275,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
String id = iiifItem.getID().toString();
|
||||
execCanvasScriptForceOption(id, "ITEM");
|
||||
execCanvasScriptForceOption(id);
|
||||
|
||||
// The existing metadata should be updated
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
@@ -309,7 +309,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
String id = col1.getID().toString();
|
||||
execCanvasScriptForceOption(id, "COLLECTION");
|
||||
execCanvasScriptForceOption(id);
|
||||
|
||||
// The existing metadata should be updated
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
@@ -343,7 +343,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
String handle = iiifItem.getHandle();
|
||||
execCanvasScriptHandle(handle);
|
||||
execCanvasScript(handle);
|
||||
// The existing canvas metadata should be unchanged
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||
@@ -406,7 +406,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
String id = parentCommunity.getID().toString();
|
||||
|
||||
execCanvasScriptWithMaxRecs(id, "COMMUNITY");
|
||||
execCanvasScriptWithMaxRecs(id);
|
||||
// check System.out for number of items processed.
|
||||
assertEquals("2 IIIF items were processed.\n", outContent.toString());
|
||||
}
|
||||
@@ -465,7 +465,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
String id = parentCommunity.getID().toString();
|
||||
|
||||
execCanvasScriptWithSkipList(id, "COMMUNITY", col2.getHandle() + "," + col3.getHandle());
|
||||
execCanvasScriptWithSkipList(id,col2.getHandle() + "," + col3.getHandle());
|
||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||
@@ -528,7 +528,7 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
String id = parentCommunity.getID().toString();
|
||||
|
||||
execCanvasScriptWithSkipList(id, "COMMUNITY", col2.getHandle());
|
||||
execCanvasScriptWithSkipList(id, col2.getHandle());
|
||||
// The test image is small so the canvas dimension should be doubled, e.g. height 200 -> height 400
|
||||
assertTrue(bitstream.getMetadata().stream()
|
||||
.filter(m -> m.getMetadataField().toString('.').contentEquals(METADATA_IIIF_HEIGHT))
|
||||
@@ -546,26 +546,21 @@ public class CanvasDimensionsIT extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
}
|
||||
|
||||
private void execCanvasScriptHandle(String handle) throws Exception {
|
||||
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", handle);
|
||||
private void execCanvasScript(String id) throws Exception {
|
||||
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id);
|
||||
}
|
||||
|
||||
private void execCanvasScript(String id, String type) throws Exception {
|
||||
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id, "-t", type);
|
||||
private void execCanvasScriptForceOption(String id) throws Exception {
|
||||
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id, "-f");
|
||||
}
|
||||
|
||||
private void execCanvasScriptForceOption(String id, String type) throws Exception {
|
||||
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id, "-f", "-t", type);
|
||||
}
|
||||
|
||||
private void execCanvasScriptWithMaxRecs(String id, String type) throws Exception {
|
||||
private void execCanvasScriptWithMaxRecs(String id) throws Exception {
|
||||
// maximum 2
|
||||
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i",
|
||||
id, "-t", type, "-m", "2", "-f", "-q");
|
||||
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id, "-m", "2", "-f", "-q");
|
||||
}
|
||||
|
||||
private void execCanvasScriptWithSkipList(String id, String type, String skip) throws Exception {
|
||||
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id, "-t", type, "-s", skip, "-f");
|
||||
private void execCanvasScriptWithSkipList(String id, String skip) throws Exception {
|
||||
runDSpaceScript("iiif-canvas-dimensions", "-e", "admin@email.com", "-i", id, "-s", skip, "-f");
|
||||
}
|
||||
|
||||
}
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
@@ -733,7 +733,7 @@ event.consumer.authority.class = org.dspace.authority.indexer.AuthorityConsumer
|
||||
event.consumer.authority.filters = Item+Modify|Modify_Metadata
|
||||
|
||||
# iiif consumer
|
||||
event.consumer.iiif.class = org.dspace.iiif.IIIFCacheEventConsumer
|
||||
event.consumer.iiif.class = org.dspace.iiif.consumer.IIIFCacheEventConsumer
|
||||
event.consumer.iiif.filters = Item+Modify:Item+Modify_Metadata:Item+Delete:Item+Remove:Bundle+ALL:Bitstream+All
|
||||
|
||||
# ...set to true to enable testConsumer messages to standard output
|
||||
|
@@ -5,6 +5,6 @@
|
||||
|
||||
<bean id="iiifCanvasDimensionServiceFactory" class="org.dspace.iiif.canvasdimension.factory.IIIFCanvasDimensionServiceFactoryImpl"/>
|
||||
<bean class="org.dspace.iiif.canvasdimension.IIIFCanvasDimensionServiceImpl" scope="prototype"/>
|
||||
<bean class="org.dspace.iiif.canvasdimension.IIIFApiQueryServiceImpl" scope="prototype"/>
|
||||
<bean class="org.dspace.iiif.IIIFApiQueryServiceImpl" scope="prototype"/>
|
||||
|
||||
</beans>
|
||||
|
Reference in New Issue
Block a user