当前位置: 首页>>代码示例>>Java>>正文


Java FileContentWriter类代码示例

本文整理汇总了Java中org.alfresco.repo.content.filestore.FileContentWriter的典型用法代码示例。如果您正苦于以下问题:Java FileContentWriter类的具体用法?Java FileContentWriter怎么用?Java FileContentWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileContentWriter类属于org.alfresco.repo.content.filestore包,在下文中一共展示了FileContentWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transformTextAndCheck

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
private void transformTextAndCheck(String text, String encoding, String checkText)
        throws IOException
{
    // Get a reader for the text
    ContentReader reader = buildContentReader(text, Charset.forName(encoding));
    
    // And a temp writer
    File out = TempFileProvider.createTempFile("AlfrescoTest_", ".pdf");
    ContentWriter writer = new FileContentWriter(out);
    writer.setMimetype("application/pdf");
    
    // Transform to PDF
    transformer.transform(reader, writer);
    
    // Read back in the PDF and check it
    PDDocument doc = PDDocument.load(out);
    PDFTextStripper textStripper = new PDFTextStripper();
    StringWriter textWriter = new StringWriter();
    textStripper.writeText(doc, textWriter);
    doc.close();
    
    String roundTrip = clean(textWriter.toString());
    
    assertEquals(
            "Incorrect text in PDF when starting from text in " + encoding,
            checkText, roundTrip
    );
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:TextToPdfContentTransformerTest.java

示例2: testHtmlSpecialCharsToText

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test transforming a valid eml with a html part containing html special characters to text
 */
public void testHtmlSpecialCharsToText() throws Exception
{
    File emlSourceFile = loadQuickTestFile("htmlChars.eml");
    File txtTargetFile = TempFileProvider.createTempFile("test6", ".txt");
    ContentReader reader = new FileContentReader(emlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);

    transformer.transform(reader, writer);

    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    String contentStr = reader2.getContentString();
    assertTrue(!contentStr.contains(HTML_SPACE_SPECIAL_CHAR));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:EMLTransformerTest.java

示例3: testCopyCommand

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
public void testCopyCommand() throws Exception
{
    String content = "<A><B></B></A>";
    // create the source
    File sourceFile = TempFileProvider.createTempFile(getName() + "_", ".txt");
    ContentWriter tempWriter = new FileContentWriter(sourceFile);
    tempWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    tempWriter.putContent(content);
    ContentReader reader = tempWriter.getReader(); 
    // create the target
    File targetFile = TempFileProvider.createTempFile(getName() + "_", ".xml");
    ContentWriter writer = new FileContentWriter(targetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_XML);
    
    // do the transformation
    transformer.transform(reader, writer);   // no options on the copy
    
    // make sure that the content was copied over
    ContentReader checkReader = writer.getReader();
    String checkContent = checkReader.getContentString();
    assertEquals("Content not copied", content, checkContent);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:RuntimeExecutableContentTransformerTest.java

示例4: testCsvOutput

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
public void testCsvOutput() throws Exception
{
   File sourceFile = AbstractContentTransformerTest.loadQuickTestFile("xls");
   ContentReader sourceReader = new FileContentReader(sourceFile);

   File targetFile = TempFileProvider.createTempFile(
         getClass().getSimpleName() + "_" + getName() + "_xls_",
         ".csv");
   ContentWriter targetWriter = new FileContentWriter(targetFile);
   
   sourceReader.setMimetype(MimetypeMap.MIMETYPE_EXCEL);
   targetWriter.setMimetype(MimetypeMap.MIMETYPE_TEXT_CSV);
   transformer.transform(sourceReader, targetWriter);
   
   ContentReader targetReader = targetWriter.getReader();
   String checkContent = targetReader.getContentString();
   
   additionalContentCheck(
         MimetypeMap.MIMETYPE_EXCEL, 
         MimetypeMap.MIMETYPE_TEXT_CSV, 
         checkContent
   );
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:PoiHssfContentTransformerTest.java

示例5: testHtmlToPdf

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test what is up with HTML to PDF
 */
public void testHtmlToPdf() throws Exception
{
    if (!isOpenOfficeWorkerAvailable())
    {
        // no connection
        System.err.println("ooWorker not available - skipping testHtmlToPdf !!");
        return;
    }
    File htmlSourceFile = loadQuickTestFile("html");
    File pdfTargetFile = TempFileProvider.createTempFile(getName() + "-target-", ".pdf");
    ContentReader reader = new FileContentReader(htmlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_HTML);
    ContentWriter writer = new FileContentWriter(pdfTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_PDF);
    
    transformer.transform(reader, writer);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:OpenOfficeContentTransformerTest.java

示例6: testEmptyHtmlToEmptyPdf

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * ALF-219. Transforamtion from .html to .pdf for empty file.
 * @throws Exception
 */
public void testEmptyHtmlToEmptyPdf() throws Exception
{
    if (!isOpenOfficeWorkerAvailable())
    {
        // no connection
        System.err.println("ooWorker not available - skipping testEmptyHtmlToEmptyPdf !!");
        return;
    }
    URL url = this.getClass().getClassLoader().getResource("misc/empty.html");
    assertNotNull("URL was unexpectedly null", url);

    File htmlSourceFile = new File(url.getFile());
    assertTrue("Test file does not exist.", htmlSourceFile.exists());
    
    File pdfTargetFile = TempFileProvider.createTempFile(getName() + "-target-", ".pdf");
    
    ContentReader reader = new FileContentReader(htmlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_HTML);
    ContentWriter writer = new FileContentWriter(pdfTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_PDF);
    
    transformer.transform(reader, writer);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:OpenOfficeContentTransformerTest.java

示例7: testMsgToText

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test transforming a valid msg file to text
 */
public void testMsgToText() throws Exception
{
    File msgSourceFile = loadQuickTestFile("msg");
    File txtTargetFile = TempFileProvider.createTempFile(getName() + "-target-1", ".txt");
    ContentReader reader = new FileContentReader(msgSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_OUTLOOK_MSG);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    
    transformer.transform(reader, writer);
    
    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    assertTrue(reader2.getContentString().contains(QUICK_CONTENT));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:MailContentTransformerTest.java

示例8: testUnicodeMsgToText

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test transforming a valid unicode msg file to text
 */
public void testUnicodeMsgToText() throws Exception
{
    File msgSourceFile = loadQuickTestFile("unicode.msg");
    File txtTargetFile = TempFileProvider.createTempFile(getName() + "-target-2", ".txt");
    ContentReader reader = new FileContentReader(msgSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_OUTLOOK_MSG);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    
    transformer.transform(reader, writer);
    
    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    assertTrue(reader2.getContentString().contains(QUICK_CONTENT));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:MailContentTransformerTest.java

示例9: testNonUnicodeChineseMsgToText

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test transforming a chinese non-unicode msg file to
 *  text
 */
public void testNonUnicodeChineseMsgToText() throws Exception
{
    File msgSourceFile = loadQuickTestFile("chinese.msg");
    File txtTargetFile = TempFileProvider.createTempFile(getName() + "-target-2", ".txt");
    ContentReader reader = new FileContentReader(msgSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_OUTLOOK_MSG);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    
    transformer.transform(reader, writer);
    
    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    
    // Check the quick text
    String text = reader2.getContentString();
    assertTrue(text.contains(QUICK_CONTENT));
    
    // Now check the non quick parts came out ok
    assertTrue(text.contains("(\u5f35\u6bd3\u502b)"));
    assertTrue(text.contains("\u683c\u5f0f\u6e2c\u8a66 )"));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:MailContentTransformerTest.java

示例10: testMediaWikiToHTML

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
public void testMediaWikiToHTML() throws Exception
{
   File input = TempFileProvider.createTempFile("mediaWikiTest", ".mw");
   FileOutputStream fos = new FileOutputStream(input);
   fos.write(WIKI_TEXT.getBytes());
   fos.close();
   
   File output = TempFileProvider.createTempFile("mediaWikiTest", ".htm");
   
   ContentReader contentReader = new FileContentReader(input);
   contentReader.setMimetype(MimetypeMap.MIMETYPE_TEXT_MEDIAWIKI);
   contentReader.setEncoding("UTF-8");
   
   ContentWriter contentWriter = new FileContentWriter(output);
   contentWriter.setMimetype(MimetypeMap.MIMETYPE_HTML);
   contentWriter.setEncoding("UTF-8");
   
   transformer.transform(contentReader, contentWriter);
   
   String line = null;
   BufferedReader reader = new BufferedReader(new FileReader(output));
   while ((line = reader.readLine()) != null) 
   {
       System.out.println(line);
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:MediaWikiContentTransformerTest.java

示例11: testRFC822ToText

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test transforming a valid eml file to text
 */
public void testRFC822ToText() throws Exception
{
    File emlSourceFile = loadQuickTestFile("eml");
    File txtTargetFile = TempFileProvider.createTempFile("test", ".txt");
    ContentReader reader = new FileContentReader(emlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);

    transformer.transform(reader, writer);

    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    assertTrue(reader2.getContentString().contains(QUICK_EML_CONTENT));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:EMLTransformerTest.java

示例12: testNonAsciiRFC822ToText

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test transforming a non-ascii eml file to text
 */
public void testNonAsciiRFC822ToText() throws Exception
{
    File emlSourceFile = loadQuickTestFile("spanish.eml");
    File txtTargetFile = TempFileProvider.createTempFile("test2", ".txt");
    ContentReader reader = new FileContentReader(emlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);

    transformer.transform(reader, writer);

    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    String contentStr = reader2.getContentString();
    assertTrue(contentStr.contains(QUICK_EML_CONTENT_SPANISH_UNICODE));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:EMLTransformerTest.java

示例13: testRFC822WithAttachmentToText

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test transforming a valid eml with an attachment to text; attachment should be ignored
 */
public void testRFC822WithAttachmentToText() throws Exception
{
    File emlSourceFile = loadQuickTestFile("attachment.eml");
    File txtTargetFile = TempFileProvider.createTempFile("test3", ".txt");
    ContentReader reader = new FileContentReader(emlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);

    transformer.transform(reader, writer);

    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    String contentStr = reader2.getContentString();
    assertTrue(contentStr.contains(QUICK_EML_WITH_ATTACHMENT_CONTENT));
    assertTrue(!contentStr.contains(QUICK_EML_ATTACHMENT_CONTENT));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:EMLTransformerTest.java

示例14: testRFC822AlternativeToText

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test transforming a valid eml with minetype multipart/alternative to text
 */
public void testRFC822AlternativeToText() throws Exception
{
    File emlSourceFile = loadQuickTestFile("alternative.eml");
    File txtTargetFile = TempFileProvider.createTempFile("test4", ".txt");
    ContentReader reader = new FileContentReader(emlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);

    transformer.transform(reader, writer);

    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    String contentStr = reader2.getContentString();
    assertTrue(contentStr.contains(QUICK_EML_ALTERNATIVE_CONTENT));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:EMLTransformerTest.java

示例15: testRFC822NestedAlternativeToText

import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
 * Test transforming a valid eml with nested mimetype multipart/alternative to text
 */
public void testRFC822NestedAlternativeToText() throws Exception
{
    File emlSourceFile = loadQuickTestFile("nested.alternative.eml");
    File txtTargetFile = TempFileProvider.createTempFile("test5", ".txt");
    ContentReader reader = new FileContentReader(emlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);

    transformer.transform(reader, writer);

    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    String contentStr = reader2.getContentString();
    assertTrue(contentStr.contains(QUICK_EML_NESTED_ALTERNATIVE_CONTENT));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:EMLTransformerTest.java


注:本文中的org.alfresco.repo.content.filestore.FileContentWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。