use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method getBanById.
@Test
public void getBanById() throws Exception {
System.out.println(CLASS_NAME + "getBanById");
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.getBanById(sess, banOnFacility.getId());
assertEquals(banOnFacility, returnedBan);
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method updateBan.
@Test
public void updateBan() throws Exception {
System.out.println(CLASS_NAME + "updateBan");
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.setDescription("New description");
banOnFacility.setValidityTo(new Date(banOnFacility.getValidityTo().getTime() + 1000000));
facilitiesManagerEntry.updateBan(sess, banOnFacility);
BanOnFacility returnedBan = facilitiesManagerEntry.getBanById(sess, banOnFacility.getId());
assertEquals(banOnFacility, returnedBan);
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntryIntegrationTest method setBan.
@Test
public void setBan() throws Exception {
System.out.println(CLASS_NAME + "setBan");
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 returnedBan = facilitiesManagerEntry.setBan(sess, banOnFacility);
banOnFacility.setId(returnedBan.getId());
assertEquals(banOnFacility, returnedBan);
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntry method updateBan.
public BanOnFacility updateBan(PerunSession sess, BanOnFacility banOnFacility) throws InternalErrorException, PrivilegeException, FacilityNotExistsException, UserNotExistsException, BanNotExistsException {
Utils.checkPerunSession(sess);
this.getFacilitiesManagerBl().checkBanExists(sess, banOnFacility.getId());
Facility facility = this.getFacilitiesManagerBl().getFacilityById(sess, banOnFacility.getFacilityId());
User user = getPerunBl().getUsersManagerBl().getUserById(sess, banOnFacility.getUserId());
// Authorization
if (!AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, facility)) {
throw new PrivilegeException(sess, "updateBan");
}
banOnFacility = getFacilitiesManagerBl().updateBan(sess, banOnFacility);
return banOnFacility;
}
use of cz.metacentrum.perun.core.api.BanOnFacility in project perun by CESNET.
the class FacilitiesManagerEntry method getBan.
public BanOnFacility getBan(PerunSession sess, int userId, int faclityId) throws InternalErrorException, BanNotExistsException, PrivilegeException, UserNotExistsException, FacilityNotExistsException {
Utils.checkPerunSession(sess);
User user = getPerunBl().getUsersManagerBl().getUserById(sess, userId);
Facility facility = getPerunBl().getFacilitiesManagerBl().getFacilityById(sess, faclityId);
// Authorization
if (!AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, facility)) {
throw new PrivilegeException(sess, "getBan");
}
return getFacilitiesManagerBl().getBan(sess, userId, faclityId);
}
Aggregations