public QueryResult<Group> createGroup(String studyStr, String groupId, String users, String sessionId) throws CatalogException {
ParamUtils.checkParameter(groupId, "group name");
String userId = catalogManager.getUserManager().getUserId(sessionId);
Study study = resolveId(studyStr, userId);
if (!groupId.startsWith("@")) {
groupId = "@" + groupId;
}
authorizationManager.checkCreateDeleteGroupPermissions(study.getUid(), userId, groupId);
List<String> userList;
if (StringUtils.isNotEmpty(users)) {
userList = Arrays.asList(users.split(","));
} else {
userList = Collections.emptyList();
}
if (existsGroup(study.getUid(), groupId)) {
throw new CatalogException("The group " + groupId + " already exists.");
}
if (userList.size() > 0) {
userDBAdaptor.checkIds(userList);
}
studyDBAdaptor.addUsersToGroup(study.getUid(), MEMBERS, userList);
return studyDBAdaptor.createGroup(study.getUid(), new Group(groupId, userList));
}