Package org.apache.chemistry.opencmis.commons.data

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


                                        + rend.getStreamId());
                        addResult(results, assertIsTrue(rend.getWidth() > 0, null, f));
                    }

                    // check the content
                    ContentStream contentStream = rend.getContentStream();
                    f = createResult(FAILURE, "A rendition has no content stream! Stream id: " + rend.getStreamId());
                    addResult(results, assertNotNull(contentStream, null, f));

                    if (contentStream != null) {
                        InputStream stream = contentStream.getStream();

                        f = createResult(FAILURE, "A rendition has no stream! Stream id: " + rend.getStreamId());
                        addResult(results, assertNotNull(stream, null, f));

                        if (stream != null) {
View Full Code Here


        }
        return id;
    }

    private String createDocument(String folderId, int no, int level) {
        ContentStream contentStream = null;
        VersioningState versioningState = VersioningState.NONE;
        List<String> policies = null;
        Acl addACEs = null;
        Acl removeACEs = null;
        ExtensionsData extension = null;
View Full Code Here

    private void repositoryInfo(OptionSet options) {
        callRepoInfo(options.valueOf(fRepoId), options.valueOf(fCount));
    }

    private void createFiles(OptionSet options) {
        ContentStream contentStream = null;
        String fileNamePattern = options.valueOf(fFileNamePattern);
        int count = options.valueOf(fCount);
        int contentSize = options.valueOf(fContentSize);
       
        System.out.println("Creating local files with content: ");
        System.out.println("Kind: " + options.valueOf(fDocsPerFolder));
        System.out.println("Number of files: " + count);
        System.out.println("File name pattern: " + fileNamePattern);
        System.out.println("Kind of content: " + options.valueOf(fContentKindStr));
        System.out.println("Size of content (text only): " + contentSize);
       
        ObjectGenerator objGen = new ObjectGenerator(null, null, null, null, null, fContentKind);
        objGen.setContentSizeInKB(contentSize);
       
        InputStream is = null;
        FileOutputStream os = null;
       
        try {
            for (int i=0; i<count; i++) {
                String fileName = String.format(fileNamePattern, i);
                System.out.println("Generating file: " + fileName);
                if (contentSize > 0) {
                    switch (fContentKind) {
                    case StaticText:
                        contentStream = objGen.createContentStaticText();
                        break;
                    case LoremIpsumText:
                        contentStream =  objGen.createContentLoremIpsumText();
                        break;
                    case LoremIpsumHtml:
                        contentStream =  objGen.createContentLoremIpsumHtml();
                        break;
                    case ImageFractalJpeg:
                        contentStream =  objGen.createContentFractalimageJpeg();
                        break;
                    }
                }

                // write to a file:
                is = contentStream.getStream();
                os = new FileOutputStream (fileName);
                byte[] b = new byte[64 * 1024]
                int read; 
                while ((read = is.read(b)) != -1)  
                    os.write(b, 0, read)
View Full Code Here

        BigInteger offset = context.getOffset();
        BigInteger length = context.getLength();

        // execute
        ContentStream content = service.getContentStream(repositoryId, objectId, streamId, offset, length, null);

        if (content == null || content.getStream() == null) {
            throw new CmisRuntimeException("Content stream is null!");
        }

        String contentType = content.getMimeType();
        if (contentType == null) {
            contentType = MEDIATYPE_OCTETSTREAM;
        }

        // set headers
        if (offset == null && length == null) {
            response.setStatus(HttpServletResponse.SC_OK);
        } else {
            setStatus(request, response, HttpServletResponse.SC_PARTIAL_CONTENT);
        }
        response.setContentType(contentType);
        if (content.getFileName() != null) {
            response.setHeader(MimeHelper.CONTENT_DISPOSITION,
                    MimeHelper.encodeContentDisposition(MimeHelper.DISPOSITION_INLINE, content.getFileName()));
        }

        // send content
        InputStream in = new BufferedInputStream(content.getStream(), BUFFER_SIZE);
        OutputStream out = new BufferedOutputStream(response.getOutputStream());

        byte[] buffer = new byte[BUFFER_SIZE];
        int b;
        while ((b = in.read(buffer)) > -1) {
View Full Code Here

        LOG.debug("start createDocumentFromSource()");
        StoredObject so = validator.createDocumentFromSource(context, repositoryId, sourceId, folderId, extension);
        TypeDefinition td = getTypeDefinition(repositoryId, so)// type definition may be copied from source object

        ContentStream content = getContentStream(context, repositoryId, sourceId, null, BigInteger.valueOf(-1),
                BigInteger.valueOf(-1), null);

        if (so == null) {
            throw new CmisObjectNotFoundException("Unknown object id: " + sourceId);
        }
View Full Code Here

        if (!(so instanceof Content)) {
            throw new CmisConstraintException("Id" + objectId
                    + " does not refer to a document or version, but only those can have content");
        }

        ContentStream csd = getContentStream(so, streamId, offset, length);

        if (null == csd) {
            throw new CmisConstraintException("Object " + so.getId() + " does not have content.");
        }
View Full Code Here

        if (streamId != null) {
            return null;
        }
        long lOffset = offset == null ? 0 : offset.longValue();
        long lLength = length == null ? -1 : length.longValue();
        ContentStream csd = ((Content) so).getContent(lOffset, lLength);
        return csd;
    }
View Full Code Here

        checkIsVersionableObject(so);

        VersionedDocument verDoc = getVersionedDocumentOfObjectId(so);

        ContentStream content = null;

        if (so instanceof DocumentVersion) {
            // get document the version is contained in to c
            content = ((DocumentVersion) so).getContent(0, -1);
        } else {
View Full Code Here

        }
        return id;
    }

    private String createDocument(String folderId, int no, int level) {
        ContentStream contentStream = null;
        VersioningState versioningState = VersioningState.NONE;
        List<String> policies = null;
        Acl addACEs = null;
        Acl removeACEs = null;
        ExtensionsData extension = null;
View Full Code Here

        return getObject().getAllowableActions().getAllowableActions().contains(Action.CAN_SET_CONTENT_STREAM);
    }

    @Override
    public boolean doAction() throws Exception {
        ContentStream content = getClientModel().createContentStream(filenameField.getText());
        ((Document) getObject()).setContentStream(content, overwriteBox.isSelected());
        return true;
    }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.commons.data.ContentStream

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.