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


Java ContentReader.getContentString方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentReader.getContentString方法的典型用法代码示例。如果您正苦于以下问题:Java ContentReader.getContentString方法的具体用法?Java ContentReader.getContentString怎么用?Java ContentReader.getContentString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.repository.ContentReader的用法示例。


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

示例1: testHtmlSpecialCharsToText

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的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

示例2: transformInternal

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
@Override
protected void transformInternal(ContentReader reader,
        ContentWriter writer, TransformationOptions options)
        throws Exception
{
    // Do not actually perform any transformation. The test above is only interested in whether
    // an exception is thrown and handled.
    if (logger.isInfoEnabled())
    {
        logger.info(springBeanName + " is attempting a transformation");
    }

    reader.getContentString();
    
    if (alwaysFail)
    {
        throw new AlfrescoRuntimeException("Test code intentionally failed method call.");
    }
    else
    {
        return;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:FailoverContentTransformerTest.java

示例3: testRFC822AlternativeToText

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的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

示例4: testNonAsciiRFC822ToText

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的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

示例5: checkContentDetails

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
private void checkContentDetails(NodeRef node, String expectedName, String expectedTitle, 
            String expectedMimetype, String expectedContent)
{
    Map<QName, Serializable> props = this.nodeService.getProperties(node);
    String name = (String)props.get(ContentModel.PROP_NAME);
    String title = (String)props.get(ContentModel.PROP_TITLE);
    assertEquals(expectedName, name);
    assertEquals(expectedTitle, title);
    
    ContentData contentData = (ContentData) this.nodeService.getProperty(node, ContentModel.PROP_CONTENT);
    assertNotNull(contentData);
    String mimetype = contentData.getMimetype();
    assertEquals(expectedMimetype, mimetype);
    
    ContentReader reader = this.contentService.getReader(node, ContentModel.PROP_CONTENT);
    assertNotNull(reader);
    String content = reader.getContentString();
    assertEquals(expectedContent, content);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:FormServiceImplTest.java

示例6: testCopyCommand

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的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

示例7: testConcurrentWritesNoTxn

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
 * Checks that multiple writes can occur to the same node outside of any transactions.
 * <p>
 * It is only when the streams are closed that the node is updated.
 */
public void testConcurrentWritesNoTxn() throws Exception
{
    // ensure that the transaction is ended - ofcourse, we need to force a commit
    txn.commit();
    txn = null;
    
    ContentWriter writer1 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
    ContentWriter writer2 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
    ContentWriter writer3 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
    
    writer1.putContent("writer1 wrote this");
    writer2.putContent("writer2 wrote this");
    writer3.putContent("writer3 wrote this");

    // get the content
    ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
    String contentCheck = reader.getContentString();
    assertEquals("Content check failed", "writer3 wrote this", contentCheck);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:RoutingContentServiceTest.java

示例8: testGetContentString_01

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
public void testGetContentString_01()
{
    // To URL
    String url = SpoofedTextContentReader.createContentUrl(Locale.ENGLISH, 12345L, 56L, "harry");
    // To Reader
    ContentReader reader = new SpoofedTextContentReader(url);
    String readerText = reader.getContentString();
    assertEquals("harry have voice the from countered growth invited      ", readerText);
    // Cannot repeat
    try
    {
        reader.getContentString();
        fail("Should not be able to reread content.");
    }
    catch (ContentIOException e)
    {
        // Expected
    }
    // Get a new Reader
    reader = reader.getReader();
    // Get exactly the same text
    assertEquals(readerText, reader.getContentString());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:SpoofedTextContentReaderTest.java

示例9: testAutoSettingOfProperties

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
 * Checks that the URL, mimetype and encoding are automatically set on the readers
 * and writers
 */
public void testAutoSettingOfProperties() throws Exception
{
    // get a writer onto the node
    ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
    assertNotNull("Writer should not be null", writer);
    assertNotNull("Content URL should not be null", writer.getContentUrl());
    assertNotNull("Content mimetype should not be null", writer.getMimetype());
    assertNotNull("Content encoding should not be null", writer.getEncoding());
    assertNotNull("Content locale should not be null", writer.getLocale());
    
    // write some content
    writer.putContent(SOME_CONTENT);
    
    // get the reader
    ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
    assertNotNull("Reader should not be null", reader);
    assertNotNull("Content URL should not be null", reader.getContentUrl());
    assertNotNull("Content mimetype should not be null", reader.getMimetype());
    assertNotNull("Content encoding should not be null", reader.getEncoding());
    assertNotNull("Content locale should not be null", reader.getLocale());
    
    // check that the content length is correct
    // - note encoding is important as we get the byte length
    long length = SOME_CONTENT.getBytes(reader.getEncoding()).length;  // ensures correct decoding
    long checkLength = reader.getSize();
    assertEquals("Content length incorrect", length, checkLength);

    // check the content - the encoding will come into effect here
    String contentCheck = reader.getContentString();
    assertEquals("Content incorrect", SOME_CONTENT, contentCheck);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:36,代码来源:RoutingContentServiceTest.java

示例10: buildPost

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
private PostInfo buildPost(NodeRef nodeRef, TopicInfo topic, String name, String preLoadedContents)
{
   PostInfoImpl post = new PostInfoImpl(nodeRef, name, topic);
   
   // Grab all the properties, we need the bulk of them anyway
   Map<QName,Serializable> props = nodeService.getProperties(nodeRef);
   
   // Start with the auditable properties
   post.setCreator((String)props.get(ContentModel.PROP_CREATOR));
   post.setModifier((String)props.get(ContentModel.PROP_MODIFIER));
   post.setCreatedAt((Date)props.get(ContentModel.PROP_CREATED));
   post.setModifiedAt((Date)props.get(ContentModel.PROP_MODIFIED));
   post.setUpdatedAt((Date)props.get(ContentModel.PROP_UPDATED));
   
   // Now do the discussion ones
   post.setTitle((String)props.get(ContentModel.PROP_TITLE));
   
   // Finally, do the content
   String contents = preLoadedContents;
   if (contents == null)
   {
      ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
      if (reader != null)
      {
         contents = reader.getContentString();
      }
   }
   post.setContents(contents);
   
   // All done
   return post;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:DiscussionServiceImpl.java

示例11: testImportXMLDocument

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
public void testImportXMLDocument() throws Exception
{
    try
    {
        FileInfo file = createXmlFile(companyHome);
        createXmlFile(companyHome, "TestTableXML.xml", testTableXml);
        FileInfo testImportTable = createXmlFile(companyHome, "TestImportTableXML.xml", testImportTableXml);

        RenditionDefinition def = renditionService.createRenditionDefinition(QName.createQName("Test"), XSLTRenderingEngine.NAME);
        def.setParameterValue(XSLTRenderingEngine.PARAM_TEMPLATE_NODE, testImportTable.getNodeRef());

        ChildAssociationRef rendition = renditionService.render(file.getNodeRef(), def);
        
        assertNotNull(rendition);
        
        ContentReader reader = contentService.getReader(rendition.getChildRef(), ContentModel.PROP_CONTENT);
        assertNotNull(reader);
        String output = reader.getContentString();
        
        log.debug("XSLT Processor output: " + output);
        Diff myDiff = new Diff("<html>\n<body>\n<h2>My CD Collection</h2>\n<table border=\"1\">\n<tr bgcolor=\"#9acd32\">\n<th>Title</th><th>Artist</th>\n</tr>\n<tr>\n<td></td><td></td>\n</tr>\n</table>\n</body>\n</html>\n", output);
        assertTrue("Pieces of XML are similar " + myDiff, myDiff.similar());
    }
    catch (Exception ex)
    {
        log.error("Error!", ex);
        fail();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:XSLTRenderingEngineTest.java

示例12: filesInCacheAreNotDeleted

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
@Test
public void filesInCacheAreNotDeleted() throws InterruptedException
{
    cleaner.setMaxDeleteWatchCount(0);
    
    // The SlowContentStore will always give out content when asked,
    // so asking for any content will cause something to be cached.
    String url = makeContentUrl();
    int numFiles = 50;
    for (int i = 0; i < numFiles; i++)
    {
        ContentReader reader = cachingStore.getReader(url);
        reader.getContentString();
    }
    
    cleaner.execute();
    
    Thread.sleep(400);
    while (cleaner.isRunning())
    {
        Thread.sleep(200);
    }
    
    for (int i = 0; i < numFiles; i++)
    {
        File cacheFile = new File(cache.getCacheFilePath(url));
        assertTrue("File should exist", cacheFile.exists());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:CachedContentCleanupJobTest.java

示例13: readTextContent

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
private String readTextContent(NodeRef nodeRef)
{
    ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
    assertNotNull("reader was null", reader);
    reader.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    return reader.getContentString();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:8,代码来源:RenditionServiceIntegrationTest.java

示例14: testParseXMLDocument

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
public void testParseXMLDocument() throws Exception
{
    try
    {
        FileInfo file = createXmlFile(companyHome);
        createXmlFile(companyHome, "TestXML.xml", sampleXML);
        FileInfo xslFile = createXmlFile(companyHome, callParseXmlDocument);

        RenditionDefinition def = renditionService.createRenditionDefinition(QName.createQName("Test"), XSLTRenderingEngine.NAME);
        def.setParameterValue(XSLTRenderingEngine.PARAM_TEMPLATE_NODE, xslFile.getNodeRef());

        ChildAssociationRef rendition = renditionService.render(file.getNodeRef(), def);
        
        assertNotNull(rendition);
        
        ContentReader reader = contentService.getReader(rendition.getChildRef(), ContentModel.PROP_CONTENT);
        assertNotNull(reader);
        String output = reader.getContentString();
        
        log.debug("XSLT Processor output: " + output);
        assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
    }
    catch (Exception ex)
    {
        log.error("Error!", ex);
        fail();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:XSLTRenderingEngineTest.java

示例15: testWriteAndReadString

import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
 * The simplest test.  Write a string and read it again, checking that we receive the same values.
 * If the resource accessed by {@link #getReader(String)} and {@link #getWriter()} is not the same, then
 * values written and read won't be the same.
 */
@Test
public void testWriteAndReadString() throws Exception
{
    ContentWriter writer = getWriter();
    
    String content = "ABC";
    writer.putContent(content);
    assertTrue("Stream close not detected", writer.isClosed());

    ContentReader reader = writer.getReader();
    String check = reader.getContentString();
    assertTrue("Read and write may not share same resource", check.length() > 0);
    assertEquals("Write and read didn't work", content, check);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:AbstractWritableContentStoreTest.java


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