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;
}