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


Java ContentStreamImpl.setStream方法代码示例

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


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

示例1: createUniqueDocument

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入方法依赖的package包/类
private Document createUniqueDocument(Folder newFolder)
		throws UnsupportedEncodingException {
	String uniqueName = getUniqueName();
       Map<String, Object> uProperties = new HashMap<String, Object>();
       uProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
       uProperties.put(PropertyIds.NAME, uniqueName);
       
       ContentStreamImpl contentStream = new ContentStreamImpl();
       contentStream.setFileName("bob");
       String shortString = "short";
       contentStream.setStream(new ByteArrayInputStream(shortString.getBytes("UTF-8")));
       contentStream.setLength(new BigInteger("5"));
       contentStream.setMimeType("text/plain");
       
       Document uniqueDocument = newFolder.createDocument(uProperties, contentStream, VersioningState.MAJOR);
       return uniqueDocument;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:18,代码来源:CMISDataCreatorTest.java

示例2: DISABLED_testBasicFileOps

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入方法依赖的package包/类
public void DISABLED_testBasicFileOps()
{
    Repository repository = getRepository("admin", "admin");
    Session session = repository.createSession();
    Folder rootFolder = session.getRootFolder();
    // create folder
    Map<String,String> folderProps = new HashMap<String, String>();
    {
        folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
        folderProps.put(PropertyIds.NAME, getName() + "-" + GUID.generate());
    }
    Folder folder = rootFolder.createFolder(folderProps, null, null, null, session.getDefaultContext());
    
    Map<String, String> fileProps = new HashMap<String, String>();
    {
        fileProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
        fileProps.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt");
    }
    ContentStreamImpl fileContent = new ContentStreamImpl();
    {
        ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(getName(), ".txt"));
        writer.putContent("Ipsum and so on");
        ContentReader reader = writer.getReader();
        fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
        fileContent.setStream(reader.getContentInputStream());
    }
    folder.createDocument(fileProps, fileContent, VersioningState.MAJOR);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:OpenCmisLocalTest.java

示例3: getContentStream

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入方法依赖的package包/类
public ContentStream getContentStream(){

    	// compile data
        ContentStreamImpl result = new ContentStreamImpl();
        result.setFileName(getName());
            
        try {
            result.setLength(BigInteger.valueOf(getPropertyLength(getNode(), CMISConstants.GREG_DATA)));
            if(getNode().getContent() != null){
                String mimeType = getNode().getProperty(CMISConstants.GREG_MIMETYPE);
                result.setMimeType(mimeType);
                //result.setMimeType(getNode().getMediaType());
            } else {
                result.setMimeType(null);
            }
            if(getNode().getContent() != null){

                InputStream inputStream = getNode().getContentStream();
                result.setStream(new BufferedInputStream(inputStream));  // stream closed by consumer
            } else {
                result.setStream(null);
            }
        } catch (RegistryException e) {
            throw new CmisRuntimeException(e.getMessage(), e);
        }

        return result;
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:29,代码来源:RegistryDocument.java

示例4: testALF19320

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入方法依赖的package包/类
@Test
  public void testALF19320() throws Exception
  {
      final TestNetwork network1 = getTestFixture().getRandomNetwork();

      String username = "user" + System.currentTimeMillis();
PersonInfo personInfo = new PersonInfo(username, username, username, TEST_PASSWORD, null, null, null, null, null, null, null);
      TestPerson person1 = network1.createUser(personInfo);
      String person1Id = person1.getId();

      final String siteName = "site" + System.currentTimeMillis();

      TenantUtil.runAsUserTenant(new TenantRunAsWork<NodeRef>()
      {
          @Override
          public NodeRef doWork() throws Exception
          {
              SiteInformation siteInfo = new SiteInformation(siteName, siteName, siteName, SiteVisibility.PRIVATE);
              TestSite site = repoService.createSite(null, siteInfo);

              String name = GUID.generate();
		NodeRef folderNodeRef = repoService.createFolder(site.getContainerNodeRef(DOCUMENT_LIBRARY_CONTAINER_NAME), name);
              return folderNodeRef;
          }
      }, person1Id, network1.getId());

      // Create a document...
      publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, CMIS_VERSION_10, AlfrescoObjectFactoryImpl.class.getName());
      AlfrescoFolder docLibrary = (AlfrescoFolder)cmisSession.getObjectByPath("/Sites/" + siteName + "/documentLibrary");
      Map<String, String> properties = new HashMap<String, String>();
      {
          // create a document with 2 aspects
          properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled,P:cm:author");
          properties.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt");
      }
      ContentStreamImpl fileContent = new ContentStreamImpl();
      {
          ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(GUID.generate(), ".txt"));
          writer.putContent("Ipsum and so on");
          ContentReader reader = writer.getReader();
          fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
          fileContent.setStream(reader.getContentInputStream());
      }
      
      AlfrescoDocument doc = (AlfrescoDocument)docLibrary.createDocument(properties, fileContent, VersioningState.MAJOR);
      String versionLabel = doc.getVersionLabel();
assertEquals(CMIS_VERSION_10, versionLabel);

      AlfrescoDocument doc1 = (AlfrescoDocument)doc.getObjectOfLatestVersion(false);
      String versionLabel1 = doc1.getVersionLabel();
assertEquals(CMIS_VERSION_10, versionLabel1);
  }
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:54,代码来源:TestCMIS.java


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