#8783 Strip out unused generateAutomaticPolicies method from AuthorizeService

This commit is contained in:
Kim Shepherd
2023-05-12 14:18:08 +12:00
parent 019d0319dc
commit 4a88573dc1
2 changed files with 1 additions and 82 deletions

View File

@@ -654,69 +654,6 @@ public class AuthorizeServiceImpl implements AuthorizeService {
}
}
/**
* Generate Policies policies READ for the date in input adding reason. New policies are assigned automatically
* at the groups that
* have right on the collection. E.g., if the anonymous can access the collection policies are assigned to
* anonymous.
*
* @param context The relevant DSpace Context.
* @param embargoDate embargo end date
* @param reason embargo reason
* @param dso DSpace object
* @param owningCollection collection to get group policies from
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
@Override
public void generateAutomaticPolicies(Context context, Date embargoDate,
String reason, DSpaceObject dso, Collection owningCollection)
throws SQLException, AuthorizeException {
if (embargoDate != null || (embargoDate == null && dso instanceof Bitstream)) {
// Get DEFAULT_BITSTREAM_READ policy from the collection
List<Group> defaultBitstreamReadGroups =
getAuthorizedGroups(context, owningCollection, Constants.DEFAULT_BITSTREAM_READ);
// Get DEFAULT_ITEM_READ policy from the collection
List<Group> defaultItemReadGroups =
getAuthorizedGroups(context, owningCollection, Constants.DEFAULT_ITEM_READ);
// By default, use DEFAULT_BITSTREAM_READ. Otherwise, use DEFAULT_ITEM_READ
List<Group> authorizedGroups = defaultBitstreamReadGroups;
if (defaultBitstreamReadGroups.isEmpty()) {
authorizedGroups = defaultItemReadGroups;
}
removeAllPoliciesByDSOAndType(context, dso, ResourcePolicy.TYPE_CUSTOM);
// look for anonymous
boolean isAnonymousInPlace = false;
for (Group g : authorizedGroups) {
if (StringUtils.equals(g.getName(), Group.ANONYMOUS)) {
isAnonymousInPlace = true;
}
}
if (!isAnonymousInPlace) {
// add policies for all the groups
for (Group g : authorizedGroups) {
ResourcePolicy rp = createOrModifyPolicy(null, context, null, g, null, embargoDate, Constants.READ,
reason, dso);
if (rp != null) {
resourcePolicyService.update(context, rp);
}
}
} else {
// add policy just for anonymous
ResourcePolicy rp = createOrModifyPolicy(null, context, null,
groupService.findByName(context, Group.ANONYMOUS), null,
embargoDate, Constants.READ, reason, dso);
if (rp != null) {
resourcePolicyService.update(context, rp);
}
}
}
}
@Override
public ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson,
int type, String rpType) throws SQLException, AuthorizeException {

View File

@@ -470,24 +470,6 @@ public interface AuthorizeService {
public ResourcePolicy findByTypeGroupAction(Context c, DSpaceObject dso, Group group, int action)
throws SQLException;
/**
* Generate Policies policies READ for the date in input adding reason. New policies are assigned automatically
* at the groups that
* have right on the collection. E.g., if the anonymous can access the collection policies are assigned to
* anonymous.
*
* @param context current context
* @param embargoDate date
* @param reason reason
* @param dso DSpaceObject
* @param owningCollection collection
* @throws SQLException if database error
* @throws AuthorizeException if authorization error
*/
public void generateAutomaticPolicies(Context context, Date embargoDate, String reason, DSpaceObject dso,
Collection owningCollection) throws SQLException, AuthorizeException;
public ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson,
int type, String rpType) throws SQLException, AuthorizeException;
@@ -603,7 +585,7 @@ public interface AuthorizeService {
/**
* Replace all the policies in the target object with exactly the same policies that exist in the source object
*
*
* @param context DSpace Context
* @param source source of policies
* @param dest destination of inherited policies