Esempio n. 1
0
 protected void grantGroupAllItemPolicies(Context context, Item item, Group group)
     throws AuthorizeException, SQLException {
   if (group != null) {
     // A list of policies the user has for this item
     List<Integer> groupHasPolicies = new ArrayList<Integer>();
     List<ResourcePolicy> itempols = authorizeService.getPolicies(context, item);
     for (ResourcePolicy resourcePolicy : itempols) {
       if (group.equals(resourcePolicy.getGroup())) {
         // The user has already got this policy so it it to the list
         groupHasPolicies.add(resourcePolicy.getAction());
       }
     }
     // Make sure we don't add duplicate policies
     if (!groupHasPolicies.contains(Constants.READ))
       addGroupPolicyToItem(context, item, Constants.READ, group);
     if (!groupHasPolicies.contains(Constants.WRITE))
       addGroupPolicyToItem(context, item, Constants.WRITE, group);
     if (!groupHasPolicies.contains(Constants.DELETE))
       addGroupPolicyToItem(context, item, Constants.DELETE, group);
     if (!groupHasPolicies.contains(Constants.ADD))
       addGroupPolicyToItem(context, item, Constants.ADD, group);
     if (!groupHasPolicies.contains(Constants.REMOVE))
       addGroupPolicyToItem(context, item, Constants.REMOVE, group);
   }
 }
Esempio n. 2
0
 protected void grantSubmitterReadPolicies(Context context, Item item)
     throws SQLException, AuthorizeException {
   // A list of policies the user has for this item
   List<Integer> userHasPolicies = new ArrayList<Integer>();
   List<ResourcePolicy> itempols = authorizeService.getPolicies(context, item);
   EPerson submitter = item.getSubmitter();
   for (ResourcePolicy resourcePolicy : itempols) {
     if (submitter.equals(resourcePolicy.getEPerson())) {
       // The user has already got this policy so add it to the list
       userHasPolicies.add(resourcePolicy.getAction());
     }
   }
   // Make sure we don't add duplicate policies
   if (!userHasPolicies.contains(Constants.READ))
     addPolicyToItem(context, item, Constants.READ, submitter);
 }