mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Let Curation CLI accept uuid identifiers
(cherry picked from commit 5020689095
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
fbb496e1c6
commit
85a9e4b731
@@ -24,6 +24,8 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.io.output.NullOutputStream;
|
||||
import org.dspace.app.util.DSpaceObjectUtilsImpl;
|
||||
import org.dspace.app.util.service.DSpaceObjectUtils;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
@@ -35,6 +37,7 @@ import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.scripts.DSpaceRunnable;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.utils.DSpace;
|
||||
|
||||
/**
|
||||
@@ -45,7 +48,9 @@ import org.dspace.utils.DSpace;
|
||||
public class Curation extends DSpaceRunnable<CurationScriptConfiguration> {
|
||||
|
||||
protected EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
|
||||
protected DSpaceObjectUtils dspaceObjectUtils = DSpaceServicesFactory.getInstance().getServiceManager()
|
||||
.getServiceByName(DSpaceObjectUtilsImpl.class.getName(), DSpaceObjectUtilsImpl.class);
|
||||
HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
protected Context context;
|
||||
private CurationClientOptions curationClientOptions;
|
||||
|
||||
@@ -345,9 +350,29 @@ public class Curation extends DSpaceRunnable<CurationScriptConfiguration> {
|
||||
|
||||
if (this.commandLine.hasOption('i')) {
|
||||
this.id = this.commandLine.getOptionValue('i').toLowerCase();
|
||||
DSpaceObject dso;
|
||||
if (!this.id.equalsIgnoreCase("all")) {
|
||||
HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
DSpaceObject dso;
|
||||
// First, try to parse the id as a UUID. If that fails, treat it as a handle.
|
||||
UUID uuid = null;
|
||||
try {
|
||||
uuid = UUID.fromString(id);
|
||||
} catch (Exception e) {
|
||||
// It's not a UUID, proceed to treat it as a handle.
|
||||
}
|
||||
if (uuid != null) {
|
||||
try {
|
||||
dso = dspaceObjectUtils.findDSpaceObject(context, uuid);
|
||||
if (dso != null) {
|
||||
// We already resolved an object, return early
|
||||
return;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String error = "SQLException trying to find dso with uuid " + uuid;
|
||||
super.handler.logError(error);
|
||||
throw new RuntimeException(error, e);
|
||||
}
|
||||
}
|
||||
// If we get here, the id is not a UUID, so we assume it's a handle.
|
||||
try {
|
||||
dso = handleService.resolveToObject(this.context, id);
|
||||
} catch (SQLException e) {
|
||||
|
Reference in New Issue
Block a user