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, ResourcePolicy.TYPE_SUBMISSION); } }
public void grantUserAllItemPolicies(Context context, Item item, EPerson epa) throws AuthorizeException, SQLException { if (epa != null) { //A list of policies the user has for this item List<Integer> userHasPolicies = new ArrayList<Integer>(); List<ResourcePolicy> itempols = authorizeService.getPolicies(context, item); for (ResourcePolicy resourcePolicy : itempols) { if (epa.equals(resourcePolicy.getEPerson())) { //The user has already got this policy so it 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, epa); } if (!userHasPolicies.contains(Constants.WRITE)) { addPolicyToItem(context, item, Constants.WRITE, epa); } if (!userHasPolicies.contains(Constants.DELETE)) { addPolicyToItem(context, item, Constants.DELETE, epa); } if (!userHasPolicies.contains(Constants.ADD)) { addPolicyToItem(context, item, Constants.ADD, epa); } if (!userHasPolicies.contains(Constants.REMOVE)) { addPolicyToItem(context, item, Constants.REMOVE, epa); } } }
/** * Return a hash code for this object. * * @return int hash of object */ @Override public int hashCode() { int hash = 7; hash = 19 * hash + this.getAction(); if (this.getGroup() != null) { hash = 19 * hash + this.getGroup().hashCode(); } else { hash = 19 * hash + -1; } if (this.getEPerson() != null) { hash = 19 * hash + this.getEPerson().hashCode(); } else { hash = 19 * hash + -1; } hash = 19 * hash + (this.getStartDate() != null ? this.getStartDate().hashCode() : 0); hash = 19 * hash + (this.getEndDate() != null ? this.getEndDate().hashCode() : 0); return hash; }
System.out.println("CHECK WARNING: Item " + item.getHandle() + ", Bundle " + bn .getName() + " allows READ by " + ((rp.getEPerson() != null) ? "Group " + rp.getGroup().getName() : "EPerson " + rp.getEPerson().getFullName())); System.out.println("CHECK WARNING: Item " + item.getHandle() + ", Bitstream " + bs .getName() + " (in Bundle " + bn.getName() + ") allows READ by " + ((rp.getEPerson() != null) ? "Group " + rp.getGroup().getName() : "EPerson " + rp.getEPerson().getFullName()));
EPerson person = policy.getEPerson();
return false; if (!ObjectUtils.equals(getEPerson(), other.getEPerson())) { return false;
@Override public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document) { try { List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, dso, Constants.READ); for (ResourcePolicy resourcePolicy : policies) { String fieldValue; if (resourcePolicy.getGroup() != null) { //We have a group add it to the value fieldValue = "g" + resourcePolicy.getGroup().getID(); } else { //We have an eperson add it to the value fieldValue = "e" + resourcePolicy.getEPerson().getID(); } document.addField("read", fieldValue); //remove the policy from the cache to save memory context.uncacheEntity(resourcePolicy); } } catch (SQLException e) { log.error(LogManager.getHeader(context, "Error while indexing resource policies", "DSpace object: (id " + dso.getID() + " type " + dso.getType() + ")")); } }
EPerson ePerson = dspacePolicy.getEPerson(); if (ePerson != null) { this.epersonId = ePerson.getID().toString();
@Override public void addPolicies(Context c, List<ResourcePolicy> policies, DSpaceObject dest) throws SQLException, AuthorizeException { // now add them to the destination object List<ResourcePolicy> newPolicies = new LinkedList<>(); for (ResourcePolicy srp : policies) { ResourcePolicy rp = resourcePolicyService.create(c); // copy over values rp.setdSpaceObject(dest); rp.setAction(srp.getAction()); rp.setEPerson(srp.getEPerson()); rp.setGroup(srp.getGroup()); rp.setStartDate(srp.getStartDate()); rp.setEndDate(srp.getEndDate()); rp.setRpName(srp.getRpName()); rp.setRpDescription(srp.getRpDescription()); rp.setRpType(srp.getRpType()); // and add policy to list of new policies newPolicies.add(rp); } resourcePolicyService.update(c, newPolicies); }
if (rp.getEPerson() != null && rp.getEPerson().equals(e)) { c.cacheAuthorizedAction(o, Constants.ADMIN, e, true, rp); return true; // match
if (rp.getEPerson() != null && rp.getEPerson().equals(userToCheck)) { c.cacheAuthorizedAction(o, action, e, true, rp); return true; // match
@Override public ResourcePolicy clone(Context context, ResourcePolicy resourcePolicy) throws SQLException, AuthorizeException { ResourcePolicy clone = create(context); clone.setGroup(resourcePolicy.getGroup()); clone.setEPerson(resourcePolicy.getEPerson()); clone.setStartDate((Date) ObjectUtils.clone(resourcePolicy.getStartDate())); clone.setEndDate((Date) ObjectUtils.clone(resourcePolicy.getEndDate())); clone.setRpType((String) ObjectUtils.clone(resourcePolicy.getRpType())); clone.setRpDescription((String) ObjectUtils.clone(resourcePolicy.getRpDescription())); update(context, clone); return clone; }