<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Page" %> <%@ page import="org.crosswire.sword.keys.SWKey" %> <%@ page import="org.crosswire.sword.keys.VerseKey" %> <%@ page import="org.crosswire.sword.keys.ListKey" %> <%@ page import="javax.validation.constraints.NotNull" %> <%@ page import="org.crosswire.xml.XMLBlock" %> <%@ page import="org.crosswire.webtools.annotation.*" %> <%@ page import="org.crosswire.webtools.*" %> <%! @Description(value = "Submit new or modified index information about the content of a manuscript page.", name = "biblicalcontent/put") public static class MyParameters extends Parameters { @NotNull @Description(value = "manuscript id to modify", example = "10046") public Integer docID = null; @NotNull @Description(value = "page id to modify", example = "10") public Integer pageID = null; @NotNull @Description(value = "index content for this page", example = "Jn.1.1-9,12") public String indexContent; @Description(value = "internal") public String biblicalContent = null; @Description(value = "userName to associate as responsible for the saved content", example = "jsmith") public String userName = null; protected Page mssPage = null; @Override protected void afterLoad() { if (userName == null && getUser() != null) userName = getUser().getUserName(); if (indexContent == null) indexContent = biblicalContent; } @Override protected void customValidation() { if (docID != null && pageID != null && indexContent != null) { mssPage = Page.getPage(docID, pageID); if (mssPage == null) { addError(-5, "docID: " + docID + "; pageID: " + pageID + " not found."); return; } if (getUser() == null) { addError(-6, "No permission. User not logged in."); return; } boolean permission = getUser().hasRole("VMR Administrator") || getUser().hasRole("Index Manager"); if (!permission && ((!getUser().getUserName().equals(userName)) || mssPage.getIndexerID() != null && !mssPage.getIndexerID().equals(getUser().getUserName()))) { addError(-7, "User not an Index Manager. To request change to data not owned by you, consider discussing this page on the forum."); return; } } else format = "html"; } } %> <% MyParameters params = new MyParameters().loadFromRequest(request, response, false); if (params.getErrors().size() == 0) { String parsedResult = params.mssPage.saveBiblicalContent(params.indexContent, params.userName); // reload the page afer we've saved biblical content params.mssPage = Page.getPage(params.docID, params.pageID); ListKey next = new VerseKey(params.mssPage.getBiblicalContent()).ParseVerseList(params.mssPage.getBiblicalContent(), params.mssPage.getBiblicalContent(), true); next.setPosition(SWKey.BOTTOM); StringBuffer retVal = new StringBuffer(); retVal.append(""); retVal.append(""); retVal.append(""); Serializer.output(response, out, params, XMLBlock.createXMLBlock(retVal.toString())); return; } Serializer.reportErrors(request, response, out, params, true); %>