本文整理汇总了Java中org.alfresco.repo.content.filestore.FileContentReader类的典型用法代码示例。如果您正苦于以下问题:Java FileContentReader类的具体用法?Java FileContentReader怎么用?Java FileContentReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileContentReader类属于org.alfresco.repo.content.filestore包,在下文中一共展示了FileContentReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testProjectTrivialDiffProjectFiles
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的package包/类
/**
* Open and close of a project file changes certain header properties.
* Test File 1 has been opened and closed.
* @throws Exception
*/
public void testProjectTrivialDiffProjectFiles() throws Exception
{
CIFSContentComparator contentComparator = new CIFSContentComparator();
contentComparator.init();
ClassPathResource file0Resource = new ClassPathResource("filesys/ContentComparatorTest0.mpp");
assertNotNull("unable to find test resource filesys/ContentComparatorTest0.mpp", file0Resource);
ClassPathResource file1Resource = new ClassPathResource("filesys/ContentComparatorTest1.mpp");
assertNotNull("unable to find test resource filesys/ContentComparatorTest1.mpp", file1Resource);
/**
* Compare trivially different project files, should ignore trivial differences and be equal
*/
{
File file0 = file0Resource.getFile();
File file1 = file1Resource.getFile();
ContentReader reader = new FileContentReader(file0);
reader.setMimetype("application/vnd.ms-project");
reader.setEncoding("UTF-8");
boolean result = contentComparator.isContentEqual(reader, file1);
assertTrue("compare trivially different project file, should be equal", result);
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:CIFSContentComparatorTest.java
示例2: testHtmlSpecialCharsToText
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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: getReader
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的package包/类
@Override
public ContentReader getReader(String contentUrl)
{
Key url = Key.forUrl(contentUrl);
if (memoryStore.contains(url))
{
String path = memoryStore.get(url);
// Getting the path for a URL from the memoryStore will reset the timeToIdle for
// that URL. It is important to perform a reverse lookup as well to ensure that the
// cache file path to URL mapping is also kept in the cache.
memoryStore.get(Key.forCacheFile(path));
File cacheFile = new File(path);
if (cacheFile.exists())
{
return new FileContentReader(cacheFile, contentUrl);
}
}
throw new CacheMissException(contentUrl);
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:ContentCacheImpl.java
示例4: loadDiskUsage
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的package包/类
private void loadDiskUsage()
{
File usageFile = new File(cache.getCacheRoot(), CACHE_USAGE_FILENAME);
if (!usageFile.exists())
{
setCurrentUsageBytes(DEFAULT_DISK_USAGE_ESTIMATE);
if (log.isInfoEnabled())
{
log.info("No previous usage file found (" + usageFile + ") so assuming: " +
getCurrentUsageBytes() + " bytes.");
}
}
else
{
FileContentReader reader = new FileContentReader(usageFile);
String usageStr = reader.getContentString();
long usage = Long.parseLong(usageStr);
currentUsageBytes.set(usage);
if (log.isInfoEnabled())
{
log.info("Using last known disk usage estimate: " + getCurrentUsageBytes());
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:StandardQuotaStrategy.java
示例5: buildContentReader
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的package包/类
/**
* Writes the supplied text out to a temporary file, and opens
* a content reader onto it.
*/
protected static ContentReader buildContentReader(String text, Charset encoding)
throws IOException
{
File tmpFile = TempFileProvider.createTempFile("AlfrescoTest_", ".txt");
FileOutputStream out = new FileOutputStream(tmpFile);
OutputStreamWriter wout = new OutputStreamWriter(out, encoding);
wout.write(text);
wout.close();
out.close();
ContentReader reader = new FileContentReader(tmpFile);
reader.setEncoding(encoding.displayName());
reader.setMimetype("text/plain");
return reader;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:AbstractContentTransformerTest.java
示例6: testCsvOutput
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例7: testHtmlToPdf
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例8: testEmptyHtmlToEmptyPdf
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例9: testMsgToText
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例10: testUnicodeMsgToText
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例11: testNonUnicodeChineseMsgToText
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例12: testMediaWikiToHTML
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例13: testRFC822ToText
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例14: testNonAsciiRFC822ToText
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例15: testRFC822WithAttachmentToText
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例16: testRFC822AlternativeToText
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例17: testRFC822NestedAlternativeToText
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的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
示例18: canGetReaderForItemInCacheHavingLiveFile
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的package包/类
@Test
public void canGetReaderForItemInCacheHavingLiveFile()
{
final String url = "store://content/url.bin";
Mockito.when(lookupTable.contains(Key.forUrl(url))).thenReturn(true);
final String path = tempfile().getAbsolutePath();
Mockito.when(lookupTable.get(Key.forUrl(url))).thenReturn(path);
FileContentReader reader = (FileContentReader) contentCache.getReader(url);
assertEquals("Reader should have correct URL", url, reader.getContentUrl());
assertEquals("Reader should be for correct cached content file", path, reader.getFile().getAbsolutePath());
// Important the get(path) was called, so that the timeToIdle is reset
// for the 'reverse lookup' as well as the URL to path mapping.
Mockito.verify(lookupTable).get(Key.forCacheFile(path));
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:ContentCacheImplTest.java
示例19: openAndCheck
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的package包/类
private Map<String, Serializable> openAndCheck(String fileBase, String expMimeType) throws Throwable {
// Get the mimetype via the MimeTypeMap
// (Uses Tika internally for the detection)
File file = open(fileBase);
ContentReader detectReader = new FileContentReader(file);
String mimetype = mimetypeMap.guessMimetype(fileBase, detectReader);
assertEquals("Wrong mimetype for " + fileBase, mimetype, expMimeType);
// Ensure the Tika Auto parser actually handles this
assertTrue("Mimetype should be supported but isn't: " + mimetype, extracter.isSupported(mimetype));
// Now create our proper reader
ContentReader sourceReader = new FileContentReader(file);
sourceReader.setMimetype(mimetype);
// And finally do the properties extraction
return extracter.extractRaw(sourceReader);
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:TikaAutoMetadataExtracterTest.java
示例20: getReader
import org.alfresco.repo.content.filestore.FileContentReader; //导入依赖的package包/类
/**
* Get a reader for a file that should be on the classpath.
*/
private static final ContentReader getReader(String fileName) throws FileNotFoundException
{
URL url = AbstractContentTransformerTest.class.getClassLoader().getResource(fileName);
if (url == null)
{
throw new FileNotFoundException("Could not find file on classpath: " + fileName);
}
File file = new File(url.getFile());
if (!file.exists())
{
throw new FileNotFoundException("Could not find file on classpath: " + fileName);
}
ContentReader reader = new FileContentReader(file);
reader.setMimetype(MimetypeMap.MIMETYPE_XML);
return reader;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:XmlMetadataExtracterTest.java
注:本文中的org.alfresco.repo.content.filestore.FileContentReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论