use of com.github.openjson.JSONObject in project openmeetings by apache.
the class TestCalendarService method testCreateWithOmMm.
@Test
public void testCreateWithOmMm() throws Exception {
JSONObject o = createAppointment("test").put("meetingMembers", new JSONArray().put(new JSONObject().put("user", new JSONObject().put("id", 1))));
String uuid = UUID.randomUUID().toString();
User u = getUser(uuid);
u.getGroupUsers().add(new GroupUser(getBean(GroupDao.class).get(1L), u));
u = createUser(getBean(UserDao.class), u);
ServiceResult sr = login(u.getLogin(), createPass());
Response resp = getClient(getCalendarUrl()).path("/").query("sid", sr.getMessage()).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());
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class TestCalendarService method createApp.
private String createApp(String title) throws Exception {
JSONObject o = createAppointment(title);
String sid = loginNewUser();
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());
return sid;
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class AppointmentMessageBodyWriter method writeTo.
@Override
public void writeTo(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);
writer.write(new JSONObject().put(ROOT, AppointmentParamConverter.json(t)).toString());
writer.flush();
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class AppointmentParamConverter method fromString.
@Override
public AppointmentDTO fromString(String val) {
JSONObject o = new JSONObject(val);
if (o.has(ROOT)) {
o = o.getJSONObject(ROOT);
}
AppointmentDTO a = new AppointmentDTO();
a.setId(optLong(o, "id"));
a.setTitle(o.optString("title"));
a.setLocation(o.optString("location"));
a.setOwner(UserDTO.get(o.optJSONObject("owner")));
String tzId = a.getOwner() == null ? null : a.getOwner().getTimeZoneId();
a.setStart(CalendarParamConverter.get(o.optString("start"), tzId));
a.setEnd(CalendarParamConverter.get(o.optString("end"), tzId));
a.setDescription(o.optString("description"));
a.setInserted(DateParamConverter.get(o.optString("inserted")));
a.setUpdated(DateParamConverter.get(o.optString("updated")));
a.setDeleted(o.optBoolean("deleted"));
a.setReminder(optEnum(Reminder.class, o, "reminder"));
a.setRoom(RoomDTO.get(o.optJSONObject("room")));
a.setIcalId(o.optString("icalId"));
JSONArray mm = o.optJSONArray("meetingMembers");
if (mm != null) {
for (int i = 0; i < mm.length(); ++i) {
a.getMeetingMembers().add(MeetingMemberDTO.get(mm.getJSONObject(i)));
}
}
a.setLanguageId(o.optLong("languageId"));
a.setPassword(o.optString("password"));
a.setPasswordProtected(o.optBoolean("passwordProtected"));
a.setConnectedEvent(o.optBoolean("connectedEvent"));
a.setReminderEmailSend(o.optBoolean("reminderEmailSend"));
return a;
}
use of com.github.openjson.JSONObject in project openmeetings by apache.
the class UserMessageBodyWriter method writeTo.
@Override
public void writeTo(UserDTO t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream out) throws IOException {
Writer writer = new OutputStreamWriter(out, UTF_8);
writer.write(new JSONObject().put(ROOT, UserParamConverter.json(t)).toString());
writer.flush();
}
Aggregations