src/de/uka/ipd/idaho/goldenGateServer/imi/importers/PdfImporterTest.java
//	having this extra method is basically to enable testing the import independent of having a host IMI around
having this extra method is basically to enable testing the import independent of having a host IMI around
having this extra method is basically to enable testing the import independent of having a host IMI around
private static void doHandleImport(File docInFile, File docCacheFolder, File docOutFolder, boolean useMultipleCores) throws IOException {
		Vector command = new Vector();
		command.addElement("java");
		command.addElement("-jar");
		command.addElement("-Xmx1024m");
		command.addElement("ImageMarkupPDF.jar");
		command.addElement("-s"); 
		command.addElement(docInFile.getAbsolutePath());
		command.addElement("-c"); 
		command.addElement(docCacheFolder.getAbsolutePath());
		command.addElement("-p"); 
		command.addElement(useMultipleCores ? "M" : "S");
		command.addElement("-t"); 
		command.addElement("G");
		command.addElement("-l"); 
		command.addElement("M");
		command.addElement("-m"); 
		command.addElement("D");
		command.addElement("-o"); 
		command.addElement(docOutFolder.getAbsolutePath());
		Process importer = Runtime.getRuntime().exec(((String[]) command.toArray(new String[command.size()])), new String[0], workingFolder);
		final BufferedReader importerError = new BufferedReader(new InputStreamReader(importer.getErrorStream()));
		new Thread() {
			public void run() {
				try {
					for (String errorLine; (errorLine = importerError.readLine()) != null;)
						System.out.println(errorLine);
				}
				catch (Exception e) {
					e.printStackTrace(System.out);
				}
			}
		}.start();
		BufferedReader importerIn = new BufferedReader(new InputStreamReader(importer.getInputStream()));
		for (String inLine; (inLine = importerIn.readLine()) != null;) {
			if (inLine.startsWith("S:"))
				System.out.println(inLine.substring("S:".length()));
			else if (inLine.startsWith("I:")) {}
			else if (inLine.startsWith("P:")) {}
			else if (inLine.startsWith("BP:")) {}
			else if (inLine.startsWith("MP:")) {}
			else break;
		}
		while (true) try {
			importer.waitFor();
			break;
		} catch (InterruptedException ie) {}
	}
private static void doHandleImport ( File docInFile , File docCacheFolder , File docOutFolder , boolean useMultipleCores ) throws IOException { Vector command = new Vector ( ) ; command . addElement ( "java" ) ; command . addElement ( "-jar" ) ; command . addElement ( "-Xmx1024m" ) ; command . addElement ( "ImageMarkupPDF.jar" ) ; command . addElement ( "-s" ) ; command . addElement ( docInFile . getAbsolutePath ( ) ) ; command . addElement ( "-c" ) ; command . addElement ( docCacheFolder . getAbsolutePath ( ) ) ; command . addElement ( "-p" ) ; command . addElement ( useMultipleCores ? "M" : "S" ) ; command . addElement ( "-t" ) ; command . addElement ( "G" ) ; command . addElement ( "-l" ) ; command . addElement ( "M" ) ; command . addElement ( "-m" ) ; command . addElement ( "D" ) ; command . addElement ( "-o" ) ; command . addElement ( docOutFolder . getAbsolutePath ( ) ) ; Process importer = Runtime . getRuntime ( ) . exec ( ( ( String [ ] ) command . toArray ( new String [ command . size ( ) ] ) ) , new String [ 0 ] , workingFolder ) ; final BufferedReader importerError = new BufferedReader ( new InputStreamReader ( importer . getErrorStream ( ) ) ) ; new Thread ( ) { public void run ( ) { try { for ( String errorLine ; ( errorLine = importerError . readLine ( ) ) != null ; ) System . out . println ( errorLine ) ; } catch ( Exception e ) { e . printStackTrace ( System . out ) ; } } } . start ( ) ; BufferedReader importerIn = new BufferedReader ( new InputStreamReader ( importer . getInputStream ( ) ) ) ; for ( String inLine ; ( inLine = importerIn . readLine ( ) ) != null ; ) { if ( inLine . startsWith ( "S:" ) ) System . out . println ( inLine . substring ( "S:" . length ( ) ) ) ; else if ( inLine . startsWith ( "I:" ) ) { } else if ( inLine . startsWith ( "P:" ) ) { } else if ( inLine . startsWith ( "BP:" ) ) { } else if ( inLine . startsWith ( "MP:" ) ) { } else break ; } while ( true ) try { importer . waitFor ( ) ; break ; } catch ( InterruptedException ie ) { } }
having this extra method is basically to enable testing the import independent of having a host IMI around
having this extra method is basically to enable testing the import independent of having a host IMI around
//	assemble command //	add parameters // source: file from importer job // cache: cache folder // CPU usage: single (slower, but we don't want to knock out the whole server) // PDF type: generic // log mode: remote progress monitor over streams // output mode: Image Markup directory (saves all the zipping and un-zipping effort) // output destination: document output folder //	start document decoder slave process //	loop through error messages //	loop through step information only //	wait for decoder to finish