Package javax.jcr

Examples of javax.jcr.Item


                }
            } catch (RepositoryException e) {
                log.error("Failed to retrieve node-specific property: " + e);
            }
            try {
                Item primaryItem = n.getPrimaryItem();
                addHrefProperty(JCR_PRIMARYITEM, new Item[] {primaryItem}, true);
            } catch (ItemNotFoundException e) {
                log.debug("No primary item present on this node '" + getResourcePath() + "'");
            } catch (RepositoryException e) {
                log.error("Error while retrieving primary item: " + e.getMessage());
View Full Code Here


     * @throws RepositoryException
     */
    private static String getCorrespondingResourceHref(DavResource resource, Session session, String workspaceHref) throws RepositoryException {
        DavResourceLocator rLoc = resource.getLocator();
        String itemPath = rLoc.getRepositoryPath();
        Item item = session.getItem(itemPath);
        if (item.isNode()) {
            String workspaceName = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), workspaceHref).getWorkspaceName();
            String corrPath = ((Node)item).getCorrespondingNodePath(workspaceName);
            DavResourceLocator corrLoc = rLoc.getFactory().createResourceLocator(rLoc.getPrefix(), "/" + workspaceName, corrPath, false);
            return corrLoc.getHref(true);
        } else {
View Full Code Here

            AccessDeniedException {

        for (Iterator<ItemInfo> itemInfos = itemInfoStore.getItemInfos(); itemInfos.hasNext();) {
            ItemInfo itemInfo = itemInfos.next();
            String jcrPath = toJCRPath(itemInfo.getPath());
            Item item = session.getItem(jcrPath);
            assertEquals(jcrPath, item.getPath());

            if (item.getDepth() > 0) {
                Node parent = item.getParent();
                if (item.isNode()) {
                    assertTrue(item.isSame(parent.getNode(item.getName())));
                }
                else {
                    assertTrue(item.isSame(parent.getProperty(item.getName())));
                }
            }

        }
    }
View Full Code Here

        String assignedPrefix = superuser.getNamespacePrefix(uri);
        assertTrue(superuser.getNamespaceURI(assignedPrefix).equals(uri));
        String path = testRootNode.getPath() + "/" + nodeName1 + "/" + propertyName1;

        assertTrue(superuser.itemExists(path));
        Item item = superuser.getItem(path);
        if (item.isNode()) {
            fail("Item with path " + path + " must be a property.");
        } else {
            Property prop = (Property) item;
            assertTrue(prop.getValue().getType() == PropertyType.NAME);
            String expectedValue = assignedPrefix + ":someLocalName";
View Full Code Here

    private Node getNodeById(NodeId id) throws ItemNotFoundException, RepositoryException {
        // check sanity of this session
        checkIsAlive();
        try {
            NodeEntry nodeEntry = getHierarchyManager().getNodeEntry(id);
            Item item = getItemManager().getItem(nodeEntry);
            if (item.isNode()) {
                return (Node) item;
            } else {
                log.error("NodeId '" + id + " does not point to a Node");
                throw new ItemNotFoundException(LogUtil.saveGetIdString(id, getPathResolver()));
            }
View Full Code Here

    /**
     * @see Session#removeItem(String)
     */
    @Override
    public void removeItem(String absPath) throws RepositoryException {
        Item item = getItem(absPath);
        item.remove();
    }
View Full Code Here

                            int i = rnd.nextInt(nodePaths.size() + propertyPaths.size());
                            String path = i < nodePaths.size()
                                ? nodePaths.get(i)
                                : propertyPaths.get(i - nodePaths.size());
                            long t1 = System.currentTimeMillis();
                            Item item = session.getItem(path);
                            long t2 = System.currentTimeMillis();
                            items.add(item);
                            return t2 - t1;
                        }

                        @Override
                        public String toString() {
                            return "getItem";
                        }
                    });
                    break;
                }

                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;
                        }

                        @Override
                        public String toString() {
                            return "getNode";
                        }
                    });
                    break;
                }

                case 2: { // getProperty
                    callables.add(new Callable<Long>() {
                        public Long call() throws Exception {
                            String path = propertyPaths.get(rnd.nextInt(propertyPaths.size()));
                            long t1 = System.currentTimeMillis();
                            Property property = session.getProperty(path);
                            long t2 = System.currentTimeMillis();
                            items.add(property);
                            return t2 - t1;
                        }

                        @Override
                        public String toString() {
                            return "getProperty";
                        }
                    });
                    break;
                }

                case 3: { // refresh
                    callables.add(new Callable<Long>() {
                        public Long call() throws Exception {
                            if (items.isEmpty()) {
                                return 0L;
                            }
                            Item item = items.get(rnd.nextInt(items.size()));
                            long t1 = System.currentTimeMillis();
                            item.refresh(rnd.nextBoolean());
                            long t2 = System.currentTimeMillis();
                            return t2 - t1;
                        }

                        @Override
View Full Code Here

     * @see DiffHandler#setProperty(String, String)
     */
    public void setProperty(String targetPath, String diffValue) throws DiffException {
        try {
            String itemPath = getItemPath(targetPath);
            Item item = session.getItem(Text.getRelativeParent(itemPath, 1));
            if (!item.isNode()) {
                throw new DiffException("No such node " + itemPath, new ItemNotFoundException(itemPath));
            }

            Node parent = (Node) item;
            String propName = Text.getName(itemPath);
View Full Code Here

            } else {
                String srcName = Text.getName(srcPath);
                int pos = diffValue.lastIndexOf('#');
                String destName = (pos == 0) ? null : Text.getName(diffValue.substring(0, pos));

                Item item = session.getItem(Text.getRelativeParent(srcPath, 1));
                if (!item.isNode()) {
                    throw new ItemNotFoundException(srcPath);
                }
                Node parent = (Node) item;

                if (ORDER_POSITION_FIRST.equals(orderPosition)) {
View Full Code Here

        return normalize(itemPath.toString());
    }

    private void addNode(String parentPath, String nodeName, String diffValue)
            throws DiffException, RepositoryException {
        Item item = session.getItem(parentPath);
        if (!item.isNode()) {
            throw new ItemNotFoundException(parentPath);
        }

        Node parent = (Node) item;
        try {
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.