Package org.modeshape.jcr.api

Examples of org.modeshape.jcr.api.Binary


            // Make sure the file on the file system contains what we put in ...
            assertFileContains(storeProjection, filePath, actualContent.getBytes());

            // Make sure that we can re-read the binary content via JCR ...
            Node contentNode = session.getNode("/testRoot/store/" + filePath + "/jcr:content");
            Binary value = (Binary)contentNode.getProperty("jcr:data").getBinary();
            assertBinaryContains(value, actualContent.getBytes());
        }
        assertTrue(((Node)session.getNode("/testRoot/store/dir3")).getNodes().getSize() >= count);
    }
View Full Code Here


    @Override
    public boolean execute( Property inputProperty,
                            Node outputNode,
                            Context context ) throws Exception {
        Binary binaryValue = (Binary)inputProperty.getBinary();
        CheckArg.isNotNull(binaryValue, "binary");

        String inputFileName = getInputFileName(inputProperty);
        String mimeType = binaryValue.getMimeType(inputFileName);

        Node sequencedNode = outputNode;
        if (outputNode.isNew()) {
            outputNode.setPrimaryType(METADATA_NODE);
        } else {
            sequencedNode = outputNode.addNode(METADATA_NODE, METADATA_NODE);
        }

        setProperty(sequencedNode, JCR_MIME_TYPE, mimeType);
        if (isPowerpoint(mimeType)) {
            try (InputStream stream = binaryValue.getStream()) {
                sequencePowerpoint(sequencedNode, context.valueFactory(), stream);
                return true;
            }
        }

        if (isWord(mimeType)) {
            try (InputStream stream = binaryValue.getStream()) {
                sequenceWord(sequencedNode, context.valueFactory(), stream);
                return true;
            }
        }

        if (isExcel(mimeType)) {
            try (InputStream stream = binaryValue.getStream()) {
                sequenceExcel(sequencedNode, context.valueFactory(), stream);
                return true;
            }
        }
View Full Code Here

    private byte[] createNodeWithBinaryProperty(String nodeName, long minBinarySize, String binaryStoreName, Session session) throws Exception {
        Node node = session.getNode("/").addNode(nodeName);
        byte[] randomBytes = new byte[(int)minBinarySize];
        RANDOM.nextBytes(randomBytes);
        Binary binary = ((ValueFactory) session.getValueFactory()).createBinary(new ByteArrayInputStream(randomBytes), binaryStoreName);
        node.setProperty("binary", binary);
        session.save();
        return randomBytes;
    }
View Full Code Here

            Node node3 = session.getRootNode().addNode("file3");
            node3.setProperty("binary", session.getValueFactory().createBinary(resourceStream("io/file3.txt")));
            session.save();

            // verify the mime-type has been extracted for the 2 nt:resources
            Binary file1Binary = (Binary)session.getNode("/file1.txt/jcr:content").getProperty("jcr:data").getBinary();
            assertEquals("Invalid mime-type", "text/plain", file1Binary.getMimeType());

            Binary file2Binary = (Binary)session.getNode("/file2.txt/jcr:content").getProperty("jcr:data").getBinary();
            assertEquals("Invalid mime-type", "text/plain", file2Binary.getMimeType());

            // expect 3 binaries
            assertEquals("Incorrect number of binaries in store", 3, binariesCount());

            session.removeItem("/file1.txt");
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.api.Binary

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.