forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 2
metadata-added-provenance #730
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
Merged
Merged
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
380fb45
added provenance metadata for update, remove and add
Paurikova2 ffe630a
checkstyle violations
Paurikova2 46335a1
added provenance metadata for update and remove bitstream
Paurikova2 96158a5
item test json added metadata provenance
Paurikova2 9d6097f
removed unwanted lines
Paurikova2 a0c500a
control provenance only by tests of item
Paurikova2 c79c000
update and remove license
Paurikova2 c55d418
provenance access control and upload bitstream
Paurikova2 499aac4
provenance move item to different collection
Paurikova2 9c361d9
provenance make item non-discoverable
Paurikova2 9f94913
checkstyle violations and test failures
Paurikova2 2a0d919
make code more readable
Paurikova2 1922907
provenance for mapped collection
Paurikova2 d9dd689
grammer check
Paurikova2 5cddf35
don't write provenance for bitstream without item
Paurikova2 4a6072a
move addProvenance to parent class
Paurikova2 e468c90
refactoring
Paurikova2 9910c90
checkstyle violations and test failures
Paurikova2 18607a5
removed unnecessary variables, added logs and checkstyle
Paurikova2 aae82cc
separated class for provenance
Paurikova2 0b3c0d7
create class for provenance management
Paurikova2 64d84a1
added metadata item and bitstream tests
Paurikova2 7c8f7e5
tests for metadata provenance
Paurikova2 43c5eb2
problem with access control test
Paurikova2 b67b4b3
tests do not work
Paurikova2 d7a270b
better service management:
Paurikova2 e4da4e1
delete clarin license mapping
Paurikova2 5b6168c
checkstyle violations
Paurikova2 a4bc467
checkstyle violations
Paurikova2 0e4c9a2
checkstyle violations
Paurikova2 556c3d4
checkstyle violations
Paurikova2 e7caf0d
checkstyle violations
Paurikova2 9b7fb5c
added json to resources
Paurikova2 eba6bbd
modified provenance patch messages
Paurikova2 a0d5d55
messages bags
Paurikova2 5282d63
refactoring based on git comparison
Paurikova2 828769f
checkstyle violations
Paurikova2 a1b95e6
used correct json
Paurikova2 8621bcd
checkstyle violations
Paurikova2 2fdc96e
log exception, replace ! by non conds, added doc comments
Paurikova2 b026ca0
added logs for replacing mtd
Paurikova2 64d7eae
removed unused services
Paurikova2 49cae22
make object from provenance service
Paurikova2 eb2315e
removed interface prom provenance msg provider
Paurikova2 876a7f2
checkstyle
Paurikova2 130d78f
Refactored method `removeReadPolicies` - add provenance after removin…
milanmajchrak 419aff3
The message templates are loaded from the Enum instead of json file.
milanmajchrak a0abf72
The `getMessage` methods was overloaded.
milanmajchrak a1324ce
Renamed `getItem` to `findItemByBitstream` to clarify the method's pu…
milanmajchrak 8ff24e0
Do not throw exception when adding to provenance
milanmajchrak 51302fa
The exceptions are caught in the ProvenanceProvider and changed order…
milanmajchrak 46ab18c
Renamed ProvenanceProvider to ProvenanceService and refactored it to …
milanmajchrak 5f63dcd
The ProvenanceService wasn't initialized in the BundleAccessControl
milanmajchrak fb82e94
Removal of unwanted changes
milanmajchrak c2083a1
The code has been prettified
milanmajchrak a783ba6
Removed the code without any effect
milanmajchrak 5d32981
Removed the logging which is not required
milanmajchrak ff86f1f
Moved calling od the provenance service to better place.
milanmajchrak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
dspace-api/src/main/java/org/dspace/core/ProvenanceMessageFormatter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /** | ||
| * The contents of this file are subject to the license and copyright | ||
| * detailed in the LICENSE and NOTICE files at the root of the source | ||
| * tree and available online at | ||
| * | ||
| * http://www.dspace.org/license/ | ||
| */ | ||
| package org.dspace.core; | ||
|
|
||
| import java.sql.SQLException; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import org.dspace.authorize.AuthorizeException; | ||
| import org.dspace.authorize.ResourcePolicy; | ||
| import org.dspace.content.Bitstream; | ||
| import org.dspace.content.Collection; | ||
| import org.dspace.content.DCDate; | ||
| import org.dspace.content.Item; | ||
| import org.dspace.content.MetadataField; | ||
| import org.dspace.content.factory.ContentServiceFactory; | ||
| import org.dspace.content.service.InstallItemService; | ||
| import org.dspace.eperson.EPerson; | ||
|
|
||
| /** | ||
| * The ProvenanceMessageProvider providing methods to generate provenance messages for DSpace items. | ||
| * It loads message templates | ||
| * from a JSON file and formats messages based on the context, including user details and timestamps. | ||
| * | ||
| * @author Michaela Paurikova (dspace at dataquest.sk) | ||
| */ | ||
| public class ProvenanceMessageFormatter { | ||
| private InstallItemService installItemService; | ||
|
|
||
| public ProvenanceMessageFormatter() {} | ||
|
|
||
| public String getMessage(Context context, String messageTemplate, Item item, Object... args) | ||
| throws SQLException, AuthorizeException { | ||
| // Initialize InstallItemService if it is not initialized. | ||
| if (installItemService == null) { | ||
| installItemService = ContentServiceFactory.getInstance().getInstallItemService(); | ||
| } | ||
| String msg = getMessage(context, messageTemplate, args); | ||
| msg = msg + "\n" + installItemService.getBitstreamProvenanceMessage(context, item); | ||
| return msg; | ||
| } | ||
|
|
||
| public String getMessage(Context context, String messageTemplate, Object... args) { | ||
| EPerson currentUser = context.getCurrentUser(); | ||
| String timestamp = DCDate.getCurrent().toString(); | ||
| String details = validateMessageTemplate(messageTemplate, args); | ||
| return String.format("%s by %s (%s) on %s", | ||
| details, | ||
| currentUser.getFullName(), | ||
| currentUser.getEmail(), | ||
| timestamp); | ||
| } | ||
|
|
||
| public String getMessage(Item item) { | ||
| String msg = "Item was in collections:\n"; | ||
| List<Collection> collsList = item.getCollections(); | ||
| for (Collection coll : collsList) { | ||
| msg = msg + coll.getName() + " (ID: " + coll.getID() + ")\n"; | ||
| } | ||
| return msg; | ||
| } | ||
|
|
||
| public String getMessage(Bitstream bitstream) { | ||
| // values of deleted bitstream | ||
| String msg = bitstream.getName() + ": " + | ||
| bitstream.getSizeBytes() + " bytes, checksum: " + | ||
| bitstream.getChecksum() + " (" + | ||
| bitstream.getChecksumAlgorithm() + ")\n"; | ||
| return msg; | ||
| } | ||
|
|
||
| public String getMessage(List<ResourcePolicy> resPolicies) { | ||
| return resPolicies.stream() | ||
| .filter(rp -> rp.getAction() == Constants.READ) | ||
| .map(rp -> String.format("[%s, %s, %d, %s, %s, %s, %s]", | ||
| rp.getRpName(), rp.getRpType(), rp.getAction(), | ||
| rp.getEPerson() != null ? rp.getEPerson().getEmail() : null, | ||
| rp.getGroup() != null ? rp.getGroup().getName() : null, | ||
| rp.getStartDate() != null ? rp.getStartDate().toString() : null, | ||
| rp.getEndDate() != null ? rp.getEndDate().toString() : null)) | ||
| .collect(Collectors.joining(";")); | ||
| } | ||
|
|
||
| public String getMetadata(String oldMtdKey, String oldMtdValue) { | ||
| return oldMtdKey + ": " + oldMtdValue; | ||
| } | ||
|
|
||
| public String getMetadataField(MetadataField metadataField) { | ||
| return metadataField.toString() | ||
| .replace('_', '.'); | ||
| } | ||
|
|
||
| private String validateMessageTemplate(String messageTemplate, Object... args) { | ||
| if (messageTemplate == null) { | ||
| throw new IllegalArgumentException("The provenance message template is null!"); | ||
| } | ||
| return String.format(messageTemplate, args); | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
dspace-api/src/main/java/org/dspace/core/ProvenanceMessageTemplates.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /** | ||
| * The contents of this file are subject to the license and copyright | ||
| * detailed in the LICENSE and NOTICE files at the root of the source | ||
| * tree and available online at | ||
| * | ||
| * http://www.dspace.org/license/ | ||
| */ | ||
| package org.dspace.core; | ||
|
|
||
| /** | ||
| * The ProvenanceMessageTemplates enum provides message templates for provenance messages. | ||
| * | ||
| * @author Michaela Paurikova (dspace at dataquest.sk) | ||
| */ | ||
| public enum ProvenanceMessageTemplates { | ||
| ACCESS_CONDITION("Access condition (%s) was added to %s (%s)"), | ||
| RESOURCE_POLICIES_REMOVED("Resource policies (%s) of %s (%s) were removed"), | ||
| BUNDLE_ADDED("Item was added bitstream to bundle (%s)"), | ||
| EDIT_LICENSE("License (%s) was %s"), | ||
| MOVE_ITEM("Item was moved from collection (%s) to different collection"), | ||
| MAPPED_ITEM("Item was mapped to collection (%s)"), | ||
| DELETED_ITEM_FROM_MAPPED("Item was deleted from mapped collection (%s)"), | ||
| EDIT_BITSTREAM("Item (%s) was deleted bitstream (%s)"), | ||
| ITEM_METADATA("Item metadata (%s) was %s"), | ||
| BITSTREAM_METADATA("Item metadata (%s) was %s bitstream (%s)"), | ||
| ITEM_REPLACE_SINGLE_METADATA("Item bitstream (%s) metadata (%s) was updated"), | ||
| DISCOVERABLE("Item was made %sdiscoverable"); | ||
|
|
||
| private final String template; | ||
|
|
||
| ProvenanceMessageTemplates(String template) { | ||
| this.template = template; | ||
| } | ||
|
|
||
| public String getTemplate() { | ||
| return template; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.