-
Notifications
You must be signed in to change notification settings - Fork 2
UFAL/Copy SWORDv2 fixes #957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* Removed `swordv2` duplicities from the `edit-media` request * Compose correctly the swordBaseUrl when the `path` is empty * Added better doc
* Using for instead of Iterator in removeBundle * Added a test to test file change in the Item * Use a default value for the plugin.single.org.dspace.sword2.WorkflowManager * Added a doc why we did that change --------- Co-authored-by: Matus Kasak <[email protected]> Co-authored-by: milanmajchrak <[email protected]>
WalkthroughThis update introduces new integration tests for the SWORDv2 API in DSpace, enhances the deletion logic to prevent redundant item deletions, adjusts URL construction to avoid extra path segments, and refactors bundle removal to prevent concurrent modification errors. Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Swordv2IT Test
participant API as SWORDv2 API
participant Config as Configuration
participant Item as DSpace Item
participant Workflow as WorkflowManager
Test->>API: Send deposit or edit request (URL config null)
API->>Config: Get swordv2-server.url
Config-->>API: Return null
API->>API: Construct default base URL
API->>Item: Create or update item
Test->>API: Retrieve item, check headers/content
Test->>API: DELETE workspace/workflow item
API->>Workflow: Use specific WorkflowManager
API->>Item: Delete item (check for prior deletion)
API-->>Test: Return 204 No Content
Test->>API: Retrieve deleted item
API-->>Test: Return 404 Not Found
Test->>API: PUT updated file to media resource
API->>Item: Update file content
API-->>Test: Return 204 No Content
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
dspace-swordv2/src/main/java/org/dspace/sword2/SwordUrlManager.java (1)
497-499: Guard against double slashes & blankswordPathinbuildSWORDUrl()
dspaceUrlmay already end with “/”, andswordPathcan be configured as empty or start/end with slashes.
The current concatenation can therefore yield URLs likehttps://dspace.org//swordv2or justhttps://dspace.org/(trailing slash but no path). A small normalisation makes this helper more robust for all call-sites.- return dspaceUrl + "/" + swordPath + (StringUtils.isNotBlank(path) ? "/" + path : ""); + StringBuilder url = new StringBuilder(dspaceUrl); + if (!dspaceUrl.endsWith("/")) { + url.append('/'); + } + if (StringUtils.isNotBlank(swordPath)) { + url.append(StringUtils.stripStart(swordPath, "/")); + } + if (StringUtils.isNotBlank(path)) { + url.append('/').append(StringUtils.stripStart(path, "/")); + } + return url.toString();This keeps behaviour identical for standard values, but prevents double-slashes and works even if
swordv2-server.pathis set to “” (allowed by the config defaults).dspace-swordv2/src/main/java/org/dspace/sword2/ContainerManagerDSpace.java (1)
800-814: Minor: linear scan over event list can be expensive in large batches
context.getEvents()may contain hundreds of entries during bulk operations. Consider short-circuiting once a match is found or holding aHashSet<UUID>of deleted IDs if this check is performed frequently.dspace-server-webapp/src/test/java/org/dspace/app/sword2/Swordv2IT.java (1)
639-645: Ensure test stream is closed to avoid file-handle leaks on Windows
getResourceAsStream("simple-article.pdf")is never closed. While short-lived in tests, Windows locks the file until GC closes the stream, potentially causing flaky behaviour.- InputStream pdf = getClass().getResourceAsStream("simple-article.pdf"); - WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, collection) + try (InputStream pdf = getClass().getResourceAsStream("simple-article.pdf")) { + WorkspaceItem witem = WorkspaceItemBuilder.createWorkspaceItem(context, collection) .withTitle("Test WorkspaceItem") .withIssueDate("2017-10-17") .withFulltext("simple-article.pdf", "/local/path/simple-article.pdf", pdf) .build(); + item = witem.getItem(); + }(This requires moving the
itemvariable outside thetryblock).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
dspace-server-webapp/src/test/java/org/dspace/app/sword2/Swordv2IT.java(4 hunks)dspace-swordv2/src/main/java/org/dspace/sword2/ContainerManagerDSpace.java(4 hunks)dspace-swordv2/src/main/java/org/dspace/sword2/SwordUrlManager.java(3 hunks)dspace-swordv2/src/main/java/org/dspace/sword2/VersionManager.java(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: dspace-dependencies / docker-build (linux/amd64, ubuntu-latest, true)
- GitHub Check: Run Integration Tests
- GitHub Check: Run Unit Tests
🔇 Additional comments (2)
dspace-swordv2/src/main/java/org/dspace/sword2/ContainerManagerDSpace.java (1)
767-773: Type consistency check when skipping second delete
isItemAlreadyDeleted(context, item.getID())compares theUUIDof the Item toevent.getSubjectID().
Please confirm thatEvent#getSubjectID()also returns ajava.util.UUID. In some older DSpace versions this method returned anint, in which case the equality check will always be false and the duplicate‐delete protection won’t work.If the types can differ, convert both sides to
String/UUIDbefore comparing, or useevent.getSubject().Example (only if required):
- if (event.getEventType() == Event.DELETE && event.getSubjectID().equals(itemUUID)) { + if (event.getEventType() == Event.DELETE + && itemUUID.toString().equals(event.getSubjectID().toString())) { return true; }dspace-swordv2/src/main/java/org/dspace/sword2/VersionManager.java (1)
47-58: Good fix – removes risk ofConcurrentModificationExceptionCollecting bundles into a separate list before removal is the safest approach here. The change keeps behavioural parity while hardening against runtime crashes.
* Fixed browse - the results are not lowercase (#954) * S3-CESNET direct downloads (#949) * Return headers for HEAD request - the bitstream download endpoint (#956) * The bitstream name is encoded in the URL. (#958) * SWORDv2 issues: Cannot update bitstream of archived Item. The swordv2 url is not composed correctly. Fixed deleting the workspace item when used org.dspace.sword2.WorkflowManagerDefault (#957) * The file preview process not required username and password in UI (#960) * Added translation of distribution license for collection to Czech (#952) * Added dead and deadSince to handle rest (#948) * Display community and collection handle (#961) * Embargo during submission not recorded in provenance (#950) * Allow to access File Downloader for any authorized user (ufal#1199) * allow.edit.metadata property should also work for submitters that are members of collection SUBMIT subgroup (ufal#1202) * Prevent error 500 for non admin user uploading file to bundle (ufal#1205) * Track downloads as pageviews (ufal#1209) * Loading the bitstreams - performance issue (ufal#1211)
Problem description
Reported issues
Not-reported issues
Analysis
(Write here, if there is needed describe some specific problem. Erase it, when it is not needed.)
Problems
(Write here, if some unexpected problems occur during solving issues. Erase it, when it is not needed.)
Summary by CodeRabbit
Bug Fixes
Tests