forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 2
UFAL/Update the resource policy rights when changing submitter #1002
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
milanmajchrak
merged 5 commits into
dtq-dev
from
ufal/share-submission-now-working-correctly
Jul 10, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
af4b38a
removed res policies for submitter and created newones when item is s…
Paurikova2 a931dc2
avoid magic number, use constant
Paurikova2 ee2961c
set submitter in existing res policies
Paurikova2 a02339c
checkstyle violations
Paurikova2 8c623fc
removed not used shared link
Paurikova2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,12 +23,15 @@ | |
| import org.dspace.builder.CollectionBuilder; | ||
| import org.dspace.builder.CommunityBuilder; | ||
| import org.dspace.builder.EPersonBuilder; | ||
| import org.dspace.builder.GroupBuilder; | ||
| import org.dspace.builder.WorkspaceItemBuilder; | ||
| import org.dspace.content.Collection; | ||
| import org.dspace.content.WorkspaceItem; | ||
| import org.dspace.content.service.WorkspaceItemService; | ||
| import org.dspace.eperson.EPerson; | ||
| import org.dspace.eperson.Group; | ||
| import org.dspace.eperson.service.EPersonService; | ||
| import org.dspace.eperson.service.GroupService; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
|
|
@@ -45,6 +48,8 @@ public class SubmissionControllerIT extends AbstractControllerIntegrationTest { | |
| private WorkspaceItemService workspaceItemService; | ||
| @Autowired | ||
| private EPersonService ePersonService; | ||
| @Autowired | ||
| private GroupService groupService; | ||
|
|
||
| WorkspaceItem wsi; | ||
|
|
||
|
|
@@ -113,4 +118,70 @@ public void generateShareTokenAndSetOwnerTest() throws Exception { | |
| assertThat(updatedWsi.getSubmitter().getEmail(), is(adminUser.getEmail())); | ||
| assertThat(updatedWsi.getSubmitter().getEmail(), not(SUBMITTER_EMAIL)); | ||
| } | ||
|
|
||
| @Test | ||
| public void generateShareTokenAndSetOwnerTo3rdPersonTest() throws Exception { | ||
| context.turnOffAuthorisationSystem(); | ||
| EPerson submitter2 = EPersonBuilder.createEPerson(context) | ||
| .withEmail("[email protected]") | ||
| .withPassword(password) | ||
| .build(); | ||
| Group group = GroupBuilder.createCollectionSubmitterGroup(context, wsi.getCollection()) | ||
| .withName("Test Submitters Group").build(); | ||
| groupService.addMember(context, group, submitter2); | ||
| context.restoreAuthSystemState(); | ||
|
|
||
| EPerson currentUser = context.getCurrentUser(); | ||
|
|
||
| String adminToken = getAuthToken(admin.getEmail(), password); | ||
| getClient(adminToken).perform(get("/api/submission/share") | ||
| .param("workspaceitemid", wsi.getID().toString()) | ||
| .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) | ||
| .andExpect(status().isOk()) | ||
| .andExpect(jsonPath("$.shareLink", is(notNullValue()))); | ||
|
|
||
| // Check that the share token was set on the WorkspaceItem and persisted into the database | ||
| WorkspaceItem updatedWsi = workspaceItemService.find(context, wsi.getID()); | ||
| assertThat(wsi.getID(), is(updatedWsi.getID())); | ||
| assertThat(updatedWsi.getSubmitter().getEmail(), is(SUBMITTER_EMAIL)); | ||
| assertThat(updatedWsi.getSubmitter().getEmail(), not(currentUser.getEmail())); | ||
|
|
||
| EPerson adminUser = ePersonService.findByEmail(context, admin.getEmail()); | ||
| context.setCurrentUser(adminUser); | ||
| // Set workspace item owner to the current user | ||
| getClient(adminToken).perform(get("/api/submission/setOwner") | ||
| .param("shareToken", updatedWsi.getShareToken()) | ||
| .param("workspaceitemid", updatedWsi.getID().toString()) | ||
| .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) | ||
| .andExpect(status().isOk()); | ||
|
|
||
| // Check that the owner of the WorkspaceItem was set to the current user | ||
| // Check the wsi was persisted into the database | ||
| updatedWsi = workspaceItemService.find(context, wsi.getID()); | ||
| assertThat(updatedWsi.getSubmitter().getEmail(), is(adminUser.getEmail())); | ||
| assertThat(updatedWsi.getSubmitter().getEmail(), not(SUBMITTER_EMAIL)); | ||
|
|
||
| getClient(adminToken).perform(get("/api/submission/share") | ||
| .param("workspaceitemid", wsi.getID().toString()) | ||
| .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) | ||
| .andExpect(status().isOk()) | ||
| .andExpect(jsonPath("$.shareLink", is(notNullValue()))); | ||
|
|
||
| updatedWsi = workspaceItemService.find(context, wsi.getID()); | ||
|
|
||
| context.setCurrentUser(submitter2); | ||
| String userToken = getAuthToken(submitter2.getEmail(), password); | ||
| // Set workspace item owner to the 3rd person | ||
| getClient(userToken).perform(get("/api/submission/setOwner") | ||
| .param("shareToken", updatedWsi.getShareToken()) | ||
| .param("workspaceitemid", updatedWsi.getID().toString()) | ||
| .contentType(MediaType.APPLICATION_JSON_PATCH_JSON)) | ||
| .andExpect(status().isOk()); | ||
|
|
||
| // Check that the owner of the WorkspaceItem was set to the current user | ||
| // Check the wsi was persisted into the database | ||
| updatedWsi = workspaceItemService.find(context, wsi.getID()); | ||
| assertThat(updatedWsi.getSubmitter().getEmail(), is(submitter2.getEmail())); | ||
| assertThat(updatedWsi.getSubmitter().getEmail(), not(adminUser.getEmail())); | ||
| } | ||
| } | ||
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.