use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class GroupWebService method addUser.
/**
* Add user to a certain group
*
* @param sid
* The SID from getSession
* @param userid
* the user id
* @param id
* the group id
* @return {@link ServiceResult} with result type, and id of the user added, or error id in case of the error as text
*/
@POST
@Path("/{id}/users/{userid}")
public ServiceResult addUser(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") Long id, @PathParam("userid") @WebParam(name = "userid") Long userid) {
return performCall(sid, User.Right.Soap, sd -> {
if (!groupUserDao.isUserInGroup(id, userid)) {
User u = userDao.get(userid);
u.getGroupUsers().add(new GroupUser(groupDao.get(id), u));
userDao.update(u, sd.getUserId());
}
return new ServiceResult(String.valueOf(userid), Type.SUCCESS);
});
}
use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class TestCalendarService method actualTest.
private void actualTest(Room r) throws Exception {
String uuid = UUID.randomUUID().toString();
User u = getUser(uuid);
u.getGroupUsers().add(new GroupUser(getBean(GroupDao.class).get(1L), u));
webCreateUser(u);
ServiceResult sr = login(u.getLogin(), createPass());
u = getBean(UserDao.class).get(u.getId());
Date start = new Date();
Appointment a = AbstractJUnitDefaults.createAppointment(getBean(AppointmentDao.class), getAppointment(u, r, start, new Date(start.getTime() + ONE_HOUR)));
AppointmentDTO app = getClient(getCalendarUrl()).path("/room/" + a.getRoom().getId()).query("sid", sr.getMessage()).get(AppointmentDTO.class);
assertNotNull("Valid DTO should be returned", app);
}
use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class TestCalendarService method testCreateWithOmMm.
@Test
public void testCreateWithOmMm() throws Exception {
JSONObject o = createAppointment("test").put("meetingMembers", new JSONArray().put(new JSONObject().put("user", new JSONObject().put("id", 1))));
String uuid = UUID.randomUUID().toString();
User u = getUser(uuid);
u.getGroupUsers().add(new GroupUser(getBean(GroupDao.class).get(1L), u));
u = createUser(getBean(UserDao.class), u);
ServiceResult sr = login(u.getLogin(), createPass());
Response resp = getClient(getCalendarUrl()).path("/").query("sid", sr.getMessage()).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());
AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
assertNotNull("Valid DTO should be returned", dto);
assertNotNull("DTO id should be valid", dto.getId());
}
use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class TestCalendarService method loginNewUser.
private String loginNewUser() throws Exception {
String uuid = UUID.randomUUID().toString();
User u = getUser(uuid);
u.getGroupUsers().add(new GroupUser(getBean(GroupDao.class).get(1L), u));
webCreateUser(u);
ServiceResult sr = login(u.getLogin(), createPass());
return sr.getMessage();
}
use of org.apache.openmeetings.db.entity.user.GroupUser in project openmeetings by apache.
the class TestAddGroup method testAddingGroup.
@Test
public void testAddingGroup() {
Group o = new Group();
o.setName("default");
o = groupDao.update(o, null);
assertNotNull("Id of group created should not be null", o.getId());
User us = userDao.get(1L);
assertNotNull("User should exist", us);
assertNotNull("Group User list should exist", us.getGroupUsers());
us.getGroupUsers().add(new GroupUser(o, us));
us = userDao.update(us, null);
log.error(us.getLastname());
log.error(us.getAddress().getTown());
}
Aggregations