<commit_before>package org.opentosca.csarrepo.servlet;

import java.io.IOException;

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

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opentosca.csarrepo.service.CreateCsarService;

/**
 * Servlet implementation class UploadCSARServlet
 */
@SuppressWarnings("serial")
@WebServlet(CreateCsarServlet.PATH)
public class CreateCsarServlet extends AbstractServlet {

	private static final Logger LOGGER = LogManager.getLogger(CreateCsarServlet.class);
	private static final String PARAM_CSAR_NAME = "csarName";
	public static final String PATH = "/createcsar";

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public CreateCsarServlet() {
		super();
	}

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.sendError(405, "Method Not Allowed");
	}

	/**
	 * @throws IOException
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
		try {
			// TODO: Check if Csar already exists and if it is empty
			String csarName = request.getParameter(PARAM_CSAR_NAME);
			CreateCsarService createCsarService = new CreateCsarService(0L, csarName);

			LOGGER.debug("Got request to create CSAR " + csarName + " delegating ...");

			if (createCsarService.hasErrors()) {
				throw new ServletException("CreateCsarService has Errors: " + createCsarService.getErrors().get(0));
			}

			response.sendRedirect(getBasePath() + ListCsarServlet.PATH);
		} catch (ServletException e) {
			response.getWriter().print(e.getMessage());
		}
	}

}<commit_msg>Csars without name are now not creatable, refs #236<commit_after>package org.opentosca.csarrepo.servlet;

import java.io.IOException;

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

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opentosca.csarrepo.service.CreateCsarService;

/**
 * Servlet implementation class UploadCSARServlet
 */
@SuppressWarnings("serial")
@WebServlet(CreateCsarServlet.PATH)
public class CreateCsarServlet extends AbstractServlet {

	private static final Logger LOGGER = LogManager.getLogger(CreateCsarServlet.class);
	private static final String PARAM_CSAR_NAME = "csarName";
	public static final String PATH = "/createcsar";

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public CreateCsarServlet() {
		super();
	}

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.sendError(405, "Method Not Allowed");
	}

	/**
	 * @throws IOException
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
		try {
			// TODO: Check if Csar already exists and if it is empty
			String csarName = request.getParameter(PARAM_CSAR_NAME);
			if (csarName.equals("")) {
				this.redirect(request, response, ListCsarServlet.PATH);
			} else {

				CreateCsarService createCsarService = new CreateCsarService(0L, csarName);

				LOGGER.debug("Got request to create CSAR " + csarName + " delegating ...");

				if (createCsarService.hasErrors()) {
					throw new ServletException("CreateCsarService has Errors: " + createCsarService.getErrors().get(0));
				}
				response.sendRedirect(getBasePath() + ListCsarServlet.PATH);

			}
		} catch (ServletException e) {
			response.getWriter().print(e.getMessage());
		}
	}
}
{'fraction_non_alphanumeric': 0.1029082774049217, 'fraction_numerical': 0.004225702212279393, 'mean_word_length': 5.238759689922481, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '679187', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1168, 'n_words': 264}