Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeType


    public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
        Name[] ntNames = ntReg.getRegisteredNodeTypes();
        Arrays.sort(ntNames);
        ArrayList<NodeType> list = new ArrayList<NodeType>(ntNames.length);
        for (Name ntName : ntNames) {
            NodeType nt = getNodeType(ntName);
            if (nt.isMixin()) {
                list.add(nt);
            }
        }
        return new NodeTypeIteratorAdapter(list);
    }
View Full Code Here


        List<Term> terms = new ArrayList<Term>();
        String mixinTypesField = npResolver.getJCRName(NameConstants.JCR_MIXINTYPES);
        String primaryTypeField = npResolver.getJCRName(NameConstants.JCR_PRIMARYTYPE);

        NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
        NodeType base = null;
        try {
            base = ntMgr.getNodeType(session.getJCRName(selector.getNodeTypeQName()));
        } catch (RepositoryException e) {
            // node type does not exist
        }

        if (base != null && base.isMixin()) {
            // search for nodes where jcr:mixinTypes is set to this mixin
            Term t = new Term(FieldNames.PROPERTIES,
                    FieldNames.createNamedValue(mixinTypesField,
                            npResolver.getJCRName(selector.getNodeTypeQName())));
            terms.add(t);
        } else {
            // search for nodes where jcr:primaryType is set to this type
            Term t = new Term(FieldNames.PROPERTIES,
                    FieldNames.createNamedValue(primaryTypeField,
                            npResolver.getJCRName(selector.getNodeTypeQName())));
            terms.add(t);
        }

        // now search for all node types that are derived from base
        if (base != null) {
            NodeTypeIterator allTypes = ntMgr.getAllNodeTypes();
            while (allTypes.hasNext()) {
                NodeType nt = allTypes.nextNodeType();
                NodeType[] superTypes = nt.getSupertypes();
                if (Arrays.asList(superTypes).contains(base)) {
                    Name n = session.getQName(nt.getName());
                    String ntName = nsMappings.translateName(n);
                    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

            types = ntmgr.getMixinNodeTypes();
        } catch (RepositoryException e) {
            fail("Cannot access NodeType iterator: " + e);
        }
        while (types.hasNext()) {
            NodeType t = (NodeType) types.next();
            String name = t.getName();
            name = "Node_" + name.replaceAll(":", "_");

            Node n = null;
            try {
                n = nt.addNode(name);
                n.addMixin(t.getName());
                // try saving, because some exceptions are trown only at save time
                session.save();
            } catch (RepositoryException e) {
                log.println("Cannot create node with mixin node type: " + e);
                // if saving failed for a node, then remove it again (or else the next save will fail on it)
View Full Code Here

    @Override
    public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
        List<NodeType> list = Lists.newArrayList();
        NodeTypeIterator iterator = getAllNodeTypes();
        while (iterator.hasNext()) {
            NodeType type = iterator.nextNodeType();
            if (!type.isMixin()) {
                list.add(type);
            }
        }
        return new NodeTypeIteratorAdapter(list);
    }
View Full Code Here

    @Override
    public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
        List<NodeType> list = Lists.newArrayList();
        NodeTypeIterator iterator = getAllNodeTypes();
        while (iterator.hasNext()) {
            NodeType type = iterator.nextNodeType();
            if (type.isMixin()) {
                list.add(type);
            }
        }
        return new NodeTypeIteratorAdapter(list);
    }
View Full Code Here

     */
    public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException {
        QName[] ntNames = ntReg.getRegisteredNodeTypes();
        ArrayList list = new ArrayList(ntNames.length);
        for (int i = 0; i < ntNames.length; i++) {
            NodeType nt = getNodeType(ntNames[i]);
            if (!nt.isMixin()) {
                list.add(nt);
            }
        }
        return new IteratorHelper(Collections.unmodifiableCollection(list));
    }
View Full Code Here

     */
    public NodeTypeIterator getMixinNodeTypes() throws RepositoryException {
        QName[] ntNames = ntReg.getRegisteredNodeTypes();
        ArrayList list = new ArrayList(ntNames.length);
        for (int i = 0; i < ntNames.length; i++) {
            NodeType nt = getNodeType(ntNames[i]);
            if (nt.isMixin()) {
                list.add(nt);
            }
        }
        return new IteratorHelper(Collections.unmodifiableCollection(list));
    }
View Full Code Here

        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

        NodeTypeIterator types = manager.getAllNodeTypes();

        // find a NodeType which is not satisfying the constraints
        findNodeTypeNotSatisfied:
            while (types.hasNext()) {
                NodeType type = types.nextNodeType();
                String name = type.getName();
                for (int i = 0; i < constraints.length; i++) {
                    if (name.equals(constraints[i])) {
                        continue findNodeTypeNotSatisfied;
                    }
                    nodeTypeNotSatisfied = name;
View Full Code Here

        NodeTypeIterator types = manager.getAllNodeTypes();

        // find a NodeType which is not satisfying the constraints
        findNodeTypeNotSatisfied:
            while (types.hasNext()) {
                NodeType type = types.nextNodeType();
                String name = type.getName();
                for (int i = 0; i < constraints.length; i++) {
                    if (name.equals(constraints[i])) {
                        continue findNodeTypeNotSatisfied;
                    }
                    nodeTypeNotSatisfied = name;
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.