private List<EObject> loadRoles(final String applicationId, final String modelId, final String userId) throws UamClientException {
final SecurityModel securityModel = getSecurityModel(modelId);
final IUser user = userManager.getUser(userId);
if (user == null) {
throw new UamClientException(MessageFormat.format("User {0} is not found.", userId)); //$NON-NLS-1$
}
try {
IRoleInstanceMetaInfo[] roleInstances = userRoles.getRoleInstances(applicationId, userId);
// Load default roles if no roles assigned to user
if (roleInstances.length == 0) {
final List<IRoleInstanceMetaInfo> defaultRoleInstances = userRoles.getDefaultRoleInstances(applicationId);
roleInstances = defaultRoleInstances.toArray(new IRoleInstanceMetaInfo[defaultRoleInstances.size()]);
}
final List<EObject> emfRoles = new ArrayList<>();
for (final IRoleInstanceMetaInfo roleInst : roleInstances) {
try {
emfRoles.add(loadRoleInstance(roleInst, user, securityModel));
} catch (final Exception e) {
throw new UamClientException(MessageFormat.format("Unable to load role instance {0}: {1}", roleInst.getRoleId(), e.getLocalizedMessage()), e); //$NON-NLS-1$
}
}
return emfRoles;
} catch (final LoadRoleInstanceException e) {
throw new UamClientException(MessageFormat.format("Unable to get roles: {0}.", e.getLocalizedMessage()), e); //$NON-NLS-1$
} catch (final RemoteAccessException e) {
throw new FlexessConnectException(MessageFormat.format("Can't connect: {0}.", e.getLocalizedMessage()), e); //$NON-NLS-1$
}
}