log.debug(userObject.toString());
IConnection current = Red5.getConnectionLocal();
String streamId = current.getClient().getId();
Client currentClient = sessionManager.getClientByStreamId(streamId, null);
// Check if this User is simulated in the OpenMeetings
// Database
if (!Strings.isEmpty(userObject.getExternalUserId())) {
// If so we need to check that we create this user in
// OpenMeetings and update its record
User user = userManager.getUserByExternalIdAndType(
userObject.getExternalUserId(),
userObject.getExternalUserType());
if (user == null) {
String iCalTz = configurationDao.getConfValue("default.timezone", String.class, "");
long userId = userManager
.addUserWithExternalKey(1, 0, 0,
userObject.getFirstname(),
userObject.getUsername(),
userObject.getLastname(), 1L,
true, "", // password is empty by default
null, null, "",
userObject.getExternalUserId(),
userObject.getExternalUserType(),
true, userObject.getEmail(),
iCalTz,
userObject.getPictureUrl());
currentClient.setUser_id(userId);
SessionVariablesUtil.setUserId(current.getClient(), userId);
} else {
user.setPictureuri(userObject.getPictureUrl());
userManager.updateUser(user);
currentClient.setUser_id(user.getUser_id());
SessionVariablesUtil.setUserId(current.getClient(), user.getUser_id());
}
}
log.debug("userObject.getExternalUserId() -2- " + currentClient.getUser_id());
currentClient.setUserObject(userObject.getUsername(), userObject.getFirstname(), userObject.getLastname());
currentClient.setPicture_uri(userObject.getPictureUrl());
currentClient.setMail(userObject.getEmail());
log.debug("UPDATE USER BY STREAMID " + streamId);
if (currentClient.getUser_id() != null) {
sessiondataDao.updateUser(SID, currentClient.getUser_id());
}
sessionManager.updateClientByStreamId(streamId, currentClient, false, null);
return new Long(1);