Search in sources :

Example 1 with RoomDTO

use of org.apache.openmeetings.db.dto.room.RoomDTO in project openmeetings by apache.

the class RoomWebService method getExternal.

/**
 * Checks if a room with this exteralRoomId + externalRoomType does exist,
 * if yes it returns the room id if not, it will create the room and then
 * return the room id of the newly created room
 *
 * @param sid
 *            The SID of the User. This SID must be marked as Loggedin
 * @param type
 *            type of the room
 * @param externalType
 *            you can specify your system-name or type of room here, for
 *            example "moodle"
 * @param externalId
 *            your external room id may set here
 * @param room
 *            details of the room to be created if not found
 *
 * @return - id of the room or error code
 */
@WebMethod
@GET
@Path("/{type}/{externaltype}/{externaliId}")
public RoomDTO getExternal(@WebParam(name = "sid") @QueryParam("sid") String sid, @PathParam("type") @WebParam(name = "type") String type, @PathParam("externaltype") @WebParam(name = "externaltype") String externalType, @PathParam("externalid") @WebParam(name = "externalid") String externalId, @WebParam(name = "room") @QueryParam("room") RoomDTO room) {
    return performCall(sid, User.Right.Soap, sd -> {
        Room r = roomDao.getExternal(Room.Type.valueOf(type), externalType, externalId);
        if (r == null) {
            if (room == null) {
                return null;
            } else {
                r = room.get(fileDao);
                r.setExternalType(externalType);
                r.setExternalId(externalId);
                r = updateRtoRoom(r, sd.getUserId());
                return new RoomDTO(r);
            }
        } else {
            return new RoomDTO(r);
        }
    });
}
Also used : RoomDTO(org.apache.openmeetings.db.dto.room.RoomDTO) Room(org.apache.openmeetings.db.entity.room.Room) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 2 with RoomDTO

use of org.apache.openmeetings.db.dto.room.RoomDTO in project openmeetings by apache.

the class RoomWebService method add.

/**
 * Adds a new Room like through the Frontend
 *
 * @param sid
 *            The SID from getSession
 * @param room
 *            room object
 *
 * @return - id of the user added or error code
 */
@WebMethod
@POST
@Path("/")
public RoomDTO add(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "room") @FormParam("room") RoomDTO room) {
    return performCall(sid, User.Right.Soap, sd -> {
        Room r = room.get(fileDao);
        r = updateRtoRoom(r, sd.getUserId());
        return new RoomDTO(r);
    });
}
Also used : RoomDTO(org.apache.openmeetings.db.dto.room.RoomDTO) Room(org.apache.openmeetings.db.entity.room.Room) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 3 with RoomDTO

use of org.apache.openmeetings.db.dto.room.RoomDTO in project openmeetings by apache.

the class AbstractWebServiceTest method createAndValidate.

protected static CallResult<RoomDTO> createAndValidate(String sid, RoomDTO r) {
    if (sid == null) {
        ServiceResult sr = login();
        sid = sr.getMessage();
    }
    RoomDTO room = getClient(getRoomUrl()).query("sid", sid).type(APPLICATION_FORM_URLENCODED).post(new Form().param("room", r.toString()), RoomDTO.class);
    assertNotNull("Valid room should be returned", room);
    assertNotNull("Room ID should be not empty", room.getId());
    RoomDTO room1 = getClient(getRoomUrl()).path(String.format("/%s", room.getId())).query("sid", sid).get(RoomDTO.class);
    assertNotNull("Valid room should be returned", room1);
    assertEquals("Room with same ID should be returned", room.getId(), room1.getId());
    assertEquals("Room with same Name should be returned", r.getName(), room1.getName());
    assertEquals("Room with same ExternalType should be returned", r.getExternalType(), room1.getExternalType());
    assertEquals("Room with same ExternalId should be returned", r.getExternalId(), room1.getExternalId());
    // TODO check other fields
    return new CallResult<>(sid, room1);
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RoomDTO(org.apache.openmeetings.db.dto.room.RoomDTO) Form(javax.ws.rs.core.Form)

Example 4 with RoomDTO

use of org.apache.openmeetings.db.dto.room.RoomDTO in project openmeetings by apache.

the class TestRoomService method testCreate2.

@Test
public void testCreate2() {
    Room.Type type = Room.Type.presentation;
    String name = "Unit Test Ext Room2";
    String comment = "Unit Test Ext Room Comments2";
    RoomDTO r = new RoomDTO();
    r.setType(type);
    r.setName(name);
    r.setComment(comment);
    r.setCapacity(CAPACITY);
    createAndValidate(r);
}
Also used : RoomDTO(org.apache.openmeetings.db.dto.room.RoomDTO) Room(org.apache.openmeetings.db.entity.room.Room) Test(org.junit.Test)

Example 5 with RoomDTO

use of org.apache.openmeetings.db.dto.room.RoomDTO in project openmeetings by apache.

the class TestRoomService method testCreate1.

@Test
public void testCreate1() {
    String extId = UUID.randomUUID().toString();
    Room.Type type = Room.Type.presentation;
    String name = "Unit Test Ext Room1";
    String comment = "Unit Test Ext Room Comments1";
    RoomDTO r = new RoomDTO();
    r.setType(type);
    r.setName(name);
    r.setComment(comment);
    r.setCapacity(CAPACITY);
    r.setExternalType(UNIT_TEST_EXT_TYPE);
    r.setExternalId(extId);
    createAndValidate(r);
}
Also used : RoomDTO(org.apache.openmeetings.db.dto.room.RoomDTO) Room(org.apache.openmeetings.db.entity.room.Room) Test(org.junit.Test)

Aggregations

RoomDTO (org.apache.openmeetings.db.dto.room.RoomDTO)9 Room (org.apache.openmeetings.db.entity.room.Room)7 Test (org.junit.Test)6 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)3 WebMethod (javax.jws.WebMethod)2 Path (javax.ws.rs.Path)2 RoomFileDTO (org.apache.openmeetings.db.dto.room.RoomFileDTO)2 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 Form (javax.ws.rs.core.Form)1 Response (javax.ws.rs.core.Response)1 FileItemDTO (org.apache.openmeetings.db.dto.file.FileItemDTO)1