Mercurial > hg > mpdl-group
diff software/eXist/mpdl-modules/src/de/mpg/mpiwg/berlin/mpdl/client/DocumentHandler.java @ 10:59ff47d1e237
TEI Unterst?tzung, Fehlerbehebungen, externe Objekte
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 11 Mar 2011 13:33:26 +0100 |
parents | 2396a569e446 |
children | 257f67be5c00 |
line wrap: on
line diff
--- a/software/eXist/mpdl-modules/src/de/mpg/mpiwg/berlin/mpdl/client/DocumentHandler.java Tue Feb 22 16:03:45 2011 +0100 +++ b/software/eXist/mpdl-modules/src/de/mpg/mpiwg/berlin/mpdl/client/DocumentHandler.java Fri Mar 11 13:33:26 2011 +0100 @@ -44,7 +44,7 @@ private MpdlXmlRpcDocHandler mpdlXmlRpcDocHandler; private ESciDocIngestor eSciDocIngestor; - private String[] docBases = {"archimedes", "echo"}; + private String[] docBases = {"archimedes", "echo", "tei"}; private String[] languages = {"ar", "de", "el", "en", "fr", "it", "la", "nl", "zh"}; private String documentRootCollectionMorph = "/db/mpdl/documents/morph"; private String documentRootCollectionStandard = "/db/mpdl/documents/standard"; @@ -282,17 +282,19 @@ FilenameFilter filter = new FilenameFilterExtension("xml"); File[] files = localFileDir.listFiles(filter); System.out.println("Adding all documents in path: \"" + localFileDirStr + "\" to eXist collection: \"" + documentCollection + "\" ..."); - for (int k=0; k < files.length; k++) { - File f = files[k]; - String localFileNameWithoutPath = f.getName(); - String fullLocalFileName = f.getPath(); - String srcUrl = "file://" + fullLocalFileName; - MpdlDocOperation docOperation = new MpdlDocOperation("updateExist", srcUrl, null, docBase, language, localFileNameWithoutPath); - long begin = new Date().getTime(); - doOperation(docOperation); - long end = new Date().getTime(); - System.out.println("Added document \"" + fullLocalFileName + "\" to eXist collection: \"" + documentCollection + "\" (" + (end - begin) + " ms)" ); - counter++; + if (files != null) { + for (int k=0; k < files.length; k++) { + File f = files[k]; + String localFileNameWithoutPath = f.getName(); + String fullLocalFileName = f.getPath(); + String srcUrl = "file://" + fullLocalFileName; + MpdlDocOperation docOperation = new MpdlDocOperation("updateExist", srcUrl, null, docBase, language, localFileNameWithoutPath); + long begin = new Date().getTime(); + doOperation(docOperation); + long end = new Date().getTime(); + System.out.println("Added document \"" + fullLocalFileName + "\" to eXist collection: \"" + documentCollection + "\" (" + (end - begin) + " ms)" ); + counter++; + } } } } @@ -311,30 +313,32 @@ FilenameFilter filter = new FilenameFilterExtension("xml"); File[] files = localFileDir.listFiles(filter); System.out.println("Generating Pdf/Html documents in path: \"" + localFileDirStr + "\" ..."); - for (int k=0; k < files.length; k++) { - File f = files[k]; - String localFileName = f.getName(); - String fullLocalFileName = f.getPath(); - String srcUrl = "file://" + fullLocalFileName; - String localFileNameWithoutExtension = localFileName.substring(0, localFileName.length() - 4); // without ".xml" - String fullLocalPdfFileName = MpdlConstants.MPDL_EXIST_DATA_DIR + "/documents/" + docBase + "/" + language + "/" + localFileNameWithoutExtension + ".pdf"; - File localPdfFile = new File(fullLocalPdfFileName); - boolean pdfFileAlreadyExists = localPdfFile.exists(); - // generate Pdf/Html file only if pdf file does not already exist - if (! pdfFileAlreadyExists) { - MpdlDocOperation docOperation = new MpdlDocOperation("generatePdf", srcUrl, null, docBase, language, localFileName); - SchemaHandler schemaHandler = new SchemaHandler(); - schemaHandler.validate(fullLocalFileName, docOperation); - long begin = new Date().getTime(); - MetadataRecord mdRecord = docOperation.getMdRecord(); // after validation, docOperation has a mdRecord - mpdlRenderer.createFile(true, true, "text", mdRecord); // generate Pdf/Html document - long end = new Date().getTime(); - System.out.println("Generate Pdf/Html document for: \"" + fullLocalFileName + "\" (" + (end - begin) + " ms)" ); - counter++; - try { - Thread.sleep(60000); // delay so that called servers (digilib, eXist) are not stressed too much - } catch (InterruptedException e) { - throw new ApplicationException(e); + if (files != null) { + for (int k=0; k < files.length; k++) { + File f = files[k]; + String localFileName = f.getName(); + String fullLocalFileName = f.getPath(); + String srcUrl = "file://" + fullLocalFileName; + String localFileNameWithoutExtension = localFileName.substring(0, localFileName.length() - 4); // without ".xml" + String fullLocalPdfFileName = MpdlConstants.MPDL_EXIST_DATA_DIR + "/documents/" + docBase + "/" + language + "/" + localFileNameWithoutExtension + ".pdf"; + File localPdfFile = new File(fullLocalPdfFileName); + boolean pdfFileAlreadyExists = localPdfFile.exists(); + // generate Pdf/Html file only if pdf file does not already exist + if (! pdfFileAlreadyExists) { + MpdlDocOperation docOperation = new MpdlDocOperation("generatePdf", srcUrl, null, docBase, language, localFileName); + SchemaHandler schemaHandler = new SchemaHandler(); + schemaHandler.validate(fullLocalFileName, docOperation); + long begin = new Date().getTime(); + MetadataRecord mdRecord = docOperation.getMdRecord(); // after validation, docOperation has a mdRecord + mpdlRenderer.createFile(true, true, "text", mdRecord); // generate Pdf/Html document + long end = new Date().getTime(); + System.out.println("Generate Pdf/Html document for: \"" + fullLocalFileName + "\" (" + (end - begin) + " ms)" ); + counter++; + try { + Thread.sleep(60000); // delay so that called servers (digilib, eXist) are not stressed too much + } catch (InterruptedException e) { + throw new ApplicationException(e); + } } } }