Package org.apache.jackrabbit.spi

Examples of org.apache.jackrabbit.spi.QNodeTypeDefinition


    /**
     * @see NodeTypeRegistry#getNodeTypeDefinition(Name)
     */
    public QNodeTypeDefinition getNodeTypeDefinition(Name nodeTypeName)
        throws NoSuchNodeTypeException {
        QNodeTypeDefinition def = (QNodeTypeDefinition) registeredNTDefs.get(nodeTypeName);
        if (def == null) {
            throw new NoSuchNodeTypeException("Nodetype " + nodeTypeName + " doesn't exist");
        }
        return def;
    }
View Full Code Here


        if (ent != null) {
            return ent;
        }

        // 2. make sure we've got the definition of the specified node type
        QNodeTypeDefinition ntd = (QNodeTypeDefinition) ntdCache.get(ntName);
        if (ntd == null) {
            throw new NoSuchNodeTypeException(ntName.toString());
        }

        // 3. build effective node type
View Full Code Here

                     * no matching sub-aggregates found:
                     * build aggregate of remaining node types through iteration
                     */
                    Name[] remainder = key.getNames();
                    for (int i = 0; i < remainder.length; i++) {
                        QNodeTypeDefinition ntd = (QNodeTypeDefinition) ntdCache.get(remainder[i]);
                        EffectiveNodeType ent = getEffectiveNodeType(ntd, ntdCache);
                        // store new effective node type
                        entCache.put(ent);
                        if (result == null) {
                            result = (EffectiveNodeTypeImpl) ent;
View Full Code Here

    }

    private void internalRegister(Map defMap) {
        for (Iterator it = defMap.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry entry = (Map.Entry)it.next();
            QNodeTypeDefinition ntd = (QNodeTypeDefinition)entry.getKey();
            internalRegister(ntd, (EffectiveNodeTypeImpl)entry.getValue());
        }
    }
View Full Code Here

            }
        }
    }

    private void internalUnregister(Name name) {
        QNodeTypeDefinition ntd = (QNodeTypeDefinition) registeredNTDefs.remove(name);
        entCache.invalidate(name);

        if (ntd != null) {
            // remove property & child node definitions
            QPropertyDefinition[] pda = ntd.getPropertyDefs();
            synchronized (propDefs) {
                for (int i = 0; i < pda.length; i++) {
                    propDefs.remove(pda[i]);
                }
            }
            synchronized (nodeDefs) {
                QNodeDefinition[] nda = ntd.getChildNodeDefs();
                for (int i = 0; i < nda.length; i++) {
                    nodeDefs.remove(nda[i]);
                }
            }
        }
View Full Code Here

            // get names of those node types that have dependencies on the
            // node type with the given nodeTypeName.
            HashSet names = new HashSet();
            Iterator iter = nodetypeDefinitions.values().iterator();
            while (iter.hasNext()) {
                QNodeTypeDefinition ntd = (QNodeTypeDefinition) iter.next();
                if (ntd.getDependencies().contains(nodeTypeName)) {
                    names.add(ntd.getName());
                }
            }
            return names;
        }
View Full Code Here

        public Object get(Object key) {
            if (!(key instanceof Name)) {
                throw new IllegalArgumentException();
            }
            QNodeTypeDefinition def = (QNodeTypeDefinition) nodetypeDefinitions.get(key);
            if (def == null) {
                try {
                    // node type does either not exist or hasn't been loaded yet
                    Iterator it = storage.getDefinitions(new Name[] {(Name) key});
                    updateInternalMap(it);
View Full Code Here

        //-------------------------------------------------------< Dumpable >---
        public void dump(PrintStream ps) {
            Iterator iter = nodetypeDefinitions.values().iterator();
            while (iter.hasNext()) {
                QNodeTypeDefinition ntd = (QNodeTypeDefinition) iter.next();
                ps.println(ntd.getName());
                Name[] supertypes = ntd.getSupertypes();
                ps.println("\tSupertypes");
                for (int i = 0; i < supertypes.length; i++) {
                    ps.println("\t\t" + supertypes[i]);
                }
                ps.println("\tMixin\t" + ntd.isMixin());
                ps.println("\tOrderableChildNodes\t" + ntd.hasOrderableChildNodes());
                ps.println("\tPrimaryItemName\t" + (ntd.getPrimaryItemName() == null ? "<null>" : ntd.getPrimaryItemName().toString()));
                QPropertyDefinition[] pd = ntd.getPropertyDefs();
                for (int i = 0; i < pd.length; i++) {
                    ps.print("\tPropertyDefinition");
                    ps.println(" (declared in " + pd[i].getDeclaringNodeType() + ") ");
                    ps.println("\t\tName\t\t" + (pd[i].definesResidual() ? "*" : pd[i].getName().toString()));
                    String type = pd[i].getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(pd[i].getRequiredType());
                    ps.println("\t\tRequiredType\t" + type);
                    String[] vca = pd[i].getValueConstraints();
                    StringBuffer constraints = new StringBuffer();
                    if (vca == null) {
                        constraints.append("<null>");
                    } else {
                        for (int n = 0; n < vca.length; n++) {
                            if (constraints.length() > 0) {
                                constraints.append(", ");
                            }
                            constraints.append(vca[n]);
                        }
                    }
                    ps.println("\t\tValueConstraints\t" + constraints.toString());
                    QValue[] defVals = pd[i].getDefaultValues();
                    StringBuffer defaultValues = new StringBuffer();
                    if (defVals == null) {
                        defaultValues.append("<null>");
                    } else {
                        for (int n = 0; n < defVals.length; n++) {
                            if (defaultValues.length() > 0) {
                                defaultValues.append(", ");
                            }
                            try {
                                defaultValues.append(defVals[n].getString());
                            } catch (RepositoryException e) {
                                defaultValues.append(defVals[n].toString());
                            }
                        }
                    }
                    ps.println("\t\tDefaultValue\t" + defaultValues.toString());
                    ps.println("\t\tAutoCreated\t" + pd[i].isAutoCreated());
                    ps.println("\t\tMandatory\t" + pd[i].isMandatory());
                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(pd[i].getOnParentVersion()));
                    ps.println("\t\tProtected\t" + pd[i].isProtected());
                    ps.println("\t\tMultiple\t" + pd[i].isMultiple());
                }
                QNodeDefinition[] nd = ntd.getChildNodeDefs();
                for (int i = 0; i < nd.length; i++) {
                    ps.print("\tNodeDefinition");
                    ps.println(" (declared in " + nd[i].getDeclaringNodeType() + ") ");
                    ps.println("\t\tName\t\t" + (nd[i].definesResidual() ? "*" : nd[i].getName().toString()));
                    Name[] reqPrimaryTypes = nd[i].getRequiredPrimaryTypes();
View Full Code Here

    public Map validateNodeTypeDefs(Collection ntDefs, Map validatedDefs)
        throws InvalidNodeTypeDefinitionException, RepositoryException {
        // tmp. map containing names/defs of validated nodetypes
        Map tmpMap = new HashMap(validatedDefs);
        for (Iterator it = ntDefs.iterator(); it.hasNext();) {
            QNodeTypeDefinition ntd = (QNodeTypeDefinition) it.next();
            tmpMap.put(ntd.getName(), ntd);
        }

        // map of nodetype definitions and effective nodetypes to be registered
        Map ntMap = new HashMap();
        ArrayList list = new ArrayList(ntDefs);

        // iterate over definitions until there are no more definitions with
        // unresolved (i.e. unregistered) dependencies or an error occurs;

        int count = -1// number of validated nt's per iteration
        while (list.size() > 0 && count != 0) {
            count = 0;
            Iterator iterator = list.iterator();
            while (iterator.hasNext()) {
                QNodeTypeDefinition ntd = (QNodeTypeDefinition) iterator.next();
                // check if definition has unresolved dependencies
                /* Note: don't compared to 'registered' nodetypes since registr. is performed later on */
                Collection dependencies = ntd.getDependencies();
                if (tmpMap.keySet().containsAll(dependencies)) {
                    EffectiveNodeType ent = validateNodeTypeDef(ntd, tmpMap);
                    ntMap.put(ntd, ent);
                    // remove it from list
                    iterator.remove();
View Full Code Here

    public NodeTypeImpl getNodeType(Name name) throws NoSuchNodeTypeException {
        synchronized (ntCache) {
            NodeTypeImpl nt = (NodeTypeImpl) ntCache.get(name);
            if (nt == null) {
                EffectiveNodeType ent = entProvider().getEffectiveNodeType(name);
                QNodeTypeDefinition def = ntReg.getNodeTypeDefinition(name);
                nt = new NodeTypeImpl(ent, def, this, mgrProvider);
                ntCache.put(name, nt);
            }
            return nt;
        }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.spi.QNodeTypeDefinition

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.