Package org.modeshape.jcr.api

Examples of org.modeshape.jcr.api.JcrTools$Operation


    }

    @Test
    @FixFor("MODE-1573")
    public void shouldPerformRoundTripOnDocumentViewWithBinaryContent() throws Exception {
        JcrTools tools = new JcrTools();

        File binaryFile = new File("src/test/resources/io/binary.pdf");
        assert (binaryFile.exists() && binaryFile.isFile());

        File outputFile = File.createTempFile("modeshape_import_export_" + System.currentTimeMillis(), "_test");
        outputFile.deleteOnExit();
        tools.uploadFile(session, "file", binaryFile);
        session.save();
        session.exportDocumentView("/file", new FileOutputStream(outputFile), false, false);
        assertTrue(outputFile.length() > 0);

        session.getRootNode().getNode("file").remove();
View Full Code Here


        sessC.importXML("/", brixWorkspace, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
        sessC.save();

        // re-import
        if (print) {
            new JcrTools().printSubgraph(sessA.getNode(root));
        }
        sessA.getItem(root).remove();
        sessA.save();

        brixWorkspace = resourceStream("io/brixWorkspace.xml");
View Full Code Here

    private Projection[] projections;
    private JcrTools tools;

    @Before
    public void before() throws Exception {
        tools = new JcrTools();
        readOnlyProjection = new Projection("readonly-files", "target/federation/files-read");
        readOnlyProjectionWithExclusion = new Projection("readonly-files-with-exclusion",
                                                         "target/federation/files-read-exclusion");
        readOnlyProjectionWithInclusion = new Projection("readonly-files-with-inclusion",
                                                         "target/federation/files-read-inclusion");
View Full Code Here

            System.exit(-1);
            return;
        }

        Session session = null;
        JcrTools tools = new JcrTools();
        try {
            // Get the repository
            repository = engine.getRepository(repositoryName);

            // Create a session ...
            session = repository.login("default");

            // Create the '/files' node that is an 'nt:folder' ...
            Node root = session.getRootNode();
            Node filesNode = root.addNode("files", "nt:folder");
            assert filesNode != null;

            // Update a couple of files ...
            tools.uploadFile(session, "/files/caution.png", getFile("caution.png"));
            tools.uploadFile(session, "/files/sample1.mp3", getFile("sample1.mp3"));
            tools.uploadFile(session, "/files/fixedWidthFile.txt", getFile("fixedWidthFile.txt"));
            tools.uploadFile(session, "/files/JcrRepository.class", getFile("JcrRepository.clazz"));

            // Save the session ...
            session.save();

            // Now look for the output. Note that sequencing may take a bit, so we'll cheat by just trying
            // to find the node until we can find it, waiting a maximum amount of time before failing.
            // The proper way is to either use events or not to expect the sequencers have finished.
            Node png = findNodeAndWait(session, "/images/caution.png", 10, TimeUnit.SECONDS);
            if (print) tools.printSubgraph(png);

            Node sampleMp3 = findNodeAndWait(session, "/audio/sample1.mp3", 10, TimeUnit.SECONDS);
            if (print) tools.printSubgraph(sampleMp3);

            Node javaClass = findNodeAndWait(session, "/java/JcrRepository.class", 10, TimeUnit.SECONDS);
            if (print) tools.printSubgraph(javaClass);

            Node textFile = findNodeAndWait(session, "/text/fixedWidthFile.txt", 10, TimeUnit.SECONDS);
            if (print) tools.printSubgraph(textFile);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (session != null) session.logout();
View Full Code Here

        assertTrue(subFolder.exists());
        assertTrue(subFolder.isDirectory());

        //now add a file
        ByteArrayInputStream bis = new ByteArrayInputStream("test string".getBytes());
        new JcrTools().uploadFile(session, "/root/sub_folder/file", bis);
        session.save();
        File file = new File(subFolder, "file");
        assertTrue(file.exists());
        assertTrue(file.isFile());
        assertEquals("test string", IoUtil.read(file));
View Full Code Here

            assertThat(testFile.getPath() + " should be a file", testFile.isFile(), is(true));
            assertThat(testFile.getPath() + " should be readable", testFile.canRead(), is(true));
            testFileSizesInBytes.put(testFile.getName(), testFile.length());
        }

        final JcrTools tools = new JcrTools();

        startRunStop(new RepositoryOperation() {
            @Override
            public Void call() throws Exception {
                Session session = repository.login();

                // Add some content ...
                session.getRootNode().addNode("testNode");
                for (File testFile : testFiles) {
                    String name = testFile.getName();
                    Node fileNode = tools.uploadFile(session, "/testNode/" + name, testFile);
                    Binary binary = fileNode.getNode("jcr:content").getProperty("jcr:data").getBinary();
                    assertThat(binary.getSize(), is(testFileSizesInBytes.get(name)));
                }

                session.save();
View Full Code Here

    public void beforeEach() throws Exception {
        super.beforeEach();
        if (startRepositoryAutomatically()) {
            startRepository();
        }
        tools = new JcrTools();
    }
View Full Code Here

        }
    }

    protected void printSubgraph( Node node ) throws RepositoryException {
        if (print) {
            JcrTools tools = new JcrTools();
            tools.printSubgraph(node);
        }
    }
View Full Code Here

        // Create node structure
        Node root1 = getTestRoot(session1);
        Node folder1 = root1.addNode("folder1", "nt:folder");
        String fileName = "simple.json";
        String filePath = folder1.getPath() + "/" + fileName;
        new JcrTools().uploadFile(session1, filePath, getClass().getResourceAsStream("/data/" + fileName));
        session1.save();

        // Find the primary item ...
        Node file1 = folder1.getNode(fileName);
        Node content = file1.getNode("jcr:content");
View Full Code Here

        }
    }

    protected void printDetails( Node node ) throws RepositoryException {
        if (print) {
            new JcrTools(true).printNode(node);
        }
    }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.api.JcrTools$Operation

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.