use of org.olat.core.gui.control.pushpoll.WindowCommand in project openolat by klemens.
the class AjaxController method pushJSON.
private void pushJSON(WindowCommand wc, Writer writer) throws IOException {
Command c = wc.getCommand();
String winId = wc.getWindowBackOffice().getWindow().getDispatchID();
try {
writer.append("{\"w\":\"").append(winId).append("\",\"cmd\":").append(Integer.toString(c.getCommand())).append(",\"cda\":");
c.getSubJSON().write(writer);
c.getSubJSON().toString(2);
writer.append("}");
} catch (JSONException e) {
throw new AssertException("json exception:", e);
}
}
use of org.olat.core.gui.control.pushpoll.WindowCommand in project openolat by klemens.
the class AjaxController method getAndClearJSON.
/**
* @param moreCmds a List of WindowCommand objects
* @return
*/
private JSONObject getAndClearJSON(boolean clear) {
JSONObject root = new JSONObject();
try {
if (Settings.isDebuging()) {
long time = System.currentTimeMillis();
root.put("time", time);
}
synchronized (windowcommands) {
// o_clusterOK by:fj
// handle all windowcommands now, create json
int sum = windowcommands.size();
// number of commands: 0..n
root.put("cmdcnt", sum);
if (sum > 0) {
JSONArray ja = new JSONArray();
root.put("cmds", ja);
// treat commands waiting for the poll
for (int i = 0; i < sum; i++) {
WindowCommand wc = windowcommands.get(i);
JSONObject jo = createJSON(wc);
ja.put(jo);
}
if (clear) {
windowcommands.clear();
}
}
}
return root;
} catch (JSONException e) {
throw new AssertException("wrong data put into json object", e);
}
}
use of org.olat.core.gui.control.pushpoll.WindowCommand in project OpenOLAT by OpenOLAT.
the class AjaxController method createJSON.
private JSONObject createJSON(WindowCommand wc) {
Command c = wc.getCommand();
WindowBackOffice wbo = wc.getWindowBackOffice();
String winId = wbo.getWindow().getDispatchID();
JSONObject jo = new JSONObject();
try {
jo.put("cmd", c.getCommand());
jo.put("w", winId);
jo.put("cda", c.getSubJSON());
return jo;
} catch (JSONException e) {
throw new AssertException("json exception:", e);
}
}
use of org.olat.core.gui.control.pushpoll.WindowCommand in project OpenOLAT by OpenOLAT.
the class AjaxController method pushJSON.
private void pushJSON(WindowCommand wc, Writer writer) throws IOException {
Command c = wc.getCommand();
String winId = wc.getWindowBackOffice().getWindow().getDispatchID();
try {
writer.append("{\"w\":\"").append(winId).append("\",\"cmd\":").append(Integer.toString(c.getCommand())).append(",\"cda\":");
c.getSubJSON().write(writer);
c.getSubJSON().toString(2);
writer.append("}");
} catch (JSONException e) {
throw new AssertException("json exception:", e);
}
}
use of org.olat.core.gui.control.pushpoll.WindowCommand in project OpenOLAT by OpenOLAT.
the class AjaxController method pushJSONAndClear.
public void pushJSONAndClear(UserRequest ureq, Writer writer) throws IOException {
synchronized (windowcommands) {
// o_clusterOK by:fj
// handle all windowcommands now, create json
writer.append("{\"cmds\":[");
int sum = windowcommands.size();
if (sum > 0) {
// treat commands waiting for the poll
for (int i = 0; i < sum; i++) {
if (i != 0)
writer.append(",");
WindowCommand wc = windowcommands.get(i);
pushJSON(wc, writer);
}
}
writer.append("],\"cmdcnt\":").append(Integer.toString(sum));
appendBusinessPathInfos(ureq, writer);
writer.append("}");
windowcommands.clear();
}
}
Aggregations