Examples of NodeType


Examples of javax.jcr.nodetype.NodeType

    @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

Examples of javax.jcr.nodetype.NodeType

        try {
            String mixinTypesField = resolver.getJCRName(NameConstants.JCR_MIXINTYPES);
            String primaryTypeField = resolver.getJCRName(NameConstants.JCR_PRIMARYTYPE);

            NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
            NodeType base = ntMgr.getNodeType(session.getJCRName(node.getValue()));

            if (base.isMixin()) {
                // search for nodes where jcr:mixinTypes is set to this mixin
                Term t = new Term(FieldNames.PROPERTIES,
                        FieldNames.createNamedValue(mixinTypesField,
                                resolver.getJCRName(node.getValue())));
                terms.add(t);
            } else {
                // search for nodes where jcr:primaryType is set to this type
                Term t = new Term(FieldNames.PROPERTIES,
                        FieldNames.createNamedValue(primaryTypeField,
                                resolver.getJCRName(node.getValue())));
                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)) {
                    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

Examples of javax.jcr.nodetype.NodeType

        }
    }

    private void internalSetPrimaryType(final String nodeTypeName) throws RepositoryException {
        // TODO: figure out the right place for this check
        NodeType nt = getNodeTypeManager().getNodeType(nodeTypeName); // throws on not found
        if (nt.isAbstract() || nt.isMixin()) {
            throw new ConstraintViolationException();
        }
        // TODO: END

        PropertyState state = PropertyStates.createProperty(
                JCR_PRIMARYTYPE, getOakName(nodeTypeName), NAME);
        dlg.setProperty(state, true, true);
        dlg.setOrderableChildren(nt.hasOrderableChildNodes());
    }
View Full Code Here

Examples of javax.jcr.nodetype.NodeType

            log.debug("Node already has " + nodeTypeName + " as primary node type.");
            return;
        }

        NodeTypeManagerImpl ntMgr = session.getNodeTypeManager();
        NodeType nt = ntMgr.getNodeType(ntName);
        if (nt.isMixin()) {
            throw new ConstraintViolationException(nodeTypeName + ": not a primary node type.");
        } else if (nt.isAbstract()) {
            throw new ConstraintViolationException(nodeTypeName + ": is an abstract node type.");
        }

        // build effective node type of new primary type & existing mixin's
        // in order to detect conflicts
View Full Code Here

Examples of javax.jcr.nodetype.NodeType

     */
    public Element toXml(Document document) {
        Element elem = super.toXml(document);
        elem.setAttribute(SAMENAMESIBLINGS_ATTRIBUTE, Boolean.toString(allowsSameNameSiblings()));
        // defaultPrimaryType can be 'null'
        NodeType defaultPrimaryType = getDefaultPrimaryType();
        if (defaultPrimaryType != null) {
            elem.setAttribute(DEFAULTPRIMARYTYPE_ATTRIBUTE, defaultPrimaryType.getName());
        }
        // reqPrimaryTypes: minimal set is nt:base.
        NodeType[] nts = getRequiredPrimaryTypes();
        Element reqPrimaryTypes = document.createElement(REQUIREDPRIMARYTYPES_ELEMENT);
  for (int i = 0; i < nts.length; i++) {
View Full Code Here

Examples of javax.jcr.nodetype.NodeType

    }

    public NodeTypeProperty(DavPropertyName name, NodeType[] nodeTypes, boolean isProtected) {
        super(name, isProtected);
        for (int i = 0; i < nodeTypes.length; i++) {
            NodeType nt = nodeTypes[i];
            if (nt != null) {
                nodetypeNames.add(nodeTypes[i].getName());
            }
        }
    }
View Full Code Here

Examples of javax.jcr.nodetype.NodeType

     * @return Xml representation of the specified {@link ItemDefinition def}.
     * @param document
     */
    public Element toXml(Document document) {
        Element elem = document.createElement(getElementName());
        NodeType dnt = getDeclaringNodeType();
        if (dnt != null) {
            elem.setAttribute(DECLARINGNODETYPE_ATTRIBUTE, dnt.getName());
        }
        elem.setAttribute(NAME_ATTRIBUTE, getName());
        elem.setAttribute(AUTOCREATED_ATTRIBUTE, Boolean.toString(isAutoCreated()));
        elem.setAttribute(MANDATORY_ATTRIBUTE, Boolean.toString(isMandatory()));
        elem.setAttribute(ONPARENTVERSION_ATTRIBUTE, OnParentVersionAction.nameFromValue(getOnParentVersion()));
View Full Code Here

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()));

            // declared supertypes
            NodeType[] snts = nt.getDeclaredSupertypes();
            Element supertypes = DomUtil.addChildElement(ntDef, SUPERTYPES_ELEMENT, null);
            for (int i = 0; i < snts.length; i++) {
                DomUtil.addChildElement(supertypes, SUPERTYPE_ELEMENT, null, snts[i].getName());
            }

            // declared childnode defs
            NodeDefinition[] cnd = nt.getChildNodeDefinitions();
            for (int i = 0; i < cnd.length; i++) {
                if (cnd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
                    ntDef.appendChild(NodeDefinitionImpl.create(cnd[i]).toXml(document));
                }
            }

            // declared propertyDefs
            PropertyDefinition[] pd = nt.getPropertyDefinitions();
            for (int i = 0; i < pd.length; i++) {
                if (pd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
                    ntDef.appendChild(PropertyDefinitionImpl.create(pd[i]).toXml(document));
                }
            }

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

Examples of javax.jcr.nodetype.NodeType

     */
    public void testIfPrimaryNodeTypesAreSubtypesOfNTBase()
            throws RepositoryException {
        NodeTypeIterator types = manager.getPrimaryNodeTypes();
        while (types.hasNext()) {
            NodeType type = types.nextNodeType();
            assertTrue("Primary node type " + type.getName() +
                    " must inherit nt:base",
                    type.isNodeType("nt:base"));
        }
    }
View Full Code Here

Examples of javax.jcr.nodetype.NodeType

                    getClass().getClassLoader().getResourceAsStream(resource));
            for (int ch = reader.read(); ch != -1; ch = reader.read()) {
                spec.append((char) ch);
            }

            NodeType type = manager.getNodeType(name);
            String current = getNodeTypeSpec(type);
            if (!System.getProperty("line.separator").equals("\n")) {
                current = normalizeLineSeparators(current);
            }
            String expected = normalizeLineSeparators(spec.toString());
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.