use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.
the class GroupWebService method add.
/**
* add a new group
*
* @param sid
* The SID from getSession
* @param name
* the name of the group
* @return {@link ServiceResult} with result type, and id of the group added
*/
@POST
@Path("/")
public ServiceResult add(@QueryParam("sid") @WebParam(name = "sid") String sid, @QueryParam("name") @WebParam(name = "name") String name) {
log.debug("add:: name {}", name);
return performCall(sid, User.Right.Soap, sd -> {
Group o = new Group();
o.setName(name);
return new ServiceResult(String.valueOf(groupDao.update(o, sd.getUserId()).getId()), Type.SUCCESS);
});
}
use of org.apache.openmeetings.db.dto.basic.ServiceResult 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.dto.basic.ServiceResult in project openmeetings by apache.
the class RoomWebService method open.
/**
* Method to remotely open 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("/open/{id}")
public ServiceResult open(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "id") @PathParam("id") long id) {
return performCall(sid, User.Right.Soap, sd -> {
Room room = roomDao.get(id);
room.setClosed(false);
roomDao.update(room, sd.getUserId());
return new ServiceResult("Opened", Type.SUCCESS);
});
}
use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.
the class UserWebService method deleteExternal.
/**
* Delete a certain user by its external user id
*
* @param sid
* The SID from getSession
* @param externalId
* externalUserId
* @param externalType
* externalUserId
*
* @return - id of user deleted, or error code
*/
@DELETE
@Path("/{externaltype}/{externalid}")
public ServiceResult deleteExternal(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "externaltype") @PathParam("externaltype") String externalType, @WebParam(name = "externalid") @PathParam("externalid") String externalId) {
return performCall(sid, User.Right.Admin, sd -> {
User user = userDao.getExternalUser(externalId, externalType);
// Setting user deleted
userDao.delete(user, sd.getUserId());
return new ServiceResult("Deleted", Type.SUCCESS);
});
}
use of org.apache.openmeetings.db.dto.basic.ServiceResult in project openmeetings by apache.
the class AbstractWebServiceTest method createVerifiedFile.
public CallResult<FileItemDTO> createVerifiedFile(File fsFile, String name, BaseFileItem.Type type) throws IOException {
ServiceResult r = login();
FileItemDTO f1 = null;
try (InputStream is = new FileInputStream(fsFile)) {
FileItemDTO file = new FileItemDTO().setName(name).setHash(UUID.randomUUID().toString()).setType(type);
List<Attachment> atts = new ArrayList<>();
atts.add(new Attachment("file", MediaType.APPLICATION_JSON, file));
atts.add(new Attachment("stream", MediaType.APPLICATION_OCTET_STREAM, is));
f1 = getClient(getFileUrl()).path("/").query("sid", r.getMessage()).type(MediaType.MULTIPART_FORM_DATA_TYPE).postCollection(atts, Attachment.class, FileItemDTO.class);
assertNotNull("Valid FileItem should be returned", f1);
assertNotNull("Valid FileItem should be returned", f1.getId());
}
return new CallResult<>(r.getMessage(), f1);
}
Aggregations