Example #1
0
  @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);
  }
Example #2
0
 @Override
 public void switchPoliciesAction(Context context, DSpaceObject dso, int fromAction, int toAction)
     throws SQLException, AuthorizeException {
   List<ResourcePolicy> rps = getPoliciesActionFilter(context, dso, fromAction);
   for (ResourcePolicy rp : rps) {
     rp.setAction(toAction);
   }
   resourcePolicyService.update(context, rps);
 }
Example #3
0
  @Override
  public ResourcePolicy createResourcePolicy(
      Context context, DSpaceObject dso, Group group, EPerson eperson, int type, String rpType)
      throws SQLException, AuthorizeException {
    if (group == null && eperson == null) {
      throw new IllegalArgumentException(
          "We need at least an eperson or a group in order to create a resource policy.");
    }

    ResourcePolicy myPolicy = resourcePolicyService.create(context);
    myPolicy.setdSpaceObject(dso);
    myPolicy.setAction(type);
    myPolicy.setGroup(group);
    myPolicy.setEPerson(eperson);
    myPolicy.setRpType(rpType);
    resourcePolicyService.update(context, myPolicy);

    return myPolicy;
  }