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


Java ContentWriter.getContentData方法代码示例

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


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

示例1: testMissingContent

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
/**
 * Checks what happens when the physical content disappears
 */
public void testMissingContent() throws Exception
{
    File tempFile = TempFileProvider.createTempFile(getName(), ".txt");
    
    ContentWriter writer = new FileContentWriter(tempFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    writer.setEncoding("UTF-8");
    writer.putContent("What about the others?  Buckwheats!");
    // check
    assertTrue("File does not exist", tempFile.exists());
    assertTrue("File not written to", tempFile.length() > 0);
    
    // update the node with this new info 
    ContentData contentData = writer.getContentData();
    nodeService.setProperty(contentNodeRef, ContentModel.PROP_CONTENT, contentData);
    
    // delete the content
    tempFile.delete();
    assertFalse("File not deleted", tempFile.exists());
    
    // now attempt to get the reader for the node
    ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
    assertFalse("Reader should indicate that content is missing", reader.exists());
    
    // check the indexing doesn't spank everthing
    txn.commit();
    txn = null;

    // cleanup
    txn = getUserTransaction();
    txn.begin();
    nodeService.deleteNode(contentNodeRef);
    txn.commit();
    txn = null;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:39,代码来源:RoutingContentServiceTest.java

示例2: createContent

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
private void createContent()
{
    final StoreRef storeRef = nodeService.createStore("test", "timings-" + GUID.generate());
    RetryingTransactionCallback<ContentData> testCallback = new RetryingTransactionCallback<ContentData>()
    {
        public ContentData execute() throws Throwable
        {
            ContentData contentData = null;
            
            for (int i = 0; i < numOrphans; i++)
            {
                // Create some content
                NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
                Map<QName, Serializable> properties = new HashMap<QName, Serializable>(13);
                properties.put(ContentModel.PROP_NAME, (Serializable)"test.txt");                    
                
                NodeRef contentNodeRef = nodeService.createNode(
                        rootNodeRef,
                        ContentModel.ASSOC_CHILDREN,
                        ContentModel.ASSOC_CHILDREN,
                        ContentModel.TYPE_CONTENT,
                        properties).getChildRef();
                
                ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
                
                
                writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
                writer.putContent("INITIAL CONTENT");
                
                contentData = writer.getContentData();
               
                // Delete the first node, bypassing archive
                nodeService.addAspect(contentNodeRef, ContentModel.ASPECT_TEMPORARY, null);
                nodeService.deleteNode(contentNodeRef);
            }
            
            // Done
            return contentData;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(testCallback);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:43,代码来源:DeletionMetricsRunner.java


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