-
Notifications
You must be signed in to change notification settings - Fork 2
ufal/embargo during submission not recorded in provenance #950
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
ufal/embargo during submission not recorded in provenance #950
Conversation
WalkthroughA new overloaded method for setting bitstream policies using an access conditions string was introduced in the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant BitstreamResourcePolicyAddPatchOperation
participant ProvenanceService
participant Item
Client->>BitstreamResourcePolicyAddPatchOperation: add()
BitstreamResourcePolicyAddPatchOperation->>BitstreamResourcePolicyAddPatchOperation: Apply resource policies
loop For each new AccessConditionDTO
BitstreamResourcePolicyAddPatchOperation->>ProvenanceService: setBitstreamPolicies(context, bitstream, item, accConditionName)
ProvenanceService->>Item: Add provenance metadata
end
BitstreamResourcePolicyAddPatchOperation->>Client: Return result
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ 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: 0
🧹 Nitpick comments (1)
dspace-server-webapp/src/main/java/org/dspace/app/rest/submit/factory/impl/BitstreamResourcePolicyAddPatchOperation.java (1)
80-85: Consider optimizing context commits and adding null checks.The current implementation iterates through all access conditions and commits after processing them all, which is good. However, consider these improvements:
- Add null check for the access condition name to prevent potential NullPointerExceptions
- Move the context.commit() outside the bitstream loop for better performance when multiple bitstreams are processed
if (CollectionUtils.isNotEmpty(newAccessConditions)) { BitstreamResourcePolicyUtils.findApplyResourcePolicy(context, uploadConfig, bitstream, newAccessConditions); String name; for (AccessConditionDTO newAccessCondition : newAccessConditions) { name = newAccessCondition.getName(); + if (name != null) { provenanceService.setBitstreamPolicies(context, bitstream, item, name); + } else { + log.warn("Null access condition name encountered for bitstream " + bitstream.getID()); + } } - context.commit(); }And after the outer bitstream loop (after line 89):
context.commit();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
dspace-api/src/main/java/org/dspace/core/ProvenanceService.java(1 hunks)dspace-api/src/main/java/org/dspace/core/ProvenanceServiceImpl.java(1 hunks)dspace-server-webapp/src/main/java/org/dspace/app/rest/submit/factory/impl/BitstreamResourcePolicyAddPatchOperation.java(3 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 (4)
dspace-api/src/main/java/org/dspace/core/ProvenanceService.java (1)
57-66: Good addition of overloaded method for granular provenance tracking.The new overloaded method provides a more flexible way to record provenance information for bitstream policies by accepting a string parameter instead of requiring a full BulkAccessControlInput object. This aligns well with the PR objective of ensuring embargo information is properly tracked in provenance metadata.
dspace-api/src/main/java/org/dspace/core/ProvenanceServiceImpl.java (2)
97-102: Clean implementation of delegation pattern.The modification to the existing method properly extracts the access conditions string and delegates to the new overloaded method. This approach follows good design principles by separating the extraction logic from the provenance recording logic.
105-119: Verify null handling for access conditions string.The implementation correctly handles SQL and authorization exceptions, but consider adding a null check for the access conditions string as an additional safeguard, even though the caller method currently checks for blank strings.
@Override public void setBitstreamPolicies(Context context, Bitstream bitstream, Item item, String accConditionsStr) { + if (accConditionsStr == null) { + log.warn("Null access conditions string provided when setting bitstream policies for bitstream " + bitstream.getID()); + return; + } String msg = messageProvider.getMessage( context, ProvenanceMessageTemplates.ACCESS_CONDITION.getTemplate(), accConditionsStr, "bitstream", bitstream.getID() ); try { addProvenanceMetadata(context, item, msg); } catch (SQLException | AuthorizeException e) { log.error("Unable to add new provenance metadata when setting bitstream policies.", e); } }dspace-server-webapp/src/main/java/org/dspace/app/rest/submit/factory/impl/BitstreamResourcePolicyAddPatchOperation.java (1)
42-43: Good autowiring of the ProvenanceService.Properly autowired the ProvenanceService to enable recording provenance information for bitstream policies.
...n/java/org/dspace/app/rest/submit/factory/impl/BitstreamResourcePolicyAddPatchOperation.java
Show resolved
Hide resolved
dspace-api/src/main/java/org/dspace/core/ProvenanceService.java
Outdated
Show resolved
Hide resolved
dspace-api/src/main/java/org/dspace/core/ProvenanceService.java
Outdated
Show resolved
Hide resolved
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.
Pull Request Overview
This PR fixes an issue where embargo information was not being recorded in the provenance metadata when access conditions are updated for bitstreams. The changes include adding an integration test for embargo handling, updating the patch operation to record provenance for each access condition, and extending the ProvenanceService API and implementation to support the new behavior.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dspace-server-webapp/src/test/java/org/dspace/app/rest/WorkflowItemRestRepositoryIT.java | Added a new integration test (patchEmbargoTest) to verify that embargo access conditions add provenance metadata. |
| dspace-server-webapp/src/main/java/org/dspace/app/rest/submit/factory/impl/BitstreamResourcePolicyAddPatchOperation.java | Updated patch operation to iterate through access conditions and record provenance metadata for each. |
| dspace-api/src/main/java/org/dspace/core/ProvenanceServiceImpl.java | Added an overloaded setBitstreamPolicies method and updated the service to use it. |
| dspace-api/src/main/java/org/dspace/core/ProvenanceService.java | Extended the ProvenanceService interface to include the new setBitstreamPolicies signature. |
Comments suppressed due to low confidence (1)
dspace-server-webapp/src/main/java/org/dspace/app/rest/submit/factory/impl/BitstreamResourcePolicyAddPatchOperation.java:80
- [nitpick] Consider renaming the 'name' variable to 'accessConditionName' to improve clarity about its purpose.
String name;
...n/java/org/dspace/app/rest/submit/factory/impl/BitstreamResourcePolicyAddPatchOperation.java
Show resolved
Hide resolved
vidiecan
left a comment
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.
check copilot
* 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)
* added embargo to provenance * added IT test
Problem description
The embargo is not recorded to provenance during submission.
Summary by CodeRabbit
New Features
Bug Fixes
Tests