<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Apparatus" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Apparatus.Segment" %> <%@ page import="org.crosswire.community.projects.ntmss.data.ProjectManagement" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription" %> <%@ page import="org.crosswire.webtools.RightsAndRoles" %> <%@ 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 = "Duplicate an existing witness across a verse range.", name = "variant/duplicate") public static class MyParameters extends Parameters { protected ProjectManagement.Project project = null; protected ProjectManagement.Project projectDest = null; @NotNull @Description(value = "manuscript id to copy", example = "20001") public Integer docIDSource = null; @NotNull @Description(value = "manuscript id for new variants", example = "31136") public Integer docIDDest = null; @NotNull @Description(value = "Index content over which to duplicate", example = "Matt") public String indexContent; @Description(value = "copy only variants in this projectID", example = "1") public Integer projectID; @Description(value = "specify {projectID} by supplying a project name", example = "ECM Matthew") public String projectName; @Description(value = "if new variants should be added to a different project, supply that destination projectID here; if not supplied, the new variants will have the same projectID as their source", example = "2") public Integer projectIDDest; @Description(value = "specify {projectIDDest} by supplying a project name", example = "My ECM Matthew") public String projectNameDest; @Override protected void afterLoad() { } @Override protected void customValidation() { projectName = Transcription.assureUnicode(projectName); projectNameDest = Transcription.assureUnicode(projectNameDest); project = projectID != null ? ProjectManagement.getProject(projectID) : projectName != null ? ProjectManagement.getProject(projectName) : null; if (projectID == null && project != null) projectID = project.getProjectID(); projectDest = projectIDDest != null ? ProjectManagement.getProject(projectIDDest) : projectNameDest != null ? ProjectManagement.getProject(projectNameDest) : projectID != null ? ProjectManagement.getProject(projectID) : null; if (projectIDDest == null && projectDest != null) projectIDDest = projectDest.getProjectID(); if (projectIDDest == null && projectID != null) projectIDDest = projectID; if (projectID == null || projectIDDest == null) { format = "html"; } } } %> <% MyParameters params = new MyParameters().loadFromRequest(request, response, false); if (params.getErrors().size() == 0) { StringBuffer retVal = new StringBuffer(); // let's check to see if we're a privileged user boolean permission = RightsAndRoles.hasRole(request, response, "VMR Administrator"); if (!permission && params.projectIDDest != null) { ProjectManagement.Project pr = ProjectManagement.getProject(params.projectIDDest); if (pr != null) permission = RightsAndRoles.hasRole(request, response, "Project Editor", pr.getProjectName()) || RightsAndRoles.hasRole(request, response, "Project Managing Editor", pr.getProjectName()); } if (permission) { int count = Apparatus.copySegmentReadingWitness(params.docIDSource, params.docIDDest, params.indexContent, params.projectID, params.projectIDDest, params.getUser().getUserName()); if (count > -1) { retVal.append(""); } else { retVal.append(""); } } else { retVal.append(""); } Serializer.output(response, out, params, XMLBlock.createXMLBlock(retVal.toString())); return; } Serializer.reportErrors(request, response, out, params, true); %>