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

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


            f = createResult(FAILURE, "Returned number of children doesn't match the page size!");
            addResult(assertEquals(pageSize, count, null, f));

            // check content
            for (Document document : documents.values()) {
                ContentStream contentStream = document.getContentStream();
                if (contentStream == null || contentStream.getStream() == null) {
                    addResult(createResult(FAILURE, "Document has no content! Id: " + document.getId()));
                    continue;
                } else {
                    try {
                        contentStream.getStream().close();
                    } catch (IOException e) {
                    }
                }

                // TODO: content checks
View Full Code Here


            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

        return createDocumentNoCatch(name, folderId, typeId, versioningState, withContent, null, null);
    }

    protected String createDocumentNoCatch(String name, String folderId, String typeId,
            VersioningState versioningState, boolean withContent, Acl addACEs, Acl removeACEs) {
        ContentStream contentStream = null;
        List<String> policies = null;
        ExtensionsData extension = null;

        Properties props = createDocumentProperties(name, typeId);
View Full Code Here

      Assert.fail("TestUser has no permissions to get renditions of the document");
   
    exceptionThrown = false;
    try
    {
      ContentStream contentStream =  fObjSvc.getContentStream(fRepositoryId,  docId, null, BigInteger.valueOf(-1),
          BigInteger.valueOf(-1), null);
    }
    catch (CmisPermissionDeniedException e)
    {
      exceptionThrown = true;
View Full Code Here

  }
 
    protected String createDocumentWithAcls(String name, String folderId, String typeId, VersioningState versioningState,
            Acl addACEs, Acl removeACEs)
    {
        ContentStream contentStream = null;
        List<String> policies = null;
        ExtensionsData extension = null;

        Properties props = createDocumentProperties(name, typeId);
View Full Code Here

 
  }
 
    protected String createDocumentWithProperties(String name, String folderId, String typeId, List<PropertyData<?>> properties,
              boolean withContent) {
          ContentStream contentStream = null;
         
          // add document properties
          properties.add(fFactory.createPropertyIdData(PropertyIds.NAME, name));
          properties.add(fFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, typeId));
          Properties props = fFactory.createPropertiesData(properties);
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

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZ");
        return sdf.format(cal.getTime());
    }

    public static void download(Component component, CmisObject object, String streamId) {
        ContentStream content = getContentStream(object, streamId);
        if (content == null) {
            return;
        }

        String filename = content.getFileName();
        if (filename == null) {
            if (object instanceof Document) {
                filename = ((Document) object).getContentStreamFileName();
            } else {
                filename = object.getName();
            }
        }

        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setSelectedFile(new File(filename));

        int chooseResult = fileChooser.showDialog(component, "Download");
        if (chooseResult == JFileChooser.APPROVE_OPTION) {
            try {
                storeStream(content.getStream(), fileChooser.getSelectedFile());
            } catch (Exception e) {
                showError(component, e);
            }
        }
    }
View Full Code Here

        return tempFile;
    }

    public static File createTempFileFromDocument(CmisObject object, String streamId) throws Exception {
        ContentStream content = getContentStream(object, streamId);
        if (content == null) {
            throw new Exception("No content!");
        }

        String filename = content.getFileName();
        if ((filename == null) || (filename.length() == 0)) {
            if (object instanceof Document) {
                filename = ((Document) object).getContentStreamFileName();
            }
        }
        if ((filename == null) || (filename.length() == 0)) {
            filename = object.getName();
        }
        if ((filename == null) || (filename.length() == 0)) {
            filename = "content";
        }

        String ext = MimeTypes.getExtension(content.getMimeType());
        if (ext.length() > 0 && !filename.endsWith(ext)) {
            filename = filename + ext;
        }

        File tempFile = ClientHelper.createTempFile(filename);
        try {
            storeStream(content.getStream(), tempFile);
        } catch (CmisConstraintException e) {
            // there is no content - leave the temp file empty
        }

        return tempFile;
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.