<commit_before>package org.apache.zookeeper.server.browser;

import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.RuntimeSingleton;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.node.SimpleNode;
import org.apache.zookeeper.KeeperException.NoNodeException;
import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.server.DataTree;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.apache.commons.lang.StringEscapeUtils.escapeHtml;


public class FileBrowserServlet extends HttpServlet {

	static final Logger logger = LoggerFactory.getLogger(FileBrowserServlet.class);


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	ZooKeeperServer zkServer;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");

		String mainTemplate = "error";

		String layout = "";

		boolean shouldParse = true;

		Stat stat = new Stat();

		String baseNode = request.getRequestURL().toString().replaceAll(".*/commands/browser/?", "/");

		Template template = null;

		Template layoutTemplate = null;

		DataTree tree = zkServer.getZKDatabase().getDataTree();

		if ("".equals(baseNode)) {
			baseNode = "";
		}

		//mainTemplate = new String(zkServer.getZKDatabase().getData("/configs/browser/views/application" + baseNode, stat, null));
		template = getTemplate("main", "/configs/browser/views/application/index.html");
		layoutTemplate = getTemplate("layout", "/configs/browser/views/layouts/application.html");

		if (template == null) {
			logger.error("loading " +  "/configs/browser/assets" + baseNode);
			template = getTemplate("x", "/configs/browser/assets" + baseNode);
			response.getWriter().write("loading " + "/configs/browser/assets" + baseNode);
			return;
		}

		boolean isFolder = false;

		// check if exists a folder
		if (!baseNode.endsWith("/")) {

			try {
				List<String> nodes = tree.getChildren(baseNode+"/", stat, null);

				isFolder = (nodes != null);
				
			    response.getWriter().write("isFolder " + isFolder);

			} catch (NoNodeException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
<commit_msg>moved template files to /content-browser node<commit_after>package org.apache.zookeeper.server.browser;

import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.RuntimeSingleton;
import org.apache.velocity.runtime.parser.ParseException;
import org.apache.velocity.runtime.parser.node.SimpleNode;
import org.apache.zookeeper.KeeperException.NoNodeException;
import org.apache.zookeeper.data.Stat;
import org.apache.zookeeper.server.DataTree;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.apache.commons.lang.StringEscapeUtils.escapeHtml;


public class FileBrowserServlet extends HttpServlet {

	static final Logger logger = LoggerFactory.getLogger(FileBrowserServlet.class);


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	ZooKeeperServer zkServer;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");

		String mainTemplate = "error";

		String layout = "";

		boolean shouldParse = true;

		Stat stat = new Stat();

		String baseNode = request.getRequestURL().toString().replaceAll(".*/commands/browser/?", "/");

		Template template = null;

		Template layoutTemplate = null;

		DataTree tree = zkServer.getZKDatabase().getDataTree();

		if ("".equals(baseNode)) {
			baseNode = "";
		}

		//mainTemplate = new String(zkServer.getZKDatabase().getData("/content-browser/views/application" + baseNode, stat, null));
		template = getTemplate("main", "/content-browser/views/application/index.html");
		layoutTemplate = getTemplate("layout", "/content-browser/views/layouts/application.html");

		if (template == null) {
			logger.error("unable to load " +  "/content-browser/assets" + baseNode + ", please create the node in your zookeeper instance");
			template = getTemplate("x", "/content-browser/assets" + baseNode);
			response.getWriter().write("loading " + "/content-browser/assets" + baseNode);
			return;
		}

		boolean isFolder = false;

		// check if exists a folder
		if (!baseNode.endsWith("/")) {

			try {
				List<String> nodes = tree.getChildren(baseNode+"/", stat, null);

				isFolder = (nodes != null);
				
			    response.getWriter().write("isFolder " + isFolder);

			} catch (NoNodeException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}

{'fraction_non_alphanumeric': 0.12355212355212356, 'fraction_numerical': 0.0010072183985227463, 'mean_word_length': 4.922465208747515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6722444', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1692, 'n_words': 341}