public void createMembership(String userId, String groupId, String role) {
try {
org.jboss.identity.idm.api.Group group = findIdmGroupByIdmGroupId(convertjbpmGroupId2IdmGroupId(groupId));
if (group==null) {
throw new JbpmException("group "+groupId+" doesn't exist");
}
org.jboss.identity.idm.api.User idUser = identitySession.getPersistenceManager().findUser(userId);
if (idUser==null) {
throw new JbpmException("user "+userId+" doesn't exist");
}
if (role == null) {
role = DEFAULT_JBPM_MEMBER_ROLE;
}
RoleType roleType = identitySession.getRoleManager().getRoleType(role);
System.out.println("The Role Type is: " + roleType);
if (roleType == null) {
roleType = identitySession.getRoleManager().createRoleType(role);
}
identitySession.getRoleManager().createRole(roleType, idUser, group);
} catch (Exception e) {
throw new JbpmException("couldn't create membership "+userId+", "+groupId+", "+role, e);
}
}