Package com.dotcms.repackage.org.codehaus.jettison.json

Examples of com.dotcms.repackage.org.codehaus.jettison.json.JSONObject


    ResourceResponse responseResource = new ResourceResponse( paramsMap );

    List<ContentletSearch> searchIndex = APILocator.getContentletAPI().searchIndex(query, limit, offset, sortBy, initData.getUser(), true);
    JSONArray array=new JSONArray();
    for(ContentletSearch cs : searchIndex) {
      array.put(new JSONObject()
      .put("inode", cs.getInode())
      .put("identifier", cs.getIdentifier()));
    }

    return responseResource.response( array.toString() );
View Full Code Here


    sb.append("</contentlet>");
    return sb.toString();
  }
 
  private String getJSONContentIds(Contentlet con) throws IOException{
    JSONObject json = new JSONObject();
    try {
      json.put("inode", con.getInode());
      json.put("identifier", con.getIdentifier());
    } catch (JSONException e) {
      Logger.warn(this.getClass(), "unable JSON contentlet " + con.getIdentifier());
      Logger.debug(this.getClass(), "unable to find contentlet", e);
    }
    return json.toString();
  }
View Full Code Here

    }
    return json.toString();
  }

  private String getJSON(List<Contentlet> cons, HttpServletRequest request, HttpServletResponse response, String render) throws IOException{
    JSONObject json = new JSONObject();
    JSONArray jsonCons = new JSONArray();

    for(Contentlet c : cons){
      try {
        jsonCons.put(contentletToJSON(c, request, response, render));
      } catch (Exception e) {
        Logger.warn(this.getClass(), "unable JSON contentlet " + c.getIdentifier());
        Logger.debug(this.getClass(), "unable to find contentlet", e);
      }
    }

    try {
      json.put("contentlets", jsonCons);
    } catch (JSONException e) {
      Logger.warn(this.getClass(), "unable to create JSONObject");
      Logger.debug(this.getClass(), "unable to create JSONObject", e);
    }

    return json.toString();
  }
View Full Code Here

        jsonFields.add(f.getVelocityVarName());
    return jsonFields;
  }

  private JSONObject contentletToJSON(Contentlet con, HttpServletRequest request, HttpServletResponse response, String render) throws JSONException, IOException{
    JSONObject jo = new JSONObject();
    Structure s = con.getStructure();
    Map<String,Object> map = con.getMap();

    Set<String> jsonFields=getJSONFields(s);

    for(String key : map.keySet()) {
      if(Arrays.binarySearch(ignoreFields, key) < 0)
        if(jsonFields.contains(key)) {
          Logger.info(this, key+" is a json field: "+map.get(key).toString());
          jo.put(key, new JSONObject(con.getKeyValueProperty(key)));
        }
        else
          jo.put(key, map.get(key));
    }

    for(Field f : FieldsCache.getFieldsByStructureInode(s.getInode())){
      if(f.getFieldType().equals(Field.FieldType.BINARY.toString())){
        jo.put(f.getVelocityVarName(), "/contentAsset/raw-data/" +  con.getIdentifier() + "/" + f.getVelocityVarName()  );
        jo.put(f.getVelocityVarName() + "ContentAsset", con.getIdentifier() + "/" +f.getVelocityVarName()  );
      }
    }

    if(s.getStructureType() == Structure.STRUCTURE_TYPE_WIDGET && "true".equals(render)) {
      jo.put("parsedCode",  WidgetResource.parseWidget(request, response, con));
    }

    return jo;
  }
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  protected void processJSON(Contentlet contentlet, InputStream input) throws JSONException, IOException {
    HashMap<String,Object> map=new HashMap<String,Object>();
    JSONObject obj=new JSONObject(IOUtils.toString(input));
    Iterator<String> keys = obj.keys();
    while(keys.hasNext()) {
      String key=keys.next();
      Object value=obj.get(key);
      map.put(key, value.toString());
    }
    processMap(contentlet,map);
  }
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.codehaus.jettison.json.JSONObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.