Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeType


     */
    public Element toXml(Document document) {
        Element report = document.createElement(NODETYPES_ELEMENT);
        // loop over the nodetypes to be returned in the report
        while (ntIter.hasNext()) {
            NodeType nt = ntIter.nextNodeType();
            Element ntDef = document.createElement(NODETYPE_ELEMENT);
            ntDef.setAttribute(NAME_ATTRIBUTE, nt.getName());
            ntDef.setAttribute(ISMIXIN_ATTRIBUTE, Boolean.toString(nt.isMixin()));
            ntDef.setAttribute(HASORDERABLECHILDNODES_ATTRIBUTE, Boolean.toString(nt.hasOrderableChildNodes()));
            // JCR 2.0 extension
            ntDef.setAttribute(ISABSTRACT_ATTRIBUTE, Boolean.toString(nt.isAbstract()));
            // JCR 2.0 extension
            ntDef.setAttribute(ISQUERYABLE_ATTRIBUTE, Boolean.toString(nt.isQueryable()));

            // declared supertypes
            Element supertypes = DomUtil.addChildElement(ntDef, SUPERTYPES_ELEMENT, null);
            for (NodeType snt : nt.getDeclaredSupertypes()) {
                DomUtil.addChildElement(supertypes, SUPERTYPE_ELEMENT, null, snt.getName());
            }

            // declared child node definitions
            for (NodeDefinition aCnd : nt.getChildNodeDefinitions()) {
                if (aCnd.getDeclaringNodeType().getName().equals(nt.getName())) {
                    ntDef.appendChild(NodeDefinitionImpl.create(aCnd).toXml(document));
                }
            }

            // declared property definitions
            for (PropertyDefinition aPd : nt.getPropertyDefinitions()) {
                if (aPd.getDeclaringNodeType().getName().equals(nt.getName())) {
                    ntDef.appendChild(PropertyDefinitionImpl.create(aPd).toXml(document));
                }
            }

            String primaryItemName = nt.getPrimaryItemName();
            if (primaryItemName != null) {
                ntDef.setAttribute(PRIMARYITEMNAME_ATTRIBUTE, primaryItemName);
            }
            report.appendChild(ntDef);
        }
View Full Code Here


        session-import
        */
        String referenceableNt = null;
        NodeTypeIterator it = superuser.getWorkspace().getNodeTypeManager().getPrimaryNodeTypes();
        while (it.hasNext() && referenceableNt == null) {
            NodeType nt = it.nextNodeType();
            String ntName = nt.getName();
            if (nt.isNodeType(mixReferenceable) &&
                    !nt.isAbstract() &&
                    // TODO: improve....
                    // ignore are built-in nodetypes (mostly version related)
                    !ntName.startsWith("nt:") &&
                    // also skip all internal node types...
                    !ntName.startsWith("rep:")) {
View Full Code Here

        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
        NodeTypeManager ntMgr = sInfo.getSession().getWorkspace().getNodeTypeManager();
        List<QNodeTypeDefinition> nodeTypes = new ArrayList<QNodeTypeDefinition>();
        try {
            for (NodeTypeIterator it = ntMgr.getAllNodeTypes(); it.hasNext(); ) {
                NodeType nt = it.nextNodeType();
                nodeTypes.add(new QNodeTypeDefinitionImpl(nt,
                        sInfo.getNamePathResolver(), getQValueFactory()));
            }
        } catch (NameException e) {
            throw new RepositoryException(e);
View Full Code Here

        NodeTypeManager ntMgr = sInfo.getSession().getWorkspace().getNodeTypeManager();
        List<QNodeTypeDefinition> defs = new ArrayList<QNodeTypeDefinition>();
        for (Name nodetypeName : nodetypeNames) {
            try {
                String ntName = sInfo.getNamePathResolver().getJCRName(nodetypeName);
                NodeType nt = ntMgr.getNodeType(ntName);
                defs.add(new QNodeTypeDefinitionImpl(nt,
                        sInfo.getNamePathResolver(), getQValueFactory()));

                // in addition pack all supertypes into the return value
                NodeType[] supertypes = nt.getSupertypes();
                for (NodeType supertype : supertypes) {
                    defs.add(new QNodeTypeDefinitionImpl(supertype,
                            sInfo.getNamePathResolver(), getQValueFactory()));
                }
            } catch (NameException e) {
View Full Code Here

        String[] resolvedNames = resolveNodeTypeName(ntName);

        // now resolve node type hierarchy
        for (String resolvedName : resolvedNames) {
            try {
                NodeType base = ntMgr.getNodeType(resolvedName);
                if (base.isMixin()) {
                    // search for nodes where jcr:mixinTypes is set to this mixin
                    addTypeConstraint(new MixinComparision(resolvedName));
                } else {
                    // search for nodes where jcr:primaryType is set to this type
                    addTypeConstraint(new PrimaryTypeComparision(resolvedName));
                }

                // now search for all node types that are derived from base
                NodeTypeIterator allTypes = ntMgr.getAllNodeTypes();
                while (allTypes.hasNext()) {
                    NodeType nt = allTypes.nextNodeType();
                    NodeType[] superTypes = nt.getSupertypes();
                    if (Arrays.asList(superTypes).contains(base)) {
                        if (nt.isMixin()) {
                            addTypeConstraint(new MixinComparision(nt.getName()));
                        } else {
                            addTypeConstraint(new PrimaryTypeComparision(nt.getName()));
                        }
                    }
                }
            } catch (NoSuchNodeTypeException e) {
                // add anyway -> will not match anything
View Full Code Here

        if (propertyNames == null) {
            propertyNames = new HashMap<String, String>();
            NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
            NodeTypeIterator it = ntMgr.getAllNodeTypes();
            while (it.hasNext()) {
                NodeType nt = it.nextNodeType();
                PropertyDefinition[] defs = nt.getDeclaredPropertyDefinitions();
                for (PropertyDefinition def : defs) {
                    String pn = def.getName();
                    if (!pn.equals("*")) {
                        String localName = pn;
                        int idx = pn.indexOf(':');
View Full Code Here

        if (childNodeNames == null) {
            childNodeNames = new HashMap<String, String>();
            NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
            NodeTypeIterator it = ntMgr.getAllNodeTypes();
            while (it.hasNext()) {
                NodeType nt = it.nextNodeType();
                NodeDefinition[] defs = nt.getDeclaredChildNodeDefinitions();
                for (NodeDefinition def : defs) {
                    String cnn = def.getName();
                    if (!cnn.equals("*")) {
                        String localName = cnn;
                        int idx = cnn.indexOf(':');
View Full Code Here

        List<NodeDefinition> childNodeDefs = new LinkedList<NodeDefinition>();
        childNodeDefs.addAll(Arrays.asList(getDeclaredChildNodeDefinitions()));
        NodeType[] supers = getSupertypes();
        if (supers!=null) {
            for (int i = 0; i < supers.length; i++) {
                NodeType aSuperNodeType = supers[i];
                NodeDefinition[] superChildNodeDefs = aSuperNodeType.getChildNodeDefinitions();
                if (superChildNodeDefs!=null) {
                    childNodeDefs.addAll(Arrays.asList(superChildNodeDefs));
                }
            }
        }
View Full Code Here

    @Test
    public void nodesuperTypesAreFound() {
        FallbackNodeTypeRegistry registry = FallbackNodeTypeRegistry.createRegistryWithDefaultNodeTypes();

        NodeType nodeType = registry.getNodeType("sling:Folder");

        assertThat("nodeType", nodeType, notNullValue());
        assertThat("nodeType.name", nodeType.getName(), equalTo("sling:Folder"));

        assertThat("nodeType.declaredSupertypeNames", nodeType.getDeclaredSupertypeNames(),
                equalTo(new String[] { "nt:folder" }));

        NodeType[] superTypes = nodeType.getSupertypes();

        assertThat("nodeType.superTypes", superTypes, notNullValue());
        assertThat("nodeType.superTypes.length", superTypes.length, equalTo(1));
        assertThat("nodeType.superTypes[0].name", superTypes[0].getName(), equalTo("nt:folder"));
    }
View Full Code Here

            return null;
        }

        Node node = session.getNode(getPath());

        NodeType primaryNodeType = node.getPrimaryNodeType();

        if (primaryNodeType.hasOrderableChildNodes()) {
            reorderChildNodes(node, resource);
        }
       
        return null;
    }
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.NodeType

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.