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


Java ContentStreamImpl类代码示例

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


ContentStreamImpl类属于org.apache.chemistry.opencmis.commons.impl.dataobjects包,在下文中一共展示了ContentStreamImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateDescriptorFile

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
@Override
public void updateDescriptorFile(String tenantId, String uuid, CMISEvidenceFile cmisFile) {
	Session session = createSession();
	Folder multitenantRootFolder = (Folder) session.getObjectByPath("/" + tenantId);
	Folder uuidFolder = getUuidFolder(session, uuid, multitenantRootFolder, repoFolderNestingLevels, true);
	for (CmisObject cmisObject : uuidFolder.getChildren()) {
		if (cmisObject.getType().getId().equals(CMISEvidenceFile.PROPERTY_DOC_ID)) {
			Document doc = (Document) cmisObject;
			if (doc.getName().equals(cmisFile.getFileName())) {
				Map<String, String> newDocProps = new HashMap<String, String>();
				newDocProps.put(CMISEvidenceFile.PROPERTY_TRANSACTION_STATUS, cmisFile.getTransactionStatus());
				doc.updateProperties(newDocProps);
				// Recover mime type from stored content
				ContentStream contentStream = new ContentStreamImpl(cmisFile.getFileName(), null, doc.getContentStreamMimeType(), cmisFile.getInputStream());
				doc.setContentStream(contentStream, true);
			} else {
				log.warn("Found unexpected CMIS object type in descriptor folder: " + cmisObject.getName() + " - " + cmisObject.getType().getId() + 
						" (expected " + cmisFile.getFileName() + ")");
			}
		}
	}
	
}
 
开发者ID:keensoft,项目名称:icearchiva,代码行数:24,代码来源:AtomBindingCMISClientImpl.java

示例2: invoke

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
public Object invoke(MethodInvocation mi) throws Throwable
{
    Class<?>[] parameterTypes = mi.getMethod().getParameterTypes();
    Object[] arguments = mi.getArguments();
    for (int i = 0; i < parameterTypes.length; i++)
    {
        if (arguments[i] instanceof ContentStreamImpl)
        {
        	ContentStreamImpl contentStream = (ContentStreamImpl) arguments[i];
            if (contentStream != null)
            {
                // ALF-18006
                if (contentStream.getMimeType() == null)
                {
                	InputStream stream = contentStream.getStream();
                    String mimeType = mimetypeService.guessMimetype(contentStream.getFileName(), stream);
                    contentStream.setMimeType(mimeType);
                }
            }
        }
    }
    return mi.proceed();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:AlfrescoCmisStreamInterceptor.java

示例3: 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

示例4: createDocument

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
public String createDocument(Folder parentFolder, String name, byte[] content) {
	logger.debug("Prepparing to create document");
    Document document = null;
    try{
    	Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.NAME, name);
        properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
        InputStream stream = new ByteArrayInputStream(content);
        ContentStream contentStream = new ContentStreamImpl(name,
                BigInteger.valueOf(content.length), "text/plain", stream);
        
        
        logger.info("Creating document in path: " + parentFolder.getPath());
        
        document = parentFolder.createDocument(properties, contentStream, null);
        logger.info("Document path: " + document.getPaths().get(0));
    }
    catch(Exception e){
    	logger.error("Failed to create document.", e);
    }
    
    return document.getPaths().get(0);
}
 
开发者ID:kylefernandadams,项目名称:cmis-jmeter-test,代码行数:24,代码来源:CmisHelper.java

示例5: uploadFile

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
private void uploadFile(String path, File file, Folder destinationFolder) throws FileNotFoundException {
  for (int x = 0; x < 3; x++) {
    try {
      Map<String, Serializable> properties = new HashMap<String, Serializable>();

      properties.put(PropertyIds.NAME, file.getName());
      properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");

      ContentStream contentStream = new ContentStreamImpl(file.getAbsolutePath(), BigInteger.valueOf(file.length()), _mimetype, new FileInputStream(file));

      _session.clear();

      Document document = destinationFolder.createDocument(properties, contentStream, VersioningState.MAJOR);

      getLog().info("Uploaded '" + file.getName() + "' to '" + path + "' with a document id of '" + document.getId() + "'");

      return;
    } catch (Exception ex) {
      getLog().debug("Upload failed, retrying...");
    }
  }
}
 
开发者ID:Redpill-Linpro,项目名称:artifact-upload-maven-plugin,代码行数:23,代码来源:CmisUploadMojo.java

示例6: 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

示例7: testDownloadEvent

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
public void testDownloadEvent() throws InterruptedException
{
    Repository repository = getRepository("admin", "admin");
    Session session = repository.createSession();
    Folder rootFolder = session.getRootFolder();
    String docname = "mydoc-" + GUID.generate() + ".txt";
    Map<String, String> props = new HashMap<String, String>();
    {
        props.put(PropertyIds.OBJECT_TYPE_ID, "D:cmiscustom:document");
        props.put(PropertyIds.NAME, docname);
    }
    
    // content
    byte[] byteContent = "Hello from Download testing class".getBytes();
    InputStream stream = new ByteArrayInputStream(byteContent);
    ContentStream contentStream = new ContentStreamImpl(docname, BigInteger.valueOf(byteContent.length), "text/plain", stream);

    Document doc1 = rootFolder.createDocument(props, contentStream, VersioningState.MAJOR);
    NodeRef doc1NodeRef = cmisIdToNodeRef(doc1.getId());
    
    ContentStream content = doc1.getContentStream();
    assertNotNull(content);
    
    //range request
    content = doc1.getContentStream(BigInteger.valueOf(2),BigInteger.valueOf(4));
    assertNotNull(content);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:OpenCmisLocalTest.java

示例8: makeContentStream

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
private ContentStreamImpl makeContentStream(String filename, String mimetype, String content) throws IOException
{
    TempStoreOutputStream tos = streamFactory.newOutputStream();
    OutputStreamWriter writer = new OutputStreamWriter(tos);
    writer.write(content);
    ContentStreamImpl contentStream = new ContentStreamImpl(filename, BigInteger.valueOf(tos.getLength()), MimetypeMap.MIMETYPE_TEXT_PLAIN, tos.getInputStream());
    return contentStream;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:9,代码来源:OpenCmisLocalTest.java

示例9: createFileFromUpload

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
@Override
public FileCustom createFileFromUpload(ByteArrayInOutStream file, String mimeType, String filename, 
		long length, String typeFichier, String prefixe, Candidature candidature, Boolean commune) throws FileException{
	try{
		String name = prefixe+"_"+filename;
		Map<String, Object> properties = new HashMap<String, Object>();
		properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());
		properties.put(PropertyIds.NAME, name);

		ByteArrayInputStream bis = file.getInputStream();
		ContentStream contentStream = new ContentStreamImpl(name, BigInteger.valueOf(length), mimeType, bis);	
		Folder master;
		if (typeFichier.equals(ConstanteUtils.TYPE_FICHIER_GESTIONNAIRE)){
			master = getFolderGestionnaire();
		}else{
			master = getFolderCandidature(candidature, commune);
		}
		
		//versioning
		VersioningState versioningState = VersioningState.NONE;
		if (enableVersioningCmis!=null && enableVersioningCmis){
			versioningState = VersioningState.MINOR;
		}
		
		Document d = master.createDocument(properties, contentStream, versioningState);
		file.close();
		bis.close();
		return getFileFromDoc(d,filename, prefixe);
	}catch(Exception e){
		logger.error("Stockage de fichier - CMIS : erreur de creation du fichier ",e);
		throw new FileException(applicationContext.getMessage("file.error.create", null, UI.getCurrent().getLocale()),e);
	}		
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:34,代码来源:FileManagerCmisImpl.java

示例10: putContent

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
public void putContent(String objectId, String filename, BigInteger length, String mimetype, InputStream content, boolean overwrite)
{
    CmisObject o = getObject(objectId);
    if(o instanceof Document)
    {
        Document d = (Document)o;
        ContentStream contentStream = new ContentStreamImpl(filename, length, mimetype, content);
        try
        {
            d.setContentStream(contentStream, overwrite);
        }
        finally
        {
            try
            {
                contentStream.getStream().close();
            }
            catch (Exception e)
            {
            }
        }
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a document");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:28,代码来源:PublicApiClient.java

示例11: getContentStream

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
@Override
public ContentStream getContentStream(String streamId, BigInteger offset, BigInteger length) {
    if (file == null) {
        return null;
    }
    try {
        return new ContentStreamImpl(name, length, mimeType, new FileInputStream(file));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:sismics,项目名称:play-cmis,代码行数:12,代码来源:DocumentImpl.java

示例12: putContent

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
public void putContent(String objectId, String filename, BigInteger length, String mimetype, InputStream content, boolean overwrite)
{
	CmisObject o = getObject(objectId);
	if(o instanceof Document)
	{
		Document d = (Document)o;
           ContentStream contentStream = new ContentStreamImpl(filename, length, mimetype, content);
		try
		{
			d.setContentStream(contentStream, overwrite);
		}
		finally
		{
			try
			{
				contentStream.getStream().close();
			}
			catch (Exception e)
            {
            }
		}
	}
	else
	{
		throw new IllegalArgumentException("Object does not exist or is not a document");
	}
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:28,代码来源:PublicApiClient.java

示例13: makeContentStream

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
private ContentStreamImpl makeContentStream(String filename, String mimetype, String content) throws IOException
{
    ThresholdOutputStream tos = streamFactory.newOutputStream();
    OutputStreamWriter writer = new OutputStreamWriter(tos);
    writer.write(content);
    ContentStreamImpl contentStream = new ContentStreamImpl(filename, BigInteger.valueOf(tos.getSize()), MimetypeMap.MIMETYPE_TEXT_PLAIN, tos.getInputStream());
    return contentStream;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:9,代码来源:OpenCmisLocalTest.java

示例14: updateNode

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
private void updateNode(CmisObject sExistingObject, String sCurrentNodePath, Node sNode) throws IOException {
    Map<String, Object> aProperties = getProperties(sNode);
    if (sNode instanceof Document) {
        sExistingObject.updateProperties(aProperties);
        ContentStream contentStream = createStreamForNode((Document) sNode);
        ((org.apache.chemistry.opencmis.client.api.Document) sExistingObject).setContentStream(contentStream, true);

        ((ContentStreamImpl) contentStream).getStream().close();
    }
}
 
开发者ID:acxio,项目名称:AGIA,代码行数:11,代码来源:CmisWriter.java

示例15: createNewNode

import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; //导入依赖的package包/类
private void createNewNode(String sCurrentNodePath, Node sNode) throws IOException {
    org.apache.chemistry.opencmis.client.api.Folder aParent = getParent(sCurrentNodePath);
    Map<String, Object> aProperties = getProperties(sNode);
    if (sNode instanceof Document) {
        ContentStream contentStream = createStreamForNode((Document) sNode);
        aParent.createDocument(aProperties, contentStream, VersioningState.MAJOR);

        ((ContentStreamImpl) contentStream).getStream().close();
    } else if (sNode instanceof Folder) {
        aParent.createFolder(aProperties);
    }
}
 
开发者ID:acxio,项目名称:AGIA,代码行数:13,代码来源:CmisWriter.java


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