} else {
catAPI.sortChildren(inode);
}
}
PaginatedCategories pagCategories = topLevelCats?catAPI.findTopLevelCategories(user, false, start, count, q, sort):
catAPI.findChildren(user, inode, false, start, count, q, sort);
List<Map<String,Object>> items = new ArrayList<Map<String,Object>>();
List<Category> categories = pagCategories.getCategories();
if(categories!=null) {
for (Category category : categories) {
Map<String,Object> catMap = new HashMap<String,Object>();
catMap.put("inode", category.getInode());
catMap.put("category_name", category.getCategoryName());
catMap.put("category_key", category.getKey());
catMap.put("category_velocity_var_name", category.getCategoryVelocityVarName());
catMap.put("sort_order", category.getSortOrder());
catMap.put("keywords", category.getKeywords());
items.add(catMap);
}
}
Map<String,Object> m = new HashMap<String, Object>();
m.put("items", items);
m.put("numRows", pagCategories.getTotalCount());
String s = mapper.writeValueAsString(m);
response.setContentType("text/plain");
response.getWriter().write(s);
response.getWriter().flush();
response.getWriter().close();