Skip to content

Commit

Permalink
Turn the DSpace deposit status ref into a URI
Browse files Browse the repository at this point in the history
  • Loading branch information
markpatton committed Dec 18, 2024
1 parent a1bf5f1 commit 236f078
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* Finally a workflow item is created referencing the workspace item in order to trigger submission.
*/
class DSpaceSession implements TransportSession {
private static final String DEPOSIT_STATUS_REF_PREFIX = "wsi:";
private static final Logger LOG = LoggerFactory.getLogger(DSpaceSession.class);

private final DspaceDepositService dspaceDepositService;
Expand Down Expand Up @@ -65,9 +66,12 @@ public TransportResponse send(PackageStream packageStream, Map<String, String> m
DocumentContext workspaceItemContext = null;

try {
workspaceItemId = Integer.parseInt(deposit.getDepositStatusRef());
String ref = deposit.getDepositStatusRef();

if (ref != null && ref.startsWith(DEPOSIT_STATUS_REF_PREFIX)) {
workspaceItemId = Integer.parseInt(ref.substring(DEPOSIT_STATUS_REF_PREFIX.length()));
}
} catch (NumberFormatException e) {
workspaceItemId = -1;
}

if (workspaceItemId == -1) {
Expand All @@ -76,7 +80,7 @@ public TransportResponse send(PackageStream packageStream, Map<String, String> m
workspaceItemId = workspaceItemContext.read("$._embedded.workspaceitems[0].id");

// Use the deposit status ref to mark that the workspace item was created
deposit.setDepositStatusRef(String.valueOf(workspaceItemId));
deposit.setDepositStatusRef(DEPOSIT_STATUS_REF_PREFIX + workspaceItemId);
passClient.updateObject(deposit);

LOG.debug("Created WorkspaceItem: {}", workspaceItemId);
Expand Down

0 comments on commit 236f078

Please sign in to comment.