Class ConsentsManagerBlImpl
- All Implemented Interfaces:
ConsentsManagerBl
- Author:
- Radoslav Čerhák invalid input: '<'r.cerhak@gmail.com>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFacility(PerunSession sess, ConsentHub consentHub, Facility facility) Adds facility to consent hub.changeConsentStatus(PerunSession sess, Consent consent, ConsentStatus status) Set consent statusvoidcheckConsentExists(PerunSession sess, Consent consent) Check if consent exists in underlying data source.voidcheckConsentHubExists(PerunSession sess, ConsentHub consentHub) Throws exception if consent hub does not exist.booleanconsentHubExists(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.voiddeleteConsent(PerunSession sess, Consent consent) Deletes consentvoiddeleteConsentHub(PerunSession sess, ConsentHub consentHub) Deletes consent hub.voidevaluateConsents(PerunSession sess, ConsentHub consentHub) Evaluates consents for given consent hub with enforced consents enabled.voidevaluateConsents(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 hubvoidremoveFacility(PerunSession sess, ConsentHub consentHub, Facility facility) Removes facility from consent hub.voidsetPerunBl(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:ConsentsManagerBlAdds facility to consent hub.- Specified by:
addFacilityin 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:ConsentsManagerBlSet consent status- Specified by:
changeConsentStatusin interfaceConsentsManagerBl- Parameters:
sess- perun sessionconsent- consent- Returns:
- consent
- Throws:
InvalidConsentStatusException- if passed status value can not be set
-
checkConsentExists
Description copied from interface:ConsentsManagerBlCheck if consent exists in underlying data source.- Specified by:
checkConsentExistsin 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:ConsentsManagerBlThrows exception if consent hub does not exist.- Specified by:
checkConsentHubExistsin interfaceConsentsManagerBl- Parameters:
sess- sessionconsentHub- consent hub- Throws:
ConsentHubNotExistsException- if consent hub does not exist
-
consentHubExists
Description copied from interface:ConsentsManagerBlReturns true, if consent hub exists, false otherwise.- Specified by:
consentHubExistsin 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:ConsentsManagerBlCreates 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:
createConsentin 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:ConsentsManagerBlCreates new consent hub.- Specified by:
createConsentHubin interfaceConsentsManagerBl- Parameters:
sess- sessionconsentHub- consent hub- Returns:
- new consent hub
- Throws:
ConsentHubExistsException- if consent hub with similar name exists
-
deleteConsent
Description copied from interface:ConsentsManagerBlDeletes consent- Specified by:
deleteConsentin 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:ConsentsManagerBlDeletes consent hub.- Specified by:
deleteConsentHubin 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:ConsentsManagerBlThis 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:
evaluateConsentsin 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:ConsentsManagerBlThis 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:
evaluateConsentsin interfaceConsentsManagerBl- Parameters:
sess- perun sessionservice- the servicefacility- the facilitymembers- the given membersconsentEval- if the consent evaluation should be performed
-
evaluateConsents
Description copied from interface:ConsentsManagerBlEvaluates 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:
evaluateConsentsin interfaceConsentsManagerBl- Parameters:
sess- sessionconsentHub- consent hub
-
evaluateConsents
Description copied from interface:ConsentsManagerBlConsolidate 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:
evaluateConsentsin interfaceConsentsManagerBl- Parameters:
sess- sessionservice- service
-
getAllConsentHubs
Description copied from interface:ConsentsManagerBlGet list of all Consent Hubs- Specified by:
getAllConsentHubsin interfaceConsentsManagerBl- Parameters:
sess- perun session- Returns:
- list of Consent Hubs
-
getAllConsents
Description copied from interface:ConsentsManagerBlGel all consents- Specified by:
getAllConsentsin interfaceConsentsManagerBl- Parameters:
sess- perun session- Returns:
- all existing consents in the database
-
getConsentById
Description copied from interface:ConsentsManagerBlGet consent object with specified id- Specified by:
getConsentByIdin 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:ConsentsManagerBlGet consent for chosen user in specified consent hub with specified status- Specified by:
getConsentForUserAndConsentHubin 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:ConsentsManagerBlFinds existing Consent Hub by facility id.- Specified by:
getConsentHubByFacilityin 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:ConsentsManagerBlFinds existing Consent Hub by id.- Specified by:
getConsentHubByIdin 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:ConsentsManagerBlFinds existing Consent Hub by name.- Specified by:
getConsentHubByNamein 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:ConsentsManagerBlFinds all existing Consent Hubs by service id (consent hubs that have given service assigned through facilities).- Specified by:
getConsentHubsByServicein 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:ConsentsManagerBlGet all consents for chosen ConsentHub with the specified status- Specified by:
getConsentsForConsentHubin 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:ConsentsManagerBlGet all consents for chosen ConsentHub- Specified by:
getConsentsForConsentHubin interfaceConsentsManagerBl- Parameters:
sess- perun sessionid- id of the ConsentHub- Returns:
- consents for chosen ConsentHub
-
getConsentsForUser
Description copied from interface:ConsentsManagerBlGet all consents for chosen User with the specified status- Specified by:
getConsentsForUserin 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:ConsentsManagerBlGet all consents for chosen User- Specified by:
getConsentsForUserin 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:ConsentsManagerBlGet all consents for chosen user in specified consent hub- Specified by:
getConsentsForUserAndConsentHubin 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:ConsentsManagerBlRemoves facility from consent hub. If it was the last facility on consent hub, deletes consent hub too.- Specified by:
removeFacilityin 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:ConsentsManagerBlUpdates the ConsentHub. Ignores related facilities.- Specified by:
updateConsentHubin interfaceConsentsManagerBl- Parameters:
perunSession- sessionconsentHub- consentHub- Returns:
- updated consent hub
- Throws:
ConsentHubExistsException- if consent hub with the same name exists
-