use of cz.metacentrum.perun.audit.events.VoManagerEvents.VoCreated in project perun by CESNET.
the class VosManagerBlImpl method createVo.
@Override
public Vo createVo(PerunSession sess, Vo vo) throws VoExistsException {
// Create entries in the DB and Grouper
vo = getVosManagerImpl().createVo(sess, vo);
getPerunBl().getAuditer().log(sess, new VoCreated(vo));
User user = sess.getPerunPrincipal().getUser();
// set creator as VO manager
if (user != null) {
try {
AuthzResolverBlImpl.setRole(sess, user, vo, Role.VOADMIN);
log.debug("User {} added like administrator to VO {}", user, vo);
} catch (AlreadyAdminException ex) {
throw new ConsistencyErrorException("Add manager to newly created VO failed because there is a particular manager already assigned", ex);
} catch (RoleCannotBeManagedException e) {
throw new InternalErrorException(e);
}
} else {
log.error("Can't set VO manager during creating of the VO. User from perunSession is null. {} {}", vo, sess);
}
try {
// Create group containing VO members
Group members = new Group(VosManager.MEMBERS_GROUP, VosManager.MEMBERS_GROUP_DESCRIPTION + " for VO " + vo.getName());
getPerunBl().getGroupsManagerBl().createGroup(sess, vo, members);
log.debug("Members group created, vo '{}'", vo);
} catch (GroupExistsException e) {
throw new ConsistencyErrorException("Group already exists", e);
}
// create empty application form
getVosManagerImpl().createApplicationForm(sess, vo);
log.info("Vo {} created", vo);
return vo;
}
Aggregations