Package javax.jcr

Examples of javax.jcr.Item


        }
    }

    @Override
    public Node getNode(final String absPath) throws RepositoryException {
        Item item = getItem(absPath);
        if (item instanceof Node) {
            return (Node) item;
        } else {
            throw new PathNotFoundException(String.format("No node found at: %s.", absPath));
        }
View Full Code Here


        throw new ItemNotFoundException(String.format("No node found with id: %s.", id));
    }

    @Override
    public Property getProperty(final String absPath) throws RepositoryException {
        Item item = getItem(absPath);
        if (item instanceof Property) {
            return (Property) item;
        } else {
            throw new PathNotFoundException(String.format("No property found at: %s.", absPath));
        }
View Full Code Here

        this.handleChangeEvent(path);
        Session session = null;
        try {
            session = createSession();
            if (session.itemExists(path)) {
                Item fileItem = session.getItem(path);
                fileItem.remove();
                session.save();
                return true;
            }
        } catch (final RepositoryException re) {
            logger.error("Cannot remove " + path, re);
View Full Code Here

                }
                Node fileNode = null;
                Node contentNode = null;
                Node parentNode = null;
                if (session.itemExists(fileName)) {
                    final Item item = session.getItem(fileName);
                    if (item.isNode()) {
                        final Node node = item.isNode() ? (Node) item : item.getParent();
                        if ("jcr:content".equals(node.getName())) {
                            // replace the content properties of the jcr:content
                            // node
                            parentNode = node;
                            contentNode = node;
                        } else if (node.isNodeType("nt:file")) {
                            // try to set the content properties of jcr:content
                            // node
                            parentNode = node;
                            contentNode = node.getNode("jcr:content");
                        } else { // fileName is a node
                            // try to set the content properties of the node
                            parentNode = node;
                            contentNode = node;
                        }
                    } else {
                        // replace property with an nt:file node (if possible)
                        parentNode = item.getParent();
                        item.remove();
                        session.save();
                        fileNode = parentNode.addNode(name, "nt:file");
                    }
                } else {
                    if (lastPos <= 0) {
                        parentNode = session.getRootNode();
                    } else {
                        Item parent = session.getItem(path);
                        if (!parent.isNode()) {
                            throw new IOException("Parent at " + path + " is not a node.");
                        }
                        parentNode = (Node) parent;
                    }
                    fileNode = parentNode.addNode(name, "nt:file");
View Full Code Here

                }
                currentNode = currentNode.getNode(name);
            }
            return currentNode;
        }
        Item item = session.getItem(path);
        return (item.isNode()) ? (Node) item : null;
    }
View Full Code Here

                if (content.hasProperty(JCR_DATA)) {
                    data = content.getProperty(JCR_DATA);
                } else {
                    // otherwise try to follow default item trail
                    try {
                        Item item = content.getPrimaryItem();
                        while (item.isNode()) {
                            item = ((Node) item).getPrimaryItem();
                        }
                        data = (Property) item;

                    } catch (ItemNotFoundException infe) {
View Full Code Here

    public void jsConstructor(Object res) {
        if (res instanceof Iterator<?>) {
            Iterator<?> itemIterator = (Iterator<?>) res;
            while (itemIterator.hasNext()) {
                Item item = (Item) itemIterator.next();
                try {
                    items.put(item.getName(), item);
                } catch (RepositoryException re) {
                    log.error("ScriptableItemMap<init>: Cannot get name of item "
                        + item, re);
                }
            }
View Full Code Here

        return items.containsKey(name);
    }

    @Override
    public Object get(int index, Scriptable start) {
        Item item = getItem(index);
        if (item != null) {
            return ScriptRuntime.toObject(this, item);
        }

        return Undefined.instance;
View Full Code Here

        // special provision for the "length" property to simulate an array
        if ("length".equals(name)) {
            return ScriptRuntime.toNumber(this.items.keySet().size()+"");
        }

        Item item = items.get(name);
        Object result = Undefined.instance;
        if (item != null) {
            result = ScriptRuntime.toObject(this, item);
        }
View Full Code Here

     *             item in the repository.
     */
    private JcrItemResource createResource(final ResourceResolver resourceResolver,
            final String path) throws RepositoryException {
        if (itemExists(path)) {
            Item item = session.getItem(path);
            if (item.isNode()) {
                log.debug(
                    "createResource: Found JCR Node Resource at path '{}'",
                    path);
                return new JcrNodeResource(resourceResolver, path, (Node) item, dynamicClassLoader);
            }
View Full Code Here

TOP

Related Classes of javax.jcr.Item

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.