Package javax.jcr

Examples of javax.jcr.Item


        Node node3 = session.getNode("/node1/node3");
        assertEquals("/node1/node3", node3.getPath());

        node3.setProperty("property1", "value1");
        Item property1 = session.getProperty("/node1/node3/property1");
        assertFalse(property1.isNode());
        assertEquals("value1", ((Property) property1).getString());

        // Make sure these items are still accessible after refresh(true);
        session.refresh(true);
        assertTrue(session.itemExists("/node1"));
View Full Code Here


    @Override
    public void removeItem(String absPath) throws VersionException,
            LockException, ConstraintViolationException, RepositoryException {
        // check sanity of this session
        sanityCheck();
        Item item;
        try {
            Path p = getQPath(absPath).getNormalizedPath();
            if (!p.isAbsolute()) {
                throw new RepositoryException("not an absolute path: " + absPath);
            }
            item = getItemManager().getItem(p);
        } catch (AccessDeniedException e) {
            throw new PathNotFoundException(absPath);
        } catch (NameException e) {
            String msg = "invalid path:" + absPath;
            log.debug(msg);
            throw new RepositoryException(msg, e);
        }
        item.remove();
    }
View Full Code Here

            log.debug("update item " + item);
        }

        ItemState state = ((ItemImpl) item).getItemState();
        // touch the corresponding cache entry
        Item cacheEntry = getItem(state);
        if (cacheEntry == null) {
            // .. or add the item to the cache, if not present yet.
            cacheItem(state, item);
        }
    }
View Full Code Here

     * @see Dumpable#dump(PrintStream)
     */
    public void dump(PrintStream ps) {
        for (Map.Entry<ItemState, Item> entry : cache.entrySet()) {
            ItemState state = entry.getKey();
            Item item = entry.getValue();
            if (item.isNode()) {
                ps.print("Node: ");
            } else {
                ps.print("Property: ");
            }
            if (item.isNew()) {
                ps.print("new ");
            } else if (item.isModified()) {
                ps.print("modified ");
            } else {
                ps.print("- ");
            }
            String path;
            try {
                path = item.getPath();
            } catch (RepositoryException e) {
                path = "-";
            }
            ps.println(state + "\t" + path + " (" + item + ")");
        }
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

        NodeImpl n = null;
        // shortcut that avoids executing a query.
        if (principal instanceof ItemBasedPrincipal) {
            String authPath = ((ItemBasedPrincipal) principal).getPath();
            if (session.itemExists(authPath)) {
                Item authItem = session.getItem(authPath);
                if (authItem.isNode()) {
                    n = (NodeImpl) authItem;
                }
            }
        } else {
            // another Principal implementation.
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

            session.save();
        } catch (PathNotFoundException e) {
            // item does not exist
        }
        try {
            Item tgt = session.getItem(targetFolder);
            tgt.remove();
            session.save();
        } catch (PathNotFoundException e) {
            // item does not exist
        }
View Full Code Here

        }


        try {
            String itemPath = member.getLocator().getRepositoryPath();
            Item memItem = getJcrSession().getItem(itemPath);
            if (memItem instanceof Node) {
                ((Node)memItem).removeShare();
            } else {
                memItem.remove();
            }
            getJcrSession().save();

            // make sure, non-jcr locks are removed, once the removal is completed
            try {
View Full Code Here

            throw new RepositoryException(msg, e);
        }

        NodeImpl parentNode;
        try {
            Item parent = itemMgr.getItem(parentPath);
            if (!parent.isNode()) {
                String msg = "cannot add a node to property " + parentPath;
                log.debug(msg);
                throw new ConstraintViolationException(msg);
            }
            parentNode = (NodeImpl) parent;
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.