use of cz.metacentrum.perun.core.api.exceptions.FacilityContactNotExistsException in project perun by CESNET.
the class FacilitiesManagerImpl method getFacilityContactGroup.
@Override
public ContactGroup getFacilityContactGroup(PerunSession sess, Facility facility, String name) throws InternalErrorException, FacilityContactNotExistsException {
try {
List<ContactGroup> contactGroups = jdbc.query("select " + facilityContactsMappingSelectQueryWithAllEntities + " from facility_contacts " + "left join facilities on facilities.id=facility_contacts.facility_id " + "left join owners on owners.id=facility_contacts.owner_id " + "left join users on users.id=facility_contacts.user_id " + "left join groups on groups.id=facility_contacts.group_id " + "where facility_contacts.facility_id=? and facility_contacts.name=?", FACILITY_CONTACT_MAPPER, facility.getId(), name);
contactGroups = mergeContactGroups(contactGroups);
if (contactGroups.size() == 1) {
return contactGroups.get(0);
} else {
throw new InternalErrorException("Merging group contacts for facility " + facility + " and contact name " + name + " failed, more than 1 object returned " + name);
}
} catch (EmptyResultDataAccessException ex) {
throw new FacilityContactNotExistsException(facility, name);
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
Aggregations