Examples of NodeType


Examples of javax.jcr.nodetype.NodeType

        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

Examples of javax.jcr.nodetype.NodeType

        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

Examples of javax.jcr.nodetype.NodeType

        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

Examples of javax.jcr.nodetype.NodeType

        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

Examples of javax.jcr.nodetype.NodeType

    @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

Examples of javax.jcr.nodetype.NodeType

            return null;
        }

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

        NodeType primaryNodeType = node.getPrimaryNodeType();

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

Examples of javax.jcr.nodetype.NodeType

        try {
            String mixinTypesField = NameFormat.format(QName.JCR_MIXINTYPES, nsMappings);
            String primaryTypeField = NameFormat.format(QName.JCR_PRIMARYTYPE, nsMappings);

            NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
            NodeType base = ntMgr.getNodeType(NameFormat.format(node.getValue(), session.getNamespaceResolver()));

            if (base.isMixin()) {
                // search for nodes where jcr:mixinTypes is set to this mixin
                Term t = new Term(FieldNames.PROPERTIES,
                        FieldNames.createNamedValue(mixinTypesField,
                                NameFormat.format(node.getValue(), nsMappings)));
                terms.add(t);
            } else {
                // search for nodes where jcr:primaryType is set to this type
                Term t = new Term(FieldNames.PROPERTIES,
                        FieldNames.createNamedValue(primaryTypeField,
                                NameFormat.format(node.getValue(), nsMappings)));
                terms.add(t);
            }

            // 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)) {
                    String ntName = nsMappings.translatePropertyName(nt.getName(),
                            session.getNamespaceResolver());
                    Term t;
                    if (nt.isMixin()) {
                        // search on jcr:mixinTypes
                        t = new Term(FieldNames.PROPERTIES,
                                FieldNames.createNamedValue(mixinTypesField, ntName));
                    } else {
                        // search on jcr:primaryType
View Full Code Here

Examples of javax.jcr.nodetype.NodeType

    }

    private List<NodeType> sortTypes(NodeTypeIterator it) {
        List<NodeType> types = new ArrayList<NodeType>();
        while (it.hasNext()) {
            NodeType nt = it.nextNodeType();
            types.add(nt);
        }
        Collections.sort(types, new Comparator<NodeType>(){
            public int compare(NodeType o1, NodeType o2) {
                return o1.getName().compareTo(o2.getName());
View Full Code Here

Examples of javax.jcr.nodetype.NodeType

        boolean createNtFile = parent.isNodeType(NT_FOLDER);
        String typeHint = prop.getTypeHint();
        if (typeHint != null) {
            try {
                NodeTypeManager ntMgr = parent.getSession().getWorkspace().getNodeTypeManager();
                NodeType nt = ntMgr.getNodeType(typeHint);
                createNtFile = nt.isNodeType(NT_FILE);
            } catch (RepositoryException e) {
                // assuming type not valid.
                typeHint = null;
            }
        }
View Full Code Here

Examples of javax.jcr.nodetype.NodeType

        }
        final List<NodeType> nodeTypes = nodeTypeRegistry.getNodeTypes();

        // detect node types which have an nt:file or nt:folder parent in the hierarchy
        for (Iterator<NodeType> it = nodeTypes.iterator(); it.hasNext();) {
            final NodeType nt = it.next();
            final String nodeType = nt.getName();
            SerializationKind serializationKind = getSerializationKind(nodeType, nodeTypeRegistry);
            if (serializationKind == null) {
                // don't care
                continue;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.