Package javax.jcr

Examples of javax.jcr.Node


    }

    @Test
    public void testNodeRemove() throws RepositoryException {
        Node rootNode = this.session.getRootNode();
        Node node1 = rootNode.addNode("node1");
        assertTrue(this.session.itemExists("/node1"));
        node1.remove();
        assertFalse(this.session.itemExists("/node1"));
        assertFalse(rootNode.getNodes().hasNext());
    }
View Full Code Here


        assertFalse(rootNode.getNodes().hasNext());
    }

    @Test
    public void testNodesWithSpecialNames() throws RepositoryException {
        Node rootNode = this.session.getRootNode();

        Node node1 = rootNode.addNode("node1.ext");
        Node node11 = node1.addNode("Node Name With Spaces");
        node11.setProperty("prop11", "value11");
        Node node12 = node1.addNode("node12_ext");
        node12.setProperty("prop12", "value12");

        assertTrue(this.session.itemExists("/node1.ext"));
        assertTrue(this.session.itemExists("/node1.ext/Node Name With Spaces"));
        assertTrue(this.session.itemExists("/node1.ext/node12_ext"));

        assertEquals("value11", node11.getProperty("prop11").getString());
        assertEquals("value12", node12.getProperty("prop12").getString());

        NodeIterator nodes = node1.getNodes();
        assertEquals(2, nodes.getSize());
    }
View Full Code Here

    }

    @Override
    protected ResourceProxy execute0(Session session) throws RepositoryException {

        Node node = session.getNode(getPath());

        return nodeToResource(node);
    }
View Full Code Here

     * @param weak true to create a WeakReference value
     * @return the value or <code>null</code>
     * @throws RepositoryException
     */
    public Value parse(String value, ValueFactory factory, boolean weak) throws RepositoryException {
        Node n = parse(value);
        if (n == null) {
            return null;
        }
        return createReferenceValue(n, factory, weak);
    }
View Full Code Here

     * @throws RepositoryException
     */
    public Value[] parse(String[] values, ValueFactory factory, boolean weak) throws RepositoryException {
        Value ret[] = new Value[values.length];
        for (int i=0; i< values.length; i++) {
            Node n = parse(values[i]);
            if (n == null) {
                return null;
            }
            ret[i] = createReferenceValue(n, factory, weak);
        }
View Full Code Here

        ValueMap props = ResourceUtil.getValueMap(resource);
        assertEquals("/content/dam/sample/header.png", props.get("imageReference", String.class));
    }

    private void assertPrimaryNodeType(final Resource resource, final String nodeType) throws RepositoryException {
        Node node = resource.adaptTo(Node.class);
        if (node != null) {
            assertEquals(nodeType, node.getPrimaryNodeType().getName());
        } else {
            ValueMap props = ResourceUtil.getValueMap(resource);
            assertEquals(nodeType, props.get(JcrConstants.JCR_PRIMARYTYPE));
        }
    }
View Full Code Here

        Aggregator aggregator = fs.getAggregateManager().getAggregator(aggregate.getNode(), null);
        boolean needsDir = true;
        if (aggregator instanceof FileAggregator) {
            needsDir = false;
            // TODO - copy-pasted from FileAggregator, and really does not belong here...
            Node content = aggregate.getNode();
            if (content.isNodeType(JcrConstants.NT_FILE)) {
                content = content.getNode(JcrConstants.JCR_CONTENT);
            }
            String mimeType = null;
            if (content.hasProperty(JcrConstants.JCR_MIMETYPE)) {
                try {
                    mimeType = content.getProperty(JcrConstants.JCR_MIMETYPE).getString();
                } catch (RepositoryException e) {
                    // ignore
                }
            }
            if (mimeType == null) {
                // guess mime type from name
                mimeType = MimeTypes.getMimeType(aggregate.getNode().getName(),
                        MimeTypes.APPLICATION_OCTET_STREAM);
            }

            needsDir = !MimeTypes.matches(aggregate.getNode().getName(), mimeType,
                    MimeTypes.APPLICATION_OCTET_STREAM);

            if (!needsDir) {
                if (content.hasProperty(JcrConstants.JCR_MIXINTYPES)) {
                    for (Value v : content.getProperty(JcrConstants.JCR_MIXINTYPES).getValues()) {
                        if (!v.getString().equals(JcrConstants.MIX_LOCKABLE)) {
                            needsDir = true;
                            break;
                        }
                    }
View Full Code Here

            QueryResult queryres = qm.createQuery(
                "SELECT * FROM [sling:chunks] ", Query.JCR_SQL2).execute();
            NodeIterator nodeItr = queryres.getNodes();
            while (nodeItr.hasNext()) {
                Node node = nodeItr.nextNode();
                if (isEligibleForCleanUp(node)) {
                    numCleaned++;
                    uploadhandler.deleteChunks(node);
                } else {
                    numLive++;
View Full Code Here

     *            {@link Node}s
     * @return true if eligible else false.
     * @throws RepositoryException
     */
    private boolean isEligibleForCleanUp(Node node) throws RepositoryException {
        Node lastChunkNode = uploadhandler.getLastChunk(node);
        return lastChunkNode != null
            && (System.currentTimeMillis() - lastChunkNode.getProperty(
                javax.jcr.Property.JCR_CREATED).getDate().getTimeInMillis()) > chunkCleanUpAge;
    }
View Full Code Here

    @Override
    public Node addNode(final String relPath, final String primaryNodeTypeName) throws RepositoryException {
        String path = makeAbsolutePath(relPath);
        ItemData itemData = ItemData.newNode(path, new MockNodeType(primaryNodeTypeName));
        Node node = new MockNode(itemData, getSession());
        getMockedSession().addItem(itemData);
        return node;
    }
View Full Code Here

TOP

Related Classes of javax.jcr.Node

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.