From 1cf13e3bfef7e3d1f5d09ae3086c7245fabd00df Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Fri, 29 Sep 2023 11:44:29 +0200 Subject: [PATCH] 106812: Fix old rest resource policy creations --- .../src/main/java/org/dspace/rest/BitstreamResource.java | 5 +++-- dspace-rest/src/main/java/org/dspace/rest/ItemsResource.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dspace-rest/src/main/java/org/dspace/rest/BitstreamResource.java b/dspace-rest/src/main/java/org/dspace/rest/BitstreamResource.java index 3a6ad859603e..b71bfad592cf 100644 --- a/dspace-rest/src/main/java/org/dspace/rest/BitstreamResource.java +++ b/dspace-rest/src/main/java/org/dspace/rest/BitstreamResource.java @@ -729,9 +729,10 @@ static String getMimeType(String name) { private void addPolicyToBitstream(org.dspace.core.Context context, ResourcePolicy policy, org.dspace.content.Bitstream dspaceBitstream) throws SQLException, AuthorizeException { - org.dspace.authorize.ResourcePolicy dspacePolicy = resourcePolicyService.create(context); + org.dspace.authorize.ResourcePolicy dspacePolicy = + resourcePolicyService.create(context, null, + groupService.findByIdOrLegacyId(context, policy.getGroupId())); dspacePolicy.setAction(policy.getActionInt()); - dspacePolicy.setGroup(groupService.findByIdOrLegacyId(context, policy.getGroupId())); dspacePolicy.setdSpaceObject(dspaceBitstream); dspacePolicy.setStartDate(policy.getStartDate()); dspacePolicy.setEndDate(policy.getEndDate()); diff --git a/dspace-rest/src/main/java/org/dspace/rest/ItemsResource.java b/dspace-rest/src/main/java/org/dspace/rest/ItemsResource.java index 615aacac21cc..761d4dfc8ae3 100644 --- a/dspace-rest/src/main/java/org/dspace/rest/ItemsResource.java +++ b/dspace-rest/src/main/java/org/dspace/rest/ItemsResource.java @@ -516,9 +516,10 @@ public Bitstream addItemBitstream(@PathParam("item_id") String itemId, InputStre bitstreamsPolicies.remove(policy); } - org.dspace.authorize.ResourcePolicy dspacePolicy = resourcePolicyService.create(context); + org.dspace.authorize.ResourcePolicy dspacePolicy = + resourcePolicyService.create(context, + null, groupService.findByIdOrLegacyId(context, groupId)); dspacePolicy.setAction(org.dspace.core.Constants.READ); - dspacePolicy.setGroup(groupService.findByIdOrLegacyId(context, groupId)); dspacePolicy.setdSpaceObject(dspaceBitstream); if ((year != null) || (month != null) || (day != null)) { Date date = new Date();