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


Java ContentWriter.guessMimetype方法代码示例

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


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

示例1: canGuessMimeType

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

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
@Override
public ContentWriter getWriter(NodeRef nodeRef)
{
    FileInfo fileInfo = toFileInfo(nodeRef, false);
    if (fileInfo.isFolder())
    {
        throw new InvalidTypeException("Unable to get a content writer for a folder: " + fileInfo);
    }
    final ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
    // Ensure that a mimetype is set based on the filename (ALF-6560)
    // This has been removed from the create code in 3.4 to prevent insert-update behaviour
    // of the ContentData.
    if (writer.getMimetype() == null)
    {
        final String name = fileInfo.getName();
        writer.guessMimetype(name);
    }
    // Done
    return writer;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:FileFolderServiceImpl.java

示例3: writeData

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
private void writeData(String fileName, final NodeRef fileNodeRef) 
{
    nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_NO_CONTENT, null);
    // Access the content
    ContentWriter writer = fileFolderService.getWriter(fileNodeRef);

    // set content properties
    writer.guessMimetype(fileName);
    writer.guessEncoding();

    // Get the input stream from the request data
    InputStream is = getClass().getClassLoader().getResourceAsStream(
          "farmers_markets_list_2003.doc");

    // Write the new data to the content node
    writer.putContent(is);

    // write info about author
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.SYSTEM_USER_NAME);
    this.transactionService.getRetryingTransactionHelper().doInTransaction(
    new RetryingTransactionCallback<Void>() {
       public Void execute() throws Throwable 
       {
          // Create the action
          Action action = actionService.createAction(ContentMetadataExtracter.EXECUTOR_NAME);
          try 
          {
             actionService.executeAction(action, fileNodeRef);
          }
          catch (Throwable th) 
          {
             // do nothing
          }
          return null;
       }
    });
    AuthenticationUtil.popAuthentication();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:40,代码来源:LockableAspectInterceptorTest.java

示例4: createAvatarDirect

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


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