unid = request.getParameter(PARAM_SNIPPET);
}
String format = getFormat(request);
String str = null;
RootNode rootNode = SnippetFactory.getJsSnippets(getServletContext(), request);
if (unid != null && unid.length() > 0) {
VFSFile rootFile = SnippetFactory.getJsRootFile(getServletContext());
JSSnippet snippet = (JSSnippet) rootNode.loadAsset(rootFile, unid);
if (snippet == null) {
service400(request, response, "Invalid unid: {0}", unid);
return;
}
if (FORMAT_JSON.equals(format)) {
str = toJson(request, snippet);
} else {
str = toXml(request, snippet);
}
} else {
List<Node> children = rootNode.getAllChildrenFlat();
if (FORMAT_JSON.equals(format)) {
str = rootNode.getAsJson();
} else if (FORMAT_GADGETS_JSON.equals(format)) {
str = toGadgetsJson(request, children);
} else {
str = toXml(request, children);
}