Package org.apache.jackrabbit.oak.jcr.delegate

Examples of org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate


        delegate.perform(new SessionOperation<Void>() {
            @Override
            public Void perform() throws RepositoryException {
                Iterator<String> iterator = sessionScopedLocks.iterator();
                while (iterator.hasNext()) {
                    NodeDelegate node = delegate.getNode(iterator.next());
                    if (node != null) {
                        try {
                            node.unlock(); // TODO: use a single commit
                        } catch (RepositoryException e) {
                            log.warn("Failed to unlock a session scoped lock", e);
                        }
                    }
                    iterator.remove();
View Full Code Here


    @Nonnull
    public Node getRootNode() throws RepositoryException {
        return perform(new ReadOperation<Node>() {
            @Override
            public Node perform() throws RepositoryException {
                NodeDelegate nd = sd.getRootNode();
                if (nd == null) {
                    throw new AccessDeniedException("Root node is not accessible.");
                }
                return NodeImpl.createNodeOrNull(nd, sessionContext);
            }
View Full Code Here

    @Nonnull
    private Node getNodeById(final String id) throws RepositoryException {
        return perform(new ReadOperation<Node>() {
            @Override
            public Node perform() throws RepositoryException {
                NodeDelegate nd = sd.getNodeByIdentifier(id);
                if (nd == null) {
                    throw new ItemNotFoundException("Node with id " + id + " does not exist.");
                }
                return NodeImpl.createNodeOrNull(nd, sessionContext);
            }
View Full Code Here

    @Nonnull
    public Node getParent() throws RepositoryException {
        return perform(new PropertyOperation<Node>(dlg) {
            @Override
            public Node perform() throws RepositoryException {
                NodeDelegate parent = property.getParent();
                if (parent == null) {
                    throw new AccessDeniedException();
                } else {
                    return NodeImpl.createNode(parent, sessionContext);
                }
View Full Code Here

            @Override
            public Node perform() throws RepositoryException {
                if (node.isRoot()) {
                    throw new ItemNotFoundException("Root has no parent");
                } else {
                    NodeDelegate parent = node.getParent();
                    if (parent == null) {
                        throw new AccessDeniedException();
                    }
                    return NodeImpl.createNode(parent, sessionContext);
                }
View Full Code Here

            @Override
            public Node perform() throws RepositoryException {
                String oakName = PathUtils.getName(oakPath);
                String parentPath = PathUtils.getParentPath(oakPath);

                NodeDelegate parent = dlg.getChild(parentPath);
                if (parent == null) {
                    // is it a property?
                    String grandParentPath = PathUtils.getParentPath(parentPath);
                    NodeDelegate grandParent = dlg.getChild(grandParentPath);
                    if (grandParent != null) {
                        String propName = PathUtils.getName(parentPath);
                        if (grandParent.getPropertyOrNull(propName) != null) {
                            throw new ConstraintViolationException("Can't add new node to property.");
                        }
                    }

                    throw new PathNotFoundException(relPath);
                }

                if (parent.getChild(oakName) != null) {
                    throw new ItemExistsException(relPath);
                }

                // check for NODE_TYPE_MANAGEMENT permission here as we cannot
                // distinguish between user-supplied and system-generated
                // modification of that property in the PermissionValidator
                if (oakTypeName != null) {
                    PropertyState prop = PropertyStates.createProperty(JCR_PRIMARYTYPE, oakTypeName, NAME);
                    sessionContext.getAccessManager().checkPermissions(dlg.getTree(), prop, Permissions.NODE_TYPE_MANAGEMENT);
                }

                NodeDelegate added = parent.addChild(oakName, oakTypeName);
                if (added == null) {
                    throw new ItemExistsException();
                }
                nodeAdded = added;
View Full Code Here

        delegate.perform(new SessionOperation<Void>() {
            @Override
            public Void perform() throws RepositoryException {
                Iterator<String> iterator = sessionScopedLocks.iterator();
                while (iterator.hasNext()) {
                    NodeDelegate node = delegate.getNode(iterator.next());
                    if (node != null) {
                        try {
                            node.unlock(); // TODO: use a single commit
                        } catch (RepositoryException e) {
                            log.warn("Failed to unlock a session scoped lock", e);
                        }
                    }
                    iterator.remove();
View Full Code Here

    public Node getNode(String relPath) throws RepositoryException {
        final String oakPath = getOakPathOrThrowNotFound(relPath);
        return perform(new NodeOperation<Node>(dlg) {
            @Override
            public Node perform() throws RepositoryException {
                NodeDelegate nd = node.getChild(oakPath);
                if (nd == null) {
                    throw new PathNotFoundException(oakPath);
                } else {
                    return NodeImpl.createNode(nd, sessionContext);
                }
View Full Code Here

    @Nonnull
    public NodeDefinition getDefinition() throws RepositoryException {
        return perform(new NodeOperation<NodeDefinition>(dlg) {
            @Override
            public NodeDefinition perform() throws RepositoryException {
                NodeDelegate parent = node.getParent();
                if (parent == null) {
                    return getNodeTypeManager().getRootDefinition();
                } else {
                    return getNodeTypeManager().getDefinition(
                            parent.getTree(), node.getTree());
                }
            }
        });
    }
View Full Code Here

        });
    }

    @Override @Nonnull
    public Lock getLock() throws RepositoryException {
        NodeDelegate lock = perform(
                new LockOperation<NodeDelegate>(sessionDelegate, dlg) {
                    @Override
                    public NodeDelegate perform(NodeDelegate node) {
                        return node.getLock();
                    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate

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.