Package org.apache.chemistry.opencmis.inmemory.storedobj.impl

Examples of org.apache.chemistry.opencmis.inmemory.storedobj.impl.ContentStreamDataImpl


    }

    @Test
    public void testCreateDocumentWithContentNoFileNameNoMimeType() {
        log.info("starting testCreateDocumentWithContent() ...");
        ContentStreamDataImpl contentStream = null;
        List<String> policies = null;
        Acl addACEs = null;
        Acl removeACEs = null;
        ExtensionsData extension = null;

        Properties props = createDocumentProperties(DOCUMENT_ID, DOCUMENT_TYPE_ID);

        contentStream = (ContentStreamDataImpl) createContent();
        contentStream.setFileName(null);
        contentStream.setMimeType(null);

        String id = null;
        try {
            id = fObjSvc.createDocument(fRepositoryId, props, fRootFolderId, contentStream, VersioningState.NONE, policies,
                    addACEs, removeACEs, extension);
View Full Code Here


    protected String createDocumentFromStream(String name, String folderId, String typeId, InputStream is,
            String contentType) throws IOException {

        Properties props = createDocumentProperties(name, typeId);

        ContentStreamDataImpl content = new ContentStreamDataImpl(0);
        content.setFileName(name);
        content.setMimeType(contentType);

        ByteArrayOutputStream ba = new ByteArrayOutputStream();
        byte[] buffer = new byte [65536];
        int noBytesRead = 0;

        while ((noBytesRead = is.read(buffer)) >=0 ) {
            ba.write(buffer, 0, noBytesRead);
        }
       
        content.setContent(new ByteArrayInputStream(ba.toByteArray()));

        String id = fObjSvc.createDocument(fRepositoryId, props, folderId, content, VersioningState.NONE, null,
                null, null, null);
        return id;
    }
View Full Code Here

        }
        return null;
    }
   
    private ContentStream createContent(String text) {
        ContentStreamDataImpl content = new ContentStreamDataImpl(-1);
        content.setFileName("data.txt");
        content.setMimeType("text/plain");

        try {
            content.setContent(new ByteArrayInputStream(text.getBytes()));
        } catch (IOException e) {
            throw new RuntimeException("Failed to fill content stream with data", e);
        }
        return content;
    }
View Full Code Here

            String pattern = StringUtil.unescape(nodeText, "\\'-");
            if (null == pattern)
              throw new CmisInvalidArgumentException("Illegal Escape sequence in text search expression " + nodeText);
           
            if (so instanceof Content && cont.hasContent()) {
                ContentStreamDataImpl cdi = (ContentStreamDataImpl) cont.getContent(0, -1);
                if (cdi.getMimeType().startsWith("text/")) {
                  byte[] ba = cdi.getBytes();
                  String text = new String(ba);
                  int match = text.indexOf(pattern);
                  return match >= 0;
                } else
                  return false;
View Full Code Here

    protected ContentStream createContent(int sizeInKB) {
        return createContent(sizeInKB, 0, null);
    }

    protected ContentStream createContent(int sizeInKB, long maxSizeInKB, String mimeType) {
        ContentStreamDataImpl content = new ContentStreamDataImpl(maxSizeInKB);
        content.setFileName("data.txt");
       
        if (null == mimeType)
            content.setMimeType("text/plain");
        else
            content.setMimeType(mimeType);
        int len = sizeInKB * 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
        int noBlocks = len / b.length;

        ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
        try {
            for (int i = 0; i < noBlocks; i++) {
                ba.write(b);
            }
            content.setContent(new ByteArrayInputStream(ba.toByteArray()));
        } catch (IOException e) {
            throw new RuntimeException("Failed to fill content stream with data", e);
        }
        return content;
    }
View Full Code Here

        }
        return content;
    }

    protected ContentStream createContent(char ch) {
        ContentStreamDataImpl content = new ContentStreamDataImpl(0);
        content.setFileName("data.txt");
        content.setMimeType("text/plain");
        int len = 32 * 1024;
        byte[] b = new byte[32];
        for (int i = 0; i < 32; i++) {
            b[i] = (byte) Character.getNumericValue(ch);
        }
        ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
        try {
            for (int i = 0; i < 1024; i++) {
                ba.write(b);
            }
            content.setContent(new ByteArrayInputStream(ba.toByteArray()));
        } catch (IOException e) {
            throw new RuntimeException("Failed to fill content stream with data", e);
        }
        return content;
    }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.inmemory.storedobj.impl.ContentStreamDataImpl

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.