Example #1
0
  private void writeError(HttpServletResponse response, String errorText, int status)
      throws IOException {
    JsonWriter writer = new JsonWriter();

    if (errorText == null || errorText.isEmpty()) errorText = "Internal server error.";

    writer.startResponse(null, false, status);
    writer.writeInfo(Arrays.asList(Message.error(errorText)), null, null);
    writer.startArray(Json.data);
    writer.finishArray();
    writer.finishResponse();

    writeResponse(response, writer.toString().getBytes(encoding.Default.toString()));
  }
Example #2
0
 @Override
 public void writeResponse(JsonWriter writer) throws Throwable {
   org.zenframework.z8.server.json.parser.JsonArray response = response();
   if (response != null) writer.writeProperty(Json.data, response);
 }
Example #3
0
 public void write(JsonWriter writer) {
   writer.writeProperty(Json.text, displayName());
   writer.writeProperty(Json.description, description());
   writer.writeProperty(Json.icon, icon());
   writer.writeProperty(Json.id, classId());
 }