org.apache.chemistry.opencmis.commons.data.ContentStream Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.data.ContentStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 7 votes vote down vote up
/**
 * Create dispatch for AtomPub
 * 
 * @param context call context
 * @param properties the properties
 * @param folderId identifier of the parent folder
 * @param contentStream stream of the document to create
 * @param versioningState state of the version
 * @param objectInfos informations
 * 
 * @return the newly created object
 */
public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream,
		VersioningState versioningState, ObjectInfoHandler objectInfos) {
	debug("create " + folderId);
	validatePermission(folderId, context, Permission.WRITE);

	String typeId = getTypeId(properties);

	TypeDefinition type = types.getType(typeId);
	if (type == null)
		throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!");

	String objectId = null;
	if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) {
		objectId = createDocument(context, properties, folderId, contentStream, versioningState);
		return compileObjectType(context, getDocument(objectId), null, false, false, objectInfos);
	} else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
		objectId = createFolder(context, properties, folderId);
		return compileObjectType(context, getFolder(objectId), null, false, false, objectInfos);
	} else {
		throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!");
	}
}
 
Example #2
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@Transactional
public void setContentStream(CmisRepositoryConfiguration config,
		Holder<String> objectId,
		Boolean overwriteFlag,
		Holder<String> changeToken,
		ContentStream contentStream,
		ExtensionsData extension) {

	Object object = getObjectInternal(config, objectId.getValue(), Collections.EMPTY_SET, false, IncludeRelationships.NONE,
			"", false, false, extension);
	if (object != null) {
		config.cmisDocumentStorage().setContent(object, contentStream.getStream());

		// re-fetch to ensure we have the latest
		object = getObjectInternal(config, objectId.getValue(), Collections.EMPTY_SET, false, IncludeRelationships.NONE,
				"", false, false, extension);

		if (BeanUtils.hasFieldWithAnnotation(object, MimeType.class)) {
			BeanUtils.setFieldWithAnnotation(object, MimeType.class, contentStream.getMimeType());
		}

		config.cmisDocumentRepository().save(object);
	}
}
 
Example #3
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 6 votes vote down vote up
public String createDocument(String repositoryId,
		Properties properties,
		String folderId,
		ContentStream contentStream,
		VersioningState versioningState,
		List<String> policies,
		Acl addAces,
		Acl removeAces,
		ExtensionsData extension) {

	return bridge.createDocument(config,
			properties,
			folderId,
			contentStream,
			versioningState,
			policies,
			addAces,
			removeAces,
			extension);
}
 
Example #4
Source File: SampleClient.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Create test document with content
 * 
 * @param target
 * @param newDocName
 */
private static void createDocument(Folder target, String newDocName) {
	Map<String, String> props = new HashMap<String, String>();
	props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
	props.put(PropertyIds.NAME, newDocName);
	props.put(TypeManager.PROP_TAGS, "tag1,tag2,tag3");
	System.out.println("This is a test document: " + newDocName);
	String content = "aegif Mind Share Leader Generating New Paradigms by aegif corporation.";
	byte[] buf = null;
	try {
		buf = content.getBytes("UTF-8");
	} catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
	ByteArrayInputStream input = new ByteArrayInputStream(buf);
	ContentStream contentStream = session.getObjectFactory().createContentStream(newDocName, buf.length,
			"text/plain; fileNameCharset=UTF-8", input);
	target.createDocument(props, contentStream, VersioningState.NONE);
}
 
Example #5
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 6 votes vote down vote up
public void checkIn(String repositoryId,
		Holder<String> objectId,
		Boolean major,
		Properties properties,
		ContentStream contentStream,
		String checkinComment,
		List<String> policies,
		Acl addAces, Acl
		removeAces,
		ExtensionsData extension) {

	bridge.checkIn(config,
			objectId.getValue(),
			major,
			properties,
			contentStream,
			checkinComment,
			policies,
			addAces,
			removeAces,
			extension);
}
 
Example #6
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String parseMimeType(ContentStream contentStream)
{
	String mimeType = null;

	String tmp = contentStream.getMimeType();
	if(tmp != null)
	{
		int idx = tmp.indexOf(";");
		if(idx != -1)
		{
			mimeType = tmp.substring(0, idx).trim();
		}
		else
		{
			mimeType = tmp;
		}
	}

	return mimeType;
}
 
Example #7
Source File: CmisRead.java    From cloud-espm-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * This is a custom implementation of the doGet method of the
 * {@link HttpServlet}.
 * <p>
 * Here, we expect an "objectId" to be passed as input parameter. This
 * objectId will be fetched to the {@link Session} to fetch the existing
 * document(if present).
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException {
	final String objectId = request.getParameter("objectId");
	try {
		if (openCmisSession != null) {
			Document doc = (Document) openCmisSession.getObject(objectId);
			ContentStream content = doc.getContentStream();
			String type = content.getMimeType();
			String name = content.getFileName();
			int length = (int) content.getLength();
			InputStream stream = content.getStream();
			response.setContentType(type);
			response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + name);
			response.setContentLength(length);
			ioCopy(stream, response.getOutputStream());
		} else {
			response.setStatus(501);
		}

	} catch (Exception exception) {
		LOGGER.error(exception.getMessage());
	}

}
 
Example #8
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ContentStream getContentStream(
        String repositoryId, String objectId, String streamId, BigInteger offset,
        BigInteger length, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    // what kind of object is it?
    CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");

    // relationships cannot have content
    if (info.isVariant(CMISObjectVariant.ASSOC))
    {
        throw new CmisInvalidArgumentException("Object is a relationship and cannot have content!");
    }

    // now get it
    return connector.getContentStream(info, streamId, offset, length);
}
 
Example #9
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Overridden to capture content upload for publishing to analytics service.
 */
@Override
public void setContentStream(String repositoryId, Holder<String> objectId,
            Boolean overwriteFlag, Holder<String> changeToken, ContentStream contentStream,
            ExtensionsData extension)
{
    FileFilterMode.setClient(Client.cmis);
    try
    {
        super.setContentStream(repositoryId, objectId, overwriteFlag, changeToken, contentStream, extension);
    }
    finally
    {
        FileFilterMode.clearClient();
    }
}
 
Example #10
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Overridden to capture content upload for publishing to analytics service.
 */
@Override
public String createDocument(String repositoryId, Properties properties, String folderId,
            ContentStream contentStream, VersioningState versioningState,
            List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension)
{
    String newId = super.createDocument(
                repositoryId,
                properties,
                folderId,
                contentStream,
                versioningState,
                policies,
                addAces,
                removeAces,
                extension);
    return newId;
}
 
Example #11
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String create(String repositoryId, Properties properties, String folderId,
            ContentStream contentStream, VersioningState versioningState,
            List<String> policies, ExtensionsData extension)
{
    FileFilterMode.setClient(Client.cmis);
    try
    {
        return super.create(
                    repositoryId,
                    properties,
                    folderId,
                    contentStream,
                    versioningState,
                    policies,
                    extension);
    }
    finally
    {
        FileFilterMode.clearClient();
    }
}
 
Example #12
Source File: OpenCmisLocalTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static Document createDocument(Folder target, String newDocName, Session session)
{
    Map<String, String> props = new HashMap<String, String>();
    props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
    props.put(PropertyIds.NAME, newDocName);
    String content = "aegif Mind Share Leader Generating New Paradigms by aegif corporation.";
    byte[] buf = null;
    try
    {
        buf = content.getBytes("ISO-8859-1"); // set the encoding here for the content stream
    }
    catch (UnsupportedEncodingException e)
    {
        e.printStackTrace();
    }

    ByteArrayInputStream input = new ByteArrayInputStream(buf);

    ContentStream contentStream = session.getObjectFactory().createContentStream(newDocName, buf.length,
            "text/plain; charset=UTF-8", input); // additionally set the charset here
    // NOTE that we intentionally specified the wrong charset here (as UTF-8)
    // because Alfresco does automatic charset detection, so we will ignore this explicit request
    return target.createDocument(props, contentStream, VersioningState.MAJOR);
}
 
Example #13
Source File: FilterCmisService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
		ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
		ExtensionsData extension) {
	getVersioningService().checkIn(repositoryId, objectId, major, properties, contentStream, checkinComment,
			policies, addAces, removeAces, extension);
}
 
Example #14
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
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");
    }
}
 
Example #15
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Document createDocument(String parentId, String name, Map<String, Serializable> properties, ContentStream contentStream, VersioningState versioningState)
{
    CmisObject o = getObject(parentId);

    if(o instanceof Folder)
    {
        Folder f = (Folder)o;

        if(properties == null)
        {
            properties = new HashMap<String, Serializable>();
        }
        String objectTypeId = (String)properties.get(PropertyIds.OBJECT_TYPE_ID);
        String type = "cmis:document";
        if(objectTypeId == null)
        {
            objectTypeId = type;
        }
        if(objectTypeId.indexOf(type) == -1)
        {
            StringBuilder sb = new StringBuilder(objectTypeId);
            if(sb.length() > 0)
            {
                sb.append(",");
            }
            sb.append(type);
            objectTypeId = sb.toString();
        }

        properties.put(PropertyIds.NAME, name);
        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);

        Document res = f.createDocument(properties, contentStream, versioningState);
        return res;
    }
    else
    {
        throw new IllegalArgumentException("Parent does not exists or is not a folder");
    }
}
 
Example #16
Source File: ContentData.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ContentData(ContentStream cs) throws IOException
{
	length = cs.getLength();
	mimeType = cs.getMimeType();
	fileName = cs.getFileName();
	bytes = FileCopyUtils.copyToByteArray(cs.getStream());
}
 
Example #17
Source File: CmisIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
private void createTextDocument(Folder newFolder, String content, String fileName)
        throws UnsupportedEncodingException {
    byte[] buf = content.getBytes("UTF-8");
    ByteArrayInputStream input = new ByteArrayInputStream(buf);
    ContentStream contentStream = createSession().getObjectFactory()
            .createContentStream(fileName, buf.length, "text/plain; charset=UTF-8", input);

    Map<String, Object> properties = new HashMap<>();
    properties.put(PropertyIds.OBJECT_TYPE_ID, CamelCMISConstants.CMIS_DOCUMENT);
    properties.put(PropertyIds.NAME, fileName);
    newFolder.createDocument(properties, contentStream, VersioningState.NONE);
}
 
Example #18
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
void setContentStreamInternal(CmisRepositoryConfiguration config,
		ContentStream contentStream,
		Object object) {

	config.cmisDocumentStorage().setContent(object, contentStream.getStream());

	if (BeanUtils.hasFieldWithAnnotation(object, MimeType.class)) {
		BeanUtils.setFieldWithAnnotation(object, MimeType.class, contentStream.getMimeType());
	}

	config.cmisDocumentRepository().save(object);
}
 
Example #19
Source File: CmisServiceImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
@HasPermission(type = DefaultPermission.class, action = "clone_content_cmis")
public void cloneContent(@ProtectedResourceId(SITE_ID_RESOURCE_ID) String siteId, String cmisRepoId, String cmisPath,
                         @ProtectedResourceId(PATH_RESOURCE_ID) String studioPath)
        throws StudioPathNotFoundException, CmisRepositoryNotFoundException, CmisUnavailableException, CmisTimeoutException, CmisPathNotFoundException, ServiceLayerException {
    if (!contentService.contentExists(siteId, studioPath))
        throw new StudioPathNotFoundException("Studio repository path does not exist for site " + siteId +
                " (path: " + studioPath + ")");
    List<CmisContentItemTO> toRet = new ArrayList<CmisContentItemTO>();
    DataSourceRepository repositoryConfig = getConfiguration(siteId, cmisRepoId);
    if (repositoryConfig != null) {
        logger.debug("Create new CMIS session");
        Session session = createCMISSession(repositoryConfig);
        if (session != null) {
            String contentPath = Paths.get(repositoryConfig.getBasePath(), cmisPath).toString();
            logger.debug("Find object for CMIS path: " + contentPath);
            CmisObject cmisObject = session.getObjectByPath(contentPath);
            if (cmisObject != null) {
                if (BaseTypeId.CMIS_FOLDER.equals(cmisObject.getBaseTypeId())) {
                    throw new CmisPathNotFoundException();
                } else if (CMIS_DOCUMENT.equals(cmisObject.getBaseTypeId())) {
                    org.apache.chemistry.opencmis.client.api.Document cmisDoc =
                            (org.apache.chemistry.opencmis.client.api.Document)cmisObject;
                    String fileName = cmisDoc.getName();
                    String savePath = studioPath + FILE_SEPARATOR + fileName;
                    ContentStream cs = cmisDoc.getContentStream();
                    logger.debug("Save CMIS file to: " + savePath);
                    contentService.writeContent(siteId, savePath, cs.getStream());
                }
            } else {
                throw new CmisPathNotFoundException();
            }
        } else {
            throw new CmisUnauthorizedException();
        }
    }
}
 
Example #20
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public ContentStream getContentStream(String repositoryId, String objectId, String streamId, BigInteger offset,
									  BigInteger length, ExtensionsData extension) {

	return bridge.getContentStream(config,
			objectId,
			streamId,
			offset,
			length,
			extension);
}
 
Example #21
Source File: FilterCmisService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public String createDocument(String repositoryId, Properties properties, String folderId,
		ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
		Acl removeAces, ExtensionsData extension) {
	return getObjectService().createDocument(repositoryId, properties, folderId, contentStream, versioningState,
			policies, addAces, removeAces, extension);
}
 
Example #22
Source File: PublicApiClient.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ContentData getContent(String objectId) throws IOException
{
    CmisObject o = getObject(objectId);
    if(o instanceof Document)
    {
        Document d = (Document)o;
        ContentStream res = d.getContentStream();
        ContentData c = new ContentData(res);
        return c;
    }
    else
    {
        throw new IllegalArgumentException("Object does not exist or is not a document");
    }
}
 
Example #23
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public String createDocument(String repositoryId, Properties properties,
		String folderId, ContentStream contentStream,
		VersioningState versioningState, List<String> policies,
		Acl addAces, Acl removeAces, ExtensionsData extension) {

	if(!eventDispatcher.contains(CmisEvent.CREATE_DOCUMENT)) {
		return objectService.createDocument(repositoryId, properties, folderId, contentStream, versioningState, policies, addAces, removeAces, extension);
	}
	else {
		XmlBuilder cmisXml = new XmlBuilder("cmis");
		cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
		cmisXml.addSubElement(buildXml("folderId", folderId));
		cmisXml.addSubElement(buildXml("versioningState", versioningState));

		XmlBuilder contentStreamXml = new XmlBuilder("contentStream");
		contentStreamXml.addAttribute("filename", contentStream.getFileName());
		contentStreamXml.addAttribute("length", contentStream.getLength());
		contentStreamXml.addAttribute("mimeType", contentStream.getMimeType());
		cmisXml.addSubElement(contentStreamXml);

		XmlBuilder propertiesXml = new XmlBuilder("properties");
		for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext();) {
			propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
		}
		cmisXml.addSubElement(propertiesXml);

		IPipeLineSession context = new PipeLineSessionBase();
		context.put("ContentStream", contentStream.getStream());
		context.put(CmisUtils.CMIS_CALLCONTEXT_KEY, callContext);
		Element result = eventDispatcher.trigger(CmisEvent.CREATE_DOCUMENT, cmisXml.toXML(), context);
		return XmlUtils.getChildTagAsString(result, "id");
	}
}
 
Example #24
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public ContentStream getContentStream(String repositoryId, String objectId,
		String streamId, BigInteger offset, BigInteger length, ExtensionsData extension) {

	if(!eventDispatcher.contains(CmisEvent.GET_CONTENTSTREAM)) {
		return objectService.getContentStream(repositoryId, objectId, streamId, offset, length, extension);
	}
	else {
		XmlBuilder cmisXml = new XmlBuilder("cmis");
		cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
		cmisXml.addSubElement(buildXml("objectId", objectId));
		cmisXml.addSubElement(buildXml("streamId", streamId));
		cmisXml.addSubElement(buildXml("offset", offset));
		cmisXml.addSubElement(buildXml("length", length));

		IPipeLineSession context = new PipeLineSessionBase();
		context.put(CmisUtils.CMIS_CALLCONTEXT_KEY, callContext);
		Element cmisResult = eventDispatcher.trigger(CmisEvent.GET_CONTENTSTREAM, cmisXml.toXML(), context);

		Element contentStreamXml = XmlUtils.getFirstChildTag(cmisResult, "contentStream");
		InputStream stream = (InputStream) context.get("ContentStream");
		String fileName = contentStreamXml.getAttribute("filename");
		String mediaType = contentStreamXml.getAttribute("mimeType");
		long longLength = Long.parseLong(contentStreamXml.getAttribute("length"));
		BigInteger fileLength = BigInteger.valueOf(longLength);

		return new ContentStreamImpl(fileName, fileLength, mediaType, stream);
	}
}
 
Example #25
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public void setContentStream(String repositoryId, Holder<String> objectId,
		Boolean overwriteFlag, Holder<String> changeToken,
		ContentStream contentStream, ExtensionsData extension) {
	// TODO Auto-generated method stub
	objectService.setContentStream(repositoryId, objectId, overwriteFlag, changeToken, contentStream, extension);
}
 
Example #26
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public void appendContentStream(String repositoryId,
		Holder<String> objectId, Holder<String> changeToken,
		ContentStream contentStream, boolean isLastChunk,
		ExtensionsData extension) {
	// TODO Auto-generated method stub
	objectService.appendContentStream(repositoryId, objectId, changeToken, contentStream, isLastChunk, extension);
}
 
Example #27
Source File: OpenCmisLocalTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testEncodingForCreateContentStream()
{
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    FileFolderService ffs = serviceRegistry.getFileFolderService();
    // Authenticate as system
    AuthenticationComponent authenticationComponent = (AuthenticationComponent) ctx
            .getBean(BEAN_NAME_AUTHENTICATION_COMPONENT);
    authenticationComponent.setSystemUserAsCurrentUser();
    try
    {
        /* Create the document using openCmis services */
        Repository repository = getRepository("admin", "admin");
        Session session = repository.createSession();
        Folder rootFolder = session.getRootFolder();
        Document document = createDocument(rootFolder, "test_file_" + GUID.generate() + ".txt", session);

        ContentStream content = document.getContentStream();
        assertNotNull(content);

        content = document.getContentStream(BigInteger.valueOf(2), BigInteger.valueOf(4));
        assertNotNull(content);

        NodeRef doc1NodeRef = cmisIdToNodeRef(document.getId());
        FileInfo fileInfo = ffs.getFileInfo(doc1NodeRef);
        Map<QName, Serializable> properties = fileInfo.getProperties();
        ContentDataWithId contentData = (ContentDataWithId) properties
                .get(QName.createQName("{http://www.alfresco.org/model/content/1.0}content"));
        String encoding = contentData.getEncoding();

        assertEquals("ISO-8859-1", encoding);
    }
    finally
    {
        authenticationComponent.clearCurrentSecurityContext();
    }
}
 
Example #28
Source File: OpenCmisLocalTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #29
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
        ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
        ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkHolderId("Object Id", objectId);
    major = getDefaultTrue(major);

    try {
        getWrappedService().checkIn(repositoryId, objectId, major, properties, contentStream, checkinComment,
                policies, addAces, removeAces, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #30
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void appendContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
        ContentStream contentStream, boolean isLastChunk, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkHolderId("Object Id", objectId);
    checkContentStream(contentStream);

    try {
        getWrappedService().appendContentStream(repositoryId, objectId, changeToken, contentStream, isLastChunk,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}