本文整理汇总了Java中org.alfresco.repo.content.filestore.FileContentWriter类的典型用法代码示例。如果您正苦于以下问题:Java FileContentWriter类的具体用法?Java FileContentWriter怎么用?Java FileContentWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileContentWriter类属于org.alfresco.repo.content.filestore包,在下文中一共展示了FileContentWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: testZeroLengthFile
import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
public void testZeroLengthFile() throws Exception
{
MetadataExtracter extractor = getExtracter();
File file = TempFileProvider.createTempFile(getName(), ".bin");
ContentWriter writer = new FileContentWriter(file);
writer.getContentOutputStream().close();
ContentReader reader = writer.getReader();
// Try the zero length file against all supported mimetypes.
// Note: Normally the reader would need to be fetched for each access, but we need to be sure
// that the content is not accessed on the reader AT ALL.
PropertyMap properties = new PropertyMap();
List<String> mimetypes = mimetypeMap.getMimetypes();
for (String mimetype : mimetypes)
{
if (!extractor.isSupported(mimetype))
{
// Not interested
continue;
}
reader.setMimetype(mimetype);
extractor.extract(reader, properties);
assertEquals("There should not be any new properties", 0, properties.size());
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:AbstractMetadataExtracterTest.java
示例17: testDITAFileWithoutDoctype
import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
public void testDITAFileWithoutDoctype() throws Exception
{
// Munge the file to skip the doctype
ContentReader reader = getReader(FILE_DITA_FILE);
assertTrue(reader.exists());
String contents = reader.getContentString();
String noDocType = contents.replaceAll("<!DOCTYPE.*?>", "");
File tmp = File.createTempFile("alfresco", ".xml");
tmp.deleteOnExit();
ContentWriter w = new FileContentWriter(tmp);
w.setEncoding(reader.getEncoding());
w.setMimetype(reader.getMimetype());
w.putContent(noDocType);
// Now test extraction
doTestDITAFile(w.getReader());
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:XmlMetadataExtracterTest.java
示例18: cleanupTemporaryContent
import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
protected void cleanupTemporaryContent()
{
// check if we can trigger eager clean up
// (standard temp lifetime of between 1:00 and 1:59 hours just causes too much build-up)
if (this.temporaryWriter instanceof FileContentWriter)
{
final File tempFile = ((FileContentWriter) this.temporaryWriter).getFile();
if (tempFile.exists() && !tempFile.delete())
{
tempFile.deleteOnExit();
}
}
else
{
try
{
this.temporaryContentStore.delete(this.temporaryWriter.getContentUrl());
}
catch (final UnsupportedOperationException uoe)
{
LOGGER.debug("Temporary content store does not support delete", uoe);
}
}
}
开发者ID:Acosix,项目名称:alfresco-simple-content-stores,代码行数:25,代码来源:DeduplicatingContentWriter.java
示例19: testHtmlToPdf
import org.alfresco.repo.content.filestore.FileContentWriter; //导入依赖的package包/类
/**
* Test what is up with HTML to PDF
*/
public void testHtmlToPdf() throws Exception
{
if (!worker.isAvailable())
{
// no connection
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,项目名称:community-edition-old,代码行数:20,代码来源:OpenOfficeContentTransformerTest.java
示例20: 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 (!worker.isAvailable())
{
// no connection
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,项目名称:community-edition-old,代码行数:27,代码来源:OpenOfficeContentTransformerTest.java
注:本文中的org.alfresco.repo.content.filestore.FileContentWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论