private JSONObject makeJson() {
   response.setContentType("text/json");
   JSONObject jsonObject = new JSONObject();
   String attributes[] =
       new String[] {
         TEST.toString(),
         PropertySEARCH,
         PropertyEDIT,
         PropertyPROPERTIES,
         PropertyVERSIONS,
         PropertyREFACTOR,
         PropertyWHERE_USED,
         PropertyRECENT_CHANGES,
         SUITE.toString(),
         PropertyPRUNE,
         PropertySECURE_READ,
         PropertySECURE_WRITE,
         PropertySECURE_TEST,
         PropertyFILES
       };
   for (String attribute : attributes) addJsonAttribute(jsonObject, attribute);
   if (pageData.hasAttribute(PropertyHELP)) {
     jsonObject.put(PropertyHELP, pageData.getAttribute(PropertyHELP));
   }
   if (pageData.hasAttribute(PropertySUITES)) {
     JSONArray tags = new JSONArray();
     for (String tag : pageData.getAttribute(PropertySUITES).split(",")) {
       if (StringUtils.isNotBlank(tag)) {
         tags.put(tag.trim());
       }
     }
     jsonObject.put(PropertySUITES, tags);
   }
   return jsonObject;
 }
Example #2
0
 public SimpleResponse asResponse() throws Exception {
   byte[] bytes = toByteArray(document);
   SimpleResponse response = new SimpleResponse();
   response.setContent(bytes);
   response.setContentType("text/xml");
   return response;
 }
  private Response makePageHistoryXmlResponse(Request request) {
    VelocityContext velocityContext = new VelocityContext();
    velocityContext.put("pageHistory", pageHistory);

    response.setContentType("text/xml");
    response.setContent(context.pageFactory.render(velocityContext, "pageHistoryXML.vm"));
    return response;
  }
 private Response generateXMLResponse(File file) {
   try {
     response.setContent(FileUtil.getFileContent(file));
   } catch (IOException e) {
     response.setContent("Error: Unable to read file '" + file.getName() + "'\n");
   }
   response.setContentType(Format.XML);
   return response;
 }
  private JSONObject makeJson() {
    response.setContentType("text/json");
    JSONObject jsonObject = new JSONObject();
    String attributes[] =
        new String[] {
          TEST.toString(),
          PropertySEARCH,
          PropertyEDIT,
          PropertyPROPERTIES,
          PropertyVERSIONS,
          PropertyREFACTOR,
          PropertyWHERE_USED,
          PropertyRECENT_CHANGES,
          SUITE.toString(),
          PropertyPRUNE,
          PropertySECURE_READ,
          PropertySECURE_WRITE,
          PropertySECURE_TEST
        };
    for (String attribute : attributes) addJsonAttribute(jsonObject, attribute);

    return jsonObject;
  }