// Path: src/main/java/technology/tabula/tabula_web/JsonTransformer.java
// public class JsonTransformer implements ResponseTransformer {
// 
//     private Gson gson = new Gson();
// 
//     @Override
//     public String render(Object model) {
//         return gson.toJson(model);
//     }
// 
// }
// 
// Path: src/main/java/technology/tabula/tabula_web/workspace/WorkspaceDAO.java
// public interface WorkspaceDAO {
// 	
// 	Workspace getWorkspace() throws WorkspaceException;
// 
// 	void addDocument(WorkspaceDocument we, List<DocumentPage> pages) throws WorkspaceException;
// 
// 	void deleteDocument(String documentId) throws WorkspaceException;
// 
// 	WorkspaceDocument getDocumentMetadata(String documentId) throws WorkspaceException;
// 
// 	List<DocumentPage> getDocumentPages(String documentId) throws WorkspaceException;
// 
// 	String getDocumentPath(String documentId);
// 	
// 	String getDocumentDir(String documentId);
// 
// 	String getDataDir();
// 	
// 	void addFile(InputStream stream, String documentId, String filename) throws WorkspaceException;
// 
// }
// 
// Path: src/main/java/technology/tabula/tabula_web/workspace/WorkspaceException.java
// @SuppressWarnings("serial")
// public class WorkspaceException extends Exception {
// 	
// 	public WorkspaceException(Throwable cause) {
// 		super(cause);
// 	}
// }


import spark.Request;
import spark.Response;
import spark.RouteGroup;
import technology.tabula.tabula_web.JsonTransformer;
import technology.tabula.tabula_web.workspace.WorkspaceDAO;
import technology.tabula.tabula_web.workspace.WorkspaceException;
import static spark.Spark.*;
package technology.tabula.tabula_web.routes;



public class PdfRouteGroup implements RouteGroup {

	private WorkspaceDAO workspaceDAO;

	public PdfRouteGroup(WorkspaceDAO workspaceDAO) {
		this.workspaceDAO = workspaceDAO;
	}

	private Object deleteDocument(Request request, Response response) {
        try {
            this.workspaceDAO.deleteDocument(request.params(":file_id"));
        } catch (WorkspaceException e) {
            halt(500, e.getMessage());
        }
        return "";
    }

	@Override
	public void addRoutes() {
		get(":file_id/metadata.json", (req, rsp) -> {
			rsp.type("application/json");
			return this.workspaceDAO.getDocumentMetadata(req.params(":file_id"));
// Path: src/main/java/technology/tabula/tabula_web/JsonTransformer.java
// public class JsonTransformer implements ResponseTransformer {
// 
//     private Gson gson = new Gson();
// 
//     @Override
//     public String render(Object model) {
//         return gson.toJson(model);
//     }
// 
// }
// 
// Path: src/main/java/technology/tabula/tabula_web/workspace/WorkspaceDAO.java
// public interface WorkspaceDAO {
// 	
// 	Workspace getWorkspace() throws WorkspaceException;
// 
// 	void addDocument(WorkspaceDocument we, List<DocumentPage> pages) throws WorkspaceException;
// 
// 	void deleteDocument(String documentId) throws WorkspaceException;
// 
// 	WorkspaceDocument getDocumentMetadata(String documentId) throws WorkspaceException;
// 
// 	List<DocumentPage> getDocumentPages(String documentId) throws WorkspaceException;
// 
// 	String getDocumentPath(String documentId);
// 	
// 	String getDocumentDir(String documentId);
// 
// 	String getDataDir();
// 	
// 	void addFile(InputStream stream, String documentId, String filename) throws WorkspaceException;
// 
// }
// 
// Path: src/main/java/technology/tabula/tabula_web/workspace/WorkspaceException.java
// @SuppressWarnings("serial")
// public class WorkspaceException extends Exception {
// 	
// 	public WorkspaceException(Throwable cause) {
// 		super(cause);
// 	}
// }


// Path: src/main/java/technology/tabula/tabula_web/routes/PdfRouteGroup.java
import spark.Request;
import spark.Response;
import spark.RouteGroup;
import technology.tabula.tabula_web.JsonTransformer;
import technology.tabula.tabula_web.workspace.WorkspaceDAO;
import technology.tabula.tabula_web.workspace.WorkspaceException;
import static spark.Spark.*;

package technology.tabula.tabula_web.routes;



public class PdfRouteGroup implements RouteGroup {

	private WorkspaceDAO workspaceDAO;

	public PdfRouteGroup(WorkspaceDAO workspaceDAO) {
		this.workspaceDAO = workspaceDAO;
	}

	private Object deleteDocument(Request request, Response response) {
        try {
            this.workspaceDAO.deleteDocument(request.params(":file_id"));
        } catch (WorkspaceException e) {
            halt(500, e.getMessage());
        }
        return "";
    }

	@Override
	public void addRoutes() {
		get(":file_id/metadata.json", (req, rsp) -> {
			rsp.type("application/json");
			return this.workspaceDAO.getDocumentMetadata(req.params(":file_id"));
		}, new JsonTransformer());