%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="org.crosswire.utils.Sessions" %>
<%@ page import="org.crosswire.webtools.RightsAndRoles" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement.Project" %>
<%@ page import="org.crosswire.xml.XMLBlock" %>
<%@ page import="org.crosswire.webtools.annotation.*" %>
<%@ page import="org.crosswire.webtools.*" %>
<%@ page import="javax.validation.constraints.NotNull" %>
<%!
@Description(value = "Completely delete a project.", name = "project/delete")
public static class MyParameters extends Parameters {
@NotNull
@Description(value = "project id of the project to delete", example = "4")
public Integer projectID;
@Override
protected void customValidation() {
if (getUser() == null) {
addError(-5, "Must be logged in.");
return;
}
}
}
%>
<%
MyParameters params = new MyParameters().loadFromRequest(request, response, false);
if (params.getErrors().size() == 0) {
String role = "VMR Administrator";
if (!params.getUser().hasRole(role)) {
params.addError(-6, "User does not have role: " + role + ". Cannot edit another user's project.");
}
else {
Project obj = ProjectManagement.getProject(params.projectID);
if (obj == null) {
params.addError(-7, "projectID: " + params.projectID + " not found.");
}
else {
params.getLogger().info("deleting project: " + obj.getProjectID());
Project.deleteProject(obj.getProjectID());
Serializer.output(response, out, params, XMLBlock.createXMLBlock(""));
return;
}
}
}
else params.format = "html";
Serializer.reportErrors(request, response, out, params, true);
%>