return initUserContext(context.getUserId());
}
@Override
public synchronized IUserContext initUserContext(final String userId) {
final UserContext userContext = new UserContext(userId);
UserContextManager.setContext(userContext);
if (applicationIds.isEmpty()) {
applicationIds.addAll(applicationService.getApplicationIds());
}
for (final String applicationId : applicationIds) {
try {
final SecurityModel securityModel = loadSecurityModel(applicationId);
final String modelId = securityModel.getId();
final String prevApplication = userContext.addApplication(modelId, applicationId);
if (prevApplication != null) {
throw new UamClientException(MessageFormat.format("Error in Flexess client initializing: the client can''t work with application ({0} and {1}), which contain the same model", applicationId, //$NON-NLS-1$
prevApplication));
}
userContext.addSecurityModels(modelId, securityModel);
userContext.setRoles(modelId, loadRoles(applicationId, modelId, userId));
} catch (final UamClientException e) {
logger.trace("Error while loading the application {}. Ignore it", applicationId, e); //$NON-NLS-1$
}
}
return userContext;