本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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);
}