Package javax.jcr

Examples of javax.jcr.Node


            move((Property) item, parent);
        }
    }

    private void removeRec(Node node) throws RepositoryException {
        Node n = node;
        while (!n.hasNodes() && !isRoot(n)) {
            Node d = n;
            n = n.getParent();
            d.remove();
        }
    }
View Full Code Here


                return nodes.hasNext();
            }

            @SuppressWarnings("unchecked")
            public Iterator<Property> next() {
                Node n = nodes.next();
                try {
                    return n.getProperties();
                } catch (RepositoryException e) {
                    errorHandler.call(n, e);
                    return empty();
                }
            }
View Full Code Here

                            final Name nodetypeName,
                            final String uuid) throws RepositoryException {
            executeGuarded(new Callable() {
                public Object run() throws RepositoryException {
                    Session s = sInfo.getSession();
                    Node parent = getParent(parentId, sInfo);

                    String jcrName = getJcrName(nodeName);
                    String ntName = getJcrName(nodetypeName);
                    if (uuid == null) {
                        if (ntName == null) {
                            parent.addNode(jcrName);
                        } else {
                            parent.addNode(jcrName, ntName);
                        }
                    } else {
                        String xml = createXMLFragment(jcrName, ntName, uuid);
                        InputStream in = new ByteArrayInputStream(xml.getBytes());
                        try {
                            s.importXML(parent.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
                        } catch (IOException e) {
                            throw new RepositoryException(e.getMessage(), e);
                        }
                    }
                    return null;
View Full Code Here

                                final QValue value)
                throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
            executeGuarded(new Callable() {
                public Object run() throws RepositoryException {
                    Session s = sInfo.getSession();
                    Node parent = getParent(parentId, sInfo);
                    Value jcrValue = ValueFormat.getJCRValue(value,
                            sInfo.getNamePathResolver(), s.getValueFactory());
                    parent.setProperty(getJcrName(propertyName), jcrValue);
                    return null;
                }
            });
        }
View Full Code Here

                                final Name propertyName,
                                final QValue[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
            executeGuarded(new Callable() {
                public Object run() throws RepositoryException {
                    Session s = sInfo.getSession();
                    Node n = getParent(parentId, sInfo);
                    Value[] jcrValues = new Value[values.length];
                    for (int i = 0; i < jcrValues.length; i++) {
                        jcrValues[i] = ValueFormat.getJCRValue(values[i],
                                sInfo.getNamePathResolver(), s.getValueFactory());
                    }
                    n.setProperty(getJcrName(propertyName), jcrValues);
                    return null;
                }
            });
        }
View Full Code Here

                                 final NodeId srcNodeId,
                                 final NodeId beforeNodeId)
                throws RepositoryException {
            executeGuarded(new Callable() {
                public Object run() throws RepositoryException {
                    Node parent = getParent(parentId, sInfo);
                    Node srcNode = getNode(srcNodeId, sInfo);
                    Node beforeNode = null;
                    if (beforeNodeId != null) {
                        beforeNode = getNode(beforeNodeId, sInfo);
                    }
                    String srcPath = srcNode.getName();
                    if (srcNode.getIndex() > 1) {
                        srcPath += "[" + srcNode.getIndex() + "]";
                    }
                    String beforePath = null;
                    if (beforeNode != null) {
                        beforePath = beforeNode.getName();
                        if (beforeNode.getIndex() > 1) {
                            beforePath += "[" + beforeNode.getIndex() + "]";
                        }
                    }
                    parent.orderBefore(srcPath, beforePath);
                    return null;
                }
View Full Code Here

                public Object run() throws RepositoryException {
                    Set<String> mixinNames = new HashSet<String>();
                    for (Name mixinNodeTypeId : mixinNodeTypeIds) {
                        mixinNames.add(getJcrName(mixinNodeTypeId));
                    }
                    Node n = getNode(nodeId, sInfo);
                    Set<String> currentMixins = new HashSet<String>();
                    for (NodeType nt : n.getMixinNodeTypes()) {
                        currentMixins.add(nt.getName());
                    }
                    Set<String> remove = new HashSet<String>(currentMixins);
                    remove.removeAll(mixinNames);
                    mixinNames.removeAll(currentMixins);
                    for (String mixName : remove) {
                        n.removeMixin(mixName);
                    }
                    for (String mixName : mixinNames) {
                        n.addMixin(mixName);
                    }
                    return null;
                }
            });
        }
View Full Code Here

        }

        public void setPrimaryType(final NodeId nodeId, final Name primaryNodeTypeName) throws RepositoryException {
            executeGuarded(new Callable() {
                public Object run() throws RepositoryException {
                    Node n = getNode(nodeId, sInfo);
                    n.setPrimaryType(getJcrName(primaryNodeTypeName));
                    return null;
                }
            });
        }
View Full Code Here

                case 1: { // getNode
                    callables.add(new Callable<Long>() {
                        public Long call() throws Exception {
                            String path = nodePaths.get(rnd.nextInt(nodePaths.size()));
                            long t1 = System.currentTimeMillis();
                            Node node = session.getNode(path);
                            long t2 = System.currentTimeMillis();
                            items.add(node);
                            return t2 - t1;
                        }
View Full Code Here

    /**
     * @see javax.jcr.Session#getNodeByUUID(String)
     */
    public Node getNodeByUUID(String uuid) throws ItemNotFoundException, RepositoryException {
        // sanity check performed by getNodeById
        Node node = getNodeById(getIdFactory().createNodeId(uuid));
        if (node instanceof NodeImpl && ((NodeImpl)node).isNodeType(NameConstants.MIX_REFERENCEABLE)) {
            return node;
        } else {
            // fall back
            String mixReferenceable = getNameResolver().getJCRName(NameConstants.MIX_REFERENCEABLE);
            if (node.isNodeType(mixReferenceable)) {
                return node;
            }
            // there is a node with that uuid but the node does not expose it
            throw new ItemNotFoundException(uuid);
        }
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.