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


Java ContentService.getWriter方法代码示例

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


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

示例1: canGuessMimeType

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
@Test
public void canGuessMimeType()
{
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    
    ContentService contentService = (ContentService) ctx.getBean("ContentService");
    NodeService nodeService = (NodeService) ctx.getBean("NodeService");
    StoreRef storeRef = nodeService.createStore("workspace", getClass().getName()+UUID.randomUUID());
    NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
    NodeRef nodeRef = nodeService.createNode(
                rootNodeRef,
                ContentModel.ASSOC_CHILDREN,
                QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, getClass().getSimpleName()),
                ContentModel.TYPE_CONTENT).getChildRef();

    ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
    // Pre-condition of test is that we're testing with a potentially problematic BackingStoreAwareCacheWriter
    // rather than a FileContentWriter, which we would expect to work.
    assertTrue(writer instanceof BackingStoreAwareCacheWriter);
    
    String content = "This is some content";
    writer.putContent(content);
    writer.guessMimetype("myfile.txt");
    
    assertEquals("text/plain", writer.getMimetype());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:FullTest.java

示例2: copyContentOnly

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
private void copyContentOnly(FileInfo sourceFileInfo, FileInfo destFileInfo, FileFolderService fileFolderService) throws WebDAVServerException
{
	ContentService contentService = getContentService();
    ContentReader reader = contentService.getReader(sourceFileInfo.getNodeRef(), ContentModel.PROP_CONTENT);
    if (reader == null)
    {
        // There is no content for the node if it is a folder
        if (!sourceFileInfo.isFolder())
        {
            // Non-folders should have content available.
            logger.error("Unable to get ContentReader for source node " + sourceFileInfo.getNodeRef());
            throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
        }
    }
    else
    {
        ContentWriter contentWriter = contentService.getWriter(destFileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true);
        contentWriter.putContent(reader);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:MoveMethod.java

示例3: delete

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
 * Delete the content stream
 */
public void delete()
{
    ContentService contentService = services.getContentService();
    ContentWriter writer = contentService.getWriter(nodeRef, this.property, true);
    OutputStream output = writer.getContentOutputStream();
    try
    {
        output.close();
    }
    catch (IOException e)
    {
        // NOTE: fall-through
    }
    writer.setMimetype(null);
    writer.setEncoding(null);
    
    // update cached variables after putContent()
    updateContentData(true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:ScriptNode.java

示例4: writeContent

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
 * Write content to the node from InputStream.
 * 
 * @param nodeRef Target node.
 * @param content Content stream.
 * @param mimetype MIME content type.
 * @param encoding Encoding. Can be null for text based content, n which case the best guess.
 */
protected void writeContent(NodeRef nodeRef, InputStream content, String mimetype, String encoding)
{
    InputStream bis = new BufferedInputStream(content, 4092);

    // Only guess the encoding if it has not been supplied
    if (encoding == null)
    {
        if (mimetypeService.isText(mimetype))
        {
            ContentCharsetFinder charsetFinder = mimetypeService.getContentCharsetFinder();
            encoding = charsetFinder.getCharset(bis, mimetype).name();
        }
        else
        {
            encoding = "UTF-8";
        }
    }
    
    if (log.isDebugEnabled())
    {
        log.debug("Write content (MimeType=\"" + mimetype + "\", Encoding=\"" + encoding + "\"");
    }
    
    
    ContentService contentService = getContentService();
    ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
    writer.setMimetype(mimetype);
    writer.setEncoding(encoding);
    writer.putContent(bis);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:39,代码来源:AbstractEmailMessageHandler.java

示例5: writeSpace

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
 * This method writes space as a content. We need this space because rules doesn't proceed documents with empty content. We need rule processing for command email messages with
 * empty body.
 * 
 * @param nodeRef Reference to the parent node
 */
private void writeSpace(NodeRef nodeRef)
{
    if (log.isDebugEnabled())
    {
        log.debug("Write space string");
    }

    ContentService contentService = getContentService();
    ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    writer.setEncoding("UTF-8");
    writer.putContent(" ");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:FolderEmailMessageHandler.java

示例6: transformNode

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
 * Generic method to transform Node content from one mimetype to another.
 * 
 * @param transformer   The Transformer delegate supplying the transformation logic
 * @param mimetype      Mimetype of the destination content
 * @param destination   Destination folder location for the resulting document
 * 
 * @return Node representing the transformed content - or null if the transform failed
 */
private ScriptNode transformNode(Transformer transformer, String mimetype, NodeRef destination)
{
    ScriptNode transformedNode = null;
    
    // get the content reader
    ContentService contentService = this.services.getContentService();
    ContentReader reader = contentService.getReader(this.nodeRef, ContentModel.PROP_CONTENT);
    
    // only perform the transformation if some content is available
    if (reader != null)
    {
        // Copy the content node to a new node
        String copyName = TransformActionExecuter.transformName(this.services.getMimetypeService(), getName(),
                mimetype, true);
        NodeRef copyNodeRef = this.services.getCopyService().copy(this.nodeRef, destination,
                ContentModel.ASSOC_CONTAINS,
                QName.createQName(ContentModel.PROP_CONTENT.getNamespaceURI(), QName.createValidLocalName(copyName)),
                false);
        
        // modify the name of the copy to reflect the new mimetype
        this.nodeService.setProperty(copyNodeRef, ContentModel.PROP_NAME, copyName);
        
        // get the writer and set it up
        ContentWriter writer = contentService.getWriter(copyNodeRef, ContentModel.PROP_CONTENT, true);
        writer.setMimetype(mimetype); // new mimetype
        writer.setEncoding(reader.getEncoding()); // original encoding
        
        // Try and transform the content using the supplied delegate
        transformedNode = transformer.transform(contentService, copyNodeRef, reader, writer);
    }
    
    return transformedNode;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:43,代码来源:ScriptNode.java

示例7: setContent

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
 * Set the content stream
 * 
 * @param content    Content string to set
 */
public void setContent(String content)
{
    ContentService contentService = services.getContentService();
    ContentWriter writer = contentService.getWriter(nodeRef, this.property, true);
    writer.setMimetype(getMimetype()); // use existing mimetype value
    writer.putContent(content);
    
    // update cached variables after putContent()
    updateContentData(true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:ScriptNode.java

示例8: write

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
 * Set the content stream from another content object.
 *  
 * @param content  ScriptContent to set
 */
public void write(Content content)
{
    ContentService contentService = services.getContentService();
    ContentWriter writer = contentService.getWriter(nodeRef, this.property, true);
    writer.setMimetype(content.getMimetype());
    writer.setEncoding(content.getEncoding());
    writer.putContent(content.getInputStream());

    // update cached variables after putContent()
    updateContentData(true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:ScriptNode.java

示例9: createAvatarDirect

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
private NodeRef createAvatarDirect(NodeRef personRef, File avatarFile)
{
    // create new avatar node
    nodeService.addAspect(personRef, ContentModel.ASPECT_PREFERENCES, null);
    ChildAssociationRef assoc = nodeService.createNode(
            personRef,
            ContentModel.ASSOC_PREFERENCE_IMAGE,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "origAvatar"),
            ContentModel.TYPE_CONTENT);
    final NodeRef avatarRef = assoc.getChildRef();

    // JSF client compatibility?
    nodeService.createAssociation(personRef, avatarRef, ContentModel.ASSOC_AVATAR);

    // upload the avatar content
    ContentService contentService = applicationContext.getBean("ContentService", ContentService.class);
    ContentWriter writer = contentService.getWriter(avatarRef, ContentModel.PROP_CONTENT, true);
    writer.guessMimetype(avatarFile.getName());
    writer.putContent(avatarFile);

    Rendition avatarR = new Rendition();
    avatarR.setId("avatar");
    Renditions renditions = applicationContext.getBean("Renditions", Renditions.class);
    renditions.createRendition(avatarRef.getId(), avatarR, false, null);

    return avatarRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:28,代码来源:TestPeople.java

示例10: testLifecycleOfXmlMetadataExtraction

import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
 * Tests metadata extraction using an action with an EAGER MetadataExtracter for XML.
 */
public void testLifecycleOfXmlMetadataExtraction() throws Exception
{
    NodeService nodeService = serviceRegistry.getNodeService();
    ContentService contentService = serviceRegistry.getContentService();
    ActionExecuter executer = (ActionExecuter) ctx.getBean("extract-metadata");
    Action action = new ActionImpl(null, GUID.generate(), SetPropertyValueActionExecuter.NAME, null);
    
    StoreRef storeRef = new StoreRef("test", getName());
    NodeRef rootNodeRef = null;
    if (nodeService.exists(storeRef))
    {
        rootNodeRef = nodeService.getRootNode(storeRef);
    }
    else
    {
        nodeService.createStore("test", getName());
        rootNodeRef = nodeService.getRootNode(storeRef);
    }
    
    // Set up some properties
    PropertyMap properties = new PropertyMap();
    properties.put(ContentModel.PROP_TITLE, "My title");
    properties.put(ContentModel.PROP_DESCRIPTION, "My description");
    
    NodeRef contentNodeRef = nodeService.createNode(
            rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, getName()),
            ContentModel.TYPE_CONTENT,
            properties).getChildRef();
    // Add some content
    ContentReader alfrescoModelReader = getReader(FILE_ALFRESCO_MODEL);
    assertTrue(alfrescoModelReader.exists());
    ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true);
    writer.setEncoding("UTF-8");
    writer.setMimetype(MimetypeMap.MIMETYPE_XML);
    writer.putContent(alfrescoModelReader);
    
    // Execute the action
    executer.execute(action, contentNodeRef);
    
    // Check the node's properties.  The EAGER overwrite policy should have replaced the required
    // properties.
    String checkTitle = (String) nodeService.getProperty(contentNodeRef, ContentModel.PROP_TITLE);
    String checkDescription = (String) nodeService.getProperty(contentNodeRef, ContentModel.PROP_DESCRIPTION);
    assertEquals("fm:forummodel", checkTitle);
    assertEquals("Forum Model", checkDescription);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:52,代码来源:XmlMetadataExtracterTest.java


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