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

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


 
    // 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

        StoredObject so = null;

        // check if content stream parameters are set and if not set some defaults
        if (null != contentStream && (contentStream.getFileName() == null || contentStream.getFileName().length() == 0 ||
            contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0)) {
            ContentStreamImpl cs = new ContentStreamImpl();
            cs.setStream(contentStream.getStream());
            if (contentStream.getFileName() == null || contentStream.getFileName().length() == 0)
                cs.setFileName(name);
            else
                cs.setFileName(contentStream.getFileName());
            cs.setLength(contentStream.getBigLength());
            if (contentStream.getMimeType() == null || contentStream.getMimeType().length() == 0)
                cs.setMimeType("application/octet-stream");
            else
                cs.setMimeType(contentStream.getMimeType());
            cs.setExtensions(contentStream.getExtensions());
            contentStream = cs;
        }

        // Now we are sure to have document type definition:
        if (((DocumentTypeDefinition) typeDef).isVersionable()) {
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

        Properties props = fFactory.createPropertiesData(properties);
        return props;
    }

    public ContentStream createContent() {
        ContentStreamImpl content = new ContentStreamImpl();
        content.setFileName("data.txt");
        content.setMimeType("text/plain");
        int len = 32 * 1024;
        byte[] b = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a,
                0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a }; // 32
        // Bytes
        ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
        try {
            for (int i = 0; i < 1024; i++)
                ba.write(b);
        } catch (IOException e) {
            throw new RuntimeException("Failed to fill content stream with data", e);
        }
        content.setStream(new ByteArrayInputStream(ba.toByteArray()));
        content.setLength(BigInteger.valueOf(len));
        return content;
    }
View Full Code Here

        content.setLength(BigInteger.valueOf(len));
        return content;
    }

    public ContentStream createAlternateContent() {
        ContentStreamImpl content = new ContentStreamImpl();
        content.setFileName("data.txt");
        content.setMimeType("text/plain");
        int len = 32 * 1024;
        byte[] b = { 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61,
                0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61 }; // 32
        // Bytes
        ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
        try {
            for (int i = 0; i < 1024; i++)
                ba.write(b);
        } catch (IOException e) {
            throw new RuntimeException("Failed to fill content stream with data", e);
        }
        content.setStream(new ByteArrayInputStream(ba.toByteArray()));
        content.setLength(BigInteger.valueOf(len));
        return content;
    }
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.getBytes().length),
                "text/plain", bais);

        return parentFolder.createDocument(properties, contentStream, versioningState);
    }
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.