%@ 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.xml.XMLBlock" %>
<%@ page import="org.crosswire.webtools.annotation.*" %>
<%@ page import="org.crosswire.webtools.*" %>
<%@ page import="javax.validation.constraints.NotNull" %>
<%!
@Description(value = "Retrieve detailed information about a manuscript", name = "manuscript/get")
public static class MyParameters extends Parameters {
Integer docIDValue = null;
@Description(value = "manuscript id to retrieve", example = "10046")
public String docID;
@Description(value = "manuscript Gregory-Aland number to retrieve (also accepts 'crosswire:modName')", defaultValue = "must provide either {docID} or {gaNum}", example = "P46")
public String gaNum;
@Description(value = "level of detail 1-10", defaultValue = "10", example = "1")
public Integer detail;
@Override
protected void customValidation() {
// backward compatible to allow docID = 'crosswire:modName'
if (docID != null) {
if (gaNum == null && docID.startsWith("crosswire:")) { gaNum = docID; docID = null; }
else try { docIDValue = Integer.parseInt(docID); } catch(Exception e) {}
}
if (docIDValue == null && gaNum == null) {
addError(-4, "must provide either {docID} or {gaNum}");
}
}
}
%>
<%
MyParameters params = new MyParameters().loadFromRequest(request, response, false);
if (params.getErrors().size() == 0) {
int contentAccessLevel = 0;
if (params.getUser() != null) {
contentAccessLevel = params.getUser().hasRole("Expert User" ) ? Math.max(1, contentAccessLevel):contentAccessLevel;
contentAccessLevel = params.getUser().hasRole("Internal User" ) ? Math.max(2, contentAccessLevel):contentAccessLevel;
contentAccessLevel = params.getUser().hasRole("VMR Administrator") ? Math.max(3, contentAccessLevel):contentAccessLevel;
}
Document doc = (params.docIDValue != null) ? Document.getDocument(params.docIDValue) : (params.gaNum.startsWith("crosswire:") ? new Document.CrossWireDocument(params.gaNum.substring("crosswire:".length())) : Document.getDocumentByGANumber(params.gaNum));
if (doc == null) {
if (params.docIDValue != null) params.addError(-6, "docID: " + params.docIDValue + " not found.");
else params.addError(-6, "gaNum: " + params.gaNum + " not found.");
}
else {
doc.setContentAccessLevel(contentAccessLevel);
Serializer.output(response, out, params, XMLBlock.createXMLBlock(doc.toFormattedXML()));
return;
}
}
else params.format = "html";
Serializer.reportErrors(request, response, out, params, true);
%>