Package org.apache.chemistry.opencmis.commons.impl.dataobjects

Examples of org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl


            try {
                contentBytes = CONTENT2.getBytes("UTF-8");
            } catch (Exception e) {
            }

            ContentStream contentStream = new ContentStreamImpl(workDoc.getName(),
                    BigInteger.valueOf(contentBytes.length), "text/plain", new ByteArrayInputStream(contentBytes));

            ObjectId newObjectId = workDoc.setContentStream(contentStream, true, true);

            // setContentStream may have created a new version
View Full Code Here


        try {
            Node contentNode = getContextNode();
            Property data = contentNode.getProperty(Property.JCR_DATA);

            // compile data
            ContentStreamImpl result = new ContentStreamImpl();
            result.setFileName(getNodeName());
            result.setLength(BigInteger.valueOf(data.getLength()));
            result.setMimeType(getPropertyOrElse(contentNode, Property.JCR_MIMETYPE, MIME_UNKNOWN));
            result.setStream(new BufferedInputStream(data.getBinary().getStream()))// stream closed by consumer

            return result;
        }
        catch (PathNotFoundException e) {
            log.debug(e.getMessage(), e);
View Full Code Here

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.OBJECT_TYPE_ID, type);
        properties.put(PropertyIds.NAME, name);

        ContentStream contentStream = new ContentStreamImpl(name, BigInteger.valueOf(file.length()), mimetype,
                new FileInputStream(file));

        return parentFolder.createDocument(properties, contentStream, versioningState);
    }
View Full Code Here

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(PropertyIds.OBJECT_TYPE_ID, type);
        properties.put(PropertyIds.NAME, name);

        ByteArrayInputStream bais = new ByteArrayInputStream(content == null ? new byte[0] : content.getBytes());
        ContentStream contentStream = new ContentStreamImpl(name, BigInteger.valueOf(content == null ? 0 : content
                .getBytes().length), "text/plain", bais);

        return parentFolder.createDocument(properties, contentStream, versioningState);
    }
View Full Code Here

        // get parameters
        String objectId = getStringParameter(request, Constants.PARAM_ID);
        String changeToken = getStringParameter(request, Constants.PARAM_CHANGE_TOKEN);
        Boolean overwriteFlag = getBooleanParameter(request, Constants.PARAM_OVERWRITE_FLAG);

        ContentStreamImpl contentStream = new ContentStreamImpl();
        contentStream.setStream(request.getInputStream());
        contentStream.setMimeType(request.getHeader("Content-Type"));
        String lengthStr = request.getHeader("Content-Length");
        if (lengthStr != null) {
            try {
                contentStream.setLength(new BigInteger(lengthStr));
            } catch (NumberFormatException e) {
            }
        }
        String contentDisposition = request.getHeader(MimeHelper.CONTENT_DISPOSITION);
        if (contentDisposition != null) {
            contentStream.setFileName(MimeHelper.decodeContentDispositionFilename(contentDisposition));
        }

        // execute
        Holder<String> objectIdHolder = new Holder<String>(objectId);
        service.setContentStream(repositoryId, objectIdHolder, overwriteFlag, changeToken == null ? null
View Full Code Here

    /**
     * Extract the content stream.
     */
    private void parseAtomContent(XMLStreamReader parser) throws Exception {
        atomContentStream = new ContentStreamImpl();

        // read attributes
        String type = "text";
        for (int i = 0; i < parser.getAttributeCount(); i++) {
            QName attrName = parser.getAttributeName(i);
View Full Code Here

    /**
     * Extract the content stream.
     */
    private void parseCmisContent(XMLStreamReader parser) throws Exception {
        cmisContentStream = new ContentStreamImpl();

        next(parser);

        // walk through all tags in content
        while (true) {
View Full Code Here

 
    // content
    String contentString = "CMIS Testdata "+name;
    byte[] content = contentString.getBytes();
    InputStream stream = new ByteArrayInputStream(content);
    ContentStream contentStream = new ContentStreamImpl(name, new BigInteger(content), "text/plain", stream);
 
    // create a major version
    folder.createDocument(contentProperties, contentStream, null);
    stream.close();
  }
View Full Code Here

    String repositoryId = session.getRepositoryInfo().getId();
    Holder<String> objectIdHolder = new Holder<String>(objectId);
    Boolean overwriteFlag = true;
    byte[] newContentByteArray = newContent.getBytes();
    InputStream stream = new ByteArrayInputStream(newContentByteArray);
    ContentStream contentStream = new ContentStreamImpl(name, new BigInteger(newContentByteArray), "text/plain", stream);
    ObjectService objectService = session.getBinding().getObjectService();
    objectService.setContentStream(repositoryId, objectIdHolder, overwriteFlag, null, contentStream, null);
  }
View Full Code Here

        try {
            Node contentNode = getContextNode();
            Property data = contentNode.getProperty(Property.JCR_DATA);

            // compile data
            ContentStreamImpl result = new ContentStreamImpl();
            result.setFileName(getNodeName());
            result.setLength(BigInteger.valueOf(data.getLength()));
            result.setMimeType(getPropertyOrElse(contentNode, Property.JCR_MIMETYPE, MIME_UNKNOWN));
            result.setStream(new BufferedInputStream(data.getBinary().getStream()))// stream closed by consumer

            return result;
        }
        catch (PathNotFoundException e) {
            log.debug(e.getMessage(), e);
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.