<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.utils.Sessions" %> <%@ page import="java.util.HashMap" %> <%@ page import="java.io.File" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription.Convert" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Document" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription.Convert.ImportSession" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription.Convert.BadTranscription" %> <% String userName = Sessions.getSessionStringValue(request, "userName"); ImportSession is = importSessions.get(userName); if (is == null) { is = new Convert.ImportSession(); importSessions.put(userName, is); } String action = request.getParameter("action"); if ("listbad".equals(action)) { response.setContentType("text/html"); String loadURL = "http://ntmss.info/BSCW/"; String strip = "/data/BSCWS/"; %> <% for (BadTranscription i : is.bad) { String f = i.fileName; if (f.startsWith(strip)) f = f.substring(strip.length()); %> <% } %>
FileNameLast PageIDError
<%= f %><%= i.lastPageID %><%= i.errorText %>
<% return; } response.setContentType("text/xml"); if ("status".equals(action)) { out.print(is.toFormattedXML()); return; } else if ("errlist".equals(action)) { out.print(is.toFormattedXML(true)); return; } else if ("start".equals(action)) { String baseFolder = request.getParameter("tfolder"); int docID = -1; try { docID = Integer.parseInt(request.getParameter("tdoc")); } catch (Exception e) {} boolean clean = "true".equals(request.getParameter("tclean")); boolean indexOnly = "true".equals(request.getParameter("indexonly")); boolean xml = "xml".equals(request.getParameter("filetype")); if (baseFolder != null) { if (!is.running) { is.startImport(baseFolder.trim(), docID, clean, indexOnly, xml); out.print("started"); } out.print("already running"); } else { out.print("missing parameter"); } return; } else if ("stop".equals(action)) { is.stopImport(); out.print("stopped"); return; } else if ("checktfolder".equals(action)) { int count = 0; String baseFolder = request.getParameter("tfolder"); int docID = -1; try { docID = Integer.parseInt(request.getParameter("tdoc")); } catch (Exception e) {} Document d = (docID > -1) ? Document.getDocument(docID) : null; if (baseFolder != null) { File [] files = Convert.getTranscriptionFiles(new File(baseFolder.trim())); for (File f : files) { try { int offset = f.getName().indexOf('_'); String docIDString = f.getName().substring(offset+1, f.getName().length()-1); offset = docIDString.indexOf('.'); if (offset > -1) docIDString = docIDString.substring(0, offset); else { offset = docIDString.indexOf('_'); if (offset > -1) docIDString = docIDString.substring(0, offset); } if (docIDString.endsWith("S")) docIDString.substring(0, docIDString.length()-1); System.out.println("checking... " + docIDString); if (d != null && d.getGANumber().equals(docIDString)) ++count; else { try { if (docID == -1 || Integer.parseInt(docIDString) == docID) { ++count; } } catch (Exception e) {} } } catch (Exception e) {} } out.print(count + " file"+(count!=1?"s":"")+" found"); return; } } %> no action taken <%! static HashMap importSessions = new HashMap(); %>