Search in sources :

Example 91 with User

use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.

the class TestRecordingService method getExternalUser.

private User getExternalUser() throws Exception {
    String uuid = UUID.randomUUID().toString();
    User u = getUser(uuid);
    u.setExternalType(UNIT_TEST_EXT_TYPE);
    u.setExternalId(uuid);
    webCreateUser(u);
    return u;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) AbstractJUnitDefaults.getUser(org.apache.openmeetings.AbstractJUnitDefaults.getUser)

Example 92 with User

use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.

the class TestRecordingService method testExternal.

@Test
public void testExternal() throws Exception {
    User u = getExternalUser();
    Recording r = new Recording();
    r.setInsertedBy(u.getId());
    r.setComment("Created by Unit Tests");
    r.setRoomId(5L);
    r = getBean(RecordingDao.class).update(r);
    ServiceResult sr = login();
    Collection<? extends RecordingDTO> recs = getClient(getRecordUrl()).path("/" + UNIT_TEST_EXT_TYPE).query("sid", sr.getMessage()).getCollection(RecordingDTO.class);
    assertNotNull("Valid collection should be returned", recs);
    assertFalse("Collection of the recordings should not be empty", recs.isEmpty());
    boolean found = false;
    for (RecordingDTO rdo : recs) {
        if (r.getId().equals(rdo.getId())) {
            // TODO check room, user
            found = true;
            break;
        }
    }
    assertTrue("Just created recording was not found by the service", found);
}
Also used : User(org.apache.openmeetings.db.entity.user.User) AbstractJUnitDefaults.getUser(org.apache.openmeetings.AbstractJUnitDefaults.getUser) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RecordingDTO(org.apache.openmeetings.db.dto.record.RecordingDTO) Recording(org.apache.openmeetings.db.entity.record.Recording) Test(org.junit.Test)

Example 93 with User

use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.

the class CalendarWebService method save.

/**
 * Save an appointment
 *
 * @param sid
 *            The SID of the User. This SID must be marked as Loggedin
 * @param appointment
 *            calendar event
 *
 * @return - appointment saved
 */
@WebMethod
@POST
@Path("/")
public AppointmentDTO save(@QueryParam("sid") @WebParam(name = "sid") String sid, @FormParam("appointment") @WebParam(name = "appointment") AppointmentDTO appointment) {
    // Seems to be create
    log.debug("save SID: {}", sid);
    return performCall(sid, sd -> {
        User u = userDao.get(sd.getUserId());
        if (!AuthLevelUtil.hasUserLevel(u.getRights())) {
            log.error("save: not authorized");
            return false;
        }
        return AuthLevelUtil.hasWebServiceLevel(u.getRights()) || appointment.getOwner() == null || appointment.getOwner().getId().equals(u.getId());
    }, sd -> {
        User u = userDao.get(sd.getUserId());
        Appointment a = appointment.get(userDao, fileDao, dao, u);
        if (a.getRoom().getId() != null) {
            if (a.getRoom().isAppointment()) {
                a.getRoom().setIspublic(false);
            } else {
                a.setRoom(roomDao.get(a.getRoom().getId()));
            }
        }
        return new AppointmentDTO(dao.update(a, u.getId()));
    });
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) User(org.apache.openmeetings.db.entity.user.User) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 94 with User

use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.

the class GroupWebService method removeUser.

/**
 * Remove user from 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
 */
@DELETE
@Path("/{id}/users/{userid}")
public ServiceResult removeUser(@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);
            for (Iterator<GroupUser> iter = u.getGroupUsers().iterator(); iter.hasNext(); ) {
                GroupUser gu = iter.next();
                if (id.equals(gu.getGroup().getId())) {
                    iter.remove();
                }
            }
            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) DELETE(javax.ws.rs.DELETE)

Example 95 with User

use of org.apache.openmeetings.db.entity.user.User in project openmeetings by apache.

the class GroupWebService method getUsers.

/**
 * Search users and return them
 *
 * @param sid
 *            The SID from getSession
 * @param id
 *            the group id
 * @param start
 *            first record
 * @param max
 *            max records
 * @param orderby
 *            orderby clause
 * @param asc
 *            asc or desc
 * @return - users found
 */
@GET
@Path("/users/{id}")
public UserSearchResult getUsers(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") long id, @QueryParam("start") @WebParam(name = "start") int start, @QueryParam("max") @WebParam(name = "max") int max, @QueryParam("orderby") @WebParam(name = "orderby") String orderby, @QueryParam("asc") @WebParam(name = "asc") boolean asc) {
    return performCall(sid, User.Right.Soap, sd -> {
        SearchResult<User> result = new SearchResult<>();
        result.setObjectName(User.class.getName());
        result.setRecords(groupUserDao.count(id));
        result.setResult(new ArrayList<User>());
        String order = isAlphanumeric(orderby) ? orderby : "id";
        for (GroupUser ou : groupUserDao.get(id, null, start, max, order + " " + (asc ? "ASC" : "DESC"))) {
            result.getResult().add(ou.getUser());
        }
        return new UserSearchResult(result);
    });
}
Also used : User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) UserSearchResult(org.apache.openmeetings.db.dto.user.UserSearchResult) SearchResult(org.apache.openmeetings.db.dto.basic.SearchResult) UserSearchResult(org.apache.openmeetings.db.dto.user.UserSearchResult) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

User (org.apache.openmeetings.db.entity.user.User)101 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)29 Test (org.junit.Test)25 Date (java.util.Date)11 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)10 ArrayList (java.util.ArrayList)8 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)8 OmException (org.apache.openmeetings.util.OmException)8 Path (javax.ws.rs.Path)7 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)7 Room (org.apache.openmeetings.db.entity.room.Room)7 AbstractJUnitDefaults.getUser (org.apache.openmeetings.AbstractJUnitDefaults.getUser)6 Client (org.apache.openmeetings.db.entity.basic.Client)6 Address (org.apache.openmeetings.db.entity.user.Address)5 Group (org.apache.openmeetings.db.entity.user.Group)5 GroupDao (org.apache.openmeetings.db.dao.user.GroupDao)4 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)4 OAuthUser (org.apache.openmeetings.db.dto.user.OAuthUser)4 Recording (org.apache.openmeetings.db.entity.record.Recording)4 AbstractJUnitDefaults.createUser (org.apache.openmeetings.AbstractJUnitDefaults.createUser)3