Skip to content

Commit

Permalink
Merged in DSC-1324 (pull request DSpace#1231)
Browse files Browse the repository at this point in the history
DSC-1324 CST-12375

Approved-by: Giuseppe Digilio
  • Loading branch information
vins01-4science authored and atarix83 committed Nov 3, 2023
2 parents 19438c5 + 02950cc commit 3fa655e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
10 changes: 8 additions & 2 deletions dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,7 @@ private List<CrisLayoutField> getThumbnailFields(List<CrisLayoutTab> crisLayoutT
* @param context
* @param item
* @param bundle
* @param metadata
* @param value
* @param requireOriginal
* @throws SQLException
* @return Bitstream
*/
Expand Down Expand Up @@ -2138,4 +2136,12 @@ public boolean isLatestVersion(Context context, Item item) throws SQLException {

}

@Override
public void addResourcePolicy(Context context, Item item, int actionID, EPerson eperson)
throws SQLException, AuthorizeException {
ResourcePolicy resourcePolicy =
this.authorizeService.createResourcePolicy(context, item, null, eperson, actionID, null);
item.getResourcePolicies().add(resourcePolicy);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -922,4 +922,17 @@ public Iterator<Item> findRelatedItemsByAuthorityControlledFields(Context contex
*/
public boolean isLatestVersion(Context context, Item item) throws SQLException;

/**
* Adds a resource policy to the specified item for the given action and EPerson.
*
* @param context the DSpace context
* @param item the item to add the policy to
* @param actionID the ID of the action to add the policy for
* @param eperson the EPerson to add the policy for
* @throws SQLException if a database error occurs
* @throws AuthorizeException if the current user is not authorized to perform this action
*/
void addResourcePolicy(Context context, Item item, int actionID, EPerson eperson)
throws SQLException, AuthorizeException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,20 @@ private Item createProfileItem(Context context, EPerson ePerson, Collection coll

item = installItemService.installItem(context, workspaceItem);

context.uncacheEntity(workspaceItem);

if (isNewProfileNotVisibleByDefault()) {
Group anonymous = groupService.findByName(context, ANONYMOUS);
authorizeService.removeGroupPolicies(context, item, anonymous);
}

authorizeService.addPolicy(context, item, READ, ePerson);
itemService.addResourcePolicy(context, item, READ, ePerson);

if (isAdditionOfWritePolicyOnProfileEnabled()) {
authorizeService.addPolicy(context, item, WRITE, ePerson);
itemService.addResourcePolicy(context, item, WRITE, ePerson);
}


return reloadItem(context, item);
}

Expand Down

0 comments on commit 3fa655e

Please sign in to comment.