Examples of ReferenceBinary


Examples of org.apache.jackrabbit.api.ReferenceBinary

        Session firstSession = superuser;

        // create a binary
        Binary b = vf.createBinary(new RandomInputStream(1, STREAM_LENGTH));

        ReferenceBinary referenceBinary = null;
        if (b instanceof ReferenceBinary) {
            referenceBinary = (ReferenceBinary) b;
        }

        assertNotNull(referenceBinary);

        assertNotNull(referenceBinary.getReference());

        // in the current test the message is exchanged via repository which is shared as well
        // put the reference message value in a property on a node
        String newNode = "sample_" + System.nanoTime();
        firstSession.getRootNode().addNode(newNode).setProperty("reference", referenceBinary.getReference());

        // save the first session
        firstSession.save();

        // get a second session over the same repository / ds
        Session secondSession = getHelper().getRepository().login(new SimpleCredentials("admin", "admin".toCharArray()));

        // read the binary referenced by the referencing binary
        String reference = secondSession.getRootNode().getNode(newNode).getProperty("reference").getString();

        ReferenceBinary ref = new SimpleReferenceBinary(reference);

        assertEquals(b, secondSession.getValueFactory().createValue(ref).getBinary());

    }
View Full Code Here

Examples of org.apache.jackrabbit.api.ReferenceBinary

        Session firstSession = createAdminSession();

        // create a binary
        Binary b = firstSession.getValueFactory().createBinary(new RandomInputStream(1, STREAM_LENGTH));

        ReferenceBinary referenceBinary = null;
        if (b instanceof ReferenceBinary) {
            referenceBinary = (ReferenceBinary) b;
        }

        assertNotNull(referenceBinary);

        assertNotNull(referenceBinary.getReference());

        // in the current test the message is exchanged via repository which is shared as well
        // put the reference message value in a property on a node
        String newNode = "sample_" + System.nanoTime();
        firstSession.getRootNode().addNode(newNode).setProperty("reference", referenceBinary.getReference());

        // save the first session
        firstSession.save();

        // get a second session over the same repository / ds
        Session secondSession = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));

        // read the binary referenced by the referencing binary
        String reference = secondSession.getRootNode().getNode(newNode).getProperty("reference").getString();

        ReferenceBinary ref = new SimpleReferenceBinary(reference);

        assertEquals(b, secondSession.getValueFactory().createValue(ref).getBinary());

        safeLogout(firstSession);
        safeLogout(secondSession);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.