protected void addGroupPolicyToItem(Context context, Item item, int type, Group group) throws AuthorizeException, SQLException { if (group != null) { authorizeService.addPolicy(context, item, type, group); List<Bundle> bundles = item.getBundles(); for (Bundle bundle : bundles) { authorizeService.addPolicy(context, bundle, type, group); List<Bitstream> bits = bundle.getBitstreams(); for (Bitstream bit : bits) { authorizeService.addPolicy(context, bit, type, group); } } } }
protected void removeGroupItemPolicies(Context context, Item item, Group e) throws SQLException, AuthorizeException { if (e != null) { // Also remove any lingering authorizations from this user authorizeService.removeGroupPolicies(context, item, e); // Remove the bundle rights List<Bundle> bundles = item.getBundles(); for (Bundle bundle : bundles) { authorizeService.removeGroupPolicies(context, bundle, e); List<Bitstream> bitstreams = bundle.getBitstreams(); for (Bitstream bitstream : bitstreams) { authorizeService.removeGroupPolicies(context, bitstream, e); } } } }
/** Add rights information. This attaches an href to the URL of the item's licence file */ protected void addRights() throws DSpaceSWORDException { try { // work our way up to the item List<Bundle> bundle2bitstreams = this.bitstream.getBundles(); if (bundle2bitstreams.isEmpty()) { log.error("Found orphaned bitstream: " + bitstream.getID()); throw new DSpaceSWORDException("Orphaned bitstream discovered"); } Bundle bundle = bundle2bitstreams.get(0); List<Item> items = bundle.getItems(); if (items.isEmpty()) { log.error("Found orphaned bundle: " + bundle.getID()); throw new DSpaceSWORDException("Orphaned bundle discovered"); } Item item = items.get(0); // now get the licence out of the item SWORDUrlManager urlManager = swordService.getUrlManager(); StringBuilder rightsString = new StringBuilder(); List<Bundle> lbundles = item.getBundles(); for (Bundle lbundle : lbundles) { if (!Constants.LICENSE_BUNDLE_NAME.equals(lbundle.getName())) { // skip non-license bundles continue; } List<Bitstream> bss = lbundle.getBitstreams(); for (Bitstream bs : bss) { String url = urlManager.getBitstreamUrl(bs); rightsString.append(url).append(" "); } } Rights rights = new Rights(); rights.setContent(rightsString.toString()); rights.setType(ContentType.TEXT); entry.setRights(rights); log.debug("Added rights entry to entity"); } catch (SQLException e) { log.error("caught exception: ", e); throw new DSpaceSWORDException(e); } }
protected void removeUserItemPolicies(Context context, Item item, EPerson e) throws SQLException, AuthorizeException { if (e != null) { // Also remove any lingering authorizations from this user authorizeService.removeEPersonPolicies(context, item, e); // Remove the bundle rights List<Bundle> bundles = item.getBundles(); for (Bundle bundle : bundles) { authorizeService.removeEPersonPolicies(context, bundle, e); List<Bitstream> bitstreams = bundle.getBitstreams(); for (Bitstream bitstream : bitstreams) { authorizeService.removeEPersonPolicies(context, bitstream, e); } } // Ensure that the submitter always retains his resource policies if (e.getID().equals(item.getSubmitter().getID())) { grantSubmitterReadPolicies(context, item); } } }