Interface ConsentsManagerBl

All Known Implementing Classes:
ConsentsManagerBlImpl

public interface ConsentsManagerBl
Consents BL logic.
Author:
Radoslav Čerhák invalid input: '<'r.cerhak@gmail.com>
  • Method Details

    • addFacility

      void addFacility(PerunSession sess, ConsentHub consentHub, Facility facility) throws FacilityAlreadyAssigned
      Adds facility to consent hub.
      Parameters:
      sess - session
      consentHub - consent hub
      facility - facility to be added
      Throws:
      FacilityAlreadyAssigned - if facility is already assigned to consent hub
    • changeConsentStatus

      Consent changeConsentStatus(PerunSession sess, Consent consent, ConsentStatus status) throws InvalidConsentStatusException
      Set consent status
      Parameters:
      sess - perun session
      consent - consent
      Returns:
      consent
      Throws:
      InvalidConsentStatusException - if passed status value can not be set
    • checkConsentExists

      void checkConsentExists(PerunSession sess, Consent consent) throws ConsentNotExistsException
      Check if consent exists in underlying data source.
      Parameters:
      sess - PerunSession
      consent - Consent to check
      Throws:
      ConsentNotExistsException - if consent doesn't exist
    • checkConsentHubExists

      void checkConsentHubExists(PerunSession sess, ConsentHub consentHub) throws ConsentHubNotExistsException
      Throws exception if consent hub does not exist.
      Parameters:
      sess - session
      consentHub - consent hub
      Throws:
      ConsentHubNotExistsException - if consent hub does not exist
    • consentHubExists

      boolean consentHubExists(PerunSession sess, ConsentHub consentHub)
      Returns true, if consent hub exists, false otherwise.
      Parameters:
      sess - session
      consentHub - consent hub
      Returns:
      whether consent hub exists
    • createConsent

      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.

      Parameters:
      perunSession - perun session
      consent - Consent to create
      Returns:
      created consent
      Throws:
      ConsentExistsException - if consent already exists
      ConsentHubNotExistsException - if consent hub doesn't exist
      UserNotExistsException - if a user with consent's userId doesn't exist
    • createConsentHub

      ConsentHub createConsentHub(PerunSession perunSession, ConsentHub consentHub) throws ConsentHubExistsException
      Creates new consent hub.
      Parameters:
      perunSession - session
      consentHub - consent hub
      Returns:
      new consent hub
      Throws:
      ConsentHubExistsException - if consent hub with similar name exists
    • deleteConsent

      void deleteConsent(PerunSession sess, Consent consent) throws ConsentNotExistsException
      Deletes consent
      Parameters:
      sess - perun session
      consent - consent to delete
      Throws:
      ConsentNotExistsException - if consent doesn't exist
    • deleteConsentHub

      void deleteConsentHub(PerunSession perunSession, ConsentHub consentHub) throws ConsentHubAlreadyRemovedException
      Deletes consent hub.
      Parameters:
      perunSession - session
      consentHub - consent hub
      Throws:
      ConsentHubAlreadyRemovedException - if no such consent hub stored in db
    • evaluateConsents

      List<Member> evaluateConsents(PerunSession sess, Service service, Facility facility, List<Member> members)
      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.

      Parameters:
      sess - perun session
      service - the service
      facility - the facility
      members - the given members
    • evaluateConsents

      List<Member> evaluateConsents(PerunSession sess, Service service, Facility facility, List<Member> members, boolean consentEval)
      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.

      Parameters:
      sess - perun session
      service - the service
      facility - the facility
      members - the given members
      consentEval - if the consent evaluation should be performed
    • evaluateConsents

      void evaluateConsents(PerunSession sess, ConsentHub consentHub)
      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.

      Parameters:
      sess - session
      consentHub - consent hub
    • evaluateConsents

      void evaluateConsents(PerunSession sess, Service service)
      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.

      Parameters:
      sess - session
      service - service
    • getAllConsentHubs

      List<ConsentHub> getAllConsentHubs(PerunSession sess)
      Get list of all Consent Hubs
      Parameters:
      sess - perun session
      Returns:
      list of Consent Hubs
      Throws:
      InternalErrorException - if an exception occurred
    • getAllConsents

      List<Consent> getAllConsents(PerunSession sess)
      Gel all consents
      Parameters:
      sess - perun session
      Returns:
      all existing consents in the database
    • getConsentById

      Consent getConsentById(PerunSession sess, int id) throws ConsentNotExistsException
      Get consent object with specified id
      Parameters:
      sess - perun session
      id - id of desired consent object
      Returns:
      consent object with specified id
      Throws:
      ConsentNotExistsException - thrown if consent with the id doesn't exist
    • getConsentForUserAndConsentHub

      Consent getConsentForUserAndConsentHub(PerunSession sess, int userId, int consentHubId, ConsentStatus status) throws ConsentNotExistsException
      Get consent for chosen user in specified consent hub with specified status
      Parameters:
      sess - perun session
      userId - if of the user
      consentHubId - id of the consent hub
      status - specified status
      Returns:
      consent
      Throws:
      ConsentNotExistsException - thrown if consent with the id doesn't exist
    • getConsentHubByFacility

      ConsentHub getConsentHubByFacility(PerunSession sess, int facilityId) throws ConsentHubNotExistsException
      Finds existing Consent Hub by facility id.
      Parameters:
      sess - perun session
      facilityId - facility for which consent hub is searched
      Returns:
      found Consent Hub
      Throws:
      ConsentHubNotExistsException - if Consent Hub doesn't exist
    • getConsentHubById

      ConsentHub getConsentHubById(PerunSession sess, int id) throws ConsentHubNotExistsException
      Finds existing Consent Hub by id.
      Parameters:
      sess - perun session
      id - id of the Consent Hub you are looking for
      Returns:
      found Consent Hub
      Throws:
      ConsentHubNotExistsException - if Consent Hub doesn't exist
      InternalErrorException - if an exception occurred
    • getConsentHubByName

      ConsentHub getConsentHubByName(PerunSession sess, String name) throws ConsentHubNotExistsException
      Finds existing Consent Hub by name.
      Parameters:
      sess - perun session
      name - name of the Consent Hub you are looking for
      Returns:
      found Consent Hub
      Throws:
      ConsentHubNotExistsException - if Consent Hub doesn't exist
      InternalErrorException - if an exception occurred
    • getConsentHubsByService

      List<ConsentHub> getConsentHubsByService(PerunSession sess, int serviceId) throws ConsentHubNotExistsException
      Finds all existing Consent Hubs by service id (consent hubs that have given service assigned through facilities).
      Parameters:
      sess - perun session
      serviceId - service for which consent hubs is searched
      Returns:
      found Consent Hubs
      Throws:
      ConsentHubNotExistsException - if Consent Hub doesn't exist
    • getConsentsForConsentHub

      List<Consent> getConsentsForConsentHub(PerunSession sess, int id, ConsentStatus status)
      Get all consents for chosen ConsentHub with the specified status
      Parameters:
      sess - perun session
      id - id of the ConsentHub
      status - status of the consent
      Returns:
      consents for chosen ConsentHub with the specified status
    • getConsentsForConsentHub

      List<Consent> getConsentsForConsentHub(PerunSession sess, int id)
      Get all consents for chosen ConsentHub
      Parameters:
      sess - perun session
      id - id of the ConsentHub
      Returns:
      consents for chosen ConsentHub
    • getConsentsForUser

      List<Consent> getConsentsForUser(PerunSession sess, int id, ConsentStatus status)
      Get all consents for chosen User with the specified status
      Parameters:
      sess - perun session
      id - id of the User
      status - status of the consent
      Returns:
      consents for chosen User with the specified status
    • getConsentsForUser

      List<Consent> getConsentsForUser(PerunSession sess, int id)
      Get all consents for chosen User
      Parameters:
      sess - perun session
      id - id of the user
      Returns:
      consents for chosen User
    • getConsentsForUserAndConsentHub

      List<Consent> getConsentsForUserAndConsentHub(PerunSession sess, int userId, int consentHubId)
      Get all consents for chosen user in specified consent hub
      Parameters:
      sess - perun session
      userId - id of the user
      consentHubId - id of the consent hub
      Returns:
      consents
    • removeFacility

      void removeFacility(PerunSession sess, ConsentHub consentHub, Facility facility) throws RelationNotExistsException, ConsentHubAlreadyRemovedException
      Removes facility from consent hub. If it was the last facility on consent hub, deletes consent hub too.
      Parameters:
      sess - session
      consentHub - consent hub
      facility - facility to be removed
      Throws:
      RelationNotExistsException - if facility is not assigned to consent hub
      ConsentHubAlreadyRemovedException - if the last facility was removed and deletion of consent hub failed
    • updateConsentHub

      ConsentHub updateConsentHub(PerunSession perunSession, ConsentHub consentHub) throws ConsentHubExistsException
      Updates the ConsentHub. Ignores related facilities.
      Parameters:
      perunSession - session
      consentHub - consentHub
      Returns:
      updated consent hub
      Throws:
      ConsentHubExistsException - if consent hub with the same name exists