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);
});
}
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);
}
});
}
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);
});
}
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;
}
}
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;
});
}
Aggregations