@Override public void replaceAllItemPolicies(Context context, Item item, List<ResourcePolicy> newpolicies) throws SQLException, AuthorizeException { // remove all our policies, add new ones authorizeService.removeAllPolicies(context, item); authorizeService.addPolicies(context, newpolicies, item); }
@Override public void replaceAllBitstreamPolicies(Context context, Bundle bundle, List<ResourcePolicy> newpolicies) throws SQLException, AuthorizeException { List<Bitstream> bitstreams = bundle.getBitstreams(); if (CollectionUtils.isNotEmpty(bitstreams)) { for (Bitstream bs : bitstreams) { // change bitstream policies authorizeService.removeAllPolicies(context, bs); authorizeService.addPolicies(context, newpolicies, bs); } } // change bundle policies authorizeService.removeAllPolicies(context, bundle); authorizeService.addPolicies(context, newpolicies, bundle); }
/** * Set the Permission on a Bitstream. * * @param c DSpace Context * @param g Dspace Group * @param actionID action identifier * @param bs Bitstream * @throws SQLException if database error * @throws AuthorizeException if authorization error * @see org.dspace.core.Constants */ protected void setPermission(Context c, Group g, int actionID, Bitstream bs) throws SQLException, AuthorizeException { if (!isTest) { // remove the default policy authorizeService.removeAllPolicies(c, bs); // add the policy ResourcePolicy rp = resourcePolicyService.create(c); rp.setdSpaceObject(bs); rp.setAction(actionID); rp.setGroup(g); resourcePolicyService.update(c, rp); } else { if (actionID == Constants.READ) { System.out.println("\t\tpermissions: READ for " + g.getName()); } else if (actionID == Constants.WRITE) { System.out.println("\t\tpermissions: WRITE for " + g.getName()); } } }
@Override public void delete(Context context, Bitstream bitstream) throws SQLException, AuthorizeException { // changed to a check on delete // Check authorisation authorizeService.authorizeAction(context, bitstream, Constants.DELETE); log.info(LogManager.getHeader(context, "delete_bitstream", "bitstream_id=" + bitstream.getID())); context.addEvent(new Event(Event.DELETE, Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()), getIdentifiers(context, bitstream))); // Remove bitstream itself bitstream.setDeleted(true); update(context, bitstream); //Remove our bitstream from all our bundles final List<Bundle> bundles = bitstream.getBundles(); for (Bundle bundle : bundles) { bundle.removeBitstream(bitstream); } //Remove all bundles from the bitstream object, clearing the connection in 2 ways bundles.clear(); // Remove policies only after the bitstream has been updated (otherwise the current user has not WRITE rights) authorizeService.removeAllPolicies(context, bitstream); }
authorizeService.removeAllPolicies(context, dso); authorizeService.addPolicies(context, policies, dso);
authorizeService.removeAllPolicies(context, dspaceBitstream);
authorizeService.removeAllPolicies(context, bs); // remove the default policy authorizeService.createResourcePolicy(context, bs, group, null, ce.permissionsActionId, null);
authorizeService.removeAllPolicies(context, b);
authorizeService.removeAllPolicies(c, myitem); authorizeService.removeAllPolicies(c, bundle); authorizeService.removeAllPolicies(c, bitstream);