Class ConsentsManagerBlImpl
- All Implemented Interfaces:
ConsentsManagerBl
- Author:
- Radoslav Čerhák invalid input: '<'r.cerhak@gmail.com>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFacility
(PerunSession sess, ConsentHub consentHub, Facility facility) Adds facility to consent hub.changeConsentStatus
(PerunSession sess, Consent consent, ConsentStatus status) Set consent statusvoid
checkConsentExists
(PerunSession sess, Consent consent) Check if consent exists in underlying data source.void
checkConsentHubExists
(PerunSession sess, ConsentHub consentHub) Throws exception if consent hub does not exist.boolean
consentHubExists
(PerunSession sess, ConsentHub consentHub) Returns true, if consent hub exists, false otherwise.createConsent
(PerunSession sess, Consent consent) Creates a new consent with status 'UNSIGNED'.createConsentHub
(PerunSession sess, ConsentHub consentHub) Creates new consent hub.void
deleteConsent
(PerunSession sess, Consent consent) Deletes consentvoid
deleteConsentHub
(PerunSession sess, ConsentHub consentHub) Deletes consent hub.void
evaluateConsents
(PerunSession sess, ConsentHub consentHub) Evaluates consents for given consent hub with enforced consents enabled.void
evaluateConsents
(PerunSession sess, Service service) Consolidate consents using given service on consent hubs the service is assigned to.evaluateConsents
(PerunSession sess, Service service, Facility facility, List<Member> members) This method runs in a new transaction!!evaluateConsents
(PerunSession sess, Service service, Facility facility, List<Member> members, boolean consentEval) This method runs in a new transaction!!Get list of all Consent HubsgetAllConsents
(PerunSession sess) Gel all consentsgetConsentById
(PerunSession sess, int id) Get consent object with specified idgetConsentForUserAndConsentHub
(PerunSession sess, int userId, int consentHubId, ConsentStatus status) Get consent for chosen user in specified consent hub with specified statusgetConsentHubByFacility
(PerunSession sess, int facilityId) Finds existing Consent Hub by facility id.getConsentHubById
(PerunSession sess, int id) Finds existing Consent Hub by id.getConsentHubByName
(PerunSession sess, String name) Finds existing Consent Hub by name.getConsentHubsByService
(PerunSession sess, int serviceId) Finds all existing Consent Hubs by service id (consent hubs that have given service assigned through facilities).getConsentsForConsentHub
(PerunSession sess, int id) Get all consents for chosen ConsentHubgetConsentsForConsentHub
(PerunSession sess, int id, ConsentStatus status) Get all consents for chosen ConsentHub with the specified statusgetConsentsForUser
(PerunSession sess, int id) Get all consents for chosen UsergetConsentsForUser
(PerunSession sess, int id, ConsentStatus status) Get all consents for chosen User with the specified statusgetConsentsForUserAndConsentHub
(PerunSession sess, int userId, int consentHubId) Get all consents for chosen user in specified consent hubvoid
removeFacility
(PerunSession sess, ConsentHub consentHub, Facility facility) Removes facility from consent hub.void
setPerunBl
(PerunBl perunBl) updateConsentHub
(PerunSession perunSession, ConsentHub consentHub) Updates the ConsentHub.
-
Constructor Details
-
ConsentsManagerBlImpl
-
-
Method Details
-
addFacility
public void addFacility(PerunSession sess, ConsentHub consentHub, Facility facility) throws FacilityAlreadyAssigned Description copied from interface:ConsentsManagerBl
Adds facility to consent hub.- Specified by:
addFacility
in interfaceConsentsManagerBl
- Parameters:
sess
- sessionconsentHub
- consent hubfacility
- facility to be added- Throws:
FacilityAlreadyAssigned
- if facility is already assigned to consent hub
-
changeConsentStatus
public Consent changeConsentStatus(PerunSession sess, Consent consent, ConsentStatus status) throws InvalidConsentStatusException Description copied from interface:ConsentsManagerBl
Set consent status- Specified by:
changeConsentStatus
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionconsent
- consent- Returns:
- consent
- Throws:
InvalidConsentStatusException
- if passed status value can not be set
-
checkConsentExists
Description copied from interface:ConsentsManagerBl
Check if consent exists in underlying data source.- Specified by:
checkConsentExists
in interfaceConsentsManagerBl
- Parameters:
sess
- PerunSessionconsent
- Consent to check- Throws:
ConsentNotExistsException
- if consent doesn't exist
-
checkConsentHubExists
public void checkConsentHubExists(PerunSession sess, ConsentHub consentHub) throws ConsentHubNotExistsException Description copied from interface:ConsentsManagerBl
Throws exception if consent hub does not exist.- Specified by:
checkConsentHubExists
in interfaceConsentsManagerBl
- Parameters:
sess
- sessionconsentHub
- consent hub- Throws:
ConsentHubNotExistsException
- if consent hub does not exist
-
consentHubExists
Description copied from interface:ConsentsManagerBl
Returns true, if consent hub exists, false otherwise.- Specified by:
consentHubExists
in interfaceConsentsManagerBl
- Parameters:
sess
- sessionconsentHub
- consent hub- Returns:
- whether consent hub exists
-
createConsent
public Consent createConsent(PerunSession sess, Consent consent) throws ConsentExistsException, ConsentHubNotExistsException, UserNotExistsException Description copied from interface:ConsentsManagerBl
Creates a new consent with status 'UNSIGNED'. Consent's attributes are computed based on the attributes of the user and the consent hub. Attributes in the consent are ignored!If the user has already 'UNSIGNED' consent for the same consent hub, that consent is deleted and replaced with the new one.
- Specified by:
createConsent
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionconsent
- Consent to create- Returns:
- created consent
- Throws:
ConsentExistsException
- if consent already existsConsentHubNotExistsException
- if consent hub doesn't existUserNotExistsException
- if a user with consent's userId doesn't exist
-
createConsentHub
public ConsentHub createConsentHub(PerunSession sess, ConsentHub consentHub) throws ConsentHubExistsException Description copied from interface:ConsentsManagerBl
Creates new consent hub.- Specified by:
createConsentHub
in interfaceConsentsManagerBl
- Parameters:
sess
- sessionconsentHub
- consent hub- Returns:
- new consent hub
- Throws:
ConsentHubExistsException
- if consent hub with similar name exists
-
deleteConsent
Description copied from interface:ConsentsManagerBl
Deletes consent- Specified by:
deleteConsent
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionconsent
- consent to delete- Throws:
ConsentNotExistsException
- if consent doesn't exist
-
deleteConsentHub
public void deleteConsentHub(PerunSession sess, ConsentHub consentHub) throws ConsentHubAlreadyRemovedException Description copied from interface:ConsentsManagerBl
Deletes consent hub.- Specified by:
deleteConsentHub
in interfaceConsentsManagerBl
- Parameters:
sess
- sessionconsentHub
- consent hub- Throws:
ConsentHubAlreadyRemovedException
- if no such consent hub stored in db
-
evaluateConsents
public List<Member> evaluateConsents(PerunSession sess, Service service, Facility facility, List<Member> members) Description copied from interface:ConsentsManagerBl
This method runs in a new transaction!! Because it is used by getData methods which run in read-only serializable transactions.Returns members from the given members list that have a valid consent for the propagation of the service required attributes to the facility.
Users must have a consent for the facility's consent hub with status GRANTED and it contains all the required attributes.
If the user has no consent in any status that contains all the required attributes, a new UNSIGNED consent is created for the user.
If the consent logic is turned off on the instance (property forceConsents) or the facility's consent hub doesn't enforce consents, all members are returned and no unsigned consents for users are created.
- Specified by:
evaluateConsents
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionservice
- the servicefacility
- the facilitymembers
- the given members
-
evaluateConsents
public List<Member> evaluateConsents(PerunSession sess, Service service, Facility facility, List<Member> members, boolean consentEval) Description copied from interface:ConsentsManagerBl
This method runs in a new transaction!! Because it is used by getData methods which run in read-only serializable transactions.Returns members from the given members list that have a valid consent for the propagation of the service required attributes to the facility.
Users must have a consent for the facility's consent hub with status GRANTED and it contains all the required attributes.
If the user has no consent in any status that contains all the required attributes, a new UNSIGNED consent is created for the user.
If the consent logic is turned off on the instance (property forceConsents) or the facility's consent hub doesn't enforce consents, all members are returned and no unsigned consents for users are created.
If the consent evaluation is turned off (in CLI without the -c option), the members with UNSIGNED consent creation is skipped.
- Specified by:
evaluateConsents
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionservice
- the servicefacility
- the facilitymembers
- the given membersconsentEval
- if the consent evaluation should be performed
-
evaluateConsents
Description copied from interface:ConsentsManagerBl
Evaluates consents for given consent hub with enforced consents enabled.For given ConsentHub, collects all attributes from services assigned to it and compares it against attributes from users' Consent objects that are assigned to resources of given ConsentHub object.
Service defines whether only active users will be evaluated or expired ones as well.
- Specified by:
evaluateConsents
in interfaceConsentsManagerBl
- Parameters:
sess
- sessionconsentHub
- consent hub
-
evaluateConsents
Description copied from interface:ConsentsManagerBl
Consolidate consents using given service on consent hubs the service is assigned to.Method finds all consent hubs that contain given service in any of its facilities and start consent consolidation for each consent hub (only selected service in consent hubs will be checked). Service defines whether only active users will be evaluated or expired ones as well. If new consent is created, attributes from ALL services under given consent hub are gathered for it.
- Specified by:
evaluateConsents
in interfaceConsentsManagerBl
- Parameters:
sess
- sessionservice
- service
-
getAllConsentHubs
Description copied from interface:ConsentsManagerBl
Get list of all Consent Hubs- Specified by:
getAllConsentHubs
in interfaceConsentsManagerBl
- Parameters:
sess
- perun session- Returns:
- list of Consent Hubs
-
getAllConsents
Description copied from interface:ConsentsManagerBl
Gel all consents- Specified by:
getAllConsents
in interfaceConsentsManagerBl
- Parameters:
sess
- perun session- Returns:
- all existing consents in the database
-
getConsentById
Description copied from interface:ConsentsManagerBl
Get consent object with specified id- Specified by:
getConsentById
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionid
- id of desired consent object- Returns:
- consent object with specified id
- Throws:
ConsentNotExistsException
- thrown if consent with the id doesn't exist
-
getConsentForUserAndConsentHub
public Consent getConsentForUserAndConsentHub(PerunSession sess, int userId, int consentHubId, ConsentStatus status) throws ConsentNotExistsException Description copied from interface:ConsentsManagerBl
Get consent for chosen user in specified consent hub with specified status- Specified by:
getConsentForUserAndConsentHub
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionuserId
- if of the userconsentHubId
- id of the consent hubstatus
- specified status- Returns:
- consent
- Throws:
ConsentNotExistsException
- thrown if consent with the id doesn't exist
-
getConsentHubByFacility
public ConsentHub getConsentHubByFacility(PerunSession sess, int facilityId) throws ConsentHubNotExistsException Description copied from interface:ConsentsManagerBl
Finds existing Consent Hub by facility id.- Specified by:
getConsentHubByFacility
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionfacilityId
- facility for which consent hub is searched- Returns:
- found Consent Hub
- Throws:
ConsentHubNotExistsException
- if Consent Hub doesn't exist
-
getConsentHubById
Description copied from interface:ConsentsManagerBl
Finds existing Consent Hub by id.- Specified by:
getConsentHubById
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionid
- id of the Consent Hub you are looking for- Returns:
- found Consent Hub
- Throws:
ConsentHubNotExistsException
- if Consent Hub doesn't exist
-
getConsentHubByName
public ConsentHub getConsentHubByName(PerunSession sess, String name) throws ConsentHubNotExistsException Description copied from interface:ConsentsManagerBl
Finds existing Consent Hub by name.- Specified by:
getConsentHubByName
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionname
- name of the Consent Hub you are looking for- Returns:
- found Consent Hub
- Throws:
ConsentHubNotExistsException
- if Consent Hub doesn't exist
-
getConsentHubsByService
public List<ConsentHub> getConsentHubsByService(PerunSession sess, int serviceId) throws ConsentHubNotExistsException Description copied from interface:ConsentsManagerBl
Finds all existing Consent Hubs by service id (consent hubs that have given service assigned through facilities).- Specified by:
getConsentHubsByService
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionserviceId
- service for which consent hubs is searched- Returns:
- found Consent Hubs
- Throws:
ConsentHubNotExistsException
- if Consent Hub doesn't exist
-
getConsentsForConsentHub
Description copied from interface:ConsentsManagerBl
Get all consents for chosen ConsentHub with the specified status- Specified by:
getConsentsForConsentHub
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionid
- id of the ConsentHubstatus
- status of the consent- Returns:
- consents for chosen ConsentHub with the specified status
-
getConsentsForConsentHub
Description copied from interface:ConsentsManagerBl
Get all consents for chosen ConsentHub- Specified by:
getConsentsForConsentHub
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionid
- id of the ConsentHub- Returns:
- consents for chosen ConsentHub
-
getConsentsForUser
Description copied from interface:ConsentsManagerBl
Get all consents for chosen User with the specified status- Specified by:
getConsentsForUser
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionid
- id of the Userstatus
- status of the consent- Returns:
- consents for chosen User with the specified status
-
getConsentsForUser
Description copied from interface:ConsentsManagerBl
Get all consents for chosen User- Specified by:
getConsentsForUser
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionid
- id of the user- Returns:
- consents for chosen User
-
getConsentsForUserAndConsentHub
public List<Consent> getConsentsForUserAndConsentHub(PerunSession sess, int userId, int consentHubId) Description copied from interface:ConsentsManagerBl
Get all consents for chosen user in specified consent hub- Specified by:
getConsentsForUserAndConsentHub
in interfaceConsentsManagerBl
- Parameters:
sess
- perun sessionuserId
- id of the userconsentHubId
- id of the consent hub- Returns:
- consents
-
getConsentsManagerImpl
-
getPerunBl
-
removeFacility
public void removeFacility(PerunSession sess, ConsentHub consentHub, Facility facility) throws RelationNotExistsException, ConsentHubAlreadyRemovedException Description copied from interface:ConsentsManagerBl
Removes facility from consent hub. If it was the last facility on consent hub, deletes consent hub too.- Specified by:
removeFacility
in interfaceConsentsManagerBl
- Parameters:
sess
- sessionconsentHub
- consent hubfacility
- facility to be removed- Throws:
RelationNotExistsException
- if facility is not assigned to consent hubConsentHubAlreadyRemovedException
- if the last facility was removed and deletion of consent hub failed
-
setPerunBl
-
updateConsentHub
public ConsentHub updateConsentHub(PerunSession perunSession, ConsentHub consentHub) throws ConsentHubExistsException Description copied from interface:ConsentsManagerBl
Updates the ConsentHub. Ignores related facilities.- Specified by:
updateConsentHub
in interfaceConsentsManagerBl
- Parameters:
perunSession
- sessionconsentHub
- consentHub- Returns:
- updated consent hub
- Throws:
ConsentHubExistsException
- if consent hub with the same name exists
-