<%@ 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.Transcription" %> <%@ page import="org.crosswire.repo.VersionedRepo" %> <%@ page import="org.crosswire.utils.Utils" %> <%@ 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 = "Save a transcription portion for a manuscript.", name = "transcription/put") public static class MyParameters extends Parameters { @NotNull @Description(value = "manuscript id for which to save a transcript", example = "10046") public Integer docID = null; @NotNull @Description(value = "manscript page id for which to save a transcript", example = "10") public Integer pageID = null; @Description(value = "user's transcription to save", defaultValue = "PUBLISHED", example = "psmith") public String userName = null; @NotNull @Description(value = "transcription body to save, as TEI") public String transcript = null; @Description(value = "should repository be pushed", defaultValue = "true", example = "false") public Boolean push = true; @Description(value = "should indexing data be extracted from transcription page and saved as global index info for page. This will only happen if no indexing data exists or if current indexing data is owned by this same user", defaultValue = "false", example = "true") public Boolean updateIndexing = false; @Override protected void afterLoad() { if ("PUBLISHED".equals(userName)) userName = null; userName = Transcription.assureUnicode(userName); transcript = Transcription.assureUnicode(transcript); if (transcript != null && !transcript.trim().startsWith("" + transcript; } @Override protected void customValidation() { if (getUser() == null) { addError(-5, "Must be logged in to edit transcriptions."); return; } } } %> <% MyParameters params = new MyParameters().loadFromRequest(request, response, false); if (params.getErrors().size() == 0) { boolean pushOnCommit = "true".equals(Utils.getSysConfig(session).getProperty("VersionedRepoPushOnCommit")); String role="VMR Administrator"; String role2="Transcription Manager"; String role3="Transcription Publisher"; // let's check to see if we're a privileged user boolean isAdmin = params.getUser().hasRole(role) || params.getUser().hasRole(role2) || params.getUser().hasRole(role3) || params.getUser().hasRole("Site Administrator", params.userName); if (!isAdmin && (params.userName == null || params.userName.length() < 1)) { params.addError(-6, "Must be a VMR Administrator or Transcription Manager to publish global transcriptions."); } else if (!isAdmin && !params.getUser().getUserName().equals(params.userName)) { params.addError(-7, "Must be a VMR Administrator to edit another user's transcription."); } else { Document doc = Document.getDocument(params.docID); if (doc == null) { params.addError(-8, "Not found docID: " + params.docID + "."); } else { params.getLogger().info("setting transcription (docID: " + doc.getDocumentID() + "; pageID: " + params.pageID + "; params.userName: " + params.userName + "; true; updateIndexing: " + params.updateIndexing + "; false)"); doc.setTranscriptionPage(params.pageID, params.transcript, params.userName, true, params.updateIndexing, false, params.userName == null || params.userName.length() < 1 ? params.getUser().getUserName() : params.userName); params.getLogger().info("finished setting transcription (docID: " + doc.getDocumentID() + "; pageID: " + params.pageID + "; params.userName: " + params.userName + "; true; updateIndexing: " + params.updateIndexing + "; false)"); if (params.push) { if (pushOnCommit) { params.getLogger().info("pushing transcription repo "); VersionedRepo.push(); } } params.getLogger().info("returning from transcript/put"); Serializer.output(response, out, params, XMLBlock.createXMLBlock("")); return; } } } else params.format = "html"; Serializer.reportErrors(request, response, out, params, true); %>