84100: Admin only files rights issue

This commit is contained in:
Marie Verdonck
2021-10-11 17:59:46 +02:00
parent d9d24427af
commit d6a9bca578

View File

@@ -1045,12 +1045,12 @@ prevent the generation of resource policy entry values with null dspace_object a
* to perform a particular action.
*/
protected void addDefaultPoliciesNotInPlace(Context context, DSpaceObject dso,
List<ResourcePolicy> defaultCollectionPolicies)
throws SQLException, AuthorizeException {
List<ResourcePolicy> defaultCollectionPolicies) throws SQLException, AuthorizeException {
for (ResourcePolicy defaultPolicy : defaultCollectionPolicies) {
if (!authorizeService
.isAnIdenticalPolicyAlreadyInPlace(context, dso, defaultPolicy.getGroup(), Constants.READ,
defaultPolicy.getID())) {
defaultPolicy.getID()) && this.isNotAlreadyACustomRPOfThisTypeOnDSO(context, dso)) {
ResourcePolicy newPolicy = resourcePolicyService.clone(context, defaultPolicy);
newPolicy.setdSpaceObject(dso);
newPolicy.setAction(Constants.READ);
@@ -1060,6 +1060,25 @@ prevent the generation of resource policy entry values with null dspace_object a
}
}
/**
* Check whether or not there is already an RP on the given dso, which has actionId={@link Constants.READ} and
* resourceTypeId={@link ResourcePolicy.TYPE_CUSTOM}
*
* @param context DSpace context
* @param dso DSpace object to check for custom read RP
* @return True if there is no RP on the item with custom read RP, otherwise false
* @throws SQLException If something goes wrong retrieving the RP on the DSO
*/
private boolean isNotAlreadyACustomRPOfThisTypeOnDSO(Context context, DSpaceObject dso) throws SQLException {
List<ResourcePolicy> readRPs = resourcePolicyService.find(context, dso, Constants.READ);
for (ResourcePolicy readRP : readRPs) {
if (readRP.getRpType().equals(ResourcePolicy.TYPE_CUSTOM)) {
return false;
}
}
return true;
}
/**
* Returns an iterator of Items possessing the passed metadata field, or only
* those matching the passed value, if value is not Item.ANY