You can subscribe to this list here.
2003 |
Jan
|
Feb
(14) |
Mar
(107) |
Apr
(211) |
May
(93) |
Jun
(158) |
Jul
(159) |
Aug
(368) |
Sep
(188) |
Oct
(151) |
Nov
(115) |
Dec
(98) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(25) |
Feb
|
Mar
(33) |
Apr
(28) |
May
(116) |
Jun
(2) |
Jul
(117) |
Aug
(19) |
Sep
(9) |
Oct
(2) |
Nov
|
Dec
(4) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(9) |
Dec
|
2006 |
Jan
|
Feb
|
Mar
(22) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(267) |
Sep
|
Oct
|
Nov
(6) |
Dec
(512) |
2008 |
Jan
(187) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(6) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: paspes <pa...@us...> - 2007-12-21 12:06:26
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11806/modules/scanner/src/com/babeldoc/scanner/worker Modified Files: VFSScanner.java Log Message: Index: VFSScanner.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/VFSScanner.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** VFSScanner.java 17 Dec 2007 16:00:03 -0000 1.4 --- VFSScanner.java 21 Dec 2007 12:05:33 -0000 1.5 *************** *** 67,70 **** --- 67,71 ---- import java.io.ByteArrayOutputStream; + import java.io.File; import java.io.InputStream; import java.util.ArrayList; *************** *** 72,79 **** import java.util.Date; import org.apache.commons.vfs.FileContent; ! import org.apache.commons.vfs.FileFilterSelector; import org.apache.commons.vfs.FileObject; ! import org.apache.commons.vfs.FileSelectInfo; import org.apache.commons.vfs.FileSystemException; import org.apache.commons.vfs.FileSystemManager; --- 73,81 ---- import java.util.Date; + import org.apache.commons.vfs.FileChangeEvent; import org.apache.commons.vfs.FileContent; ! import org.apache.commons.vfs.FileListener; import org.apache.commons.vfs.FileObject; ! import org.apache.commons.vfs.FileSystem; import org.apache.commons.vfs.FileSystemException; import org.apache.commons.vfs.FileSystemManager; *************** *** 81,88 **** import org.apache.commons.vfs.FileType; import org.apache.commons.vfs.FileTypeSelector; - import org.apache.commons.vfs.CacheStrategy; import org.apache.commons.vfs.VFS; import org.apache.commons.vfs.auth.StaticUserAuthenticator; import org.apache.commons.vfs.impl.DefaultFileSystemConfigBuilder; import com.babeldoc.core.I18n; --- 83,90 ---- import org.apache.commons.vfs.FileType; import org.apache.commons.vfs.FileTypeSelector; import org.apache.commons.vfs.VFS; import org.apache.commons.vfs.auth.StaticUserAuthenticator; import org.apache.commons.vfs.impl.DefaultFileSystemConfigBuilder; + import org.apache.commons.vfs.provider.ftp.FtpFileSystemConfigBuilder; import com.babeldoc.core.I18n; *************** *** 91,95 **** import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; - import com.babeldoc.core.option.ValueListConfigOptionType; import com.babeldoc.core.pipeline.PipelineDocument; import com.babeldoc.scanner.ScannerConfigurationException; --- 93,96 ---- *************** *** 113,120 **** public static final String FILTER_FILENAME = "filter"; public static final String MINIMUM_FILE_AGE = "minimumFileAge"; ! public static final String SCAN_NEW = "scanNew"; ! ! public static final String SCAN_NEW_DELETE = "delete"; ! public static final String SCAN_NEW_FOLDER = "doneFolder"; private LogService log = LogService.getInstance(this.getClass().getName()); --- 114,125 ---- public static final String FILTER_FILENAME = "filter"; public static final String MINIMUM_FILE_AGE = "minimumFileAge"; ! public static final String DELETE = "deleteIn"; ! ! public static final String IN_DOMAIN = "inDomain"; ! public static final String IN_USERNAME = "inUsername"; ! public static final String IN_PASSWORD = "inPassword"; ! public static final String OUT_DOMAIN = "outDomain"; ! public static final String OUT_USERNAME = "outUsername"; ! public static final String OUT_PASSWORD = "outPassword"; private LogService log = LogService.getInstance(this.getClass().getName()); *************** *** 131,135 **** private FileSystemManager fsManager; ! private FileSystemOptions opts; /** URI to scan */ --- 136,144 ---- private FileSystemManager fsManager; ! private FileSystemOptions optsIn; ! private FileSystemOptions optsOut; ! ! private FileSystem fs; ! private TestListener listener; /** URI to scan */ *************** *** 141,144 **** --- 150,156 ---- /** flag to include sub directories */ private boolean includeSubDirs = false; + + /** flag to delete procesed files */ + private boolean delete = true; /** *************** *** 172,182 **** public void initialize() throws ScannerConfigurationException { try { - StaticUserAuthenticator auth = new StaticUserAuthenticator("username", "password", null); - opts = new FileSystemOptions(); - DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); - //FileObject fo = VFS.getManager().resolveFile("smb://host/anyshare/dir", opts); fsManager = VFS.getManager(); ! // new File((String) this.getInfo().getOption(IN_DIR).getValue())); setInDirectory(this.getInfo().getStrValue(IN_DIR)); --- 184,200 ---- public void initialize() throws ScannerConfigurationException { try { fsManager = VFS.getManager(); ! // Create connection options (autentication) ! StaticUserAuthenticator authIn = new StaticUserAuthenticator(this.getInfo().getStrValue(IN_DOMAIN),this.getInfo().getStrValue(IN_USERNAME), this.getInfo().getStrValue(IN_PASSWORD)); ! optsIn = new FileSystemOptions(); ! DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(optsIn, authIn); ! ! StaticUserAuthenticator authOut = new StaticUserAuthenticator(this.getInfo().getStrValue(OUT_DOMAIN),this.getInfo().getStrValue(OUT_USERNAME), this.getInfo().getStrValue(OUT_PASSWORD)); ! optsOut = new FileSystemOptions(); ! DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(optsOut, authOut); ! ! ! //Create in directory setInDirectory(this.getInfo().getStrValue(IN_DIR)); *************** *** 187,200 **** getInDirectory()), null); } setDoneDirectory(this.getInfo().getStrValue(DONE_DIR)); if (getDoneDirectory() != null && !"".equals(getDoneDirectory())) { - /* - * // if the done directory does not end with '/' then add one. - * if (!getDoneDirectory().endsWith(File.pathSeparator)) { - * setDoneDirectory(getDoneDirectory() + File.separator); } - */ - // Check of the donedirectory actually is a directory if (doneDirectory.getType() != FileType.FOLDER) { --- 205,220 ---- getInDirectory()), null); } + + fs= getInDirectory().getParent().getFileSystem(); + listener = new TestListener(getInDirectory()); + fs.addListener(getInDirectory(), listener); + listener.addCreateEvent(); + listener.addChangeEvent(); + + //Create out directory setDoneDirectory(this.getInfo().getStrValue(DONE_DIR)); if (getDoneDirectory() != null && !"".equals(getDoneDirectory())) { // Check of the donedirectory actually is a directory if (doneDirectory.getType() != FileType.FOLDER) { *************** *** 204,222 **** } } else { ! getLog() ! .logInfo( ! "Done directory not specified. All processed file will be deleted!!!"); setDoneDirectory(null); } ! setIncludeSubDirs("true".equals(this.getInfo().getStrValue( ! INCLUDE_SUB_DIRS))); ! ! setMinimumFileAge(this.getInfo().getIntValue(MINIMUM_FILE_AGE)); if (getMinimumFileAge() > 0) { ! LogService.getInstance().logInfo( ! "Minimum file age: " + getMinimumFileAge() + " ms"); } --- 224,240 ---- } } else { ! getLog().logInfo("Done directory not specified. All processed file will be deleted!!!"); setDoneDirectory(null); } ! //Other configuration options ! setIncludeSubDirs("true".equals(this.getInfo().getStrValue(INCLUDE_SUB_DIRS))); ! setDeleteProcesedFiles("true".equals(this.getInfo().getStrValue(DELETE))); ! ! setMinimumFileAge(this.getInfo().getIntValue(MINIMUM_FILE_AGE)); if (getMinimumFileAge() > 0) { ! LogService.getInstance().logInfo("Minimum file age: " + getMinimumFileAge() + " ms"); } *************** *** 254,260 **** if (getDoneDirectory() != null) { ! ! String path = file.getName().getPath(); ! FileObject outDir = fsManager.resolveFile(getDoneDirectory()); // create out dir if not exist --- 272,282 ---- if (getDoneDirectory() != null) { ! ! String path = file.getParent().getURL().toString(); ! int index = path.length() + 1; ! //String name = path.substring(index);// ! ! FileObject outDir = fsManager.resolveFile(getDoneDirectory()+ ! path.substring(getInDirectory().getURL().toString().length(),index - 1)); // create out dir if not exist *************** *** 264,270 **** // create file with the same name (path) in out dir ! FileObject outfile = fsManager.resolveFile(outDir.getName() ! .getURI() ! + "/" + file.getName().getBaseName()); // delete file it is already exists --- 286,291 ---- // create file with the same name (path) in out dir ! FileObject outfile = fsManager.resolveFile(outDir.getName().getURI() ! + File.separatorChar + file.getName().getBaseName()); // delete file it is already exists *************** *** 289,311 **** .get("scanner.VFSScanner.error.finishing"), e); } ! ! if (this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_DELETE) { if (!file.delete()) { ! throw new ScannerException(I18n ! .get("scanner.VFSScanner.error.finishing"), null); ! // Exceptio no es podra saber si es nou pq no ha borrat!!! } return; } - if (this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_FOLDER) { - if (getDoneDirectory() == null) - throw new ScannerException(I18n - .get("scanner.VFSScanner.error.finishing"), null); - // Exceptio no es podra saber si es nou pq no a mogut!!! - return; - - } - } --- 310,321 ---- .get("scanner.VFSScanner.error.finishing"), e); } ! ! if(getDeleteProcesedFiles()){ if (!file.delete()) { ! throw new ScannerException(I18n.get("scanner.VFSScanner.error.finishing")+" can't delete procesed file " + file.getName().getBaseName(), null); } return; } } *************** *** 345,352 **** for (int i = 0; i < files.length; i++) { if (files[i].getType() == FileType.FOLDER) { ! // add files from this folder ! processVFS(files[i]); } else { ! if(acceptFile(files[i])){ // create scan document and queue it! try { --- 355,364 ---- for (int i = 0; i < files.length; i++) { if (files[i].getType() == FileType.FOLDER) { ! if(isIncludeSubDirs()){ //Directory filter ! // add files from this folder ! processVFS(files[i]); ! } } else { ! if(acceptFile(files[i])){ //File filter // create scan document and queue it! try { *************** *** 416,421 **** */ private boolean acceptFile(FileObject file) throws FileSystemException { - // Afegir if ( this.getInfo().getStrValue(SCAN_NEW) == - // VFSScanner.SCAN_NEW_DELETE ){ i FOLDER // Check name filter first, and then age. --- 428,431 ---- *************** *** 433,436 **** --- 443,447 ---- return false; } + /** *************** *** 452,457 **** public void setInDirectory(String inDirectory) throws FileSystemException { ! this.inDirectory = fsManager.resolveFile(this.getInfo().getStrValue( ! IN_DIR),opts); } --- 463,468 ---- public void setInDirectory(String inDirectory) throws FileSystemException { ! //FtpFileSystemConfigBuilder.getInstance().setPassiveMode(optsIn, true); ! this.inDirectory = fsManager.resolveFile(inDirectory,optsIn); } *************** *** 462,467 **** public void setDoneDirectory(String doneDirectory) throws FileSystemException { ! this.doneDirectory = fsManager.resolveFile(this.getInfo().getStrValue( ! DONE_DIR)); } --- 473,477 ---- public void setDoneDirectory(String doneDirectory) throws FileSystemException { ! this.doneDirectory = fsManager.resolveFile(doneDirectory,optsOut); } *************** *** 473,476 **** --- 483,496 ---- this.includeSubDirs = includeSubDirs; } + + public boolean getDeleteProcesedFiles() { + return delete; + } + + public void setDeleteProcesedFiles(boolean delete) { + this.delete = delete; + } + + public long getMinimumFileAge() { *************** *** 534,545 **** .get("scanner.VFSScannerInfo.option.minimumFileAge"))); ! String[] scanNewTypes = { VFSScanner.SCAN_NEW_DELETE, ! VFSScanner.SCAN_NEW_FOLDER }; ! options.add(new ConfigOption(VFSScanner.SCAN_NEW, ! new ValueListConfigOptionType(scanNewTypes), ! VFSScanner.SCAN_NEW_DELETE, false, I18n ! .get("scanner.VfsScannerInfo.option.scanNew"))); ! return options; } } --- 554,676 ---- .get("scanner.VFSScannerInfo.option.minimumFileAge"))); ! options.add(new ConfigOption(VFSScanner.DELETE, ! IConfigOptionType.BOOLEAN, "true", false, I18n ! .get("scanner.VFSScannerInfo.option.delete"))); ! ! options.add(new ConfigOption(VFSScanner.IN_DOMAIN, ! IConfigOptionType.STRING, null, false, I18n ! .get("scanner.VFSScannerInfo.option.domain",VFSScanner.IN_DIR))); ! ! options.add(new ConfigOption(VFSScanner.IN_USERNAME, ! IConfigOptionType.STRING, null, false, I18n ! .get("scanner.VFSScannerInfo.option.username",VFSScanner.IN_DIR))); ! ! options.add(new ConfigOption(VFSScanner.IN_PASSWORD, ! IConfigOptionType.STRING, null, false, I18n ! .get("scanner.VFSScannerInfo.option.password",VFSScanner.IN_DIR))); ! ! options.add(new ConfigOption(VFSScanner.OUT_DOMAIN, ! IConfigOptionType.STRING, null, false, I18n ! .get("scanner.VFSScannerInfo.option.domain",VFSScanner.DONE_DIR))); ! ! options.add(new ConfigOption(VFSScanner.OUT_USERNAME, ! IConfigOptionType.STRING, null, false, I18n ! .get("scanner.VFSScannerInfo.option.username",VFSScanner.DONE_DIR))); ! ! options.add(new ConfigOption(VFSScanner.OUT_PASSWORD, ! IConfigOptionType.STRING, null, false, I18n ! .get("scanner.VFSScannerInfo.option.password",VFSScanner.DONE_DIR))); ! ! return options; } } + + /*** + * A test listener. + */ + class TestListener implements FileListener + { + private final FileObject file; + private final ArrayList events = new ArrayList(); + private static final Object CREATE = "create"; + private static final Object DELETE = "delete"; + private static final Object CHANGED = "changed"; + + public TestListener(final FileObject file) + { + this.file = file; + } + + /*** + * Called when a file is created. + */ + public void fileCreated(final FileChangeEvent event) + { + System.out.println("fileCreated"); + /* assertTrue("Unexpected create event", events.size() > 0); + assertSame("Expecting a create event", CREATE, events.remove(0)); + assertSame(file, event.getFile()); + try + { + assertTrue(file.exists()); + } + catch (FileSystemException e) + { + fail(); + } + */ + } + + /*** + * Called when a file is deleted. + */ + public void fileDeleted(final FileChangeEvent event) + { + System.out.println("fileDeleted"); + /* assertTrue("Unexpected delete event", events.size() > 0); + assertSame("Expecting a delete event", DELETE, events.remove(0)); + assertSame(file, event.getFile()); + try + { + assertTrue(!file.exists()); + } + catch (FileSystemException e) + { + fail(); + } + */ + } + + public void fileChanged(FileChangeEvent event) throws Exception + { + System.out.println("fileChanged"); + /*assertTrue("Unexpected changed event", events.size() > 0); + assertSame("Expecting a changed event", CHANGED, events.remove(0)); + assertSame(file, event.getFile()); + try + { + assertTrue(!file.exists()); + } + catch (FileSystemException e) + { + fail(); + } + */ + } + + public void addCreateEvent() + { + events.add(CREATE); + } + + public void addChangeEvent() + { + events.add(CHANGED); + } + + public void assertFinished() + { + //assertEquals("Missing event", 0, events.size()); + } + } \ No newline at end of file |
From: JM E. <jos...@us...> - 2007-12-18 10:36:59
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29002/modules/sql/src/com/babeldoc/sql/pipeline/stage Modified Files: SqlWriterPipelineStage.java Log Message: news pipeline stages Index: SqlWriterPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage/SqlWriterPipelineStage.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** SqlWriterPipelineStage.java 18 Dec 2007 10:02:55 -0000 1.17 --- SqlWriterPipelineStage.java 18 Dec 2007 10:37:02 -0000 1.18 *************** *** 101,105 **** public static final String SQL = "sql"; ! // 20071217 jmenriquez public static final String ISO_FORMAT = "isoFormat"; --- 101,105 ---- public static final String SQL = "sql"; ! // 20071217 josem_dev public static final String ISO_FORMAT = "isoFormat"; *************** *** 145,149 **** null, true, I18n.get("sql.195"))); ! // 20071217 jmenriquez options.add(new ConfigOption(ISO_FORMAT, IConfigOptionType.BOOLEAN, "false", false, I18n.get("sql.300"))); --- 145,149 ---- null, true, I18n.get("sql.195"))); ! // 20071217 josem_dev options.add(new ConfigOption(ISO_FORMAT, IConfigOptionType.BOOLEAN, "false", false, I18n.get("sql.300"))); *************** *** 216,225 **** } ! // 20071217 jmenriquez private boolean isOracle(String productName) { return productName.toUpperCase().indexOf("ORACLE") > -1; } ! // 20071217 jmenriquez private boolean isSqlServer(String productName) { return productName.toUpperCase().indexOf("MICROSOFT") > -1 --- 216,225 ---- } ! // 20071217 josem_dev private boolean isOracle(String productName) { return productName.toUpperCase().indexOf("ORACLE") > -1; } ! // 20071217 josem_dev private boolean isSqlServer(String productName) { return productName.toUpperCase().indexOf("MICROSOFT") > -1 *************** *** 261,265 **** int commandCount = 0; ! // 20071217 jmenriquez if (hasOption(ISO_FORMAT) && "true".equalsIgnoreCase(getOptions(ISO_FORMAT))) { // configure connection --- 261,265 ---- int commandCount = 0; ! // 20071217 josem_dev if (hasOption(ISO_FORMAT) && "true".equalsIgnoreCase(getOptions(ISO_FORMAT))) { // configure connection |
From: JM E. <jos...@us...> - 2007-12-18 10:36:12
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28971/modules/core/src/com/babeldoc/core/pipeline Modified Files: PipelineDocument.java Log Message: news pipeline stages Index: PipelineDocument.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/PipelineDocument.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PipelineDocument.java 4 Aug 2007 11:37:26 -0000 1.24 --- PipelineDocument.java 18 Dec 2007 10:36:16 -0000 1.25 *************** *** 464,472 **** public String getContents() { try { ! System.out.println("Using encoding " + this.getEncoding()); return new String(buffer, this.getEncoding()); } catch (UnsupportedEncodingException e) { //TODO: Handle this error better if it is possible... ! e.printStackTrace(); return new String(buffer); } --- 464,480 ---- public String getContents() { try { ! // 20071114 jmenriquez ! //System.out.println("Using encoding " + this.getEncoding()); ! if (LogService.getInstance().isDebugEnabled()) { ! LogService.getInstance().logDebug("Using encoding " + this.getEncoding()); ! } return new String(buffer, this.getEncoding()); } catch (UnsupportedEncodingException e) { + // 20071114 jmenriquez //TODO: Handle this error better if it is possible... ! //e.printStackTrace(); ! if (LogService.getInstance().isWarnEnabled()) { ! LogService.getInstance().logWarn("PipelineDocument.getContents() UnsupportedEncodingException, encoding: " + this.getEncoding()); ! } return new String(buffer); } |
From: JM E. <jos...@us...> - 2007-12-18 10:35:58
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28600/modules/core/src/com/babeldoc/core/pipeline/stage Modified Files: GenericWriterPipelineStage.java FileWriterPipelineStage.java Log Message: news pipeline stages Index: FileWriterPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/FileWriterPipelineStage.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** FileWriterPipelineStage.java 18 Dec 2007 10:02:55 -0000 1.10 --- FileWriterPipelineStage.java 18 Dec 2007 10:35:54 -0000 1.11 *************** *** 119,123 **** options.add(new ConfigOption(DONE_FILE, IConfigOptionType.FILENAME, null, false, I18n.get("100021"))); ! // 20071114 jmenriquez // ENCODING it's a general Option and NEW_LINE it's undefined //options.add(new ConfigOption(ENCODING, IConfigOptionType.STRING, --- 119,123 ---- options.add(new ConfigOption(DONE_FILE, IConfigOptionType.FILENAME, null, false, I18n.get("100021"))); ! // 20071114 josem_dev // ENCODING it's a general Option and NEW_LINE it's undefined //options.add(new ConfigOption(ENCODING, IConfigOptionType.STRING, *************** *** 185,189 **** BufferedWriter writer = new BufferedWriter(new FileWriter(outfile, append)); ! // 20071114 jmenriquez //writer.write(new String(document.getBytes())); writer.write(document.getContents()); --- 185,189 ---- BufferedWriter writer = new BufferedWriter(new FileWriter(outfile, append)); ! // 20071114 josem_dev //writer.write(new String(document.getBytes())); writer.write(document.getContents()); Index: GenericWriterPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/GenericWriterPipelineStage.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GenericWriterPipelineStage.java 18 Dec 2007 10:02:55 -0000 1.7 --- GenericWriterPipelineStage.java 18 Dec 2007 10:35:54 -0000 1.8 *************** *** 124,128 **** newDocument.setMimeType(this.getDocument().getMimeType()); newDocument.setBinary(this.getDocument().isBinary()); ! // 20071114 jmenriquez // why not setEncoding and setName? newDocument.setEncoding(this.getDocument().getEncoding()); --- 124,128 ---- newDocument.setMimeType(this.getDocument().getMimeType()); newDocument.setBinary(this.getDocument().isBinary()); ! // 20071114 josem_dev // why not setEncoding and setName? newDocument.setEncoding(this.getDocument().getEncoding()); |
From: JM E. <jos...@us...> - 2007-12-18 10:04:43
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/config/service In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16556/modules/core/config/service Modified Files: query.properties Log Message: news pipeline stages Index: query.properties =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/config/service/query.properties,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** query.properties 4 Sep 2003 00:25:39 -0000 1.13 --- query.properties 18 Dec 2007 10:04:42 -0000 1.14 *************** *** 22,25 **** --- 22,27 ---- PipelineStage.JournalUpdate=com.babeldoc.core.pipeline.stage.JournalUpdatePipelineStage PipelineStage.Reader=com.babeldoc.core.pipeline.stage.ReaderPipelineStage + PipelineStage.EncodingConversion=com.babeldoc.core.pipeline.stage.EncodingConversionPipelineStage + PipelineStage.XmlToSql=com.babeldoc.core.pipeline.stage.XmlToSqlPipelineStage Journal.simple=com.babeldoc.core.journal.simple.SimpleJournal |
From: JM E. <jos...@us...> - 2007-12-18 10:04:43
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/config/i18n In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16556/modules/sql/config/i18n Modified Files: messages.properties Log Message: news pipeline stages Index: messages.properties =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/config/i18n/messages.properties,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** messages.properties 30 Mar 2004 19:15:41 -0000 1.9 --- messages.properties 18 Dec 2007 10:04:42 -0000 1.10 *************** *** 38,39 **** --- 38,41 ---- sql.900=Creates an XML file from a SQL query sql.901=Name of the resource that contains Database Connection + + sql.300=Use ISO format (dates) |
From: JM E. <jos...@us...> - 2007-12-18 10:04:43
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/config/i18n In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16556/modules/core/config/i18n Modified Files: messages.properties Log Message: news pipeline stages Index: messages.properties =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/config/i18n/messages.properties,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** messages.properties 4 Aug 2007 11:37:05 -0000 1.31 --- messages.properties 18 Dec 2007 10:04:42 -0000 1.32 *************** *** 221,224 **** --- 221,225 ---- 100020=Output filename 100021=Write the "done" file when the document is written. This can act as a flag for other disk scanning processes + 100022=newline character to use 100024=Write the document to the FTP host core.pipeline.stage.ftpwriter.desc=Write the document using the FTP protocol to an FTP server. This will enable pipelines to distribute documents on the internet using this well supported protocol *************** *** 435,436 **** --- 436,460 ---- core.pipeline.feeder.asyncfeeder.config.poolsize=The number of threads to create in the threadpool - this determines the possible number of concurrent pipeline executing. core.pipeline.feeder.asyncfeeder.config.inactivetime=The length of time to keep idle threads in the threadpool alive + + core.pipeline.stage.EncodingConversion.desc=Encoding conversión of the document with the defined encoding. + core.pipeline.stage.EncodingConversionPipelineStage.charset=Name of charset used to write file + + core.pipeline.stage.XmlToSql.desc=Converts a XML to a SQL script (SQL insert's or/and update's commands) + + sql.101=Name of the resource that contains Database Connection + sql.103=Error getting the resource + sql.104=Error executing sql: + sql.201=Option resourceName is not optional! + sql.1000=Creates an SQL script from a XML file + sql.1001=Empty document, script not made + sql.1002=Could not read file + sql.1003=Could not create XML Document + sql.1004=Empty DOM list of matching Element nodes + sql.1005=Option whereRowsName is not optional! + sql.1008=Option whereRowsName must be defined! + sql.1006=Option tableName is not optional! + sql.1007=Option schemaUrl is not optional! + sql.1009=Name of the table to insert/update data + sql.1010=URL to the db table schema (XSD) + sql.1011=List of row names for the SQL WHERE clause (usually the primary key). + sql.1012=XML node name to convert, else convert all XML level 1 nodes (note: root element it's level 0) |
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15776/modules/core/src/com/babeldoc/core/pipeline/stage Modified Files: GenericWriterPipelineStage.java FileWriterPipelineStage.java Added Files: XmlToSqlPipelineStage.java EncodingConversionPipelineStage.java Log Message: news pipeline stage --- NEW FILE: XmlToSqlPipelineStage.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/XmlToSqlPipelineStage.java,v 1.1 2007/12/18 10:02:55 josem_dev Exp $ * $DateTime$ * $Author: josem_dev $ * */package com.babeldoc.core.pipeline.stage; import java.io.ByteArrayInputStream; import java.io.FileInputStream; import java.io.IOException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.Collection; import com.babeldoc.core.I18n; //import com.babeldoc.core.LogService; import com.babeldoc.core.NameValuePair; import com.babeldoc.core.option.ComplexConfigOptionType; import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; import com.babeldoc.core.option.ServiceTypeConfigOptionType; import com.babeldoc.core.pipeline.PipelineException; import com.babeldoc.core.pipeline.PipelineStage; import com.babeldoc.core.pipeline.PipelineStageInfo; import com.babeldoc.core.pipeline.PipelineStageResult; import com.babeldoc.core.pipeline.PipelineStageType; import com.babeldoc.core.resource.IResource; import com.babeldoc.core.resource.ResourceException; import com.babeldoc.core.resource.ResourceFactory; import org.apache.xerces.parsers.DOMParser; //import org.xml.sax.ErrorHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; //import org.xml.sax.SAXNotRecognizedException; //import org.xml.sax.SAXNotSupportedException; //import org.xml.sax.SAXParseException; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NodeList; /** * Converts a XML to a SQL script (SQL insert's or/and update's commands) * * @author josem_dev * @version 1.0 */ public class XmlToSqlPipelineStage extends PipelineStage { /** * (mandatory) Name of the resource that contains Database Connection. */ protected static final String RESOURCE_NAME = "resourceName"; /** * (mandatory) Schema (usually XSD) DB table. */ protected static final String SCHEMA_URL = "schemaUrl"; /** * (mandatory) List of row names for the SQL WHERE clause, usually the primary key. */ protected static final String WHERE_ROW_NAMES = "whereRowNames"; /** * (optional) XML node name to convert, else convert all XML level 1 nodes (note: root element it's level 0) */ protected static final String TARGET_NODE = "targetNode"; /** * (mandatory) DB table name where insert/update data */ protected static final String TABLE_NAME = "tableName"; // Connection pool private IResource resource = null; // JDBC connectionn private Connection conn = null; // JDBC statement private Statement stmt = null; // DOM Document DB schema private Document schema; ///** // * Class for schema validation. // */ /* private class Validator implements ErrorHandler { public SAXParseException saxParseException = null; public void error(SAXParseException exception) throws SAXException { saxParseException = exception; } public void fatalError(SAXParseException exception) throws SAXException { saxParseException = exception; } public void warning(SAXParseException exception) throws SAXException { saxParseException = exception; } } */ /** * Construct this stage - create the information object */ public XmlToSqlPipelineStage() { super(new PipelineStageInfo() { public String getName() { return "XmlToSql"; } public String getDescription() { return I18n.get("conversion.pipeline.stage.XmlToSql.desc"); } public Collection getTypeSpecificOptions() { Collection options; IConfigOptionType whereRowNamesType; options = new ArrayList(); options.add( new ConfigOption( RESOURCE_NAME, IConfigOptionType.STRING, null, true, I18n.get("sql.101") ) ); options.add( new ConfigOption( TABLE_NAME, IConfigOptionType.STRING, null, true, I18n.get("sql.1009") ) ); options.add( new ConfigOption( SCHEMA_URL, IConfigOptionType.STRING, null, true, I18n.get("sql.1010") ) ); whereRowNamesType = new ComplexConfigOptionType( new ConfigOption[]{ new ConfigOption( "whereRowNamesType", new ServiceTypeConfigOptionType( PipelineStageType.SERVICE_PREFIX ), I18n.get("sql.1011") ) } ); options.add( new ConfigOption( WHERE_ROW_NAMES, whereRowNamesType, I18n.get("sql.1011") ) ); options.add( new ConfigOption( TARGET_NODE, IConfigOptionType.STRING, null, true, I18n.get("sql.1012") ) ); return options; } }); } /** * Process. * * @return array of pipelinestage results * @throws PipelineException */ public PipelineStageResult[] process() throws PipelineException { String script; checkOptions(); LoadOptions(); script = buildScript(); if(script.length() > 0) { this.getDocument().setBytes(script.getBytes()); } else { throw new PipelineException(I18n.get("sql.1001")); } return super.processHelper(); } /** * Check mandatory options. * @throws PipelineException */ private void checkOptions() throws PipelineException { if (!hasOption(RESOURCE_NAME)) { throw new PipelineException(I18n.get("sql.201")); } // !hasOption(WHERE_ROW_NAMES) if(getOptionList(new String[]{WHERE_ROW_NAMES}) == null ) { throw new PipelineException(I18n.get("sql.1005")); } if(!hasOption(TABLE_NAME)) { throw new PipelineException(I18n.get("sql.1006")); } if(!hasOption(SCHEMA_URL)) { throw new PipelineException("sql.1007"); } } private void LoadOptions() throws PipelineException { String schemaUrl; DOMParser parser; schemaUrl = getOptions(SCHEMA_URL); parser = new DOMParser(); try { parser.parse( new InputSource( new FileInputStream(schemaUrl) ) ); } catch (IOException e){ throw new PipelineException(I18n.get("sql.1002")); } catch (SAXException e) { throw new PipelineException(I18n.get("sql.1003")); } schema = parser.getDocument(); } private String buildScript() throws PipelineException { NameValuePair[] whereRows; NodeList nodeList, nodeChildList; Node node; int i; StringBuffer sql, query; String lineSeparator; sql = new StringBuffer(""); lineSeparator = System.getProperty("line.separator", "\n"); whereRows = getWhereRowsList(); nodeList = getDomNodeList(); try { conn = getConnection(); stmt = conn.createStatement(); for (i = 0; i < nodeList.getLength(); i++) { nodeChildList = nodeList.item(i).getChildNodes(); if(existsRow(nodeChildList, whereRows)) { query = sqlUpdate(nodeChildList, whereRows); sql.append(query); } else { query = sqlInsert(nodeChildList, whereRows); sql.append(query); } sql.append(lineSeparator); } } catch(ResourceException e) { throw new PipelineException(I18n.get("sql.103"), e); } catch (SQLException e) { throw new PipelineException(I18n.get("sql.104"), e); } finally { try { if (stmt != null) { stmt.close(); } if (conn != null) { resource.checkIn(conn); } } catch (Exception ignoreThis) {} } return sql.toString(); } private boolean existsRow(NodeList childList, NameValuePair[] whereRows) throws PipelineException { String query, value; ResultSet rs = null; boolean ret = false; query = sqlSelect(childList, whereRows); try { rs = stmt.executeQuery(query); rs.next(); value = rs.getString(1); if ((value != null) && Long.parseLong(value) > 0) { ret = true; } } catch (SQLException e) { throw new PipelineException(I18n.get("sql.104", query), e); } finally { try { if (rs != null) { rs.close(); } } catch (Exception ignoreThis) {} } return ret; } private NodeList getDomNodeList() throws PipelineException { String targetNode;//, schemaUrl; DOMParser parser; Document doc; NodeList nodeList; //Validator validador; //schemaUrl = getOptions(SCHEMA_URL); targetNode = getOptions(TARGET_NODE); parser = new DOMParser(); /* validador = new Validator(); try { parser.setFeature("http://xml.org/sax/features/validation", true); parser.setFeature("http://apache.org/xml/features/validation/schema", true); parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true); parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", schemaUrl ); // "http://apache.org/xml/properties/schema/external-schemaLocation" parser.setErrorHandler(validador); } catch(SAXNotRecognizedException e) { throw new PipelineException(I18n.get("")); // todo } catch(SAXNotSupportedException e) { throw new PipelineException(I18n.get("")); // todo } */ try { parser.parse( new InputSource( new ByteArrayInputStream( this.getDocument().getContents().getBytes() ) ) ); } catch (IOException ie){ throw new PipelineException(I18n.get("sql.1002")); } catch (SAXException e) { throw new PipelineException(I18n.get("sql.1003")); } /* if(validador.saxParseException != null) { throw new PipelineException(I18n.get(""), validador.saxParseException); // todo } */ doc = parser.getDocument(); if (targetNode != null && (!targetNode.equals(""))) { nodeList = doc.getElementsByTagName(targetNode); } else { nodeList = doc.getElementsByTagName("*"); } if (nodeList == null || nodeList.getLength() == 0) { throw new PipelineException(I18n.get("sql.1004")); } return nodeList; } private String getSchemaNodeType(String nodeName) { String out; NodeList nodeList; Node node; int i, j, alt; NamedNodeMap attr; nodeList = schema.getElementsByTagName("xs:element"); if(nodeList != null && nodeList.getLength() > 0) { for(i = 0; i < nodeList.getLength(); i++) { attr = nodeList.item(i).getAttributes(); if(attr != null && attr.getLength() > 1) { alt = -1; for (j = 0; j < attr.getLength(); j++) { if( attr.item(j).getNodeName().equalsIgnoreCase("name") && attr.item(j).getNodeValue().equalsIgnoreCase(nodeName)) { alt = j; break; } } if (alt > -1) { for (j = 0; j < attr.getLength(); j++) { // recycle if(j != alt && attr.item(j).getNodeName().equalsIgnoreCase("type")) { out = attr.item(j).getNodeValue(); alt = out.indexOf(':'); // recycle if (alt > -1) { return out.substring(alt + 1).toLowerCase(); } else { return out.toLowerCase(); } } } } } } } return ""; } private NameValuePair[] getWhereRowsList() throws PipelineException { NameValuePair[] attributes; attributes = this.getOptionList(new String[]{WHERE_ROW_NAMES}); if (attributes == null) { throw new PipelineException(I18n.get("sql.1008")); } return attributes; } /** * * @param nodeName DOM node name * @param whereRows where row names list */ private boolean isWhereRow(String nodeName, NameValuePair[] whereRows) { String val; int i; for (i = 0; i < whereRows.length; i++) { val = whereRows[i].getValue(); if ((val != null) && !val.equals("")) { if (val.equals(nodeName)) { return true; } } } return false; } private String sqlSelect(NodeList childList, NameValuePair[] whereRows) { return "SELECT COUNT(*) FROM " + getOptions(TABLE_NAME) + whereClause(childList, whereRows); } private StringBuffer whereClause(NodeList childList, NameValuePair[] whereRows) { StringBuffer buf; int j; Node node; buf = new StringBuffer(""); for(j = 0; j < childList.getLength(); j++) { if (childList.item(j).getNodeType() == Node.ELEMENT_NODE) { node = childList.item(j); if (isWhereRow(node.getNodeName(), whereRows)) { if (buf.length() > 0) { buf.append(" AND"); } buf.append(" "); buf.append(node.getNodeName()); buf.append(getNodeValue(node, true)); } } } if(buf.length() > 0) { buf.insert(0, " WHERE"); } return buf; } private StringBuffer getNodeValue(Node node, boolean withOperator) { String value; StringBuffer buf; boolean isStr; Node nodeChild; buf = new StringBuffer(""); if(withOperator) { if(isTypeNull(node)) { buf.append(" is "); } else { buf.append(" = "); } } isStr = isTypeString(node); nodeChild = node.getFirstChild(); if(isStr && nodeChild != null) { buf.append("'"); } if (nodeChild == null) { buf.append("null"); } else { value = nodeChild.getNodeValue(); if (isStr) { value = value.replaceAll("[']", "''"); } buf.append(value); } if(isStr && nodeChild != null) { buf.append("'"); } return buf; } private boolean isTypeString(Node node) { String typeName; typeName = getSchemaNodeType(node.getNodeName()); if ((typeName != null) && !typeName.equals("")) { if (typeName.equals("string") || typeName.equals("date")) { return true; } } return false; } private boolean isTypeNull(Node node) { String typeName; typeName = getSchemaNodeType(node.getNodeName()); if ((typeName != null) && !typeName.equals("")) { if (typeName.equals("null")) { return true; } } return false; } private StringBuffer sqlInsert(NodeList childList, NameValuePair[] whereRows) { StringBuffer buf, bufValues; int j, rowCount; Node node; buf = new StringBuffer(""); bufValues = new StringBuffer(""); buf.append("INSERT INTO "); buf.append(getOptions(TABLE_NAME)); buf.append(" ("); rowCount = 0; for(j = 0; j < childList.getLength(); j++) { if (childList.item(j).getNodeType() == Node.ELEMENT_NODE) { node = childList.item(j); if(rowCount > 0){ buf.append(", "); bufValues.append(", "); } buf.append(node.getNodeName()); bufValues.append(getNodeValue(node, false)); rowCount++; } } buf.append(") VALUES ("); buf.append(bufValues); buf.append(")"); return buf; } private StringBuffer sqlUpdate(NodeList childList, NameValuePair[] whereRows) { StringBuffer buf; int j, rowCount; Node node; buf = new StringBuffer(""); buf.append("UPDATE "); buf.append(getOptions(TABLE_NAME)); buf.append(" SET "); rowCount = 0; for(j = 0; j < childList.getLength(); j++) { if (childList.item(j).getNodeType() == Node.ELEMENT_NODE) { node = childList.item(j); if (!isWhereRow(node.getNodeName(), whereRows)) { if(rowCount > 0) { buf.append(", "); } buf.append(node.getNodeName()); buf.append(getNodeValue(node, true)); rowCount++; } } } buf.append(whereClause(childList, whereRows)); return buf; } /** * Get the named resource name from the resource factory * * @return JDBC Connection * * @throws ResourceException */ private Connection getConnection() throws ResourceException { if (resource == null) { resource = ResourceFactory.getResource(this.getOptions(RESOURCE_NAME)); if (resource == null) { throw new ResourceException(I18n.get("sql.103")); } } return ((Connection) resource.checkOut()); } } Index: FileWriterPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/FileWriterPipelineStage.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** FileWriterPipelineStage.java 4 Aug 2007 11:37:14 -0000 1.9 --- FileWriterPipelineStage.java 18 Dec 2007 10:02:55 -0000 1.10 *************** *** 119,124 **** options.add(new ConfigOption(DONE_FILE, IConfigOptionType.FILENAME, null, false, I18n.get("100021"))); ! options.add(new ConfigOption(ENCODING, IConfigOptionType.STRING, ! null, false, I18n.get("core.pipeline.stage.FileWriterPipelineStage.charset"))); return options; --- 119,128 ---- options.add(new ConfigOption(DONE_FILE, IConfigOptionType.FILENAME, null, false, I18n.get("100021"))); ! // 20071114 jmenriquez ! // ENCODING it's a general Option and NEW_LINE it's undefined ! //options.add(new ConfigOption(ENCODING, IConfigOptionType.STRING, ! // null, false, I18n.get("core.pipeline.stage.FileWriterPipelineStage.charset"))); ! options.add(new ConfigOption(NEW_LINE, IConfigOptionType.BOOLEAN, ! "false", false, I18n.get("100022"))); return options; *************** *** 172,175 **** --- 176,180 ---- if (document.isBinary()) { + LogService.getInstance().logDebug("FileWriterPipeline.writeFileMessage Write binary file"); FileOutputStream fos = new FileOutputStream(outfile, append); fos.write(document.getBytes()); *************** *** 177,184 **** } else { if(encoding==null){ ! LogService.getInstance().logDebug("FileWriterPipeline.writeFileMessage Write File with null encoding"); BufferedWriter writer = new BufferedWriter(new FileWriter(outfile, append)); ! writer.write(new String(document.getBytes())); if (newLine) { --- 182,191 ---- } else { if(encoding==null){ ! LogService.getInstance().logDebug("FileWriterPipeline.writeFileMessage Write File with PipelineDocument.encoding"); BufferedWriter writer = new BufferedWriter(new FileWriter(outfile, append)); ! // 20071114 jmenriquez ! //writer.write(new String(document.getBytes())); ! writer.write(document.getContents()); if (newLine) { *************** *** 190,196 **** else{ ! LogService.getInstance().logDebug("FileWriterPipeline.writeFileMessage Write File using encoding:" + encoding); ! BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile, append),encoding)); //BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileWriter(outfile, append),encoding)) ; writer.write(new String(document.getBytes())); --- 197,203 ---- else{ ! LogService.getInstance().logDebug("FileWriterPipeline.writeFileMessage Write File using PipelineStage.encoding:" + encoding); ! BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile, append),encoding)); //BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileWriter(outfile, append),encoding)) ; writer.write(new String(document.getBytes())); *************** *** 227,231 **** boolean newLine = "true".equalsIgnoreCase(this.getOptions(NEW_LINE)); ! String encoding = this.getOptions(ENCODING); // Get the donefile suffix --- 234,240 ---- boolean newLine = "true".equalsIgnoreCase(this.getOptions(NEW_LINE)); ! String encoding = this.getOptions(ENCODING);//PipelineStage.encoding ! //if encoding not null then writeFileMessage write using this encoding, ! //else use de default (PipelineDocument) encoding // Get the donefile suffix Index: GenericWriterPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/GenericWriterPipelineStage.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** GenericWriterPipelineStage.java 30 Jul 2004 01:33:04 -0000 1.6 --- GenericWriterPipelineStage.java 18 Dec 2007 10:02:55 -0000 1.7 *************** *** 124,127 **** --- 124,131 ---- newDocument.setMimeType(this.getDocument().getMimeType()); newDocument.setBinary(this.getDocument().isBinary()); + // 20071114 jmenriquez + // why not setEncoding and setName? + newDocument.setEncoding(this.getDocument().getEncoding()); + newDocument.setName(this.getDocument().getName()); return newDocument; --- NEW FILE: EncodingConversionPipelineStage.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/EncodingConversionPipelineStage.java,v 1.1 2007/12/18 10:02:55 josem_dev Exp $ * $DateTime$ * $Author: josem_dev $ * */ package com.babeldoc.core.pipeline.stage; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Collection; import com.babeldoc.core.I18n; import com.babeldoc.core.LogService; import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; import com.babeldoc.core.pipeline.PipelineException; import com.babeldoc.core.pipeline.PipelineStage; import com.babeldoc.core.pipeline.PipelineStageInfo; import com.babeldoc.core.pipeline.PipelineStageResult; import com.babeldoc.core.pipeline.PipelineDocument; /** * Encoding conversión of the document with the defined encoding. * * @author josem_dev * @version 1.0 */ public class EncodingConversionPipelineStage extends PipelineStage { /** * Construct this stage - create the information object */ public EncodingConversionPipelineStage() { super(new PipelineStageInfo() { public String getName() { return "EncodingConversion"; } public String getDescription() { return I18n.get("core.pipeline.stage.EncodingConversion.desc"); } public Collection getTypeSpecificOptions() { ArrayList options = new ArrayList(); options.add( new ConfigOption( ENCODING, IConfigOptionType.STRING, null, true, I18n.get("core.pipeline.stage.EncodingConversionPipelineStage.charset") ) ); return options; } }); } /** * Encoding conversion of de input document with the output encoding. * * @param inputDocument pipeline document to convert * @param outputEncoding desired encoding */ public void convert(PipelineDocument inputDocument, String outputEncoding) throws PipelineException { byte[] newBuffer; if(inputDocument.isBinary()) { if (LogService.getInstance().isWarnEnabled()) { LogService.getInstance().logWarn("EncodingConversionPipelineStage.convert() document is binary, not encoding conversion"); } } else { try { newBuffer = inputDocument.getContents().getBytes(outputEncoding); this.getDocument().setBytes(newBuffer); } catch (UnsupportedEncodingException x) { throw new PipelineException( "[EncodingConversionPipelineStage.convert] UnsupportedEncodingException, encoding: " + outputEncoding, x ); } } } /** * Process. * * @return array of pipelinestage results * @throws PipelineException */ public PipelineStageResult[] process() throws PipelineException { try { convert(this.getDocument(), this.getOptions(ENCODING)); return super.processHelper(); } catch (PipelineException pe) { throw pe; } catch (Exception x) { throw new PipelineException( "[EncodingConversionPipelineStage.process] exception", x ); } } } |
From: JM E. <jos...@us...> - 2007-12-18 10:02:56
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15776/modules/sql/src/com/babeldoc/sql/pipeline/stage Modified Files: SqlWriterPipelineStage.java Log Message: news pipeline stage Index: SqlWriterPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage/SqlWriterPipelineStage.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** SqlWriterPipelineStage.java 24 Jul 2004 00:18:54 -0000 1.16 --- SqlWriterPipelineStage.java 18 Dec 2007 10:02:55 -0000 1.17 *************** *** 100,103 **** --- 100,106 ---- public static final String BATCH_SIZE = "batchSize"; public static final String SQL = "sql"; + + // 20071217 jmenriquez + public static final String ISO_FORMAT = "isoFormat"; //This is used for specifying message that should be retuned. It should be *************** *** 142,145 **** --- 145,152 ---- null, true, I18n.get("sql.195"))); + // 20071217 jmenriquez + options.add(new ConfigOption(ISO_FORMAT, IConfigOptionType.BOOLEAN, + "false", false, I18n.get("sql.300"))); + return options; } *************** *** 208,211 **** --- 215,230 ---- return ((Connection) resource.checkOut()); } + + // 20071217 jmenriquez + private boolean isOracle(String productName) { + return productName.toUpperCase().indexOf("ORACLE") > -1; + } + + // 20071217 jmenriquez + private boolean isSqlServer(String productName) { + return productName.toUpperCase().indexOf("MICROSOFT") > -1 + && productName.toUpperCase().indexOf("SQL") > -1 + && productName.toUpperCase().indexOf("SERVER") > -1; + } /** *************** *** 241,247 **** int currentBatchSize = 0; int commandCount = 0; while (true) { ! try { //excute statement String command = br.readLine(); --- 260,279 ---- int currentBatchSize = 0; int commandCount = 0; + + // 20071217 jmenriquez + if (hasOption(ISO_FORMAT) && "true".equalsIgnoreCase(getOptions(ISO_FORMAT))) { + // configure connection + String productName = conn.getMetaData().getDatabaseProductName(); + if (isOracle(productName)) { + stmt.executeUpdate("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'"); + stmt.executeUpdate("ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '.,'"); + } + if (isSqlServer(productName)) { + stmt.executeUpdate("SET DATEFORMAT YMD"); + } + } while (true) { ! try { //excute statement String command = br.readLine(); |
From: paspes <pa...@us...> - 2007-12-17 17:07:46
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6726/modules/scanner/src/com/babeldoc/scanner/worker Modified Files: VFSScanner.java Log Message: vfs (tst directori) Index: VFSScanner.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/VFSScanner.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** VFSScanner.java 14 Dec 2007 00:51:12 -0000 1.3 --- VFSScanner.java 17 Dec 2007 16:00:03 -0000 1.4 *************** *** 73,76 **** --- 73,77 ---- import org.apache.commons.vfs.FileContent; + import org.apache.commons.vfs.FileFilterSelector; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSelectInfo; *************** *** 79,83 **** --- 80,88 ---- import org.apache.commons.vfs.FileSystemOptions; import org.apache.commons.vfs.FileType; + import org.apache.commons.vfs.FileTypeSelector; + import org.apache.commons.vfs.CacheStrategy; import org.apache.commons.vfs.VFS; + import org.apache.commons.vfs.auth.StaticUserAuthenticator; + import org.apache.commons.vfs.impl.DefaultFileSystemConfigBuilder; import com.babeldoc.core.I18n; *************** *** 167,174 **** public void initialize() throws ScannerConfigurationException { try { fsManager = VFS.getManager(); ! opts = new FileSystemOptions(); ! ! // setInDirectory( // new File((String) this.getInfo().getOption(IN_DIR).getValue())); setInDirectory(this.getInfo().getStrValue(IN_DIR)); --- 172,181 ---- public void initialize() throws ScannerConfigurationException { try { + StaticUserAuthenticator auth = new StaticUserAuthenticator("username", "password", null); + opts = new FileSystemOptions(); + DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); + //FileObject fo = VFS.getManager().resolveFile("smb://host/anyshare/dir", opts); fsManager = VFS.getManager(); ! // new File((String) this.getInfo().getOption(IN_DIR).getValue())); setInDirectory(this.getInfo().getStrValue(IN_DIR)); *************** *** 226,230 **** */ public void relinquishResources() { ! } --- 233,240 ---- */ public void relinquishResources() { ! fsManager.closeFileSystem(getInDirectory().getFileSystem()); ! if (doneDirectory != null) { ! fsManager.closeFileSystem(doneDirectory.getFileSystem()); ! } } *************** *** 246,252 **** String path = file.getName().getPath(); ! FileObject outDir = fsManager.resolveFile(getDoneDirectory() ! + getInDirectory().getName().getPathDecoded() ! .toString()); // create out dir if not exist --- 256,260 ---- String path = file.getName().getPath(); ! FileObject outDir = fsManager.resolveFile(getDoneDirectory()); // create out dir if not exist *************** *** 258,262 **** FileObject outfile = fsManager.resolveFile(outDir.getName() .getURI() ! + file.getName().getBaseName()); // delete file it is already exists --- 266,270 ---- FileObject outfile = fsManager.resolveFile(outDir.getName() .getURI() ! + "/" + file.getName().getBaseName()); // delete file it is already exists *************** *** 264,270 **** outfile.delete(); } ! ! // copy ! outfile.getContent().getFile().copyFrom(file, null); // rename file /* --- 272,280 ---- outfile.delete(); } ! ! FileTypeSelector filter = new FileTypeSelector(FileType.FILE); ! outfile.createFile(); ! outfile.copyFrom(file, filter); ! outfile.close(); // rename file /* *************** *** 308,313 **** */ private void processVFS(FileObject dir) throws FileSystemException { // inner class that implements FileFilter interface ! org.apache.commons.vfs.FileFilter filter = new org.apache.commons.vfs.FileFilter() { public boolean accept(FileSelectInfo currentInfo) { FileObject currentFile = currentInfo.getFile(); --- 318,324 ---- */ private void processVFS(FileObject dir) throws FileSystemException { + dir.refresh(); // inner class that implements FileFilter interface ! /*org.apache.commons.vfs.FileFilter filter = new org.apache.commons.vfs.FileFilter() { public boolean accept(FileSelectInfo currentInfo) { FileObject currentFile = currentInfo.getFile(); *************** *** 327,333 **** } }; FileObject[] files = dir.getChildren(); ! for (int i = 0; i < files.length; i++) { if (files[i].getType() == FileType.FOLDER) { --- 338,346 ---- } }; + */ + FileObject[] files = dir.getChildren(); ! for (int i = 0; i < files.length; i++) { if (files[i].getType() == FileType.FOLDER) { *************** *** 335,345 **** processVFS(files[i]); } else { ! // create scan document and queue it! ! try { ! processFile(files[i]); ! moveFile(files[i]); ! } catch (Exception ex) { ! log.logError( ! "Error getting document from file " + files[i], ex); } } --- 348,360 ---- processVFS(files[i]); } else { ! if(acceptFile(files[i])){ ! // create scan document and queue it! ! try { ! processFile(files[i]); ! moveFile(files[i]); ! } catch (Exception ex) { ! log.logError( ! "Error getting document from file " + files[i], ex); ! } } } *************** *** 438,442 **** public void setInDirectory(String inDirectory) throws FileSystemException { this.inDirectory = fsManager.resolveFile(this.getInfo().getStrValue( ! IN_DIR)); } --- 453,457 ---- public void setInDirectory(String inDirectory) throws FileSystemException { this.inDirectory = fsManager.resolveFile(this.getInfo().getStrValue( ! IN_DIR),opts); } |
From: paspes <pa...@us...> - 2007-12-17 17:05:51
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/config/service In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv6726/modules/scanner/config/service Modified Files: query.properties Log Message: vfs (tst directori) Index: query.properties =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/config/service/query.properties,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** query.properties 12 Nov 2007 13:47:02 -0000 1.8 --- query.properties 17 Dec 2007 16:00:03 -0000 1.9 *************** *** 9,13 **** ScannerWorker.http=com.babeldoc.scanner.worker.HttpScanner ScannerWorker.null=com.babeldoc.scanner.worker.NullScanner ! Command.scanner=com.babeldoc.scanner.Scanner --- 9,13 ---- ScannerWorker.http=com.babeldoc.scanner.worker.HttpScanner ScannerWorker.null=com.babeldoc.scanner.worker.NullScanner ! ScannerWorker.virtualfs=com.babeldoc.scanner.worker.VFSScanner Command.scanner=com.babeldoc.scanner.Scanner |
From: paspes <pa...@us...> - 2007-12-14 02:01:25
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15709/modules/scanner/src/com/babeldoc/scanner/worker Modified Files: VFSScanner.java Log Message: Pujat falta accept segons parametre scan Index: VFSScanner.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/VFSScanner.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** VFSScanner.java 13 Dec 2007 00:02:02 -0000 1.1 --- VFSScanner.java 13 Dec 2007 17:21:43 -0000 1.2 *************** *** 66,74 **** package com.babeldoc.scanner.worker; import java.io.InputStream; - import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSelectInfo; --- 66,76 ---- package com.babeldoc.scanner.worker; + import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; + import java.util.Date; + import org.apache.commons.vfs.FileContent; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSelectInfo; *************** *** 84,87 **** --- 86,90 ---- import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; + import com.babeldoc.core.option.ValueListConfigOptionType; import com.babeldoc.core.pipeline.PipelineDocument; import com.babeldoc.scanner.ScannerConfigurationException; *************** *** 105,108 **** --- 108,115 ---- public static final String FILTER_FILENAME = "filter"; public static final String MINIMUM_FILE_AGE = "minimumFileAge"; + public static final String SCAN_NEW = "scanNew"; + + public static final String SCAN_NEW_DELETE ="delete"; + public static final String SCAN_NEW_FOLDER ="doneFolder"; private LogService log = LogService.getInstance(this.getClass().getName()); *************** *** 167,171 **** setInDirectory(this.getInfo().getStrValue(IN_DIR)); ! if (getInDirectory().getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", IN_DIR, --- 174,178 ---- setInDirectory(this.getInfo().getStrValue(IN_DIR)); ! if (!getInDirectory().exists() || !getInDirectory().isReadable() || getInDirectory().getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", IN_DIR, *************** *** 183,187 **** // Check of the donedirectory actually is a directory ! if (doneDirectory.getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", DONE_DIR, --- 190,194 ---- // Check of the donedirectory actually is a directory ! if ( doneDirectory.getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", DONE_DIR, *************** *** 233,267 **** protected void moveFile(FileObject file) throws Exception { try { ! if (getDoneDirectory() == null) { ! file.delete(); ! return; ! } ! ! String path = file.getName().getPath(); ! ! FileObject outDir = fsManager.resolveFile(getDoneDirectory()+ getInDirectory().getName().getPathDecoded().toString()); ! ! // create out dir if not exist ! if (!outDir.exists()) { ! outDir.createFolder(); ! } ! ! // create file with the same name (path) in out dir ! FileObject outfile = fsManager.resolveFile(outDir.getName().toString() + file.getName().getBaseName()); ! // delete file it is already exists ! if (outfile.exists()) { ! outfile.delete(); } - - // rename file - if(!file.canRenameTo(outfile)) - throw new ScannerException(I18n.get("scanner.VFSScanner.error.finishing")); - //TODO Probably can do that more simply with a moveTo() - // } catch (Exception e) { throw new ScannerException(I18n .get("scanner.VFSScanner.error.finishing"), e); } } --- 240,294 ---- protected void moveFile(FileObject file) throws Exception { try { ! ! if (getDoneDirectory() != null ){ ! ! String path = file.getName().getPath(); ! FileObject outDir = fsManager.resolveFile(getDoneDirectory()+ getInDirectory().getName().getPathDecoded().toString()); ! // create out dir if not exist ! if (!outDir.exists()) { ! outDir.createFolder(); ! } ! ! // create file with the same name (path) in out dir ! FileObject outfile = fsManager.resolveFile(outDir.getName().getURI() + file.getName().getBaseName()); ! ! // delete file it is already exists ! if (outfile.exists()) { ! outfile.delete(); ! } ! ! //copy ! outfile.getContent().getFile().copyFrom(file,null); ! // rename file ! /*if(!file.canRenameTo(outfile)) ! throw new ScannerException(I18n.get("scanner.VFSScanner.error.finishing")); ! ! */ ! } } catch (Exception e) { throw new ScannerException(I18n .get("scanner.VFSScanner.error.finishing"), e); } + + if ( this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_DELETE ){ + if(!file.delete()){ + throw new ScannerException(I18n + .get("scanner.VFSScanner.error.finishing"), null); + //Exceptio no es podra saber si es nou pq no ha borrat!!! + } + return; + } + + if ( this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_FOLDER ){ + if (getDoneDirectory() == null) + throw new ScannerException(I18n + .get("scanner.VFSScanner.error.finishing"), null); + // Exceptio no es podra saber si es nou pq no a mogut!!! + return; + + } + } *************** *** 303,307 **** try { processFile(files[i]); ! moveFile(files[i]); } catch (Exception ex) { log.logError( --- 330,334 ---- try { processFile(files[i]); ! moveFile(files[i]); } catch (Exception ex) { log.logError( *************** *** 323,334 **** private void processFile(FileObject file) throws Exception { InputStream fis = null; ! OutputStream baos = null; try { ! // getting message from file byte[] data = new byte[1024]; ! long modified = file.getContent().getLastModifiedTime(); ! fis = file.getContent().getInputStream(); ! baos = file.getContent().getOutputStream(); int charsRead = 0; --- 350,362 ---- private void processFile(FileObject file) throws Exception { InputStream fis = null; ! ByteArrayOutputStream baos = null; try { ! FileContent fileContent= file.getContent(); ! //getting message from file byte[] data = new byte[1024]; ! long modified = new Date(fileContent.getLastModifiedTime()).getTime(); ! fis = fileContent.getInputStream(); ! baos = new ByteArrayOutputStream((int)fileContent.getSize()); int charsRead = 0; *************** *** 338,352 **** } ! this.enqueue(baos.toByteArray(), new NameValuePair[] { ! new NameValuePair(SCAN_MIMETYPE_KEY, PipelineDocument ! .getMimeTypeForFile(file.getName().getBaseName())), new NameValuePair(SCAN_DATE_KEY, Long.toString(modified)), new NameValuePair(SCAN_PATH_KEY, file.getName().getPath()), new NameValuePair(FILE_NAME_KEY, file.getName().getBaseName()), ! new NameValuePair(DONE_DIR_KEY, getDoneDirectory()) }); } finally { fis.close(); baos.close(); } } --- 366,383 ---- } ! this.enqueue( ! baos.toByteArray(), ! new NameValuePair[] { ! new NameValuePair(SCAN_MIMETYPE_KEY, ! PipelineDocument.getMimeTypeForFile(file.getName().getBaseName())), new NameValuePair(SCAN_DATE_KEY, Long.toString(modified)), new NameValuePair(SCAN_PATH_KEY, file.getName().getPath()), new NameValuePair(FILE_NAME_KEY, file.getName().getBaseName()), ! new NameValuePair(DONE_DIR_KEY, getDoneDirectory())}); } finally { fis.close(); baos.close(); } + } *************** *** 362,365 **** --- 393,398 ---- */ private boolean acceptFile(FileSelectInfo fileInfo) throws FileSystemException { + //Afegir if ( this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_DELETE ){ i FOLDER + // Check name filter first, and then age. if (acceptEntry(FILTER_FILENAME, fileInfo.getFile().getName().toString())) { *************** *** 439,443 **** */ public String getDescription() { ! return I18n.get("scanner.VFSScannerInfo.description"); } --- 472,476 ---- */ public String getDescription() { ! return I18n.get("scanner.VfsScannerInfo.description"); } *************** *** 475,478 **** --- 508,516 ---- IConfigOptionType.INTEGER, null, false, I18n .get("scanner.VFSScannerInfo.option.minimumFileAge"))); + + String[] scanNewTypes = { VFSScanner.SCAN_NEW_DELETE, VFSScanner.SCAN_NEW_FOLDER }; + options.add(new ConfigOption(VFSScanner.SCAN_NEW, + new ValueListConfigOptionType(scanNewTypes), VFSScanner.SCAN_NEW_DELETE, + false, I18n.get("scanner.VfsScannerInfo.option.scanNew"))); return options; |
From: Santi B. <san...@us...> - 2007-12-14 00:51:12
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23586/modules/scanner/src/com/babeldoc/scanner/worker Modified Files: VFSScanner.java Log Message: Minor update Index: VFSScanner.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/VFSScanner.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VFSScanner.java 13 Dec 2007 17:21:43 -0000 1.2 --- VFSScanner.java 14 Dec 2007 00:51:12 -0000 1.3 *************** *** 109,115 **** public static final String MINIMUM_FILE_AGE = "minimumFileAge"; public static final String SCAN_NEW = "scanNew"; ! ! public static final String SCAN_NEW_DELETE ="delete"; ! public static final String SCAN_NEW_FOLDER ="doneFolder"; private LogService log = LogService.getInstance(this.getClass().getName()); --- 109,115 ---- public static final String MINIMUM_FILE_AGE = "minimumFileAge"; public static final String SCAN_NEW = "scanNew"; ! ! public static final String SCAN_NEW_DELETE = "delete"; ! public static final String SCAN_NEW_FOLDER = "doneFolder"; private LogService log = LogService.getInstance(this.getClass().getName()); *************** *** 141,145 **** * against incomplete reads when the writer of the file is "slow". */ ! private int minimumFileAge = 0; /** --- 141,145 ---- * against incomplete reads when the writer of the file is "slow". */ ! private long minimumFileAge = 0; /** *************** *** 174,178 **** setInDirectory(this.getInfo().getStrValue(IN_DIR)); ! if (!getInDirectory().exists() || !getInDirectory().isReadable() || getInDirectory().getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", IN_DIR, --- 174,179 ---- setInDirectory(this.getInfo().getStrValue(IN_DIR)); ! if (!getInDirectory().exists() || !getInDirectory().isReadable() ! || getInDirectory().getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", IN_DIR, *************** *** 190,194 **** // Check of the donedirectory actually is a directory ! if ( doneDirectory.getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", DONE_DIR, --- 191,195 ---- // Check of the donedirectory actually is a directory ! if (doneDirectory.getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", DONE_DIR, *************** *** 205,210 **** INCLUDE_SUB_DIRS))); ! setMinimumFileAge(this.getInfo().getIntValue(MINIMUM_FILE_AGE)); ! if (getMinimumFileAge() > 0) { LogService.getInstance().logInfo( --- 206,212 ---- INCLUDE_SUB_DIRS))); ! ! setMinimumFileAge(this.getInfo().getIntValue(MINIMUM_FILE_AGE)); ! if (getMinimumFileAge() > 0) { LogService.getInstance().logInfo( *************** *** 240,248 **** protected void moveFile(FileObject file) throws Exception { try { ! ! if (getDoneDirectory() != null ){ ! String path = file.getName().getPath(); ! FileObject outDir = fsManager.resolveFile(getDoneDirectory()+ getInDirectory().getName().getPathDecoded().toString()); // create out dir if not exist --- 242,252 ---- protected void moveFile(FileObject file) throws Exception { try { ! ! if (getDoneDirectory() != null) { ! String path = file.getName().getPath(); ! FileObject outDir = fsManager.resolveFile(getDoneDirectory() ! + getInDirectory().getName().getPathDecoded() ! .toString()); // create out dir if not exist *************** *** 250,270 **** outDir.createFolder(); } ! // create file with the same name (path) in out dir ! FileObject outfile = fsManager.resolveFile(outDir.getName().getURI() + file.getName().getBaseName()); ! // delete file it is already exists if (outfile.exists()) { outfile.delete(); } ! ! //copy ! outfile.getContent().getFile().copyFrom(file,null); ! // rename file ! /*if(!file.canRenameTo(outfile)) ! throw new ScannerException(I18n.get("scanner.VFSScanner.error.finishing")); ! */ ! } } catch (Exception e) { --- 254,277 ---- outDir.createFolder(); } ! // create file with the same name (path) in out dir ! FileObject outfile = fsManager.resolveFile(outDir.getName() ! .getURI() ! + file.getName().getBaseName()); ! // delete file it is already exists if (outfile.exists()) { outfile.delete(); } ! ! // copy ! outfile.getContent().getFile().copyFrom(file, null); ! // rename file ! /* ! * if(!file.canRenameTo(outfile)) throw new ! * ScannerException(I18n.get("scanner.VFSScanner.error.finishing")); ! * */ ! } } catch (Exception e) { *************** *** 272,293 **** .get("scanner.VFSScanner.error.finishing"), e); } ! ! if ( this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_DELETE ){ ! if(!file.delete()){ throw new ScannerException(I18n .get("scanner.VFSScanner.error.finishing"), null); ! //Exceptio no es podra saber si es nou pq no ha borrat!!! } return; } ! ! if ( this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_FOLDER ){ if (getDoneDirectory() == null) throw new ScannerException(I18n .get("scanner.VFSScanner.error.finishing"), null); ! // Exceptio no es podra saber si es nou pq no a mogut!!! return; ! ! } } --- 279,300 ---- .get("scanner.VFSScanner.error.finishing"), e); } ! ! if (this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_DELETE) { ! if (!file.delete()) { throw new ScannerException(I18n .get("scanner.VFSScanner.error.finishing"), null); ! // Exceptio no es podra saber si es nou pq no ha borrat!!! } return; } ! ! if (this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_FOLDER) { if (getDoneDirectory() == null) throw new ScannerException(I18n .get("scanner.VFSScanner.error.finishing"), null); ! // Exceptio no es podra saber si es nou pq no a mogut!!! return; ! ! } } *************** *** 298,314 **** * @param dir * DOCUMENT ME! ! * @throws FileSystemException */ private void processVFS(FileObject dir) throws FileSystemException { // inner class that implements FileFilter interface org.apache.commons.vfs.FileFilter filter = new org.apache.commons.vfs.FileFilter() { ! public boolean accept(FileSelectInfo current) { try { ! if (current.getFile().getType() == FileType.FOLDER) { // if iclude subDirs if it is scpecified return isIncludeSubDirs(); } else { // if file fulfils configured criteria ! return acceptFile(current); } } catch (FileSystemException e) { --- 305,322 ---- * @param dir * DOCUMENT ME! ! * @throws FileSystemException */ private void processVFS(FileObject dir) throws FileSystemException { // inner class that implements FileFilter interface org.apache.commons.vfs.FileFilter filter = new org.apache.commons.vfs.FileFilter() { ! public boolean accept(FileSelectInfo currentInfo) { ! FileObject currentFile = currentInfo.getFile(); try { ! if (currentFile.getType() == FileType.FOLDER) { // if iclude subDirs if it is scpecified return isIncludeSubDirs(); } else { // if file fulfils configured criteria ! return acceptFile(currentFile); } } catch (FileSystemException e) { *************** *** 330,334 **** try { processFile(files[i]); ! moveFile(files[i]); } catch (Exception ex) { log.logError( --- 338,342 ---- try { processFile(files[i]); ! moveFile(files[i]); } catch (Exception ex) { log.logError( *************** *** 353,362 **** try { ! FileContent fileContent= file.getContent(); ! //getting message from file byte[] data = new byte[1024]; ! long modified = new Date(fileContent.getLastModifiedTime()).getTime(); fis = fileContent.getInputStream(); ! baos = new ByteArrayOutputStream((int)fileContent.getSize()); int charsRead = 0; --- 361,371 ---- try { ! FileContent fileContent = file.getContent(); ! // getting message from file byte[] data = new byte[1024]; ! long modified = new Date(fileContent.getLastModifiedTime()) ! .getTime(); fis = fileContent.getInputStream(); ! baos = new ByteArrayOutputStream((int) fileContent.getSize()); int charsRead = 0; *************** *** 366,383 **** } ! this.enqueue( ! baos.toByteArray(), ! new NameValuePair[] { ! new NameValuePair(SCAN_MIMETYPE_KEY, ! PipelineDocument.getMimeTypeForFile(file.getName().getBaseName())), new NameValuePair(SCAN_DATE_KEY, Long.toString(modified)), new NameValuePair(SCAN_PATH_KEY, file.getName().getPath()), ! new NameValuePair(FILE_NAME_KEY, file.getName().getBaseName()), ! new NameValuePair(DONE_DIR_KEY, getDoneDirectory())}); } finally { fis.close(); baos.close(); } ! } --- 375,391 ---- } ! this.enqueue(baos.toByteArray(), new NameValuePair[] { ! new NameValuePair(SCAN_MIMETYPE_KEY, PipelineDocument ! .getMimeTypeForFile(file.getName().getBaseName())), new NameValuePair(SCAN_DATE_KEY, Long.toString(modified)), new NameValuePair(SCAN_PATH_KEY, file.getName().getPath()), ! new NameValuePair(FILE_NAME_KEY, file.getName() ! .getBaseName()), ! new NameValuePair(DONE_DIR_KEY, getDoneDirectory()) }); } finally { fis.close(); baos.close(); } ! } *************** *** 390,407 **** * The file to be checked against configuration * @return true If the file should be processed at this time ! * @throws FileSystemException */ ! private boolean acceptFile(FileSelectInfo fileInfo) throws FileSystemException { ! //Afegir if ( this.getInfo().getStrValue(SCAN_NEW) == VFSScanner.SCAN_NEW_DELETE ){ i FOLDER ! // Check name filter first, and then age. ! if (acceptEntry(FILTER_FILENAME, fileInfo.getFile().getName().toString())) { ! if (getMinimumFileAge() <= fileInfo.getFile().getContent().getLastModifiedTime() - getFileAge(fileInfo.getFile())) { return true; } else { if (log.isDebugEnabled()) ! log.logDebug("Ignoring " + fileInfo.getFile().getName().getPathDecoded() + " (age " ! + getFileAge(fileInfo.getFile()) + " < " + getMinimumFileAge() ! + ")"); } // Potentially add additional checks here. --- 398,416 ---- * The file to be checked against configuration * @return true If the file should be processed at this time ! * @throws FileSystemException */ ! private boolean acceptFile(FileObject file) throws FileSystemException { ! // Afegir if ( this.getInfo().getStrValue(SCAN_NEW) == ! // VFSScanner.SCAN_NEW_DELETE ){ i FOLDER ! // Check name filter first, and then age. ! if (acceptEntry(FILTER_FILENAME, file.getName().toString())) { ! if (getMinimumFileAge() <= getFileAge(file)) { return true; } else { if (log.isDebugEnabled()) ! log.logDebug("Ignoring " + file.getName().getPathDecoded() ! + " (age " + getFileAge(file) + " < " ! + getMinimumFileAge() + ")"); } // Potentially add additional checks here. *************** *** 416,420 **** * The file to get the age of. * @return long The age of the file in ms. ! * @throws FileSystemException */ private long getFileAge(FileObject file) throws FileSystemException { --- 425,429 ---- * The file to get the age of. * @return long The age of the file in ms. ! * @throws FileSystemException */ private long getFileAge(FileObject file) throws FileSystemException { *************** *** 428,432 **** public void setInDirectory(String inDirectory) throws FileSystemException { ! this.inDirectory = fsManager.resolveFile(this.getInfo().getStrValue(IN_DIR)); } --- 437,442 ---- public void setInDirectory(String inDirectory) throws FileSystemException { ! this.inDirectory = fsManager.resolveFile(this.getInfo().getStrValue( ! IN_DIR)); } *************** *** 449,457 **** } ! public int getMinimumFileAge() { return minimumFileAge; } ! public void setMinimumFileAge(int minimumFileAge) { if (minimumFileAge < 0) minimumFileAge = 0; --- 459,467 ---- } ! public long getMinimumFileAge() { return minimumFileAge; } ! public void setMinimumFileAge(long minimumFileAge) { if (minimumFileAge < 0) minimumFileAge = 0; *************** *** 508,516 **** IConfigOptionType.INTEGER, null, false, I18n .get("scanner.VFSScannerInfo.option.minimumFileAge"))); ! ! String[] scanNewTypes = { VFSScanner.SCAN_NEW_DELETE, VFSScanner.SCAN_NEW_FOLDER }; ! options.add(new ConfigOption(VFSScanner.SCAN_NEW, ! new ValueListConfigOptionType(scanNewTypes), VFSScanner.SCAN_NEW_DELETE, ! false, I18n.get("scanner.VfsScannerInfo.option.scanNew"))); return options; --- 518,528 ---- IConfigOptionType.INTEGER, null, false, I18n .get("scanner.VFSScannerInfo.option.minimumFileAge"))); ! ! String[] scanNewTypes = { VFSScanner.SCAN_NEW_DELETE, ! VFSScanner.SCAN_NEW_FOLDER }; ! options.add(new ConfigOption(VFSScanner.SCAN_NEW, ! new ValueListConfigOptionType(scanNewTypes), ! VFSScanner.SCAN_NEW_DELETE, false, I18n ! .get("scanner.VfsScannerInfo.option.scanNew"))); return options; |
From: Santi B. <san...@us...> - 2007-12-14 00:51:11
|
Update of /cvsroot/babeldoc/babeldoc In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23586 Modified Files: .classpath Log Message: Minor update Index: .classpath =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/.classpath,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** .classpath 13 Dec 2007 00:02:02 -0000 1.6 --- .classpath 14 Dec 2007 00:51:12 -0000 1.7 *************** *** 55,59 **** <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/j2sdk1.4.2_16"/> <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/C-_apache-tomcat-5.5.25"/> ! <classpathentry kind="lib" path="C:/wks_eclipse/apache.commons.vfs/target/commons-vfs-1.1-SNAPSHOT.jar"/> <classpathentry kind="output" path="bin"/> </classpath> --- 55,59 ---- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/j2sdk1.4.2_16"/> <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/C-_apache-tomcat-5.5.25"/> ! <classpathentry kind="lib" path="modules/core/lib/commons-vfs-1.1-SNAPSHOT.jar"/> <classpathentry kind="output" path="bin"/> </classpath> |
From: Santi B. <san...@us...> - 2007-12-13 00:06:55
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/lib In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv3749/modules/core/lib Added Files: commons-vfs-1.1-SNAPSHOT.jar Log Message: Added VFS scanner. Preliminar version. --- NEW FILE: commons-vfs-1.1-SNAPSHOT.jar --- (This appears to be a binary file; contents omitted.) |
From: Santi B. <san...@us...> - 2007-12-13 00:02:01
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv1821/modules/scanner/src/com/babeldoc/scanner/worker Added Files: VFSScanner.java Log Message: Added VFS scanner. Preliminar version. --- NEW FILE: VFSScanner.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/VFSScanner.java,v 1.1 2007/12/13 00:02:02 santibegue Exp $ * $DateTime$ * $Author: santibegue $ * */ package com.babeldoc.scanner.worker; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Collection; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSelectInfo; import org.apache.commons.vfs.FileSystemException; import org.apache.commons.vfs.FileSystemManager; import org.apache.commons.vfs.FileSystemOptions; import org.apache.commons.vfs.FileType; import org.apache.commons.vfs.VFS; import com.babeldoc.core.I18n; import com.babeldoc.core.LogService; import com.babeldoc.core.NameValuePair; import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; import com.babeldoc.core.pipeline.PipelineDocument; import com.babeldoc.scanner.ScannerConfigurationException; import com.babeldoc.scanner.ScannerException; import com.babeldoc.scanner.ScannerWorker; import com.babeldoc.scanner.ScannerWorkerInfo; /** * VFSScanner - scannerworker that scans a Virtual File System and sends to a * pipeline stage * * @author Begue, Santiago * @version $Revision: 1.1 $ */ public class VFSScanner extends ScannerWorker { /** Configuration options */ public static final String IN_DIR = "inDirectory"; public static final String DONE_DIR = "doneDirectory"; public static final String BUFFER_LEN = "bufferLen"; public static final String INCLUDE_SUB_DIRS = "includeSubfolders"; public static final String FILTER_FILENAME = "filter"; public static final String MINIMUM_FILE_AGE = "minimumFileAge"; private LogService log = LogService.getInstance(this.getClass().getName()); /** * This is used to provide information to the pipeline stages about where * documents processed by this scanner are moved. */ public static final String DONE_DIR_KEY = "done_dir"; public VFSScanner() { super(new VFSScannerInfo()); } private FileSystemManager fsManager; private FileSystemOptions opts; /** URI to scan */ private FileObject inDirectory; /** Directory to place output files */ private FileObject doneDirectory; /** flag to include sub directories */ private boolean includeSubDirs = false; /** * Minimum time in ms since file was last modified. Attempts to guard * against incomplete reads when the writer of the file is "slow". */ private int minimumFileAge = 0; /** * This method will scan for new documents. It will queue documents by * itself, so it will return null no matter how many documents found! * * @throws ScannerException * DOCUMENT ME! */ public void doScan() throws ScannerException { try { processVFS(this.getInDirectory()); } catch (FileSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * Setup the options. Each of the options lives in the hashtable held by the * superclass. * * @throws ScannerConfigurationException */ public void initialize() throws ScannerConfigurationException { try { fsManager = VFS.getManager(); opts = new FileSystemOptions(); // setInDirectory( // new File((String) this.getInfo().getOption(IN_DIR).getValue())); setInDirectory(this.getInfo().getStrValue(IN_DIR)); if (getInDirectory().getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", IN_DIR, getInDirectory()), null); } setDoneDirectory(this.getInfo().getStrValue(DONE_DIR)); if (getDoneDirectory() != null && !"".equals(getDoneDirectory())) { /* * // if the done directory does not end with '/' then add one. * if (!getDoneDirectory().endsWith(File.pathSeparator)) { * setDoneDirectory(getDoneDirectory() + File.separator); } */ // Check of the donedirectory actually is a directory if (doneDirectory.getType() != FileType.FOLDER) { throw new ScannerConfigurationException(I18n.get( "scanner.VFSScanner.error.notDir", DONE_DIR, getDoneDirectory()), null); } } else { getLog() .logInfo( "Done directory not specified. All processed file will be deleted!!!"); setDoneDirectory(null); } setIncludeSubDirs("true".equals(this.getInfo().getStrValue( INCLUDE_SUB_DIRS))); setMinimumFileAge(this.getInfo().getIntValue(MINIMUM_FILE_AGE)); if (getMinimumFileAge() > 0) { LogService.getInstance().logInfo( "Minimum file age: " + getMinimumFileAge() + " ms"); } // Add filename filter if exist addFilter(FILTER_FILENAME); } catch (FileSystemException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } /** * release the held resource. Do nothing - no held resources. */ public void relinquishResources() { } /** * This method will move current file to out directory. * * @param file * DOCUMENT ME! * * @throws Exception * DOCUMENT ME! * @throws ScannerException * DOCUMENT ME! */ protected void moveFile(FileObject file) throws Exception { try { if (getDoneDirectory() == null) { file.delete(); return; } String path = file.getName().getPath(); FileObject outDir = fsManager.resolveFile(getDoneDirectory()+ getInDirectory().getName().getPathDecoded().toString()); // create out dir if not exist if (!outDir.exists()) { outDir.createFolder(); } // create file with the same name (path) in out dir FileObject outfile = fsManager.resolveFile(outDir.getName().toString() + file.getName().getBaseName()); // delete file it is already exists if (outfile.exists()) { outfile.delete(); } // rename file if(!file.canRenameTo(outfile)) throw new ScannerException(I18n.get("scanner.VFSScanner.error.finishing")); //TODO Probably can do that more simply with a moveTo() // } catch (Exception e) { throw new ScannerException(I18n .get("scanner.VFSScanner.error.finishing"), e); } } /** * Process all files in this directory * * @param dir * DOCUMENT ME! * @throws FileSystemException */ private void processVFS(FileObject dir) throws FileSystemException { // inner class that implements FileFilter interface org.apache.commons.vfs.FileFilter filter = new org.apache.commons.vfs.FileFilter() { public boolean accept(FileSelectInfo current) { try { if (current.getFile().getType() == FileType.FOLDER) { // if iclude subDirs if it is scpecified return isIncludeSubDirs(); } else { // if file fulfils configured criteria return acceptFile(current); } } catch (FileSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } } }; FileObject[] files = dir.getChildren(); for (int i = 0; i < files.length; i++) { if (files[i].getType() == FileType.FOLDER) { // add files from this folder processVFS(files[i]); } else { // create scan document and queue it! try { processFile(files[i]); moveFile(files[i]); } catch (Exception ex) { log.logError( "Error getting document from file " + files[i], ex); } } } } /** * Process a single file. This involves loading the file as data and adding * to the queue. * * @param file * * @throws Exception * DOCUMENT ME! */ private void processFile(FileObject file) throws Exception { InputStream fis = null; OutputStream baos = null; try { // getting message from file byte[] data = new byte[1024]; long modified = file.getContent().getLastModifiedTime(); fis = file.getContent().getInputStream(); baos = file.getContent().getOutputStream(); int charsRead = 0; while ((charsRead = fis.read(data)) != -1) { baos.write(data, 0, charsRead); } this.enqueue(baos.toByteArray(), new NameValuePair[] { new NameValuePair(SCAN_MIMETYPE_KEY, PipelineDocument .getMimeTypeForFile(file.getName().getBaseName())), new NameValuePair(SCAN_DATE_KEY, Long.toString(modified)), new NameValuePair(SCAN_PATH_KEY, file.getName().getPath()), new NameValuePair(FILE_NAME_KEY, file.getName().getBaseName()), new NameValuePair(DONE_DIR_KEY, getDoneDirectory()) }); } finally { fis.close(); baos.close(); } } /** * Consult configuration if this file should be processed or not. Current * configurable constraints include the age of the file and a filename * filter, both optional and by default all permissive. * * @param file * The file to be checked against configuration * @return true If the file should be processed at this time * @throws FileSystemException */ private boolean acceptFile(FileSelectInfo fileInfo) throws FileSystemException { // Check name filter first, and then age. if (acceptEntry(FILTER_FILENAME, fileInfo.getFile().getName().toString())) { if (getMinimumFileAge() <= fileInfo.getFile().getContent().getLastModifiedTime() - getFileAge(fileInfo.getFile())) { return true; } else { if (log.isDebugEnabled()) log.logDebug("Ignoring " + fileInfo.getFile().getName().getPathDecoded() + " (age " + getFileAge(fileInfo.getFile()) + " < " + getMinimumFileAge() + ")"); } // Potentially add additional checks here. } return false; } /** * Get age of file in ms. * * @param file * The file to get the age of. * @return long The age of the file in ms. * @throws FileSystemException */ private long getFileAge(FileObject file) throws FileSystemException { return System.currentTimeMillis() - file.getContent().getLastModifiedTime(); } public FileObject getInDirectory() { return inDirectory; } public void setInDirectory(String inDirectory) throws FileSystemException { this.inDirectory = fsManager.resolveFile(this.getInfo().getStrValue(IN_DIR)); } public String getDoneDirectory() throws FileSystemException { return doneDirectory.getURL().toString(); } public void setDoneDirectory(String doneDirectory) throws FileSystemException { this.doneDirectory = fsManager.resolveFile(this.getInfo().getStrValue( DONE_DIR)); } public boolean isIncludeSubDirs() { return includeSubDirs; } public void setIncludeSubDirs(boolean includeSubDirs) { this.includeSubDirs = includeSubDirs; } public int getMinimumFileAge() { return minimumFileAge; } public void setMinimumFileAge(int minimumFileAge) { if (minimumFileAge < 0) minimumFileAge = 0; this.minimumFileAge = minimumFileAge; } } /** * The configuration information object for the directory scanner * * @author $author$ * @version $Revision: 1.1 $ */ class VFSScannerInfo extends ScannerWorkerInfo { /** * @return The description */ public String getDescription() { return I18n.get("scanner.VFSScannerInfo.description"); } /** * @return The name */ public String getName() { return "VFSScanner"; } /** * @return The collection of type specific options */ public Collection getTypeSpecificOptions() { ArrayList options = new ArrayList(); // add specific options options.add(new ConfigOption(VFSScanner.IN_DIR, IConfigOptionType.DIRECTORY, null, true, I18n .get("scanner.VFSScannerInfo.option.inDirectory"))); options.add(new ConfigOption(VFSScanner.DONE_DIR, IConfigOptionType.DIRECTORY, null, false, I18n .get("scanner.VFSScannerInfo.option.doneDirectory"))); options.add(new ConfigOption(VFSScanner.INCLUDE_SUB_DIRS, IConfigOptionType.BOOLEAN, "false", false, I18n .get("scanner.VFSScannerInfo.option.includeSubdirs"))); options.add(new ConfigOption(VFSScanner.FILTER_FILENAME, IConfigOptionType.STRING, null, false, I18n .get("scanner.VFSScannerInfo.option.filter"))); options.add(new ConfigOption(VFSScanner.MINIMUM_FILE_AGE, IConfigOptionType.INTEGER, null, false, I18n .get("scanner.VFSScannerInfo.option.minimumFileAge"))); return options; } } |
From: Santi B. <san...@us...> - 2007-12-13 00:02:01
|
Update of /cvsroot/babeldoc/babeldoc In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv1821 Modified Files: .classpath Log Message: Added VFS scanner. Preliminar version. Index: .classpath =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/.classpath,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** .classpath 9 Dec 2007 23:35:46 -0000 1.5 --- .classpath 13 Dec 2007 00:02:02 -0000 1.6 *************** *** 55,58 **** --- 55,59 ---- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/j2sdk1.4.2_16"/> <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/C-_apache-tomcat-5.5.25"/> + <classpathentry kind="lib" path="C:/wks_eclipse/apache.commons.vfs/target/commons-vfs-1.1-SNAPSHOT.jar"/> <classpathentry kind="output" path="bin"/> </classpath> |
From: Santi B. <san...@us...> - 2007-12-11 00:38:32
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/build/META-INF/services In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17594/modules/conversion/build/META-INF/services Removed Files: com.babeldoc.core.module.BabeldocModule Log Message: Minor update. Project reorganization. --- com.babeldoc.core.module.BabeldocModule DELETED --- |
From: Santi B. <san...@us...> - 2007-12-11 00:38:32
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/build/conversion/service In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17594/modules/conversion/build/conversion/service Removed Files: query.properties Log Message: Minor update. Project reorganization. --- query.properties DELETED --- |
From: Santi B. <san...@us...> - 2007-12-11 00:38:32
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/build/com/babeldoc/conversion/excel In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17594/modules/conversion/build/com/babeldoc/conversion/excel Removed Files: ExcelConverter.class ExcelConversionClient.class Log Message: Minor update. Project reorganization. --- ExcelConverter.class DELETED --- --- ExcelConversionClient.class DELETED --- |
From: Santi B. <san...@us...> - 2007-12-11 00:38:32
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/build/conversion/i18n In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17594/modules/conversion/build/conversion/i18n Removed Files: messages.properties Log Message: Minor update. Project reorganization. --- messages.properties DELETED --- |
From: Santi B. <san...@us...> - 2007-12-11 00:38:31
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/build/com/babeldoc/conversion/module In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17594/modules/conversion/build/com/babeldoc/conversion/module Removed Files: ConversionModule.class Log Message: Minor update. Project reorganization. --- ConversionModule.class DELETED --- |
From: Santi B. <san...@us...> - 2007-12-11 00:38:31
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/build/com/babeldoc/conversion In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17594/modules/conversion/build/com/babeldoc/conversion Removed Files: ConversionException.class ConversionHelper.class Log Message: Minor update. Project reorganization. --- ConversionHelper.class DELETED --- --- ConversionException.class DELETED --- |
From: Santi B. <san...@us...> - 2007-12-11 00:38:31
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/build/com/babeldoc/conversion/flatfile/digester In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17594/modules/conversion/build/com/babeldoc/conversion/flatfile/digester Removed Files: InputDocument.class Field.class LineSegment.class DigesterConversionUnmarshaller.class Header.class OutputDocument.class Conversion.class Log Message: Minor update. Project reorganization. --- Conversion.class DELETED --- --- OutputDocument.class DELETED --- --- Field.class DELETED --- --- LineSegment.class DELETED --- --- Header.class DELETED --- --- DigesterConversionUnmarshaller.class DELETED --- --- InputDocument.class DELETED --- |
From: Santi B. <san...@us...> - 2007-12-11 00:38:31
|
Update of /cvsroot/babeldoc/babeldoc/modules/conversion/build/com/babeldoc/conversion/flatfile In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17594/modules/conversion/build/com/babeldoc/conversion/flatfile Removed Files: FlatFileConversionClient.class ConversionUnmarshaller.class FlatFileConverter.class LineSegmentData.class FieldData.class Log Message: Minor update. Project reorganization. --- ConversionUnmarshaller.class DELETED --- --- FlatFileConversionClient.class DELETED --- --- FlatFileConverter.class DELETED --- --- FieldData.class DELETED --- --- LineSegmentData.class DELETED --- |