// Path: src/main/java/octopus/server/ftpserver/OctopusFTPServer.java
// public class OctopusFTPServer {
// 
// 	private static final Logger logger = LoggerFactory
// 			.getLogger(OctopusFTPServer.class);
// 
// 	private static final String FTP_SERVER_HOST = "localhost";
// 	private static final int FTP_SERVER_PORT = 23231;
// 
// 	FtpServer server;
// 	FtpServerFactory serverFactory = new FtpServerFactory();
// 	ListenerFactory factory = new ListenerFactory();
// 	ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
// 
// 	public void start() throws FtpException
// 	{
// 		factory.setPort(FTP_SERVER_PORT);
// 		factory.setServerAddress(FTP_SERVER_HOST);
// 
// 		configureAnonymousLogin();
// 
// 		serverFactory.addListener("default", factory.createListener());
// 
// 		server = serverFactory.createServer();
// 		server.start();
// 	}
// 
// 	private void configureAnonymousLogin() throws FtpException
// 	{
// 		connectionConfigFactory.setAnonymousLoginEnabled(true);
// 		serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
// 
// 		BaseUser user = configureAnonymousUser();
// 		String projectDirStr = OctopusEnvironment.PROJECTS_DIR.toString();
// 		user.setHomeDirectory(projectDirStr);
// 
// 		serverFactory.getUserManager().save(user);
// 	}
// 
// 	private BaseUser configureAnonymousUser()
// 	{
// 		BaseUser user = new BaseUser();
// 		user.setName("anonymous");
// 		List<Authority> auths = new ArrayList<Authority>();
// 		Authority auth = new WritePermission();
// 		auths.add(auth);
// 		user.setAuthorities(auths);
// 		return user;
// 	}
// 
// }
// 
// Path: src/main/java/octopus/server/restServer/OctopusRestServer.java
// public class OctopusRestServer {
// 
// 	private static final int REST_PORT = 2480;
// 
// 	public static void start()
// 	{
// 		port(REST_PORT);
// 
// 		/*
// 		 * This is a complete list of all REST commands. If you want to
// 		 * add a command, please stick to the following RULES:
// 		 *
// 		 * - If you need optional parameters, create multiple routes
// 		 *   but do NOT use slack. This will ensure that all ways of
// 		 *   executing commands remain visible in this file.
// 		 *
// 		 * - Try to place your command into one of the existing
// 		 * 	 groups first. Only if none exists that matches, create
// 		 *   your own group.
// 		 *
// 		 * - Choose a group name that describes functionality, not
// 		 *   code origin.
// 		 **/
// 
// 		post("executeplugin/", (req, res) -> {
// 			return new ExecutePluginHandler().handle(req, res); });
// 
// 		get("manageprojects/create/:projectName", (req, res) -> {
// 			return new CreateProjectHandler().handle(req, res);
// 		});
// 
// 		get("manageprojects/delete/:projectName", (req, res) -> {
// 			return new DeleteProjectHandler().handle(req, res);
// 		});
// 
// 		get("manageprojects/list", (req, res) -> {
// 			return new ListProjectsHandler().handle(req, res);
// 		});
// 
// 		get("database/importcsv/:projectName", (req, res) -> {
// 			return new ImportCSVHandler().handle(req, res);
// 		});
// 
// 		get("database/importcsv/:projectName/:nodeFilename/:edgeFilename", (req, res) -> {
// 			return new ImportCSVHandler().handle(req, res);
// 		});
// 
// 		get("database/reset/:projectName", (req, res) -> {
// 			return new ResetDatabaseHandler().handle(req, res);
// 		});
// 
// 		get("manageshells/list", (req, res) -> {
// 			return new ListShellsHandler().handle(req, res);
// 		});
// 
// 		get("manageshells/create/:projectName/:shellName", (req, res) -> {
// 			return new CreateShellHandler().handle(req,res);
// 		});
// 
// 		exception(RuntimeException.class, (e, req, res) -> {
// 			res.status(400);
// 			res.body("Runtime Exception: " + e.getMessage());
// 		});
// 
// 	}
// 
// }


import org.apache.ftpserver.FtpServerConfigurationException;
import org.apache.ftpserver.ftplet.FtpException;
import octopus.server.ftpserver.OctopusFTPServer;
import octopus.server.restServer.OctopusRestServer;
package octopus;



public class OctopusMain {

    static OctopusMain main;


    OctopusFTPServer ftpServer;

    public static void main(String[] args) throws java.lang.Exception
    {
        main = new OctopusMain();
        main.startFTPServer();
        main.startRestServer();
    }

    private void startFTPServer()
    {
		ftpServer = new OctopusFTPServer();
		try {
			ftpServer.start();
		} catch (FtpException| FtpServerConfigurationException e) {
			System.out.println("Error starting Octopus");
			System.out.println(e.getMessage());
			System.exit(-1);
		}
	}

    private void startRestServer()
    {
// Path: src/main/java/octopus/server/ftpserver/OctopusFTPServer.java
// public class OctopusFTPServer {
// 
// 	private static final Logger logger = LoggerFactory
// 			.getLogger(OctopusFTPServer.class);
// 
// 	private static final String FTP_SERVER_HOST = "localhost";
// 	private static final int FTP_SERVER_PORT = 23231;
// 
// 	FtpServer server;
// 	FtpServerFactory serverFactory = new FtpServerFactory();
// 	ListenerFactory factory = new ListenerFactory();
// 	ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
// 
// 	public void start() throws FtpException
// 	{
// 		factory.setPort(FTP_SERVER_PORT);
// 		factory.setServerAddress(FTP_SERVER_HOST);
// 
// 		configureAnonymousLogin();
// 
// 		serverFactory.addListener("default", factory.createListener());
// 
// 		server = serverFactory.createServer();
// 		server.start();
// 	}
// 
// 	private void configureAnonymousLogin() throws FtpException
// 	{
// 		connectionConfigFactory.setAnonymousLoginEnabled(true);
// 		serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
// 
// 		BaseUser user = configureAnonymousUser();
// 		String projectDirStr = OctopusEnvironment.PROJECTS_DIR.toString();
// 		user.setHomeDirectory(projectDirStr);
// 
// 		serverFactory.getUserManager().save(user);
// 	}
// 
// 	private BaseUser configureAnonymousUser()
// 	{
// 		BaseUser user = new BaseUser();
// 		user.setName("anonymous");
// 		List<Authority> auths = new ArrayList<Authority>();
// 		Authority auth = new WritePermission();
// 		auths.add(auth);
// 		user.setAuthorities(auths);
// 		return user;
// 	}
// 
// }
// 
// Path: src/main/java/octopus/server/restServer/OctopusRestServer.java
// public class OctopusRestServer {
// 
// 	private static final int REST_PORT = 2480;
// 
// 	public static void start()
// 	{
// 		port(REST_PORT);
// 
// 		/*
// 		 * This is a complete list of all REST commands. If you want to
// 		 * add a command, please stick to the following RULES:
// 		 *
// 		 * - If you need optional parameters, create multiple routes
// 		 *   but do NOT use slack. This will ensure that all ways of
// 		 *   executing commands remain visible in this file.
// 		 *
// 		 * - Try to place your command into one of the existing
// 		 * 	 groups first. Only if none exists that matches, create
// 		 *   your own group.
// 		 *
// 		 * - Choose a group name that describes functionality, not
// 		 *   code origin.
// 		 **/
// 
// 		post("executeplugin/", (req, res) -> {
// 			return new ExecutePluginHandler().handle(req, res); });
// 
// 		get("manageprojects/create/:projectName", (req, res) -> {
// 			return new CreateProjectHandler().handle(req, res);
// 		});
// 
// 		get("manageprojects/delete/:projectName", (req, res) -> {
// 			return new DeleteProjectHandler().handle(req, res);
// 		});
// 
// 		get("manageprojects/list", (req, res) -> {
// 			return new ListProjectsHandler().handle(req, res);
// 		});
// 
// 		get("database/importcsv/:projectName", (req, res) -> {
// 			return new ImportCSVHandler().handle(req, res);
// 		});
// 
// 		get("database/importcsv/:projectName/:nodeFilename/:edgeFilename", (req, res) -> {
// 			return new ImportCSVHandler().handle(req, res);
// 		});
// 
// 		get("database/reset/:projectName", (req, res) -> {
// 			return new ResetDatabaseHandler().handle(req, res);
// 		});
// 
// 		get("manageshells/list", (req, res) -> {
// 			return new ListShellsHandler().handle(req, res);
// 		});
// 
// 		get("manageshells/create/:projectName/:shellName", (req, res) -> {
// 			return new CreateShellHandler().handle(req,res);
// 		});
// 
// 		exception(RuntimeException.class, (e, req, res) -> {
// 			res.status(400);
// 			res.body("Runtime Exception: " + e.getMessage());
// 		});
// 
// 	}
// 
// }


// Path: src/main/java/octopus/OctopusMain.java
import org.apache.ftpserver.FtpServerConfigurationException;
import org.apache.ftpserver.ftplet.FtpException;
import octopus.server.ftpserver.OctopusFTPServer;
import octopus.server.restServer.OctopusRestServer;

package octopus;



public class OctopusMain {

    static OctopusMain main;


    OctopusFTPServer ftpServer;

    public static void main(String[] args) throws java.lang.Exception
    {
        main = new OctopusMain();
        main.startFTPServer();
        main.startRestServer();
    }

    private void startFTPServer()
    {
		ftpServer = new OctopusFTPServer();
		try {
			ftpServer.start();
		} catch (FtpException| FtpServerConfigurationException e) {
			System.out.println("Error starting Octopus");
			System.out.println(e.getMessage());
			System.exit(-1);
		}
	}

    private void startRestServer()
    {
		OctopusRestServer.start();