use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerBlImpl method removeBan.
public void removeBan(PerunSession sess, int banId) throws InternalErrorException, BanNotExistsException {
BanOnFacility ban = this.getBanById(sess, banId);
getFacilitiesManagerImpl().removeBan(sess, banId);
getPerunBl().getAuditer().log(sess, "Ban {} was removed for userId {} on facilityId {}.", ban, ban.getUserId(), ban.getFacilityId());
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method getBansForUser.
@Test
public void getBansForUser() throws Exception {
System.out.println(CLASS_NAME + "getBansForUser");
Vo vo = setUpVo();
Resource resource = setUpResource(vo);
Member member = setUpMember(vo);
User user = perun.getUsersManagerBl().getUserByMember(sess, member);
Group group = setUpGroup(vo, member);
perun.getResourcesManagerBl().assignGroupToResource(sess, group, resource);
BanOnFacility banOnFacility = new BanOnFacility();
banOnFacility.setUserId(user.getId());
banOnFacility.setFacilityId(facility.getId());
banOnFacility.setDescription("Popisek");
banOnFacility.setValidityTo(new Date());
banOnFacility = facilitiesManagerEntry.setBan(sess, banOnFacility);
List<BanOnFacility> returnedBans = facilitiesManagerEntry.getBansForUser(sess, banOnFacility.getUserId());
assertEquals(banOnFacility, returnedBans.get(0));
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerBlImpl method deleteFacility.
public void deleteFacility(PerunSession sess, Facility facility) throws InternalErrorException, RelationExistsException, FacilityAlreadyRemovedException, HostAlreadyRemovedException, GroupAlreadyRemovedException, ResourceAlreadyRemovedException, GroupAlreadyRemovedFromResourceException {
if (getFacilitiesManagerImpl().getAssignedResources(sess, facility).size() > 0) {
throw new RelationExistsException("Facility is still used as a resource");
}
//remove hosts
List<Host> hosts = this.getHosts(sess, facility);
for (Host host : hosts) {
this.removeHost(sess, host);
}
//remove destinations
getPerunBl().getServicesManagerBl().removeAllDestinations(sess, facility);
// remove assigned security teams
List<SecurityTeam> teams = getAssignedSecurityTeams(sess, facility);
for (SecurityTeam team : teams) {
removeSecurityTeam(sess, facility, team);
}
// remove assigned facility contacts
List<ContactGroup> contacts = getFacilityContactGroups(sess, facility);
if (contacts != null && !contacts.isEmpty()) {
removeFacilityContacts(sess, contacts);
}
// remove associated attributes
try {
getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, facility);
} catch (WrongAttributeValueException e) {
throw new InternalErrorException(e);
} catch (WrongReferenceAttributeValueException e) {
throw new InternalErrorException(e);
}
//Remove all facility bans
List<BanOnFacility> bansOnFacility = this.getBansForFacility(sess, facility.getId());
for (BanOnFacility banOnFacility : bansOnFacility) {
try {
this.removeBan(sess, banOnFacility.getId());
} catch (BanNotExistsException ex) {
//it is ok, we just want to remove it anyway
}
}
// delete facility
getFacilitiesManagerImpl().deleteFacilityOwners(sess, facility);
getFacilitiesManagerImpl().deleteFacility(sess, facility);
getPerunBl().getAuditer().log(sess, "Facility deleted {}.", facility);
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method removeBan.
@Test
public void removeBan() throws Exception {
System.out.println(CLASS_NAME + "removeBan");
Vo vo = setUpVo();
Resource resource = setUpResource(vo);
Member member = setUpMember(vo);
User user = perun.getUsersManagerBl().getUserByMember(sess, member);
Group group = setUpGroup(vo, member);
perun.getResourcesManagerBl().assignGroupToResource(sess, group, resource);
BanOnFacility banOnFacility = new BanOnFacility();
banOnFacility.setUserId(user.getId());
banOnFacility.setFacilityId(facility.getId());
banOnFacility.setDescription("Popisek");
banOnFacility.setValidityTo(new Date());
banOnFacility = facilitiesManagerEntry.setBan(sess, banOnFacility);
List<BanOnFacility> bansOnFacility = facilitiesManagerEntry.getBansForFacility(sess, banOnFacility.getFacilityId());
assertTrue(bansOnFacility.size() == 1);
perun.getFacilitiesManagerBl().removeBan(sess, banOnFacility.getUserId(), banOnFacility.getFacilityId());
bansOnFacility = facilitiesManagerEntry.getBansForFacility(sess, banOnFacility.getFacilityId());
assertTrue(bansOnFacility.isEmpty());
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method getBan.
@Test
public void getBan() throws Exception {
System.out.println(CLASS_NAME + "getBan");
Vo vo = setUpVo();
Resource resource = setUpResource(vo);
Member member = setUpMember(vo);
User user = perun.getUsersManagerBl().getUserByMember(sess, member);
Group group = setUpGroup(vo, member);
perun.getResourcesManagerBl().assignGroupToResource(sess, group, resource);
BanOnFacility banOnFacility = new BanOnFacility();
banOnFacility.setUserId(user.getId());
banOnFacility.setFacilityId(facility.getId());
banOnFacility.setDescription("Popisek");
banOnFacility.setValidityTo(new Date());
banOnFacility = facilitiesManagerEntry.setBan(sess, banOnFacility);
BanOnFacility returnedBan = facilitiesManagerEntry.getBan(sess, banOnFacility.getUserId(), banOnFacility.getFacilityId());
assertEquals(banOnFacility, returnedBan);
}
Aggregations