/** * figures out if the date is valid for the policy * * @param resourcePolicy resource policy * @return true if policy has begun and hasn't expired yet (or no dates are * set) */ @Override public boolean isDateValid(ResourcePolicy resourcePolicy) { Date sd = resourcePolicy.getStartDate(); Date ed = resourcePolicy.getEndDate(); // if no dates set, return true (most common case) if ((sd == null) && (ed == null)) { return true; } // one is set, now need to do some date math Date now = new Date(); // check start date first if (sd != null && now.before(sd)) { // start date is set, return false if we're before it return false; } // now expiration date if (ed != null && now.after(ed)) { // end date is set, return false if we're after it return false; } // if we made it this far, start < now < end return true; // date must be okay }
private boolean willChangeStatus(Item item) throws SQLException { List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, item, Constants.READ); for (ResourcePolicy policy : policies) { if ((policy.getGroup() != null) && (policy.getGroup().getName().equals("Anonymous"))) { if (policy.getStartDate() != null && policy.getStartDate().after(new Date())) { return true; } if (policy.getEndDate() != null && policy.getEndDate().after(new Date())) { return true; } } } return false; }
for (ResourcePolicy policy : policies) { if ((policy.getGroup() != null) && (policy.getGroup().getName().equals("Anonymous"))) { if (policy.getStartDate() != null) { dates.add(policy.getStartDate());
/** * 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; }
Date now = new Date(); SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd"); if (policy.getStartDate() != null) { rightsContext.setAttribute("start-date", iso8601.format(policy.getStartDate())); if (policy.getStartDate().after(now)) { rightsContext.setAttribute("in-effect", "false");
if (rp.getStartDate() == null) { System.out.println("CHECK WARNING: Item " + item.getHandle() + ", Bundle " + bn .getName() + " allows READ by " + for (ResourcePolicy rp : getAuthorizeService() .getPoliciesActionFilter(context, bs, Constants.READ)) { if (rp.getStartDate() == null) { System.out.println("CHECK WARNING: Item " + item.getHandle() + ", Bitstream " + bs .getName() + " (in Bundle " + bn.getName() + ") allows READ by " +
return false; if (!ObjectUtils.equals(getStartDate(), other.getStartDate())) { return false;
this.rpName = dspacePolicy.getRpName(); this.rpType = dspacePolicy.getRpType(); this.startDate = dspacePolicy.getStartDate(); this.endDate = dspacePolicy.getEndDate(); switch (dspacePolicy.getdSpaceObject().getType()) {
@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); }
@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; }