Search in sources :

Example 31 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.

the class GroupWebService method addRoom.

/**
 * Adds a room to an group
 *
 * @param sid - The SID of the User. This SID must be marked as Loggedin
 * @param id - Id of group that the room is being paired with
 * @param roomid - Id of room to be added
 *
 * @return {@link ServiceResult} with result type
 */
@POST
@Path("/{id}/rooms/add/{roomid}")
public ServiceResult addRoom(@QueryParam("sid") @WebParam(name = "sid") String sid, @PathParam("id") @WebParam(name = "id") Long id, @PathParam("roomid") @WebParam(name = "roomid") Long roomid) {
    return performCall(sid, User.Right.Soap, sd -> {
        Room r = roomDao.get(roomid);
        if (r != null) {
            if (r.getGroups() == null) {
                r.setGroups(new ArrayList<RoomGroup>());
            }
            boolean found = false;
            for (RoomGroup ro : r.getGroups()) {
                if (ro.getGroup().getId().equals(id)) {
                    found = true;
                }
            }
            if (!found) {
                r.getGroups().add(new RoomGroup(groupDao.get(id), r));
                roomDao.update(r, sd.getUserId());
                return new ServiceResult("Success", Type.SUCCESS);
            }
        }
        return new ServiceResult("Not added", Type.ERROR);
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) Room(org.apache.openmeetings.db.entity.room.Room) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 32 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.

the class RoomWebService method hash.

/**
 * Method to get invitation hash with given parameters
 *
 * @param sid - The SID of the User. This SID must be marked as Loggedin
 * @param invite - parameters of the invitation
 * @param sendmail - flag to determine if email should be sent or not
 * @return - serviceResult object with the result
 */
@WebMethod
@POST
@Path("/hash")
public ServiceResult hash(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "invite") @QueryParam("invite") InvitationDTO invite, @WebParam(name = "sendmail") @QueryParam("sendmail") boolean sendmail) {
    log.debug("[hash] invite {}", invite);
    return performCall(sid, User.Right.Soap, sd -> {
        Invitation i = invite.get(sd.getUserId(), userDao, roomDao);
        i = inviteDao.update(i);
        if (i != null) {
            if (sendmail) {
                try {
                    inviteManager.sendInvitationLink(i, MessageType.Create, invite.getSubject(), invite.getMessage(), false);
                } catch (Exception e) {
                    throw new ServiceException(e.getMessage());
                }
            }
            return new ServiceResult(i.getHash(), Type.SUCCESS);
        } else {
            return new ServiceResult("error.unknown", Type.ERROR);
        }
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) ServiceException(org.apache.openmeetings.webservice.error.ServiceException) Invitation(org.apache.openmeetings.db.entity.room.Invitation) ServiceException(org.apache.openmeetings.webservice.error.ServiceException) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 33 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.

the class RoomWebService method close.

/**
 * Method to remotely close rooms. If a room is closed all users
 * inside the room and all users that try to enter it will be redirected to
 * the redirectURL that is defined in the Room-Object.
 *
 * Returns positive value if authentication was successful.
 *
 * @param sid
 *            The SID of the User. This SID must be marked as Loggedin
 * @param id
 *            the room id
 *
 * @return - 1 in case of success, -2 otherwise
 */
@WebMethod
@GET
@Path("/close/{id}")
public ServiceResult close(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "id") @PathParam("id") long id) {
    return performCall(sid, User.Right.Soap, sd -> {
        Long userId = sd.getUserId();
        Room room = roomDao.get(id);
        room.setClosed(true);
        roomDao.update(room, userId);
        WebSocketHelper.sendRoom(new RoomMessage(room.getId(), userDao.get(userId), RoomMessage.Type.roomClosed));
        return new ServiceResult("Closed", Type.SUCCESS);
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage) Room(org.apache.openmeetings.db.entity.room.Room) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 34 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.

the class UserWebService method login.

/**
 * @param user - login or email of Openmeetings user with admin or SOAP-rights
 * @param pass - password
 *
 * @return - {@link ServiceResult} with error code or SID and userId
 */
@WebMethod
@GET
@Path("/login")
public ServiceResult login(@WebParam(name = "user") @QueryParam("user") String user, @WebParam(name = "pass") @QueryParam("pass") String pass) {
    try {
        log.debug("Login user");
        User u = userDao.login(user, pass);
        if (u == null) {
            return new ServiceResult("error.bad.credentials", Type.ERROR);
        }
        Sessiondata sd = sessionDao.create(u.getId(), u.getLanguageId());
        log.debug("Login user: {}", u.getId());
        return new ServiceResult(sd.getSessionId(), Type.SUCCESS);
    } catch (OmException oe) {
        return oe.getKey() == null ? UNKNOWN : new ServiceResult(oe.getKey(), Type.ERROR);
    } catch (Exception err) {
        log.error("[login]", err);
        return UNKNOWN;
    }
}
Also used : User(org.apache.openmeetings.db.entity.user.User) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) OmException(org.apache.openmeetings.util.OmException) OmException(org.apache.openmeetings.util.OmException) ServiceException(org.apache.openmeetings.webservice.error.ServiceException) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 35 with ServiceResult

use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.

the class UserWebService method getRoomHash.

/**
 * Description: sets the SessionObject for a certain SID, after setting this
 * Session-Object you can use the SID + a RoomId to enter any Room. ...
 * Session-Hashs are deleted 15 minutes after the creation if not used.
 *
 * @param sid
 *            The SID from getSession
 * @param user
 *            user details to set
 * @param options
 *            room options to set
 *
 * @return - secure hash or error code
 */
@WebMethod
@POST
@Path("/hash")
public ServiceResult getRoomHash(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "user") @FormParam("user") ExternalUserDTO user, @WebParam(name = "options") @FormParam("options") RoomOptionsDTO options) {
    return performCall(sid, User.Right.Soap, sd -> {
        RemoteSessionObject remoteSessionObject = new RemoteSessionObject(user.getLogin(), user.getFirstname(), user.getLastname(), user.getProfilePictureUrl(), user.getEmail(), user.getExternalId(), user.getExternalType());
        log.debug(remoteSessionObject.toString());
        String xmlString = remoteSessionObject.toXml();
        log.debug("xmlString " + xmlString);
        String hash = soapDao.addSOAPLogin(sid, options.getRoomId(), options.isModerator(), options.isShowAudioVideoTest(), options.isAllowSameURLMultipleTimes(), options.getRecordingId(), options.isAllowRecording());
        if (hash != null) {
            if (options.isAllowSameURLMultipleTimes()) {
                sd.setPermanent(true);
            }
            sd.setXml(xmlString);
            sessionDao.update(sd);
            return new ServiceResult(hash, Type.SUCCESS);
        }
        return UNKNOWN;
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RemoteSessionObject(org.apache.openmeetings.db.entity.server.RemoteSessionObject) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)37 Test (org.junit.Test)18 Path (javax.ws.rs.Path)12 User (org.apache.openmeetings.db.entity.user.User)8 Response (javax.ws.rs.core.Response)7 WebMethod (javax.jws.WebMethod)5 POST (javax.ws.rs.POST)5 Room (org.apache.openmeetings.db.entity.room.Room)5 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)5 DELETE (javax.ws.rs.DELETE)4 Form (javax.ws.rs.core.Form)4 AbstractJUnitDefaults.getUser (org.apache.openmeetings.AbstractJUnitDefaults.getUser)4 GET (javax.ws.rs.GET)3 AbstractJUnitDefaults.createUser (org.apache.openmeetings.AbstractJUnitDefaults.createUser)3 GroupDao (org.apache.openmeetings.db.dao.user.GroupDao)3 RoomDTO (org.apache.openmeetings.db.dto.room.RoomDTO)3 Locale (java.util.Locale)2 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)2 UserDTO (org.apache.openmeetings.db.dto.user.UserDTO)2 FileItem (org.apache.openmeetings.db.entity.file.FileItem)2