Skip to content

Commit

Permalink
When making public, set the resource policy type to inherited for items
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgomez committed May 22, 2024
1 parent 7d7d5a6 commit ea49314
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.sql.SQLException;

import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.ResourcePolicy;
import org.dspace.authorize.factory.AuthorizeServiceFactory;
import org.dspace.authorize.service.AuthorizeService;
import org.dspace.authorize.service.ResourcePolicyService;
Expand Down Expand Up @@ -51,7 +52,11 @@ public int perform(DSpaceObject dso) throws IOException {
Context context = Curator.curationContext();
Group anonymous = groupService.findByName(context, Group.ANONYMOUS);
resourcePolicyService.removePolicies(context, dso, Constants.READ);
authorizeService.createResourcePolicy(context, dso, anonymous, null, Constants.READ, null);
if (dso instanceof Item) {
authorizeService.createResourcePolicy(context, dso, anonymous, null, Constants.READ, ResourcePolicy.TYPE_INHERITED);
} else {
authorizeService.createResourcePolicy(context, dso, anonymous, null, Constants.READ, null);
}
result = "DSpaceObject has been successfully made public: " + dso.getID();
setResult(result);
report(result);
Expand Down

0 comments on commit ea49314

Please sign in to comment.