Search in sources :

Example 1 with ServiceResult

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

Example 2 with ServiceResult

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);
    });
}
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 3 with ServiceResult

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);
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) Room(org.apache.openmeetings.db.entity.room.Room) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 4 with ServiceResult

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

Example 5 with ServiceResult

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);
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileItemDTO(org.apache.openmeetings.db.dto.file.FileItemDTO) ArrayList(java.util.ArrayList) Attachment(org.apache.cxf.jaxrs.ext.multipart.Attachment) FileInputStream(java.io.FileInputStream)

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