<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.community.projects.ntmss.data.DocumentGroup" %> <%@ 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 document group and all associated document links.", name = "documentgroup/delete") public static class MyParameters extends Parameters { @NotNull @Description(value = "document group id of the document group to delete", example = "2") public Integer documentGroupID = null; @Override protected void customValidation() { if (getUser() == null) { addError(-5, "Must be logged in to delete a document group."); return; } } } %> <% MyParameters params = new MyParameters().loadFromRequest(request, response, false); if (params.getErrors().size() == 0) { String role = "VMR Administrator"; boolean admin = params.getUser().hasRole(role); DocumentGroup obj = DocumentGroup.getDocumentGroup(params.documentGroupID); if (obj == null) { params.addError(-6, "documentGroupID: " + params.documentGroupID + " not found."); } else if (!admin && !params.getUser().getUserName().equals(obj.getUserID())) { params.addError(-7, "User does not have role: " + role + ". Cannot delete another user's Document Group."); } else { DocumentGroup.deleteDocumentGroup(obj.getDocumentGroupID()); Serializer.output(response, out, params, XMLBlock.createXMLBlock("")); return; } } else params.format = "html"; Serializer.reportErrors(request, response, out, params, true); %>