use of cz.metacentrum.perun.core.api.exceptions.BanAlreadyExistsException in project perun by CESNET.
the class ResourcesManagerBlImpl method setBan.
@Override
public BanOnResource setBan(PerunSession sess, BanOnResource banOnResource) throws BanAlreadyExistsException {
if (this.banExists(sess, banOnResource.getMemberId(), banOnResource.getResourceId()))
throw new BanAlreadyExistsException(banOnResource);
banOnResource = getResourcesManagerImpl().setBan(sess, banOnResource);
getPerunBl().getAuditer().log(sess, new BanSetForResource(banOnResource, banOnResource.getMemberId(), banOnResource.getResourceId()));
return banOnResource;
}
use of cz.metacentrum.perun.core.api.exceptions.BanAlreadyExistsException in project perun by CESNET.
the class MembersManagerBlImpl method moveMembersBans.
/**
* Moves bans on resources and ban on VO from source member to target member.
*
* @param sess
* @param sourceMember member to move bans from
* @param targetMember member to move bans to
*/
private void moveMembersBans(PerunSession sess, Member sourceMember, Member targetMember) {
// move members bans on resources
List<BanOnResource> bansOnResources = getPerunBl().getResourcesManagerBl().getBansForMember(sess, sourceMember.getId());
for (BanOnResource banOnResource : bansOnResources) {
try {
banOnResource.setMemberId(targetMember.getId());
getPerunBl().getResourcesManagerBl().setBan(sess, banOnResource);
} catch (BanAlreadyExistsException e) {
log.warn("Moving ban on resource {} from source member {} to target member {}, but the target member" + " already has ban on the resource.", banOnResource, sourceMember, targetMember);
}
}
// move members ban on VO
Optional<BanOnVo> banOnVo = getPerunBl().getVosManagerBl().getBanForMember(sess, sourceMember.getId());
if (banOnVo.isPresent()) {
banOnVo.get().setMemberId(targetMember.getId());
try {
getPerunBl().getVosManagerBl().setBan(sess, banOnVo.get());
} catch (MemberNotExistsException e) {
throw new InternalErrorException(e);
}
}
}
use of cz.metacentrum.perun.core.api.exceptions.BanAlreadyExistsException in project perun by CESNET.
the class FacilitiesManagerBlImpl method setBan.
@Override
public BanOnFacility setBan(PerunSession sess, BanOnFacility banOnFacility) throws BanAlreadyExistsException {
if (this.banExists(sess, banOnFacility.getUserId(), banOnFacility.getFacilityId()))
throw new BanAlreadyExistsException(banOnFacility);
banOnFacility = getFacilitiesManagerImpl().setBan(sess, banOnFacility);
getPerunBl().getAuditer().log(sess, new BanSetForFacility(banOnFacility, banOnFacility.getUserId(), banOnFacility.getFacilityId()));
return banOnFacility;
}
Aggregations