diff --git a/src/main/java/com/metaweb/gridworks/GridworksServlet.java b/src/main/java/com/metaweb/gridworks/GridworksServlet.java index 47eb4a186..f5d92322c 100644 --- a/src/main/java/com/metaweb/gridworks/GridworksServlet.java +++ b/src/main/java/com/metaweb/gridworks/GridworksServlet.java @@ -19,6 +19,7 @@ import com.metaweb.gridworks.commands.edit.DoTextTransformCommand; import com.metaweb.gridworks.commands.edit.FacetBasedEditCommand; import com.metaweb.gridworks.commands.edit.JoinMultiValueCellsCommand; import com.metaweb.gridworks.commands.edit.RemoveColumnCommand; +import com.metaweb.gridworks.commands.edit.DeleteProjectCommand; import com.metaweb.gridworks.commands.edit.SaveProtographCommand; import com.metaweb.gridworks.commands.edit.SplitMultiValueCellsCommand; import com.metaweb.gridworks.commands.edit.UndoRedoCommand; @@ -58,6 +59,8 @@ public class GridworksServlet extends HttpServlet { _commands.put("get-project-metadata", new GetProjectMetadataCommand()); _commands.put("get-all-project-metadata", new GetAllProjectMetadataCommand()); + + _commands.put("delete-project", new DeleteProjectCommand()); _commands.put("get-models", new GetModelsCommand()); _commands.put("get-rows", new GetRowsCommand()); diff --git a/src/main/java/com/metaweb/gridworks/ProjectManager.java b/src/main/java/com/metaweb/gridworks/ProjectManager.java index e209a29bd..a710b4ee5 100644 --- a/src/main/java/com/metaweb/gridworks/ProjectManager.java +++ b/src/main/java/com/metaweb/gridworks/ProjectManager.java @@ -307,4 +307,16 @@ public class ProjectManager implements Serializable { } } } + + public boolean deleteProject(Project project) { + File file = new File(_dir, project.id + ".project"); + if (file.exists()) { + _projects.remove(project.id); + _projectsMetadata.remove(project.id); + boolean result = file.delete(); + save(); + return result; + } + return false; + } } diff --git a/src/main/java/com/metaweb/gridworks/commands/edit/DeleteProjectCommand.java b/src/main/java/com/metaweb/gridworks/commands/edit/DeleteProjectCommand.java new file mode 100644 index 000000000..045a8254c --- /dev/null +++ b/src/main/java/com/metaweb/gridworks/commands/edit/DeleteProjectCommand.java @@ -0,0 +1,26 @@ +package com.metaweb.gridworks.commands.edit; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.metaweb.gridworks.ProjectManager; +import com.metaweb.gridworks.commands.Command; + +public class DeleteProjectCommand extends Command { + @Override + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + try { + boolean result = ProjectManager.singleton.deleteProject(getProject(request)); + + respond(response, "{ \"code\" : " + (result ? "\"ok\"" : "\"error\"") + " }"); + + } catch (Exception e) { + respondException(response, e); + } + } +} diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index 00afb05a5..f6ce84ff0 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -1 +1 @@ -
Create a new project by uploading a tab-separated value or comma-separated value file.
Create a new project by uploading a tab-separated value or comma-separated value file.
last modified |
last modified |