Package javax.jcr

Examples of javax.jcr.NodeIterator


        for (int i = 0; i < supertypesFromManager.length; i++) {
            assertEquals(supertypesFromManager[i].getName(), supertypesFromGraph[i].getString());
        }

        Map<PropertyDefinitionKey, Node> propertyDefsFromGraph = new HashMap<PropertyDefinitionKey, Node>();
        NodeIterator properties = typeNode.getNodes(JcrLexicon.PROPERTY_DEFINITION.getString(registry));
        while (properties.hasNext()) {
            Node def = properties.nextNode();
            propertyDefsFromGraph.put(new PropertyDefinitionKey(def, registry), def);
        }

        PropertyDefinition[] propertyDefs = nodeType.getDeclaredPropertyDefinitions();
        for (int i = 0; i < propertyDefs.length; i++) {
            JcrPropertyDefinition propertyDef = (JcrPropertyDefinition)propertyDefs[i];
            Node propNode = propertyDefsFromGraph.get(new PropertyDefinitionKey(propertyDef));
            compareProperty(propertyDef, propNode, registry);
        }

        Map<NodeDefinitionKey, Node> nodeDefsFromGraph = new HashMap<NodeDefinitionKey, Node>();
        NodeIterator nodes = typeNode.getNodes(JcrLexicon.CHILD_NODE_DEFINITION.getString(registry));
        while (nodes.hasNext()) {
            Node def = nodes.nextNode();
            nodeDefsFromGraph.put(new NodeDefinitionKey(def, registry), def);
        }

        NodeDefinition[] nodeDefs = nodeType.getDeclaredChildNodeDefinitions();
        for (int i = 0; i < nodeDefs.length; i++) {
View Full Code Here


    }

    protected int traverseChildren( Node parentNode ) throws Exception {

        int childCount = 0;
        NodeIterator children = parentNode.getNodes();

        while (children.hasNext()) {
            childCount++;

            childCount += traverseChildren(children.nextNode());
        }

        return childCount;
    }
View Full Code Here

        prius.getNode(null);
    }

    @Test
    public void shouldProvideNodeIterator() throws Exception {
        NodeIterator iter = hybrid.getNodes();
        assertThat(iter, notNullValue());
        assertThat(iter.getSize(), is(3L));
        assertThat(iter.next(), is((Object)prius));
        assertThat(iter.next(), is((Object)highlander));
        assertThat(iter.next(), is((Object)altima));
        assertThat(iter.hasNext(), is(false));
    }
View Full Code Here


            long time = System.currentTimeMillis();
            QueryResult res = q.execute();

            NodeIterator it = res.getNodes();
            long taken = System.currentTimeMillis() - time;
            if (taken > 2000) {
                log.debug("QueryExec time is: " + (System.currentTimeMillis() - time));
                log.debug("SQL is " + sql);
                log.debug(it.getClass().getName());
            }
            return new AssetItemIterator(it, this.rulesRepository);
        } catch ( RepositoryException e ) {
            throw new RulesRepositoryException(e);
        }
View Full Code Here

    return node;
  }

  private NodeIterator getMetaDataTypeNodes() throws RepositoryException {
    Node schemaNode = getAreaNode(SCHEMA_AREA);
    NodeIterator node = addNodeIfNew(schemaNode,
        METADATA_TYPE_AREA, "nt:folder").getNodes();
    return node;
  }  
View Full Code Here

    try {
      //SCHEMA_AREA and WORKSPACE_AREA may not exist if the repository is imported from an old version.
            Node schemaNode = addNodeIfNew(this.session.getRootNode().getNode( RULES_REPOSITORY_NAME ),
                                       SCHEMA_AREA,
                                       "nt:folder" );
            NodeIterator workspaceNodes = addNodeIfNew(schemaNode, WORKSPACE_AREA, "nt:folder").getNodes();
       
           while (workspaceNodes.hasNext()) {
            Node workspaceNode = workspaceNodes.nextNode();
            result.add(workspaceNode.getName());
           }

        } catch ( Exception e ) {
            log.error( e.getMessage(), e );
View Full Code Here

        try {
            if ( !snaps.hasNode( packageName ) ) {
                return new String[0];
            } else {
                List<String> result = new ArrayList<String>();
                NodeIterator it = snaps.getNode( packageName ).getNodes();
                while ( it.hasNext() ) {
                    Node element = (Node) it.next();
                    result.add( element.getName() );
                }
                return result.toArray( new String[result.size()] );
            }
        } catch ( RepositoryException e ) {
View Full Code Here

    /**
     * @return A list of statii in the system.
     */
    public StateItem[] listStates() {
        List<StateItem> states = new ArrayList<StateItem>();
        NodeIterator it;
        try {
            it = this.getAreaNode( STATE_AREA ).getNodes();

            while ( it.hasNext() ) {
                states.add( new StateItem( this,
                                           it.nextNode() ) );
            }
        } catch ( RepositoryException e ) {
            log.error( e.getMessage(), e );
            throw new RulesRepositoryException( e );
        }
View Full Code Here

    protected Roster retrieveRosterInternal(Entity bareJid) {
        final Node rosterNode = retrieveRosterNode(jcrStorage, bareJid);

        MutableRoster roster = new MutableRoster();

        NodeIterator nodes = null;
        try {
            nodes = rosterNode.getNodes();
        } catch (RepositoryException e) {
            return roster; // empty roster object
        }
        while (nodes != null && nodes.hasNext()) {
            Node node = nodes.nextNode();

            String contactJidString = null;
            try {
                contactJidString = node.getName();
            } catch (RepositoryException e) {
View Full Code Here

        } catch (JcrStorageException e) {
            throw new RosterException("failed to retrieve roster store for " + jidUser.getFullQualifiedName(), e);
        }
        if (rosterNode == null) return; // done, no contacts anyway. oops

        NodeIterator nodes = null;
        try {
            nodes = rosterNode.getNodes("contact");
        } catch (RepositoryException e) {
            return; // failed to find any contacts, done.
        }
        boolean foundOne = false;
        while (nodes != null && nodes.hasNext()) {
            Node node = nodes.nextNode();
            String contactJidString = readAttribute(node, "jid");
            if (contactJidString != null && contactJidString.equals(jidContact.getFullQualifiedName())) {
                foundOne = true;
                try {
                    node.remove();
View Full Code Here

TOP

Related Classes of javax.jcr.NodeIterator

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.