예제 #1
0
 /**
  * Get JS snippets in JSON format, including sbtx.sample.web's JS snippets.
  *
  * @param context
  * @param request
  * @return JSSnippets in JSON format.
  */
 public static String getJsSnippetsAsJson(ServletContext context, HttpServletRequest request) {
   RootNode root = getJsSnippets(context, request);
   String json = root.getAsJson();
   String jsonEx = readRemoteJson(context, request);
   if (StringUtil.isNotEmpty(jsonEx) && jsonEx.contains("children")) {
     jsonEx = jsonEx.substring("[{\"id\":\"_root\",\"name\":\"_root\",\"children\":[".length());
     json = json.substring(0, json.length() - 3) + "," + jsonEx;
   }
   return json;
 }
예제 #2
0
 /**
  * Returns an Asset based on its name, NodeFactory type and root path.
  *
  * @param context
  * @param request
  * @param assetName
  * @param nodeFactory
  * @param rootPath
  * @return
  */
 private static Asset getAsset(
     ServletContext context,
     HttpServletRequest request,
     String assetName,
     NodeFactory nodeFactory,
     String rootPath) {
   try {
     RootNode root = getSnippets(context, nodeFactory, rootPath, request);
     return root.loadAsset(getRootFile(context, rootPath), assetName);
   } catch (IOException ioe) {
     return null;
   }
 }