<commit_before>package ru.semiot.platform.apigateway.config;

import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map.Entry;

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

@WebServlet("/ConfigurationDriverHandler")
public class ConfigurationDriverHandler extends HttpServlet {
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		HashMap<String, String> parameters = getRequestParameters(request);
		String pid = parameters.get("pid");

		if (request.getParameter("save") != null) {

			parameters.remove("pid");
			parameters.remove("save");

			try {
				// parameters
				StringBuilder propertyList = new StringBuilder();
				if (parameters.size() < 1) {
					return;
				}
				for (Entry<String, String> entry : parameters.entrySet()) {
					if (propertyList.length() > 0) {
						propertyList.append(",");
					}
					propertyList.append(entry.getKey());
				}
				System.out.println(propertyList.toString());
				parameters.put("post", "true");
				parameters.put("apply", "true");
				parameters.put("propertylist", propertyList.toString());

				QueryUtils.sendGetUrl(BundleConstants.urlConfigMgr + pid,
						parameters, true);

				QueryUtils.start(pid);
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
		} else if (request.getParameter("uninstall") != null) {
			try {
				QueryUtils.uninstall(pid);
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
		}

		response.sendRedirect("/config/DriversInstalled");
		// request.getRequestDispatcher("/config/DriversInstalled").forward(request,
		// response);
	}

	private static HashMap<String, String> getRequestParameters(
			HttpServletRequest request) {
		HashMap<String, String> parameters = new HashMap<String, String>();
		Enumeration _enum = request.getParameterNames();
		while (_enum.hasMoreElements()) {
			String key = (String) _enum.nextElement();
			String value = request.getParameter(key);
			parameters.put(key, value);
			System.out.println(key + " " + value);
		}
		return parameters;
	}

}<commit_msg>Added validation changes in the existing configuration<commit_after>package ru.semiot.platform.apigateway.config;

import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map.Entry;

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

@WebServlet("/ConfigurationDriverHandler")
public class ConfigurationDriverHandler extends HttpServlet {
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		HashMap<String, String> parameters = getRequestParameters(request);
		String pid = parameters.get("pid");

		if (request.getParameter("save") != null) {
			try {
				String statusConf = QueryUtils.getStatusConfigurations();
				if (statusConf.indexOf("\"PID = " + pid + "\"") == -1) {

					parameters.remove("pid");
					parameters.remove("save");

					// parameters
					StringBuilder propertyList = new StringBuilder();
					if (parameters.size() < 1) {
						return;
					}
					for (Entry<String, String> entry : parameters.entrySet()) {
						if (propertyList.length() > 0) {
							propertyList.append(",");
						}
						propertyList.append(entry.getKey());
					}
					System.out.println(propertyList.toString());
					parameters.put("post", "true");
					parameters.put("apply", "true");
					parameters.put("propertylist", propertyList.toString());

					QueryUtils.sendGetUrl(BundleConstants.urlConfigMgr + pid,
							parameters, true);

					QueryUtils.start(pid);
				}
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
		} else if (request.getParameter("uninstall") != null) {
			try {
				QueryUtils.uninstall(pid);
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
		}

		response.sendRedirect("/config/DriversInstalled");
		// request.getRequestDispatcher("/config/DriversInstalled").forward(request,
		// response);
	}

	private static HashMap<String, String> getRequestParameters(
			HttpServletRequest request) {
		HashMap<String, String> parameters = new HashMap<String, String>();
		Enumeration _enum = request.getParameterNames();
		while (_enum.hasMoreElements()) {
			String key = (String) _enum.nextElement();
			String value = request.getParameter(key);
			parameters.put(key, value);
			System.out.println(key + " " + value);
		}
		return parameters;
	}

}
{'fraction_non_alphanumeric': 0.1340805313408053, 'fraction_numerical': 0.0010377750103777502, 'mean_word_length': 4.307268722466961, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3961771', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1354, 'n_words': 267}