Package org.dspace.authorize
Class ResourcePolicyServiceImpl
java.lang.Object
org.dspace.authorize.ResourcePolicyServiceImpl
- All Implemented Interfaces:
ResourcePolicyService
Service implementation for the ResourcePolicy object.
This class is responsible for all business logic calls for the ResourcePolicy object and is autowired by spring.
This class should never be accessed directly.
- Author:
- kevinvandevelde at atmire.com
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone(Context context, ResourcePolicy resourcePolicy) Create and persist a copy of a given ResourcePolicy, with an empty dSpaceObject field.intcountByEPerson(Context context, EPerson eperson) Count all the resource policies of the ePersonintcountByGroupAndResourceUuid(Context context, Group group, UUID resourceUuid) Count all the resource policies of the group and of the resourceUuidintcountByResouceUuidAndActionId(Context context, UUID resourceUuid, int actionId) Count all the policies related to a resourceUuid and actionIdintcountByResourceUuid(Context context, UUID resourceUuid) Count all the policies by resourceUuidintcountResourcePoliciesByEPersonAndResourceUuid(Context context, EPerson eperson, UUID resourceUuid) Count all the policies related to a resourceUuid belong to an ePersonintcountResourcePolicyByGroup(Context context, Group group) Count all the resource policies of the groupCreate a new ResourcePolicyvoiddelete(Context context, ResourcePolicy resourcePolicy) Delete an ResourcePolicyGet an ResourcePolicy from the database.find(Context c, DSpaceObject o) find(Context c, DSpaceObject o, int actionId) find(Context c, DSpaceObject o, String type) find(Context c, DSpaceObject dso, Group group, int action) Retrieve a list of ResourcePolicies by EPersonfindByEPerson(Context context, EPerson ePerson, int offset, int limit) Return a paginated list of policies that belong to an EPersonfindByEPersonAndResourceUuid(Context context, EPerson eperson, UUID resourceUuid, int offset, int limit) Return a paginated list of policies related to a resourceUuid belong to an ePersonfindByGroup(Context context, Group group, int offset, int limit) Return a paginated list of policies related to a groupfindByGroupAndResourceUuid(Context context, Group group, UUID resourceUuid, int offset, int limit) Return a paginated list of policies related to a group and related to a resourceUuidfindByResouceUuid(Context context, UUID resourceUuid, int offset, int limit) Return a paginated list of policies related to a DSpace resourcefindByResouceUuidAndActionId(Context context, UUID resourceUuid, int actionId, int offset, int limit) Return a paginated list of policies related to a DSpace resource filter by actionIdfindByTypeGroupActionExceptId(Context context, DSpaceObject dso, Group group, int action, int notPolicyID) Look for ResourcePolicies by DSpaceObject, Group, and action, ignoring IDs with a specific PolicyID.findExceptRpType(Context c, DSpaceObject o, int actionID, String rpType) Return a list of policies for an object that match the action except the record labeled with the rpTypegetActionText(ResourcePolicy resourcePolicy) booleanisDateValid(ResourcePolicy resourcePolicy) figures out if the date is valid for the policybooleanisMyResourcePolicy(Context context, EPerson eperson, Integer id) Check if the resource policy identified with (id) belong to ePersonvoidremoveAllEPersonPolicies(Context context, EPerson ePerson) Removes all ResourcePolicies related to an EPersonvoidvoidremoveDsoAndTypeNotEqualsToPolicies(Context c, DSpaceObject o, String type) voidremoveDsoEPersonPolicies(Context context, DSpaceObject dso, EPerson ePerson) voidremoveDsoGroupPolicies(Context context, DSpaceObject dso, Group group) voidremoveGroupPolicies(Context c, Group group) voidremovePolicies(Context c, DSpaceObject o, int actionId) voidremovePolicies(Context c, DSpaceObject o, String type) voidremovePolicies(Context c, DSpaceObject o, String type, int action) voidupdate(Context context, List<ResourcePolicy> resourcePolicies) Update the ResourcePoliciesvoidupdate(Context context, ResourcePolicy resourcePolicy) Update the ResourcePolicy
-
Field Details
-
contentServiceFactory
-
resourcePolicyDAO
-
-
Constructor Details
-
ResourcePolicyServiceImpl
protected ResourcePolicyServiceImpl()
-
-
Method Details
-
find
Get an ResourcePolicy from the database.- Specified by:
findin interfaceResourcePolicyService- Parameters:
context- DSpace context objectid- ID of the ResourcePolicy- Returns:
- the ResourcePolicy format, or null if the ID is invalid.
- Throws:
SQLException- if database error
-
create
Create a new ResourcePolicy- Specified by:
createin interfaceResourcePolicyService- Parameters:
context- DSpace context objectePerson-group-- Returns:
- ResourcePolicy
- Throws:
SQLException- if database error
-
find
- Specified by:
findin interfaceResourcePolicyService- Throws:
SQLException
-
find
- Specified by:
findin interfaceResourcePolicyService- Throws:
SQLException
-
find
- Specified by:
findin interfaceResourcePolicyService- Throws:
SQLException
-
find
- Specified by:
findin interfaceResourcePolicyService- Throws:
SQLException
-
find
public List<ResourcePolicy> find(Context c, DSpaceObject dso, Group group, int action) throws SQLException - Specified by:
findin interfaceResourcePolicyService- Throws:
SQLException
-
find
public List<ResourcePolicy> find(Context c, EPerson e, List<Group> groups, int action, int type_id) throws SQLException - Specified by:
findin interfaceResourcePolicyService- Throws:
SQLException
-
find
Description copied from interface:ResourcePolicyServiceRetrieve a list of ResourcePolicies by EPerson- Specified by:
findin interfaceResourcePolicyService- Parameters:
context- contextePerson- the EPerson for which to look up the resource policies- Returns:
- a list of ResourcePolicies for the provided EPerson
- Throws:
SQLException- if there's a database problem
-
findByTypeGroupActionExceptId
public List<ResourcePolicy> findByTypeGroupActionExceptId(Context context, DSpaceObject dso, Group group, int action, int notPolicyID) throws SQLException Description copied from interface:ResourcePolicyServiceLook for ResourcePolicies by DSpaceObject, Group, and action, ignoring IDs with a specific PolicyID. This method can be used to detect duplicate ResourcePolicies.- Specified by:
findByTypeGroupActionExceptIdin interfaceResourcePolicyService- Parameters:
context- current DSpace session.dso- find policies for this object.group- find policies referring to this group.action- find policies for this action.notPolicyID- ResourcePolicies with this ID will be ignored while looking out for equal ResourcePolicies.- Returns:
- List of resource policies for the same DSpaceObject, group and action but other policyID.
- Throws:
SQLException- passed through.
-
delete
public void delete(Context context, ResourcePolicy resourcePolicy) throws SQLException, AuthorizeException Delete an ResourcePolicy- Specified by:
deletein interfaceResourcePolicyService- Parameters:
context- contextresourcePolicy- resource policy- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
getActionText
- Specified by:
getActionTextin interfaceResourcePolicyService- Parameters:
resourcePolicy- resource policy- Returns:
- action text or 'null' if action row empty
-
isDateValid
figures out if the date is valid for the policy- Specified by:
isDateValidin interfaceResourcePolicyService- Parameters:
resourcePolicy- resource policy- Returns:
- true if policy has begun and hasn't expired yet (or no dates are set)
-
clone
public ResourcePolicy clone(Context context, ResourcePolicy resourcePolicy) throws SQLException, AuthorizeException Description copied from interface:ResourcePolicyServiceCreate and persist a copy of a given ResourcePolicy, with an empty dSpaceObject field.- Specified by:
clonein interfaceResourcePolicyService- Parameters:
context- current DSpace session.resourcePolicy- the policy to be copied.- Returns:
- the copy.
- Throws:
SQLException- passed through.AuthorizeException- passed through.
-
removeAllPolicies
- Specified by:
removeAllPoliciesin interfaceResourcePolicyService- Throws:
SQLExceptionAuthorizeException
-
removePolicies
public void removePolicies(Context c, DSpaceObject o, String type) throws SQLException, AuthorizeException - Specified by:
removePoliciesin interfaceResourcePolicyService- Throws:
SQLExceptionAuthorizeException
-
removePolicies
public void removePolicies(Context c, DSpaceObject o, String type, int action) throws SQLException, AuthorizeException - Specified by:
removePoliciesin interfaceResourcePolicyService- Throws:
SQLExceptionAuthorizeException
-
removeDsoGroupPolicies
public void removeDsoGroupPolicies(Context context, DSpaceObject dso, Group group) throws SQLException, AuthorizeException - Specified by:
removeDsoGroupPoliciesin interfaceResourcePolicyService- Throws:
SQLExceptionAuthorizeException
-
removeDsoEPersonPolicies
public void removeDsoEPersonPolicies(Context context, DSpaceObject dso, EPerson ePerson) throws SQLException, AuthorizeException - Specified by:
removeDsoEPersonPoliciesin interfaceResourcePolicyService- Throws:
SQLExceptionAuthorizeException
-
removeAllEPersonPolicies
public void removeAllEPersonPolicies(Context context, EPerson ePerson) throws SQLException, AuthorizeException Description copied from interface:ResourcePolicyServiceRemoves all ResourcePolicies related to an EPerson- Specified by:
removeAllEPersonPoliciesin interfaceResourcePolicyService- Parameters:
context- contextePerson- the EPerson for which the ResourcePolicies will be deleted- Throws:
SQLException- if there's a database problemAuthorizeException- when the current user is not authorized
-
removeGroupPolicies
- Specified by:
removeGroupPoliciesin interfaceResourcePolicyService- Throws:
SQLException
-
removePolicies
public void removePolicies(Context c, DSpaceObject o, int actionId) throws SQLException, AuthorizeException - Specified by:
removePoliciesin interfaceResourcePolicyService- Throws:
SQLExceptionAuthorizeException
-
removeDsoAndTypeNotEqualsToPolicies
public void removeDsoAndTypeNotEqualsToPolicies(Context c, DSpaceObject o, String type) throws SQLException, AuthorizeException - Specified by:
removeDsoAndTypeNotEqualsToPoliciesin interfaceResourcePolicyService- Throws:
SQLExceptionAuthorizeException
-
update
public void update(Context context, ResourcePolicy resourcePolicy) throws SQLException, AuthorizeException Update the ResourcePolicy- Specified by:
updatein interfaceResourcePolicyService- Parameters:
context- contextresourcePolicy- resource policy- Throws:
SQLException- if database errorAuthorizeException- if authorization error
-
update
public void update(Context context, List<ResourcePolicy> resourcePolicies) throws SQLException, AuthorizeException Update the ResourcePolicies- Specified by:
updatein interfaceResourcePolicyServiceresourcePolicies- object to be persisted.- Throws:
SQLException- passed through.AuthorizeException- passed through.
-
findExceptRpType
public List<ResourcePolicy> findExceptRpType(Context c, DSpaceObject o, int actionID, String rpType) throws SQLException Description copied from interface:ResourcePolicyServiceReturn a list of policies for an object that match the action except the record labeled with the rpType- Specified by:
findExceptRpTypein interfaceResourcePolicyService- Parameters:
c- contexto- DSpaceObject policies relate toactionID- action (defined in class Constants)rpType- the resource policy type- Returns:
- list of resource policies
- Throws:
SQLException- if there's a database problem
-
findByEPerson
public List<ResourcePolicy> findByEPerson(Context context, EPerson ePerson, int offset, int limit) throws SQLException Description copied from interface:ResourcePolicyServiceReturn a paginated list of policies that belong to an EPerson- Specified by:
findByEPersonin interfaceResourcePolicyService- Parameters:
context- DSpace context objectePerson- ePerson whose policies want to findoffset- the position of the first result to returnlimit- paging limit- Returns:
- some of the policies referring to
ePerson. - Throws:
SQLException- if database error
-
countByEPerson
Description copied from interface:ResourcePolicyServiceCount all the resource policies of the ePerson- Specified by:
countByEPersonin interfaceResourcePolicyService- Parameters:
context- DSpace context objecteperson- ePerson whose policies want to count- Returns:
- total resource policies of the ePerson
- Throws:
SQLException- if database error
-
findByEPersonAndResourceUuid
public List<ResourcePolicy> findByEPersonAndResourceUuid(Context context, EPerson eperson, UUID resourceUuid, int offset, int limit) throws SQLException Description copied from interface:ResourcePolicyServiceReturn a paginated list of policies related to a resourceUuid belong to an ePerson- Specified by:
findByEPersonAndResourceUuidin interfaceResourcePolicyService- Parameters:
context- DSpace context objecteperson- ePerson whose policies want to findresourceUuid- the uuid of an DSpace resourceoffset- the position of the first result to returnlimit- paging limit- Returns:
- list of resource policies
- Throws:
SQLException- if database error
-
countResourcePoliciesByEPersonAndResourceUuid
public int countResourcePoliciesByEPersonAndResourceUuid(Context context, EPerson eperson, UUID resourceUuid) throws SQLException Description copied from interface:ResourcePolicyServiceCount all the policies related to a resourceUuid belong to an ePerson- Specified by:
countResourcePoliciesByEPersonAndResourceUuidin interfaceResourcePolicyService- Parameters:
context- DSpace context objecteperson- ePerson whose policies want to findresourceUuid- the uuid of an DSpace resource- Returns:
- total policies
- Throws:
SQLException- if database error
-
findByResouceUuidAndActionId
public List<ResourcePolicy> findByResouceUuidAndActionId(Context context, UUID resourceUuid, int actionId, int offset, int limit) throws SQLException Description copied from interface:ResourcePolicyServiceReturn a paginated list of policies related to a DSpace resource filter by actionId- Specified by:
findByResouceUuidAndActionIdin interfaceResourcePolicyService- Parameters:
context- DSpace context objectresourceUuid- the uuid of an DSpace resourceactionId- id relative to action as READ, WRITE, DELITE etc.offset- the position of the first result to returnlimit- paging limit- Returns:
- list of resource policies
- Throws:
SQLException- if database error
-
countByResouceUuidAndActionId
public int countByResouceUuidAndActionId(Context context, UUID resourceUuid, int actionId) throws SQLException Description copied from interface:ResourcePolicyServiceCount all the policies related to a resourceUuid and actionId- Specified by:
countByResouceUuidAndActionIdin interfaceResourcePolicyService- Parameters:
context- DSpace context objectresourceUuid- the uuid of an DSpace resourceactionId- id relative to action as READ, WRITE, DELITE etc.- Returns:
- total policies
- Throws:
SQLException- if database error
-
findByResouceUuid
public List<ResourcePolicy> findByResouceUuid(Context context, UUID resourceUuid, int offset, int limit) throws SQLException Description copied from interface:ResourcePolicyServiceReturn a paginated list of policies related to a DSpace resource- Specified by:
findByResouceUuidin interfaceResourcePolicyService- Parameters:
context- DSpace context objectresourceUuid- the uuid of an DSpace resourceoffset- the position of the first result to returnlimit- paging limit- Returns:
- list of resource policies
- Throws:
SQLException- if database error
-
countByResourceUuid
Description copied from interface:ResourcePolicyServiceCount all the policies by resourceUuid- Specified by:
countByResourceUuidin interfaceResourcePolicyService- Parameters:
context- DSpace context objectresourceUuid- the uuid of an DSpace resource- Returns:
- total policies
- Throws:
SQLException- if database error
-
findByGroup
public List<ResourcePolicy> findByGroup(Context context, Group group, int offset, int limit) throws SQLException Description copied from interface:ResourcePolicyServiceReturn a paginated list of policies related to a group- Specified by:
findByGroupin interfaceResourcePolicyService- Parameters:
context- DSpace context objectgroup- DSpace groupoffset- the position of the first result to returnlimit- paging limit- Returns:
- list of resource policies
- Throws:
SQLException- if database error
-
countResourcePolicyByGroup
Description copied from interface:ResourcePolicyServiceCount all the resource policies of the group- Specified by:
countResourcePolicyByGroupin interfaceResourcePolicyService- Parameters:
context- DSpace context objectgroup- DSpace group- Returns:
- total policies
- Throws:
SQLException- if database error
-
findByGroupAndResourceUuid
public List<ResourcePolicy> findByGroupAndResourceUuid(Context context, Group group, UUID resourceUuid, int offset, int limit) throws SQLException Description copied from interface:ResourcePolicyServiceReturn a paginated list of policies related to a group and related to a resourceUuid- Specified by:
findByGroupAndResourceUuidin interfaceResourcePolicyService- Parameters:
context- DSpace context objectgroup- DSpace groupresourceUuid- the uuid of an DSpace resourceoffset- the position of the first result to returnlimit- paging limit- Returns:
- list of resource policies
- Throws:
SQLException- if database error
-
countByGroupAndResourceUuid
public int countByGroupAndResourceUuid(Context context, Group group, UUID resourceUuid) throws SQLException Description copied from interface:ResourcePolicyServiceCount all the resource policies of the group and of the resourceUuid- Specified by:
countByGroupAndResourceUuidin interfaceResourcePolicyService- Parameters:
context- DSpace context objectgroup- DSpace groupresourceUuid- the uuid of an DSpace resource- Returns:
- total policies
- Throws:
SQLException- if database error
-
isMyResourcePolicy
Description copied from interface:ResourcePolicyServiceCheck if the resource policy identified with (id) belong to ePerson- Specified by:
isMyResourcePolicyin interfaceResourcePolicyService- Parameters:
context- DSpace context objecteperson- ePersonid- id of resource policy- Returns:
- Throws:
SQLException- if database error
-