%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="org.crosswire.community.projects.ntmss.data.ShelfInstance" %>
<%@ 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 shelf instance and all associated page links.", name = "shelfinstance/delete")
public static class MyParameters extends Parameters {
@NotNull
@Description(value = "shelf id of the shelf instance to delete", example = "149297")
public Integer shelfID;
@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";
boolean permission = params.getUser().hasRole(role);
if (!permission) {
params.addError(-6, "User does not have the role: " + role + ".");
}
else {
ShelfInstance si = ShelfInstance.getShelfInstance(params.shelfID);
if (si == null) {
params.addError(-7, "Couldn't find shelf instance, shelfID: " + params.shelfID + ".");
}
else {
ShelfInstance.deleteShelfInstance(si.getShelfInstanceID());
Serializer.output(response, out, params, XMLBlock.createXMLBlock(""));
return;
}
}
}
else params.format = "html";
Serializer.reportErrors(request, response, out, params, true);
%>