From: Santi B. <san...@us...> - 2007-08-04 11:37:45
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv1742/modules/core/src/com/babeldoc/core/pipeline/stage Modified Files: FileWriterPipelineStage.java DecompressionPipelineStage.java SmtpWriterPipelineStage.java Log Message: 2007-08-04 Added readme/doc with javadoc generation 2007-03-15 Many changes: - MailboxScanner can filter by field TO - Can debug MailboxScanner - Add timeout connection parameter to MailboxScanner - MailboxScanner obtain the value of the properties: 'to', 'from' and 'reply to' - Add three parameters that they allowed to deny a regular expression from filters (to,from and reply) - Add encoding parameter to Pipeline Writefile - Pipeline HttpClient save cookie information - Add parameter to pipeline HttpClient. It indicates if we want copy attributes in the new document - Pipeline HttpClient can send files in the parameters of POST method. To Manage the MIME types automatically (from the extension of the file) when adding attached files - Names of attached files in SmtpWriterPipelineStage don't contains absolute path - When decompressing a file in DecompressionPipeline, the name and the extension of the decompressed file it's original name Index: FileWriterPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/FileWriterPipelineStage.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FileWriterPipelineStage.java 30 Jul 2004 01:33:04 -0000 1.8 --- FileWriterPipelineStage.java 4 Aug 2007 11:37:14 -0000 1.9 *************** *** 71,74 **** --- 71,75 ---- import com.babeldoc.core.pipeline.PipelineStageInfo; import com.babeldoc.core.pipeline.PipelineStageResult; + import com.babeldoc.core.LogService; import java.io.*; *************** *** 94,97 **** --- 95,99 ---- public static final String NEW_LINE = "newLine"; + /** * construct with this stages info. *************** *** 117,120 **** --- 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; *************** *** 157,182 **** * @param append append (or overwrite) mode * @param newLine newline character to use * @throws IOException */ public static void writeFileMessage(String outfile, String donefile, com.babeldoc.core.pipeline.PipelineDocument document, boolean append, ! boolean newLine) throws IOException { createPath(outfile); createPath(donefile); ! if (document.isBinary()) { ! FileOutputStream fos = new FileOutputStream(outfile, append); ! fos.write(document.getBytes()); ! fos.close(); ! } else { ! BufferedWriter writer = new BufferedWriter(new FileWriter(outfile, append)); ! writer.write(document.getContents()); ! if (newLine) { ! writer.newLine(); ! } ! writer.close(); ! } // Do the done file stuff --- 161,206 ---- * @param append append (or overwrite) mode * @param newLine newline character to use + * @param encoding Charset output encoding (default none) * @throws IOException */ public static void writeFileMessage(String outfile, String donefile, com.babeldoc.core.pipeline.PipelineDocument document, boolean append, ! boolean newLine,String encoding) throws IOException { createPath(outfile); createPath(donefile); ! ! if (document.isBinary()) { ! FileOutputStream fos = new FileOutputStream(outfile, append); ! fos.write(document.getBytes()); ! fos.close(); ! } 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) { ! writer.newLine(); ! } ! ! writer.close(); ! } ! ! 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())); ! ! if (newLine) { ! writer.newLine(); ! } ! ! writer.close(); ! } ! } // Do the done file stuff *************** *** 203,206 **** --- 227,232 ---- boolean newLine = "true".equalsIgnoreCase(this.getOptions(NEW_LINE)); + String encoding = this.getOptions(ENCODING); + // Get the donefile suffix if (this.hasOption(DONE_FILE)) { *************** *** 210,214 **** try { writeFileMessage(outfile, donefile, this.getContentDocument(), append, ! newLine); return super.processHelper(); --- 236,240 ---- try { writeFileMessage(outfile, donefile, this.getContentDocument(), append, ! newLine,encoding); return super.processHelper(); Index: SmtpWriterPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/SmtpWriterPipelineStage.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SmtpWriterPipelineStage.java 30 Jul 2004 01:33:04 -0000 1.14 --- SmtpWriterPipelineStage.java 4 Aug 2007 11:37:14 -0000 1.15 *************** *** 74,77 **** --- 74,78 ---- import com.babeldoc.core.pipeline.PipelineStage; import com.babeldoc.core.pipeline.PipelineStageResult; + import com.babeldoc.core.LogService; import java.io.IOException; *************** *** 267,271 **** //getChild all file names ! if (attachDoc && (fileNames != null) && !"".equals(fileNames)) { StringTokenizer st = new StringTokenizer(fileNames, "|"); filesToAttach = new ArrayList(); --- 268,273 ---- //getChild all file names ! //if (attachDoc && (fileNames != null) && !"".equals(fileNames)) { ! if ((fileNames != null) && !"".equals(fileNames)) { StringTokenizer st = new StringTokenizer(fileNames, "|"); filesToAttach = new ArrayList(); *************** *** 361,365 **** DataSource ds = new FileDataSource(fileName); attachment.setDataHandler(new DataHandler(ds)); ! attachment.setFileName(fileName); multipart.addBodyPart(attachment); } --- 363,368 ---- DataSource ds = new FileDataSource(fileName); attachment.setDataHandler(new DataHandler(ds)); ! //attachment.setFileName(fileName); ! attachment.setFileName((new java.io.File(fileName)).getName()); multipart.addBodyPart(attachment); } Index: DecompressionPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/DecompressionPipelineStage.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** DecompressionPipelineStage.java 30 Jul 2004 01:33:04 -0000 1.6 --- DecompressionPipelineStage.java 4 Aug 2007 11:37:14 -0000 1.7 *************** *** 128,135 **** * @param in the input stream (uncompressed) * @param compressType compression type * @throws IOException * @throws PipelineException */ ! public static void decompressData(OutputStream out, InputStream in, String compressType) throws IOException, PipelineException { //Create a buffer for reading raw bytes from the file. --- 128,136 ---- * @param in the input stream (uncompressed) * @param compressType compression type + * @return Arraylist with filenames * @throws IOException * @throws PipelineException */ ! public static ArrayList decompressData(OutputStream out, InputStream in, String compressType) throws IOException, PipelineException { //Create a buffer for reading raw bytes from the file. *************** *** 139,142 **** --- 140,144 ---- //Read from the file and write to the gzip archive. InputStream cis = null; + ArrayList entryNames = new ArrayList(); if ("gzip".equalsIgnoreCase(compressType)) { *************** *** 153,156 **** --- 155,159 ---- while ((entry = ((ZipInputStream) cis).getNextEntry()) != null) { //System.out.println(entry.getName()+":"+entry.getSize()); + entryNames.add(entry.getName()); while ((len = cis.read(buf)) > -1) { out.write(buf, 0, len); *************** *** 164,167 **** --- 167,171 ---- throw new PipelineException(I18n.get("100263") + ": " + compressType); } + return entryNames; } *************** *** 176,182 **** ByteArrayOutputStream baos = new ByteArrayOutputStream(getDocument() .getBytes().length * 2); ! try { ! decompressData(baos, in, this.getOptions(COMPRESS_TYPE)); } catch (IOException e) { throw new PipelineException(I18n.get("100271"), e); --- 180,186 ---- ByteArrayOutputStream baos = new ByteArrayOutputStream(getDocument() .getBytes().length * 2); ! ArrayList entryNames = new ArrayList(); try { ! entryNames = decompressData(baos, in, this.getOptions(COMPRESS_TYPE)); } catch (IOException e) { throw new PipelineException(I18n.get("100271"), e); *************** *** 186,191 **** --- 190,214 ---- PipelineDocument newDocument = new PipelineDocument(this.getDocument(), data); newDocument.setBinary(true); + newDocument.setName(formatEntryName(entryNames)); return super.processHelper(newDocument); } + + /** + * + * Create a name of descompress file + * + * @param entryNames Arraylist that it contains the filenames + * @return string with the filenames + */ + private String formatEntryName(ArrayList entryNames){ + String entryName = ""; + for (int i=0; i< entryNames.size(); i++){ + if(i==0) + entryName = entryNames.get(i).toString(); + else + entryName = entryName + "_" + entryNames.get(i).toString(); + } + return entryName; + } } |