Skip to content

Commit 5311248

Browse files
committed
[DURACOM-461] Added DSpaceObjectDeletionProcessCli
1 parent 086e1a1 commit 5311248

5 files changed

Lines changed: 639 additions & 387 deletions

File tree

dspace-api/src/main/java/org/dspace/deletion/process/DSpaceObjectDeletionProcess.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public void internalRun() throws Exception {
101101
DSpaceObject dso = dSpaceObjectOptional.get();
102102

103103
if (!authorizeService.isAdmin(context, dso)) {
104-
throw new AuthorizeException("Current user is not eligible to execute script: " + OBJECT_DELETION_SCRIPT);
104+
throw new AuthorizeException("Current user is not eligible to execute script: " +
105+
"'" + OBJECT_DELETION_SCRIPT + "'");
105106
}
106107

107108
var info = "Performing deletion of DSpaceObject (and all child objects) for type=%s and uuid=%s";

dspace-api/src/main/java/org/dspace/deletion/process/DSpaceObjectDeletionProcessCli.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.apache.commons.cli.ParseException;
1313
import org.dspace.eperson.EPerson;
1414
import org.dspace.eperson.factory.EPersonServiceFactory;
15-
import org.dspace.utils.DSpace;
1615

1716
/**
1817
* Extension of {@link DSpaceObjectDeletionProcess} for CLI execution.
@@ -26,12 +25,12 @@ public class DSpaceObjectDeletionProcessCli extends DSpaceObjectDeletionProcess
2625

2726
/**
2827
* Assigns the current user to the context based on the email parameter for CLI execution.
29-
*
28+
*
3029
* This method overrides the parent implementation to support command-line execution
3130
* with explicit user specification via the -e (email) parameter. This is required for
3231
* CLI scenarios where the script is invoked directly from the command line rather than
3332
* through the REST API or other programmatic interfaces.
34-
*
33+
*
3534
* Process:
3635
* <ul>
3736
* <li>Creates a new DSpace Context instance</li>
@@ -40,14 +39,14 @@ public class DSpaceObjectDeletionProcessCli extends DSpaceObjectDeletionProcess
4039
* <li>Validates that the EPerson exists in the system</li>
4140
* <li>Sets the found EPerson as the current user in the context</li>
4241
* </ul>
43-
*
42+
*
4443
* Usage Example:
4544
* <pre>
4645
* ./dspace object-deletion -e admin@example.com -i [object-uuid]
4746
* </pre>
4847
*
49-
* @throws SQLException if a database error occurs during EPerson lookup
50-
* @throws ParseException if the required -e parameter is missing from command line
48+
* @throws SQLException if a database error occurs during EPerson lookup
49+
* @throws ParseException if the required -e parameter is missing from command line
5150
* @throws IllegalArgumentException if the provided email address doesn't match any existing EPerson
5251
*/
5352
@Override
@@ -67,4 +66,10 @@ protected void assignCurrentUserInContext() throws SQLException, ParseException
6766
}
6867
}
6968

69+
@Override
70+
public DSpaceObjectDeletionProcessScriptConfiguration<DSpaceObjectDeletionProcess> getScriptConfiguration() {
71+
org.dspace.kernel.ServiceManager sm = new org.dspace.utils.DSpace().getServiceManager();
72+
return sm.getServiceByName(OBJECT_DELETION_SCRIPT, DSpaceObjectDeletionProcessCliScriptConfiguration.class);
73+
}
74+
7075
}

0 commit comments

Comments
 (0)