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() + ".");
}
}
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);
}
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() + ".");
}
}
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);
}
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;
}
Aggregations