commit a055f333aefcf2cc6bebf09c5d0bd3e53e0a56c9
Author: Pavel Fidranský <fidransky@outlook.com>
Date:   Mon Aug 27 19:18:27 2018 +0200

    dropped unused servlets

diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/DeleteAllComponents.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/DeleteAllComponents.java
deleted file mode 100644
index e22b992..0000000
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/DeleteAllComponents.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package cz.zcu.kiv.offscreen.servlets.actions;
-
-import java.io.File;
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import cz.zcu.kiv.offscreen.loader.configuration.ConfigurationLoader;
-import cz.zcu.kiv.offscreen.session.SessionManager;
-import cz.zcu.kiv.offscreen.storage.FileManager;
-
-/**
- * @author Jindra Pavlíková <jindra.pav2@seznam.cz>
- */
-public class DeleteAllComponents extends HttpServlet {
-
-    /**
-     * Delete all components from the graph. Optionally, only components of a particular graph version set in query
-     * parameter can be deleted. For AJAX requests, 204 NO_CONTENT status code is returned.
-     */
-    @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        String workingDirectory;
-        if (request.getParameter("diagram_hash") == null) {
-            workingDirectory = SessionManager.getSessionValue(request, "JSESSIONID");
-        } else {
-            workingDirectory = request.getParameter("diagram_hash");
-        }
-
-        if (request.getParameter("graphVersion") != null) {
-            workingDirectory += File.separator + request.getParameter("graphVersion");
-        }
-
-        String storageLocation = ConfigurationLoader.getStorageLocation(request.getServletContext());
-        
-        FileManager fileManager = new FileManager(workingDirectory, storageLocation);
-        fileManager.deleteAllFiles();
-
-        String requestedWith = request.getHeader("X-Requested-With");
-        if (requestedWith != null && requestedWith.equals("XMLHttpRequest")) {
-            // AJAX request, send response
-            response.setStatus(response.SC_NO_CONTENT);
-
-        } else {
-            request.setAttribute("componentNames", fileManager.getUploadedComponentsNames());
-
-            // redirect
-            response.sendRedirect(getServletContext().getInitParameter("HOME_URL"));
-        }
-    }
-}
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/DeleteComponent.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/DeleteComponent.java
deleted file mode 100644
index 9842f15..0000000
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/DeleteComponent.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cz.zcu.kiv.offscreen.servlets.actions;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import cz.zcu.kiv.offscreen.loader.configuration.ConfigurationLoader;
-import cz.zcu.kiv.offscreen.session.SessionManager;
-import cz.zcu.kiv.offscreen.storage.FileManager;
-import cz.zcu.kiv.offscreen.user.DB;
-import cz.zcu.kiv.offscreen.user.Diagram;
-
-/**
- * @author Jindra Pavlíková <jindra.pav2@seznam.cz>
- */
-public class DeleteComponent extends HttpServlet {
-
-    /**
-     * Deleted a single component from either the current graph version or the version set in query parameter. For AJAX
-     * requests, 204 NO_CONTENT status code is returned.
-     */
-    @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        String workingDirectory;
-        if (request.getParameter("diagram_hash") == null) {
-            workingDirectory = SessionManager.getSessionValue(request, "JSESSIONID");
-        } else {
-            workingDirectory = request.getParameter("diagram_hash");
-        }
-
-        if (request.getParameter("graphVersion") != null) {
-            workingDirectory += File.separator + request.getParameter("graphVersion");
-        } else {
-            workingDirectory += File.separator + SessionManager.getSessionValue(request, "graphVersion");
-        }
-
-        String storageLocation = ConfigurationLoader.getStorageLocation(request.getServletContext());
-
-        boolean doDeleteComponent = true;
-        String redirectUrlParams = "";
-
-        if (request.getParameter("diagram_id") != null && request.getParameter("diagram_hash") != null) {
-            Integer diagramId = Integer.parseInt(request.getParameter("id_diagram"));
-
-            DB db = new DB(getServletContext());
-            Diagram diagram = new Diagram(db, diagramId);
-            Map<String, String> diag_param = diagram.getDiagram();
-
-            if (request.getSession().getAttribute("logged_user_id") == null) {
-        		doDeleteComponent = false;
-            } else if (request.getSession().getAttribute("logged_user_id").toString().equals(diag_param.get("user_id"))) {
-            	doDeleteComponent = true;
-        	} else {
-        		doDeleteComponent = false;
-        	}
-
-            redirectUrlParams = "?diagram_id=" + request.getParameter("diagram_id") + "&diagram_hash=" + request.getParameter("diagram_hash");
-        }
-        
-        if (doDeleteComponent) {
-	        FileManager fileManager = new FileManager(workingDirectory, storageLocation);
-	        fileManager.deleteFile(request.getParameter("name"));
-
-	        request.setAttribute("componentNames", fileManager.getUploadedComponentsNames());
-        }
-
-        String requestedWith = request.getHeader("X-Requested-With");
-        if (requestedWith != null && requestedWith.equals("XMLHttpRequest")) {
-            // AJAX request, send response
-            response.setStatus(response.SC_NO_CONTENT);
-
-        } else {
-            // redirect
-            response.sendRedirect(getServletContext().getInitParameter("HOME_URL") + redirectUrlParams);
-        }
-    }
-}
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/DiagramEndpoint.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/DiagramEndpoint.java
deleted file mode 100644
index 812f069..0000000
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/DiagramEndpoint.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package cz.zcu.kiv.offscreen.servlets.actions;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Map;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import cz.zcu.kiv.offscreen.loader.configuration.ConfigurationLoader;
-import cz.zcu.kiv.offscreen.storage.FileManager;
-import cz.zcu.kiv.offscreen.user.DB;
-import cz.zcu.kiv.offscreen.user.Diagram;
-
-public class DiagramEndpoint extends HttpServlet {
-
-    /**
-     * Returns position of components in diagram by id and hash code.
-     */
-    @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        // diagram ID is not set
-        if (request.getParameter("id_diagram") == null) {
-            response.sendError(response.SC_BAD_REQUEST);
-            return;
-        }
-
-        Integer diagramId = Integer.parseInt(request.getParameter("diagram_id"));
-
-        DB db = new DB(getServletContext());
-        Diagram diagram = new Diagram(db, diagramId);
-        Map<String, String> diag_param = diagram.getDiagram();
-
-        // user is not owner of the diagram
-        if (!request.getSession().getAttribute("logged_user_id").toString().equals(diag_param.get("user_id"))) {
-            response.sendError(response.SC_UNAUTHORIZED);
-            return;
-        }
-
-        // send response
-        response.setContentType("application/json");
-
-        PrintWriter out = response.getWriter();
-        out.write(diag_param.get("vertices_position"));
-        out.flush();
-    }
-
-    /**
-     * Method saves position of component, which are send by parameter in post method.
-     */
-    @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        // user is not logged in
-        if (request.getSession().getAttribute("logged_user_id") == null) {
-            response.sendError(response.SC_UNAUTHORIZED);
-            return;
-        }
-
-        // diagram ID is not set
-        if (request.getParameter("id_diagram") == null) {
-            response.sendError(response.SC_BAD_REQUEST);
-            return;
-        }
-
-        Integer diagramId = Integer.parseInt(request.getParameter("diagram_id"));
-
-        DB db = new DB(getServletContext());
-        Diagram diagram = new Diagram(db, diagramId);
-        Map<String, String> diag_param = diagram.getDiagram();
-
-        // user is not owner of the diagram
-        if (!request.getSession().getAttribute("logged_user_id").toString().equals(diag_param.get("user_id"))) {
-            response.sendError(response.SC_UNAUTHORIZED);
-            return;
-        }
-
-        String verticesPosition = request.getParameter("vertices_position");
-        //diagram.updateVerticesPosition(verticesPosition); REMOVED FROM DATABASE
-
-        // send response
-        response.setContentType("application/json");
-
-        PrintWriter out = response.getWriter();
-        out.write(verticesPosition);
-        out.flush();
-    }
-
-    /**
-     * Deletes diagram from database and from file system.
-     * Id of diagrams is loaded from get parameter in url.
-     * In method is controlled logged user and user, who uploaded diagram.
-     */
-    @Override
-    protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        // user is not logged in
-        if (request.getSession().getAttribute("logged_user_id") == null) {
-            response.sendError(response.SC_UNAUTHORIZED);
-            return;
-        }
-
-        // diagram ID is not set
-        if (request.getParameter("id_diagram") == null) {
-            response.sendError(response.SC_BAD_REQUEST);
-            return;
-        }
-
-        Integer diagramId = Integer.parseInt(request.getParameter("id_diagram"));
-
-        DB db = new DB(getServletContext());
-        Diagram diagram = new Diagram(db, diagramId);
-        Map<String, String> diag_param = diagram.getDiagram();
-
-        // user is not owner of the diagram
-        if (!request.getSession().getAttribute("logged_user_id").toString().equals(diag_param.get("user_id"))) {
-            response.sendError(response.SC_UNAUTHORIZED);
-            return;
-        }
-
-        String workingDirectory = diag_param.get("hash") + "_" + diag_param.get("id");
-        String storageLocation = ConfigurationLoader.getStorageLocation(request.getServletContext());
-
-        FileManager fileManager = new FileManager(workingDirectory, storageLocation);
-        fileManager.deleteAllFiles();
-        fileManager.deleteDirectory();
-
-        diagram.delete();
-
-        // send response
-        response.setStatus(response.SC_NO_CONTENT);
-    }
-}
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/LoadLog.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/LoadLog.java
deleted file mode 100644
index 8d04ba4..0000000
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/LoadLog.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package cz.zcu.kiv.offscreen.servlets.actions;
-
-import cz.zcu.kiv.offscreen.user.DB;
-import cz.zcu.kiv.offscreen.user.Diagram;
-import cz.zcu.kiv.offscreen.user.Log;
-import cz.zcu.kiv.offscreen.user.User;
-import net.sf.json.JSONObject;
-import org.apache.log4j.Logger;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import net.sf.json.JSONArray;
-
-public class LoadLog extends HttpServlet {
-
-    private Logger logger = Logger.getLogger(LoadLog.class);
-    
-    /**
-     * Handles the HTTP
-     * <code>GET</code> method.
-     *
-     * @param request servlet request
-     * @param response servlet response
-     * @throws ServletException if a servlet-specific error occurs
-     * @throws IOException if an I/O error occurs
-     */
-    @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        throw new UnsupportedOperationException();
-    }
-    
-    /**
-     * Handles the HTTP
-     * <code>POST</code> method.
-     *
-     * @param request servlet request
-     * @param response servlet response
-     * @throws ServletException if a servlet-specific error occurs
-     * @throws IOException if an I/O error occurs
-     */
-    @Override
-    protected void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        logger.info("Servlet - LoadLog \t\t method - doGet \t\t Start");
-        Object userIdStr = request.getSession().getAttribute("logged_user_id");
-        String diagramIDStr = request.getParameter("id_diagram");
-
-        response.setContentType("application/json");
-        PrintWriter out = response.getWriter();
-        if(diagramIDStr != null && userIdStr!=null) {
-                int diagramID = Integer.parseInt(diagramIDStr);
-                int userId = Integer.parseInt(userIdStr.toString());
-                DB dbConn = new DB(getServletContext());
-                String output = "";
-                Log log= new Log(dbConn);
-                List<Map<String,String>> listLogs = log.readLogs(diagramID);
-                JSONArray o = JSONArray.fromObject(listLogs);
-                output += o;
-                out.write(output);
-                logger.info("Servlet - LoadLog \t\t method - doGet \t\t return: " +o.toString());
-            }else {
-                logger.info("Servlet - LoadLog \t\t method - doGet \t\t diagramId or userId is null");
-            }
-        out.close();
-        logger.info("Servlet - LoadLog \t\t method - doGet \t\t end");
-    }
-}
diff --git a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/SaveLog.java b/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/SaveLog.java
deleted file mode 100644
index d96d69e..0000000
--- a/sources/src/main/java/cz/zcu/kiv/offscreen/servlets/actions/SaveLog.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package cz.zcu.kiv.offscreen.servlets.actions;
-
-import cz.zcu.kiv.offscreen.user.DB;
-import cz.zcu.kiv.offscreen.user.Diagram;
-import cz.zcu.kiv.offscreen.user.Log;
-import org.apache.log4j.Logger;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.HashMap;
-
-/**
- * Class for save log
- * 
- * @author Marek Rasocha
- *
- */
-public class SaveLog extends HttpServlet{
-    private Logger logger = Logger.getLogger(SaveLog.class);
-  
-    
-    /**
-     * Method saves position of component, which are send by parameter in post method.
-     */
-    protected void doPost(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
- logger.info("Servlet - SaveLog \t\t method - doPost \t\t start");
-        //id of diagram, which will be updated
-        String diagramIdStr  = request.getParameter("id_diagram");
-        Object userIdStr = request.getSession().getAttribute("logged_user_id");
-        DB db = new DB(getServletContext());
-        PrintWriter out = response.getWriter();
-        try{
-            if(diagramIdStr != null && userIdStr!=null) {
-                if (checkUserId(Integer.parseInt(diagramIdStr),Integer.parseInt(userIdStr.toString()),db)){
-                    HashMap<String, String> log = new HashMap<String, String>();
-                    log.put("user_name", request.getSession().getAttribute("logged_user_nick").toString());
-                    log.put("user_id", userIdStr.toString());
-                    log.put("id_diagram", diagramIdStr);
-                    String event = request.getParameter("log_event");
-                    log.put("log_event", event );
-                    log.put("log_date_delay", request.getParameter("log_date_delay"));
-                    log.put("change_jar", request.getParameter("change_jar"));
-                    log.put("new_version", request.getParameter("new_version"));
-                    if(event==null){
-                        out.write("{\"err\":\""+ "event is null" +"\"}");
-                    }else{
-                        Log logDao = new Log(db);
-                        if(logDao.createLog(log)>0){
-                            out.write("{\"ok\":\"ok\"}");
-                            logger.info("Servlet - SaveLog \t\t method - doPost \t\t Log created");
-                        }else{
-                            out.write("{\"err\":\""+ "database error " +"\"}");
-                            logger.info("Servlet - SaveLog \t\t method - doPost \t\t error database");
-                        }
-                        
-                    }
-                    
-                }else{
-                    logger.info("Servlet - SaveLog \t\t method - doPost \t\t This user dont have a permisson");
-                    out.write("{\"err\":\""+ "This user has not permission for showing the log " +"\"}");
-                }
-            }else{
-                logger.info("Servlet - SaveLog \t\t method - doPost \t\t diagramId or userId is null");
-                out.write("{\"err\":\""+ "diagramId or userId is null" +"\"}");
-            }
-
-        	
-        }catch(NumberFormatException e){
-        	e.printStackTrace();
-        }catch(Exception e){
-        	e.printStackTrace();
-        }
-        out.close();
-        logger.info("Servlet - SaveLog \t\t method - doPost \t\t end");
-    }
-
-    private boolean checkUserId(int diagramID, int userId, DB db) {
-
-        Diagram diag = new Diagram(db, diagramID);
-        HashMap<String,String> param = (HashMap<String, String>) diag.getDiagram();
-        String idStr = param.get("user_id");
-        int id = Integer.parseInt(idStr);
-        if (userId==0){
-            return false;
-        }
-        return  id==userId ? true : false;
-    }
-    protected void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        logger.info("Servlet - SaveLog \t\t method - doPost \t\t start");
-        //id of diagram, which will be updated
-        String diagramIdStr  = request.getParameter("id_diagram");
-        Object userIdStr = request.getSession().getAttribute("logged_user_id");
-        DB db = new DB(getServletContext());
-        PrintWriter out = response.getWriter();
-        try{
-            if(diagramIdStr != null && userIdStr!=null) {
-                if (checkUserId(Integer.parseInt(diagramIdStr),Integer.parseInt(userIdStr.toString()),db)){
-                    HashMap<String, String> log = new HashMap<String, String>();
-                    log.put("user_name", request.getSession().getAttribute("logged_user_nick").toString());
-                    log.put("user_id", userIdStr.toString());
-                    log.put("id_diagram", diagramIdStr);
-                    String event = request.getParameter("log_event");
-                    log.put("log_event", event );
-                    log.put("log_date_delay", request.getParameter("log_date_delay"));
-                    log.put("change_jar", request.getParameter("change_jar"));
-                    log.put("new_version", request.getParameter("new_version"));
-                    if(event==null){
-                        out.write("{\"err\":\""+ "event is null" +"\"}");
-                    }else{
-                        Log logDao = new Log(db);
-                        if(logDao.createLog(log)>0){
-                            out.write("{\"ok\":\"ok\"}");
-                            logger.info("Servlet - SaveLog \t\t method - doPost \t\t Log created");
-                        }else{
-                            out.write("{\"err\":\""+ "database error " +"\"}");
-                            logger.info("Servlet - SaveLog \t\t method - doPost \t\t error database");
-                        }
-                        
-                    }
-                    
-                }else{
-                    logger.info("Servlet - SaveLog \t\t method - doPost \t\t This user dont have a permisson");
-                    out.write("{\"err\":\""+ "This user has not permission for showing the log " +"\"}");
-                }
-            }else{
-                logger.info("Servlet - SaveLog \t\t method - doPost \t\t diagramId or userId is null");
-                out.write("{\"err\":\""+ "diagramId or userId is null" +"\"}");
-            }
-
-        	
-        }catch(NumberFormatException e){
-        	e.printStackTrace();
-        }catch(Exception e){
-        	e.printStackTrace();
-        }
-        out.close();
-        logger.info("Servlet - SaveLog \t\t method - doPost \t\t end");
-    }
-}
diff --git a/sources/src/main/webapp/WEB-INF/web.xml b/sources/src/main/webapp/WEB-INF/web.xml
index d851dd4..7c93791 100644
--- a/sources/src/main/webapp/WEB-INF/web.xml
+++ b/sources/src/main/webapp/WEB-INF/web.xml
@@ -72,18 +72,6 @@
 		<servlet-name>RemoveDiagram</servlet-name>
 		<servlet-class>cz.zcu.kiv.offscreen.servlets.actions.RemoveDiagram</servlet-class>
 	</servlet>
-	<servlet>
-		<servlet-name>DeleteAllComponents</servlet-name>
-		<servlet-class>cz.zcu.kiv.offscreen.servlets.actions.DeleteAllComponents</servlet-class>
-	</servlet>
-	<servlet>
-		<servlet-name>DeleteComponent</servlet-name>
-		<servlet-class>cz.zcu.kiv.offscreen.servlets.actions.DeleteComponent</servlet-class>
-	</servlet>
-	<servlet>
-		<servlet-name>DiagramEndpoint</servlet-name>
-		<servlet-class>cz.zcu.kiv.offscreen.servlets.actions.DiagramEndpoint</servlet-class>
-	</servlet>
 	<servlet>
 		<servlet-name>LoadGraphData</servlet-name>
 		<servlet-class>cz.zcu.kiv.offscreen.servlets.LoadGraphData</servlet-class>
@@ -120,19 +108,6 @@
 		<servlet-name>RemoveDiagram</servlet-name>
 		<url-pattern>/api/remove-diagram</url-pattern>
 	</servlet-mapping>
-
-	<servlet-mapping>
-		<servlet-name>DeleteAllComponents</servlet-name>
-		<url-pattern>/delete-components</url-pattern>
-	</servlet-mapping>
-	<servlet-mapping>
-		<servlet-name>DeleteComponent</servlet-name>
-		<url-pattern>/delete-component</url-pattern>
-	</servlet-mapping>
-	<servlet-mapping>
-		<servlet-name>DiagramEndpoint</servlet-name>
-		<url-pattern>/api/diagram</url-pattern>
-	</servlet-mapping>
 	<servlet-mapping>
 		<servlet-name>LoadGraphData</servlet-name>
 		<url-pattern>/api/graph-data</url-pattern>
