rp.setRpName(element.getAttributeValue("rpName"));
@Override public ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson, int type, String rpType, String rpName, String rpDescription, Date startDate, Date endDate) 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); myPolicy.setRpName(rpName); myPolicy.setRpDescription(rpDescription); myPolicy.setEndDate(endDate); myPolicy.setStartDate(startDate); resourcePolicyService.update(context, myPolicy); return myPolicy; }
policy.setEndDate(null); policy.setRpName(name); policy.setRpDescription(reason); return policy;
@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); }
rp.setGroup(group); rp.setRpName(name); rp.setRpDescription(description); rp.setStartDate(startDate); rp.setGroup(group); rp.setRpName(name); rp.setRpDescription(description); rp.setStartDate(startDate); rp.setGroup(group); rp.setRpName(name); rp.setRpDescription(description); rp.setStartDate(startDate);
/** * Add policy(org.dspace.rest.common.ResourcePolicy) to bitstream. * * @param context Context to create DSpace ResourcePolicy. * @param policy Policy which will be added to bitstream. * @param dspaceBitstream DSpace Bitstream object. * @throws SQLException An exception that provides information on a database access error or other errors. * @throws AuthorizeException Exception indicating the current user of the context does not have permission * to perform a particular action. */ private void addPolicyToBitstream(org.dspace.core.Context context, ResourcePolicy policy, org.dspace.content.Bitstream dspaceBitstream) throws SQLException, AuthorizeException { org.dspace.authorize.ResourcePolicy dspacePolicy = resourcePolicyService.create(context); dspacePolicy.setAction(policy.getActionInt()); dspacePolicy.setGroup(groupService.findByIdOrLegacyId(context, policy.getGroupId())); dspacePolicy.setdSpaceObject(dspaceBitstream); dspacePolicy.setStartDate(policy.getStartDate()); dspacePolicy.setEndDate(policy.getEndDate()); dspacePolicy.setRpDescription(policy.getRpDescription()); dspacePolicy.setRpName(policy.getRpName()); resourcePolicyService.update(context, dspacePolicy); }