#8783 New bitstreams inherit DEFAULT_BITSTREAM_READ from owning collection

Otherwise will keep inherited READ from bundle. Does not affect embargos set during submission or workflow, these will always be applied afterwards.
This commit is contained in:
Kim Shepherd
2023-05-12 14:01:14 +12:00
parent 03c39cf6f1
commit 019d0319dc
2 changed files with 81 additions and 2 deletions

View File

@@ -34,6 +34,7 @@ import org.dspace.content.service.ItemService;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogHelper;
import org.dspace.eperson.Group;
import org.dspace.event.Event;
import org.springframework.beans.factory.annotation.Autowired;
@@ -173,6 +174,28 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
// copy authorization policies from bundle to bitstream
// FIXME: multiple inclusion is affected by this...
authorizeService.inheritPolicies(context, bundle, bitstream);
if (owningItem != null) {
// Resolve owning collection
Collection owningCollection = owningItem.getOwningCollection();
if (owningCollection != null) {
// Get DEFAULT_BITSTREAM_READ policy from the collection
List<Group> defaultBitstreamReadGroups =
authorizeService.getAuthorizedGroups(context, owningCollection,
Constants.DEFAULT_BITSTREAM_READ);
log.info(defaultBitstreamReadGroups.size());
// If this collection is configured with a DEFAULT_BITSTREAM_READ group, overwrite the READ policy
// inherited from the bundle with this policy.
if (!defaultBitstreamReadGroups.isEmpty()) {
// Remove read policies from the bitstream
authorizeService.removePoliciesActionFilter(context, bitstream, Constants.READ);
for (Group defaultBitstreamReadGroup : defaultBitstreamReadGroups) {
// Inherit this policy as READ, directly from the collection roles
authorizeService.addPolicy(context, bitstream,
Constants.READ, defaultBitstreamReadGroup, ResourcePolicy.TYPE_INHERITED);
}
}
}
}
bitstreamService.update(context, bitstream);
}