// Path: kbox.fusca/src/main/java/org/aksw/kbox/fusca/exception/ServerStartException.java
// public class ServerStartException extends Exception {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = -8495102644748797751L;
// 
// 	public ServerStartException(String message, Exception e) {
// 		super(message, e);
// 	}
// }


import org.aksw.kbox.fusca.exception.ServerStartException;
import org.apache.jena.fuseki.main.FusekiServer;
import org.apache.jena.query.ARQ;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory;
	public Server(int port, String pagePath, String subDomain, Model model, Listener listener) {
		this.port = port;
		this.subDomain = subDomain;
		this.pagePath = pagePath;
		Dataset dataset = DatasetFactory.create(model);
		this.dsg = dataset.asDatasetGraph();
		this.listener = listener;
	}
	
	public Server(int port, String pagePath, String subDomain, String datasetPath) {
		this.port = port;
		this.subDomain = subDomain;
		this.pagePath = pagePath;
		this.dsg = TDBFactory.createDatasetGraph(datasetPath);
	}

	public void start() throws ServerStartException {
		try {
			listener.starting();			
			String staticContentDir = pagePath;
			FusekiServer server = FusekiServer.create()
					.add("/" + subDomain, dsg)
					.enablePing(true)
					.enableStats(true)
					.staticFileBase(staticContentDir)
					.port(port)
					.build();
			server.start();
			listener.started();
		} catch (Exception e) {
// Path: kbox.fusca/src/main/java/org/aksw/kbox/fusca/exception/ServerStartException.java
// public class ServerStartException extends Exception {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = -8495102644748797751L;
// 
// 	public ServerStartException(String message, Exception e) {
// 		super(message, e);
// 	}
// }


// Path: kbox.fusca/src/main/java/org/aksw/kbox/fusca/Server.java
import org.aksw.kbox.fusca.exception.ServerStartException;
import org.apache.jena.fuseki.main.FusekiServer;
import org.apache.jena.query.ARQ;
import org.apache.jena.query.Dataset;
import org.apache.jena.query.DatasetFactory;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.sparql.core.DatasetGraph;
import org.apache.jena.tdb.TDBFactory;

	public Server(int port, String pagePath, String subDomain, Model model, Listener listener) {
		this.port = port;
		this.subDomain = subDomain;
		this.pagePath = pagePath;
		Dataset dataset = DatasetFactory.create(model);
		this.dsg = dataset.asDatasetGraph();
		this.listener = listener;
	}
	
	public Server(int port, String pagePath, String subDomain, String datasetPath) {
		this.port = port;
		this.subDomain = subDomain;
		this.pagePath = pagePath;
		this.dsg = TDBFactory.createDatasetGraph(datasetPath);
	}

	public void start() throws ServerStartException {
		try {
			listener.starting();			
			String staticContentDir = pagePath;
			FusekiServer server = FusekiServer.create()
					.add("/" + subDomain, dsg)
					.enablePing(true)
					.enableStats(true)
					.staticFileBase(staticContentDir)
					.port(port)
					.build();
			server.start();
			listener.started();
		} catch (Exception e) {
			throw new ServerStartException("Failed to start the server.", e);