Examples of ItemDelegate


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

    }

    @CheckForNull
    private ItemImpl<?> getItemInternal(@Nonnull String oakPath)
            throws RepositoryException {
        ItemDelegate item = sd.getItem(oakPath);
        if (item instanceof NodeDelegate) {
            return NodeImpl.createNodeOrNull((NodeDelegate) item, sessionContext);
        } else if (item instanceof PropertyDelegate) {
            return new PropertyImpl((PropertyDelegate) item, sessionContext);
        } else {
View Full Code Here

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

    public void removeItem(final String absPath) throws RepositoryException {
        final String oakPath = getOakPathOrThrowNotFound(absPath);
        perform(new WriteOperation<Void>() {
            @Override
            public Void perform() throws RepositoryException {
                ItemDelegate item = sd.getItem(oakPath);
                if (item == null) {
                    throw new PathNotFoundException(absPath);
                } else if (item.isProtected()) {
                    throw new ConstraintViolationException(
                            item.getPath() + " is protected");
                } else if (item.remove()) {
                    return null;
                } else {
                    throw new RepositoryException(
                            item.getPath() + " could not be removed");
                }
            }
        });
    }
View Full Code Here

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

    @Override
    public boolean hasCapability(String methodName, Object target, Object[] arguments) throws RepositoryException {
        sd.checkAlive();

        if (target instanceof ItemImpl) {
            ItemDelegate dlg = ((ItemImpl) target).dlg;
            if (dlg.isProtected()) {
                return false;
            }

            boolean isNode = ((ItemImpl) target).isNode();
            Node parent = (isNode) ? (Node) target : ((ItemImpl) target).getParent();
            if (!parent.isCheckedOut()) {
                return false;
            }
            if (parent.isLocked()) {
                return false;
            }

            AccessManager accessMgr = sessionContext.getAccessManager();
            long permission = Permissions.NO_PERMISSION;
            if (isNode) {
                Tree tree = ((NodeDelegate) dlg).getTree();
                if ("addNode".equals(methodName)) {
                    if (arguments != null && arguments.length > 0) {
                        // add-node needs to be checked on the (path of) the
                        // new node that has/will be added
                        String path = PathUtils.concat(tree.getPath(), sessionContext.getOakName(arguments[0].toString()));
                        return accessMgr.hasPermissions(path, Session.ACTION_ADD_NODE);
                    }
                } else if ("setPrimaryType".equals(methodName) || "addMixin".equals(methodName) || "removeMixin".equals(methodName)) {
                    permission = Permissions.NODE_TYPE_MANAGEMENT;
                } else if ("orderBefore".equals(methodName)) {
                    if (tree.isRoot()) {
                        return false;
                    } else {
                        permission = Permissions.MODIFY_CHILD_NODE_COLLECTION;
                        tree = tree.getParent();
                    }
                } else if ("setProperty".equals(methodName)) {
                    permission = Permissions.ADD_PROPERTY;
                } else if ("remove".equals(methodName)) {
                    permission = Permissions.REMOVE_NODE;
                }
                return accessMgr.hasPermissions(tree, null, permission);
            } else {
                if (methodName.equals("setValue")) {
                    permission = Permissions.MODIFY_PROPERTY;
                } else if ("remove".equals(methodName)) {
                    permission = Permissions.REMOVE_PROPERTY;
                }
                Tree tree = dlg.getParent().getTree();
                return accessMgr.hasPermissions(tree, ((PropertyDelegate) dlg).getPropertyState(), permission);
            }
        }
        // TODO: add more best-effort checks
        return true;
View Full Code Here

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

                    getPath() + "Invalid ancestor depth " + depth);
        } else if (depth == 0) {
            return sessionContext.getSession().getRootNode();
        }

        ItemDelegate ancestor = perform(new ItemOperation<ItemDelegate>(dlg) {
            @Override
            public ItemDelegate perform() throws RepositoryException {
                String path = item.getPath();

                int slash = 0;
View Full Code Here

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

                    getPath() + "Invalid ancestor depth " + depth);
        } else if (depth == 0) {
            return sessionContext.getSession().getRootNode();
        }

        ItemDelegate ancestor = perform(new ItemOperation<ItemDelegate>(dlg) {
            @Override
            public ItemDelegate perform() throws RepositoryException {
                String path = item.getPath();

                int slash = 0;
View Full Code Here

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

                    getPath() + "Invalid ancestor depth " + depth);
        } else if (depth == 0) {
            return sessionContext.getSession().getRootNode();
        }

        ItemDelegate ancestor = perform(new ItemOperation<ItemDelegate>(dlg) {
            @Override
            public ItemDelegate perform() throws RepositoryException {
                String path = item.getPath();

                int slash = 0;
View Full Code Here

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

    }

    @CheckForNull
    private ItemImpl<?> getItemInternal(@Nonnull String oakPath)
            throws RepositoryException {
        ItemDelegate item = sd.getItem(oakPath);
        if (item instanceof NodeDelegate) {
            return NodeImpl.createNodeOrNull((NodeDelegate) item, sessionContext);
        } else if (item instanceof PropertyDelegate) {
            return new PropertyImpl((PropertyDelegate) item, sessionContext);
        } else {
View Full Code Here

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

    public void removeItem(final String absPath) throws RepositoryException {
        final String oakPath = getOakPathOrThrowNotFound(absPath);
        perform(new WriteOperation<Void>() {
            @Override
            public Void perform() throws RepositoryException {
                ItemDelegate item = sd.getItem(oakPath);
                if (item == null) {
                    throw new PathNotFoundException(absPath);
                } else if (item.isProtected()) {
                    throw new ConstraintViolationException(
                            item.getPath() + " is protected");
                } else if (item.remove()) {
                    return null;
                } else {
                    throw new RepositoryException(
                            item.getPath() + " could not be removed");
                }
            }
        });
    }
View Full Code Here

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

    @Override
    public boolean hasCapability(String methodName, Object target, Object[] arguments) throws RepositoryException {
        sd.checkAlive();

        if (target instanceof ItemImpl) {
            ItemDelegate dlg = ((ItemImpl) target).dlg;
            if (dlg.isProtected()) {
                return false;
            }

            boolean isNode = ((ItemImpl) target).isNode();
            Node parent = (isNode) ? (Node) target : ((ItemImpl) target).getParent();
            if (!parent.isCheckedOut()) {
                return false;
            }
            if (parent.isLocked()) {
                return false;
            }

            AccessManager accessMgr = sessionContext.getAccessManager();
            long permission = Permissions.NO_PERMISSION;
            if (isNode) {
                Tree tree = ((NodeDelegate) dlg).getTree();
                if ("addNode".equals(methodName)) {
                    if (arguments != null && arguments.length > 0) {
                        // add-node needs to be checked on the (path of) the
                        // new node that has/will be added
                        String path = PathUtils.concat(tree.getPath(), sessionContext.getOakName(arguments[0].toString()));
                        return accessMgr.hasPermissions(path, Session.ACTION_ADD_NODE);
                    }
                } else if ("setPrimaryType".equals(methodName) || "addMixin".equals(methodName) || "removeMixin".equals(methodName)) {
                    permission = Permissions.NODE_TYPE_MANAGEMENT;
                } else if ("orderBefore".equals(methodName)) {
                    if (tree.isRoot()) {
                        return false;
                    } else {
                        permission = Permissions.MODIFY_CHILD_NODE_COLLECTION;
                        tree = tree.getParent();
                    }
                } else if ("setProperty".equals(methodName)) {
                    permission = Permissions.ADD_PROPERTY;
                } else if ("remove".equals(methodName)) {
                    permission = Permissions.REMOVE_NODE;
                }
                return accessMgr.hasPermissions(tree, null, permission);
            } else {
                if (methodName.equals("setValue")) {
                    permission = Permissions.MODIFY_PROPERTY;
                } else if ("remove".equals(methodName)) {
                    permission = Permissions.REMOVE_PROPERTY;
                }
                Tree tree = dlg.getParent().getTree();
                return accessMgr.hasPermissions(tree, ((PropertyDelegate) dlg).getPropertyState(), permission);
            }
        }
        // TODO: add more best-effort checks
        return true;
View Full Code Here

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

    }

    @CheckForNull
    private ItemImpl<?> getItemInternal(@Nonnull String oakPath)
            throws RepositoryException {
        ItemDelegate item = sd.getItem(oakPath);
        if (item instanceof NodeDelegate) {
            return NodeImpl.createNodeOrNull((NodeDelegate) item, sessionContext);
        } else if (item instanceof PropertyDelegate) {
            return new PropertyImpl((PropertyDelegate) item, sessionContext);
        } else {
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.