Search in sources :

Example 11 with ContactGroup

use of cz.metacentrum.perun.core.api.ContactGroup in project perun by CESNET.

the class FacilitiesManagerBlImpl method removeAllOwnerContacts.

@Override
public void removeAllOwnerContacts(PerunSession sess, Owner owner) throws InternalErrorException {
    List<ContactGroup> contactGroups = getFacilityContactGroups(sess, owner);
    this.facilitiesManagerImpl.removeAllOwnerContacts(sess, owner);
    for (ContactGroup contactGroup : contactGroups) {
        sess.getPerun().getAuditer().log(sess, "Owner (" + owner.getId() + ") successfully removed from contact groups " + contactGroup.toString() + ".");
    }
}
Also used : ContactGroup(cz.metacentrum.perun.core.api.ContactGroup)

Example 12 with ContactGroup

use of cz.metacentrum.perun.core.api.ContactGroup in project perun by CESNET.

the class FacilitiesManagerBlImpl method getFacilityContactGroup.

@Override
public ContactGroup getFacilityContactGroup(PerunSession sess, Facility facility, String name) throws InternalErrorException, FacilityContactNotExistsException {
    //need to get richUsers with attributes
    List<AttributeDefinition> mandatoryAttributes = this.getListOfMandatoryAttributes(sess);
    ContactGroup cg = this.getFacilitiesManagerImpl().getFacilityContactGroup(sess, facility, name);
    return this.setAttributesForRichUsersInContactGroup(sess, cg, mandatoryAttributes);
}
Also used : AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup)

Example 13 with ContactGroup

use of cz.metacentrum.perun.core.api.ContactGroup in project perun by CESNET.

the class FacilitiesManagerBlImpl method removeAllUserContacts.

@Override
public void removeAllUserContacts(PerunSession sess, User user) throws InternalErrorException {
    List<ContactGroup> contactGroups = getFacilityContactGroups(sess, user);
    this.facilitiesManagerImpl.removeAllUserContacts(sess, user);
    for (ContactGroup contactGroup : contactGroups) {
        sess.getPerun().getAuditer().log(sess, "User (" + user.getId() + ") successfully removed from contact groups " + contactGroup.toString() + ".");
    }
}
Also used : ContactGroup(cz.metacentrum.perun.core.api.ContactGroup)

Example 14 with ContactGroup

use of cz.metacentrum.perun.core.api.ContactGroup in project perun by CESNET.

the class FacilitiesManagerEntry method removeFacilityContacts.

@Override
public void removeFacilityContacts(PerunSession sess, List<ContactGroup> contactGroupsToRemove) throws InternalErrorException, PrivilegeException, FacilityNotExistsException, UserNotExistsException, OwnerNotExistsException, GroupNotExistsException {
    Utils.checkPerunSession(sess);
    this.checkFacilityContactsEntitiesExist(sess, contactGroupsToRemove);
    Iterator<ContactGroup> iter = contactGroupsToRemove.iterator();
    while (iter.hasNext()) {
        ContactGroup contactGroupToRemove = iter.next();
        if (!AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, contactGroupToRemove.getFacility())) {
            throw new PrivilegeException(sess, "removeFacilityContacts");
        }
    }
    this.getFacilitiesManagerBl().removeFacilityContacts(sess, contactGroupsToRemove);
}
Also used : PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup)

Example 15 with ContactGroup

use of cz.metacentrum.perun.core.api.ContactGroup in project perun by CESNET.

the class FacilitiesManagerImpl method addFacilityContact.

@Override
public ContactGroup addFacilityContact(PerunSession sess, Facility facility, String name, Group group) throws InternalErrorException {
    Utils.notNull(facility, "facility");
    Utils.notNull(group, "group");
    if (name == null || name.isEmpty()) {
        throw new InternalErrorException("ContactGroupName can't be null or empty.");
    }
    ContactGroup contactGroup;
    try {
        jdbc.update("insert into facility_contacts(facility_id, name, group_id) " + "values (?,?,?)", facility.getId(), name, group.getId());
        List<Group> grplist = new ArrayList<>();
        grplist.add(group);
        contactGroup = new ContactGroup(name, facility, grplist, new ArrayList<Owner>(), new ArrayList<RichUser>());
        log.info("Facility contact {} created", contactGroup);
    } catch (RuntimeException ex) {
        throw new InternalErrorException(ex);
    }
    return contactGroup;
}
Also used : Group(cz.metacentrum.perun.core.api.Group) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup) ArrayList(java.util.ArrayList) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) ContactGroup(cz.metacentrum.perun.core.api.ContactGroup)

Aggregations

ContactGroup (cz.metacentrum.perun.core.api.ContactGroup)26 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)10 Test (org.junit.Test)10 Group (cz.metacentrum.perun.core.api.Group)9 RichUser (cz.metacentrum.perun.core.api.RichUser)9 Member (cz.metacentrum.perun.core.api.Member)8 ArrayList (java.util.ArrayList)8 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)6 Owner (cz.metacentrum.perun.core.api.Owner)5 User (cz.metacentrum.perun.core.api.User)4 RelationExistsException (cz.metacentrum.perun.core.api.exceptions.RelationExistsException)2 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)1 BanOnFacility (cz.metacentrum.perun.core.api.BanOnFacility)1 Facility (cz.metacentrum.perun.core.api.Facility)1 Host (cz.metacentrum.perun.core.api.Host)1 SecurityTeam (cz.metacentrum.perun.core.api.SecurityTeam)1 BanNotExistsException (cz.metacentrum.perun.core.api.exceptions.BanNotExistsException)1 FacilityContactNotExistsException (cz.metacentrum.perun.core.api.exceptions.FacilityContactNotExistsException)1 OwnerAlreadyRemovedException (cz.metacentrum.perun.core.api.exceptions.OwnerAlreadyRemovedException)1 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)1