<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Document" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Page" %> <%@ 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 = "Clear all folio numbers for a manuscript.", name = "manuscript/clearfolionumbers") public static class MyParameters extends Parameters { @NotNull @Description(value = "manuscript id", example = "10046") public Integer docID; @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); Document d = Document.getDocument(params.docID); if (d == null) { params.addError(-5, "Document docID: " + params.docID + " not found."); } else { if (!permission) permission = params.getUser().getUserName().equals(d.getUserID()); if (!permission) { params.addError(-6, "User does not own this document or has the role: " + role + "."); } else { int count = 0; for (Page p : d.getPages()) { if (p.getFolioNumber() == null || p.getFolioNumber().length() > 0) { Page pOrig = (Page)p.clone(); p.setFolioNumber(""); p.save(pOrig); ++count; } } Serializer.output(response, out, params, XMLBlock.createXMLBlock( "" )); return; } } } else params.format = "html"; Serializer.reportErrors(request, response, out, params, true); %>