Search in sources :

Example 6 with GroupUser

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);
    });
}
Also used : User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 7 with GroupUser

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);
}
Also used : AbstractJUnitDefaults.getAppointment(org.apache.openmeetings.AbstractJUnitDefaults.getAppointment) Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) User(org.apache.openmeetings.db.entity.user.User) AbstractJUnitDefaults.createUser(org.apache.openmeetings.AbstractJUnitDefaults.createUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) AbstractJUnitDefaults.getUser(org.apache.openmeetings.AbstractJUnitDefaults.getUser) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) GroupDao(org.apache.openmeetings.db.dao.user.GroupDao) AppointmentDao(org.apache.openmeetings.db.dao.calendar.AppointmentDao) Date(java.util.Date)

Example 8 with GroupUser

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());
}
Also used : Response(javax.ws.rs.core.Response) User(org.apache.openmeetings.db.entity.user.User) AbstractJUnitDefaults.createUser(org.apache.openmeetings.AbstractJUnitDefaults.createUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) AbstractJUnitDefaults.getUser(org.apache.openmeetings.AbstractJUnitDefaults.getUser) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) JSONObject(com.github.openjson.JSONObject) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) Form(javax.ws.rs.core.Form) JSONArray(com.github.openjson.JSONArray) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) GroupDao(org.apache.openmeetings.db.dao.user.GroupDao) Test(org.junit.Test)

Example 9 with GroupUser

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();
}
Also used : User(org.apache.openmeetings.db.entity.user.User) AbstractJUnitDefaults.createUser(org.apache.openmeetings.AbstractJUnitDefaults.createUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) AbstractJUnitDefaults.getUser(org.apache.openmeetings.AbstractJUnitDefaults.getUser) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupDao(org.apache.openmeetings.db.dao.user.GroupDao)

Example 10 with GroupUser

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());
}
Also used : Group(org.apache.openmeetings.db.entity.user.Group) User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) Test(org.junit.Test)

Aggregations

GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)28 User (org.apache.openmeetings.db.entity.user.User)19 Group (org.apache.openmeetings.db.entity.user.Group)9 Test (org.junit.Test)7 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)5 Date (java.util.Date)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Path (javax.ws.rs.Path)3 AbstractJUnitDefaults.createUser (org.apache.openmeetings.AbstractJUnitDefaults.createUser)3 AbstractJUnitDefaults.getUser (org.apache.openmeetings.AbstractJUnitDefaults.getUser)3 GroupDao (org.apache.openmeetings.db.dao.user.GroupDao)3 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)3 RoomGroup (org.apache.openmeetings.db.entity.room.RoomGroup)3 JSONObject (com.github.openjson.JSONObject)2 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)2 OAuthUser (org.apache.openmeetings.db.dto.user.OAuthUser)2 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)2 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)2 JSONArray (com.github.openjson.JSONArray)1