@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 createOrModifyPolicy(
      ResourcePolicy policy,
      Context context,
      String name,
      Group group,
      EPerson ePerson,
      Date embargoDate,
      int action,
      String reason,
      DSpaceObject dso)
      throws AuthorizeException, SQLException {

    int policyID = -1;
    if (policy != null) policyID = policy.getID();

    // if an identical policy (same Action and same Group) is already in place modify it...
    ResourcePolicy policyTemp = findByTypeIdGroupAction(context, dso, group, action, policyID);
    if (policyTemp != null) {
      policy = policyTemp;
      policy.setRpType(ResourcePolicy.TYPE_CUSTOM);
    }

    if (policy == null) {
      policy =
          createResourcePolicy(context, dso, group, ePerson, action, ResourcePolicy.TYPE_CUSTOM);
    }
    policy.setGroup(group);
    policy.setEPerson(ePerson);

    if (embargoDate != null) {
      policy.setStartDate(embargoDate);
    } else {
      policy.setStartDate(null);
      policy.setEndDate(null);
    }
    policy.setRpName(name);
    policy.setRpDescription(reason);
    return policy;
  }