Search in sources :

Example 31 with JSONArray

use of com.github.openjson.JSONArray in project openmeetings by apache.

the class Client method streamJson.

public JSONObject streamJson(String _sid, boolean self, IStreamClientManager mgr) {
    JSONArray _streams = new JSONArray();
    boolean avFound = false;
    for (String _uid : streams) {
        StreamClient rc = mgr.get(_uid);
        if (rc == null) {
            continue;
        }
        Type t = rc.getType();
        if (Type.room == t) {
            avFound = true;
        }
        _streams.put(RoomHelper.addScreenActivities(new JSONObject().put("type", t.name()).put("uid", self && Type.room == t ? uid : rc.getUid()).put("broadcastId", rc.getBroadcastId()).put("width", rc.getWidth()).put("height", rc.getHeight()), rc));
    }
    if (self && !avFound && hasAnyActivity(Activity.broadcastA, Activity.broadcastV)) {
        _streams.put(new JSONObject().put("type", Type.room.name()).put("uid", uid).put("width", width).put("height", height));
    }
    return toJson(self).put("sid", _sid).put("streams", _streams);
}
Also used : JSONObject(com.github.openjson.JSONObject) StreamClient(org.apache.openmeetings.db.entity.room.StreamClient) JSONArray(com.github.openjson.JSONArray)

Example 32 with JSONArray

use of com.github.openjson.JSONArray in project openmeetings by apache.

the class ReminderJob method loadRss.

public void loadRss() {
    log.trace("ReminderJob.loadRss");
    if (!isInitComplete()) {
        return;
    }
    if (!cfgDao.getBool(CONFIG_DASHBOARD_SHOW_RSS, false)) {
        log.debug("Rss disabled by Admin");
        return;
    }
    JSONArray feed = new JSONArray();
    for (String url : new String[] { cfgDao.getString(CONFIG_DASHBOARD_RSS_FEED1, ""), cfgDao.getString(CONFIG_DASHBOARD_RSS_FEED2, "") }) {
        if (!Strings.isEmpty(url)) {
            AtomReader.load(url, feed);
        }
    }
    if (feed.length() > 0) {
        setRss(feed);
    }
}
Also used : JSONArray(com.github.openjson.JSONArray)

Example 33 with JSONArray

use of com.github.openjson.JSONArray in project openmeetings by apache.

the class TestCalendarService method testCreateWithGuests.

@Test
public void testCreateWithGuests() throws Exception {
    String sid = loginNewUser();
    AppointmentDTO dto = createEventWithGuests(sid);
    // try to change MM list
    JSONObject o1 = AppointmentParamConverter.json(dto).put("meetingMembers", new JSONArray().put(new JSONObject().put("user", new JSONObject().put("id", 1))));
    Response resp = getClient(getCalendarUrl()).path("/").query("sid", sid).form(new Form().param("appointment", o1.toString()));
    assertNotNull("Valid AppointmentDTO should be returned", resp);
    assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
    dto = resp.readEntity(AppointmentDTO.class);
    assertNotNull("Valid DTO should be returned", dto);
    assertNotNull("DTO id should be valid", dto.getId());
    assertEquals("DTO should have 1 attendees", 1, dto.getMeetingMembers().size());
}
Also used : Response(javax.ws.rs.core.Response) JSONObject(com.github.openjson.JSONObject) Form(javax.ws.rs.core.Form) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) JSONArray(com.github.openjson.JSONArray) Test(org.junit.Test)

Example 34 with JSONArray

use of com.github.openjson.JSONArray in project openmeetings by apache.

the class TestCalendarService method createEventWithGuests.

private static AppointmentDTO createEventWithGuests(String sid) throws Exception {
    JSONObject o = createAppointment("test").put("meetingMembers", new JSONArray().put(new JSONObject().put("user", new JSONObject().put("firstname", "John 1").put("lastname", "Doe").put("address", new JSONObject().put("email", "john1@doe.email")))).put(new JSONObject().put("user", new JSONObject().put("firstname", "John 2").put("lastname", "Doe").put("address", new JSONObject().put("email", "john2@doe.email")))));
    Response resp = getClient(getCalendarUrl()).path("/").query("sid", sid).form(new Form().param("appointment", o.toString()));
    assertNotNull("Valid AppointmentDTO should be returned", resp);
    assertEquals("Call should be successful", Response.Status.OK.getStatusCode(), resp.getStatus());
    AppointmentDTO dto = resp.readEntity(AppointmentDTO.class);
    assertNotNull("Valid DTO should be returned", dto);
    assertNotNull("DTO id should be valid", dto.getId());
    assertEquals("DTO should have 2 attendees", 2, dto.getMeetingMembers().size());
    for (MeetingMemberDTO mm : dto.getMeetingMembers()) {
        assertNotNull("Email should be valid", mm.getUser().getAddress().getEmail());
    }
    return dto;
}
Also used : Response(javax.ws.rs.core.Response) JSONObject(com.github.openjson.JSONObject) Form(javax.ws.rs.core.Form) JSONArray(com.github.openjson.JSONArray) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) MeetingMemberDTO(org.apache.openmeetings.db.dto.calendar.MeetingMemberDTO)

Example 35 with JSONArray

use of com.github.openjson.JSONArray in project openmeetings by apache.

the class AppointmentListMessageBodyWriter method writeTo.

@Override
public void writeTo(List<AppointmentDTO> t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream out) throws IOException {
    Writer writer = new OutputStreamWriter(out, UTF_8);
    JSONArray rr = new JSONArray();
    for (AppointmentDTO dto : t) {
        rr.put(AppointmentParamConverter.json(dto));
    }
    writer.write(new JSONObject().put(ROOT, rr).toString());
    writer.flush();
}
Also used : JSONObject(com.github.openjson.JSONObject) JSONArray(com.github.openjson.JSONArray) AppointmentDTO(org.apache.openmeetings.db.dto.calendar.AppointmentDTO) OutputStreamWriter(java.io.OutputStreamWriter) MessageBodyWriter(javax.ws.rs.ext.MessageBodyWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

JSONArray (com.github.openjson.JSONArray)35 JSONObject (com.github.openjson.JSONObject)30 Test (org.junit.jupiter.api.Test)11 List (java.util.List)5 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)5 ArrayList (java.util.ArrayList)4 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)4 Form (javax.ws.rs.core.Form)3 Response (javax.ws.rs.core.Response)3 JSONException (com.github.openjson.JSONException)2 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Client (org.apache.openmeetings.db.entity.basic.Client)2 Room (org.apache.openmeetings.db.entity.room.Room)2 RoomElement (org.apache.openmeetings.db.entity.room.Room.RoomElement)2 NullStringer (org.apache.openmeetings.util.NullStringer)2 PDDocument (org.apache.pdfbox.pdmodel.PDDocument)2