use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class StreamClientManager method update.
@Override
public StreamClient update(StreamClient rcl, boolean forceSize) {
if (rcl == null) {
return null;
}
Client client = clientManager.getBySid(rcl.getSid());
if (client == null) {
if (Client.Type.mobile == rcl.getType()) {
Sessiondata sd = sessionDao.check(rcl.getSid());
User u = userDao.get(sd.getUserId());
rcl = mobileService.create(rcl, u);
// Mobile client enters the room
client = new Client(rcl, userDao.get(rcl.getUserId()));
clientManager.add(client);
if (rcl.getRoomId() != null) {
client.setCam(0);
client.setMic(0);
client.setRoom(roomDao.get(rcl.getRoomId()));
clientManager.add(client);
WebSocketHelper.sendRoom(new RoomMessage(client.getRoom().getId(), client, RoomMessage.Type.roomEnter));
}
} else if (client == null && Client.Type.sip == rcl.getType()) {
rcl.setLogin(SIP_USER_NAME);
rcl.setUserId(SIP_USER_ID);
// SipTransport enters the room
User u = new User();
u.setId(SIP_USER_ID);
u.setLogin(SIP_USER_NAME);
u.setFirstname(SIP_FIRST_NAME);
client = new Client(rcl, u);
clientManager.add(client);
client.setCam(0);
client.setMic(0);
client.allow(Room.Right.audio, Room.Right.video);
client.set(Activity.broadcastA);
clientManager.addToRoom(client);
WebSocketHelper.sendRoom(new RoomMessage(client.getRoom().getId(), client, RoomMessage.Type.roomEnter));
} else {
return null;
}
}
if (rcl.getRoomId() == null || !rcl.getRoomId().equals(client.getRoom().getId())) {
return null;
}
User u = client.getUser();
rcl.setUserId(u.getId());
rcl.setLogin(u.getLogin());
rcl.setFirstname(u.getFirstname());
rcl.setLastname(u.getLastname());
rcl.setEmail(u.getAddress() == null ? null : u.getAddress().getEmail());
rcl.setSuperMod(client.hasRight(Right.superModerator));
rcl.setMod(client.hasRight(Right.moderator));
if (client.hasActivity(Activity.broadcastA) && !client.isMicEnabled()) {
client.remove(Activity.broadcastA);
}
if (client.hasActivity(Activity.broadcastV) && !client.isCamEnabled()) {
client.remove(Activity.broadcastV);
}
if (client.hasActivity(Activity.broadcastA) || client.hasActivity(Activity.broadcastV)) {
if (forceSize || rcl.getWidth() == 0 || rcl.getHeight() == 0) {
rcl.setWidth(client.getWidth());
rcl.setHeight(client.getHeight());
}
if (client.getPod() != Pod.none) {
rcl.setInterviewPodId(client.getPod() == Pod.left ? 1 : 2);
}
StringBuilder sb = new StringBuilder();
if (client.hasActivity(Activity.broadcastA)) {
sb.append('a');
}
if (client.hasActivity(Activity.broadcastV)) {
sb.append('v');
}
if (!rcl.isBroadcasting() || hasVideo(rcl) != hasVideo(client)) {
rcl.setBroadcasting(true);
}
rcl.setAvsettings(sb.toString());
} else {
rcl.setAvsettings("n");
rcl.setBroadcasting(false);
}
clientManager.update(client);
streamClientManager.update(rcl);
return rcl;
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class GroupUsersPanel method update.
public void update(GroupUser grpUser) {
User u = userDao.get(grpUser.getUser().getId());
int idx = u.getGroupUsers().indexOf(grpUser);
if (idx > -1) {
u.getGroupUsers().get(idx).setModerator(grpUser.isModerator());
} else {
u.getGroupUsers().add(grpUser);
}
userDao.update(u, WebSession.getUserId());
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class UserManager method registerUserInit.
/**
* @param rights - {@link Right} to be assigned to the user
* @param login - user login
* @param password - user password
* @param lastname - user last name
* @param firstname - user first name
* @param email - user email
* @param age - user birthday
* @param street - user address street
* @param additionalname - user additional name
* @param fax - user fax
* @param zip - user zip code
* @param country - user country code
* @param town - user town
* @param languageId - language id
* @param sendWelcomeMessage - should confirmation email be sent
* @param groups - ids of user groups
* @param phone - user phone
* @param sendSMS - should SMS be sent to this user
* @param sendConfirmation - should confirmation be sent
* @param timezone - the name of the time zone
* @param forceTimeZoneCheck - should time zone be verified by user
* @param userOffers - what user offers
* @param userSearchs - what user searches
* @param showContactData - is contact data publicly visible
* @param showContactDataToContacts - is contact data visible to contacts
* @param activatedHash - activation hash
* @return {@link User} of code of error as {@link String}
* @throws NoSuchAlgorithmException in case password hashing algorithm is not found
* @throws OmException in case of any issues with provided data
*/
@Override
public Object registerUserInit(Set<Right> rights, String login, String password, String lastname, String firstname, String email, Date age, String street, String additionalname, String fax, String zip, String country, String town, long languageId, boolean sendWelcomeMessage, List<Long> groups, String phone, boolean sendSMS, Boolean sendConfirmation, TimeZone timezone, Boolean forceTimeZoneCheck, String userOffers, String userSearchs, Boolean showContactData, Boolean showContactDataToContacts, String activatedHash) throws OmException, NoSuchAlgorithmException {
// Check for required data
if (login.length() >= getMinLoginLength(cfgDao)) {
// Check for duplicates
boolean checkName = userDao.checkLogin(login, User.Type.user, null, null);
boolean checkEmail = Strings.isEmpty(email) || userDao.checkEmail(email, User.Type.user, null, null);
if (checkName && checkEmail) {
String hash = Strings.isEmpty(activatedHash) ? UUID.randomUUID().toString() : activatedHash;
if (sendWelcomeMessage && email.length() != 0) {
emailManager.sendMail(login, email, hash, sendConfirmation, languageId);
}
Address a = new Address();
a.setStreet(street);
a.setZip(zip);
a.setTown(town);
a.setCountry(country);
a.setAdditionalname(additionalname);
a.setComment("");
a.setFax(fax);
a.setPhone(phone);
a.setEmail(email);
// code then set the status to 0
if (sendConfirmation && rights.contains(Right.Login)) {
rights.remove(Right.Login);
}
User u = new User();
u.setFirstname(firstname);
u.setLogin(login);
u.setLastname(lastname);
u.setAge(age);
u.setAddress(a);
u.setSendSMS(sendSMS);
u.setRights(rights);
u.setLastlogin(new Date());
u.setSalutation(Salutation.mr);
u.setActivatehash(hash);
u.setTimeZoneId(timezone.getID());
u.setForceTimeZoneCheck(forceTimeZoneCheck);
if (!Strings.isEmpty(u.getExternalType())) {
u.setType(Type.external);
}
u.setUserOffers(userOffers);
u.setUserSearchs(userSearchs);
u.setShowContactData(showContactData);
u.setShowContactDataToContacts(showContactDataToContacts);
// this is needed cause the language is not a needed data at registering
u.setLanguageId(languageId != 0 ? languageId : 1);
if (!Strings.isEmpty(password)) {
u.updatePassword(cfgDao, password);
}
if (groups != null) {
for (Long grpId : groups) {
u.getGroupUsers().add(new GroupUser(groupDao.get(grpId), u));
}
}
u = userDao.update(u, null);
log.debug("Added user-Id " + u.getId());
if (a.getId() != null && u.getId() != null) {
return u;
}
} else {
if (!checkName) {
return "error.login.inuse";
} else {
return "error.email.inuse";
}
}
} else {
return "error.short.login";
}
return UNKNOWN.getKey();
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class GeneralUserForm method onValidate.
@Override
protected void onValidate() {
User u = getModelObject();
if (!userDao.checkEmail(email.getConvertedInput(), u.getType(), u.getDomainId(), u.getId())) {
error(getString("error.email.inuse"));
}
super.onValidate();
}
use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.
the class TestCalendarService method testCreateWithGuestsCleanOne.
@Test
public void testCreateWithGuestsCleanOne() throws Exception {
String sid = loginNewUser();
AppointmentDTO dto = createEventWithGuests(sid);
List<MeetingMemberDTO> initialList = new ArrayList<>(dto.getMeetingMembers());
MeetingMemberDao mmDao = getBean(MeetingMemberDao.class);
MeetingMember mm = mmDao.get(initialList.get(initialList.size() - 1).getId());
Long mmId = mm.getId(), mmUserId = mm.getUser().getId();
String hash = mm.getInvitation().getHash();
dto.getMeetingMembers().remove(initialList.size() - 1);
// try to change MM list
JSONObject o = AppointmentParamConverter.json(dto);
Response resp = getClient(getCalendarUrl()).path("/").query("sid", sid).form(new Form().param("appointment", o.toString()));
assertNotNull("Valid AppointmentDTO should be returned", resp);
assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
dto = resp.readEntity(AppointmentDTO.class);
assertNotNull("Valid DTO should be returned", dto);
assertNotNull("DTO id should be valid", dto.getId());
assertEquals("DTO should have 1 attendees", 1, dto.getMeetingMembers().size());
assertNull("Meeting member should deleted", mmDao.get(mmId));
assertNull("Invitation should deleted", getBean(InvitationDao.class).getByHash(hash, true, false));
User uc = getBean(UserDao.class).get(mmUserId);
assertNotNull("Meeting member user should not be deleted", uc);
assertFalse("Meeting member user should not be deleted", uc.isDeleted());
}
Aggregations