Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 30072 invoked from network); 18 Oct 2007 18:43:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Oct 2007 18:43:48 -0000 Received: (qmail 25452 invoked by uid 500); 18 Oct 2007 18:43:33 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 25398 invoked by uid 500); 18 Oct 2007 18:43:33 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 25369 invoked by uid 99); 18 Oct 2007 18:43:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Oct 2007 11:43:33 -0700 X-ASF-Spam-Status: No, hits=-98.9 required=10.0 tests=ALL_TRUSTED,FB_GET_MEDS X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Oct 2007 18:43:32 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 08C641A9846; Thu, 18 Oct 2007 11:42:42 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r586065 [3/8] - in /jackrabbit/trunk/contrib/spi: client/src/test/java/org/apache/jackrabbit/jcr2spi/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ jcr2spi/src/main/java/... Date: Thu, 18 Oct 2007 18:41:57 -0000 To: commits@jackrabbit.apache.org From: angela@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071018184242.08C641A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java Thu Oct 18 11:41:45 2007 @@ -16,11 +16,15 @@ */ package org.apache.jackrabbit.jcr2spi.nodetype; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.spi.QNodeTypeDefinition; import org.apache.jackrabbit.spi.QNodeDefinition; import org.apache.jackrabbit.spi.QPropertyDefinition; import org.apache.jackrabbit.spi.QValue; +import org.apache.jackrabbit.nodetype.InvalidNodeTypeDefException; +import org.apache.jackrabbit.nodetype.NodeTypeConflictException; +import org.apache.jackrabbit.name.NameConstants; +import org.apache.jackrabbit.name.NameFactoryImpl; import org.slf4j.LoggerFactory; import org.slf4j.Logger; @@ -67,7 +71,7 @@ Map tmpMap = new HashMap(validatedDefs); for (Iterator it = ntDefs.iterator(); it.hasNext();) { QNodeTypeDefinition ntd = (QNodeTypeDefinition) it.next(); - tmpMap.put(ntd.getQName(), ntd); + tmpMap.put(ntd.getName(), ntd); } // map of nodetype definitions and effective nodetypes to be registered @@ -101,7 +105,7 @@ msg.append("the following node types could not be registered because of unresolvable dependencies: "); Iterator iterator = list.iterator(); while (iterator.hasNext()) { - msg.append(((QNodeTypeDefinition) iterator.next()).getQName()); + msg.append(((QNodeTypeDefinition) iterator.next()).getName()); msg.append(" "); } log.error(msg.toString()); @@ -132,7 +136,7 @@ */ EffectiveNodeTypeImpl ent = null; - QName name = ntDef.getQName(); + Name name = ntDef.getName(); if (name == null) { String msg = "no name specified"; log.debug(msg); @@ -141,7 +145,7 @@ checkNamespace(name); // validate supertypes - QName[] supertypes = ntDef.getSupertypes(); + Name[] supertypes = ntDef.getSupertypes(); if (supertypes.length > 0) { for (int i = 0; i < supertypes.length; i++) { checkNamespace(supertypes[i]); @@ -187,8 +191,8 @@ try { EffectiveNodeType est = entProvider.getEffectiveNodeType(supertypes, validatedDefs); // make sure that all primary types except nt:base extend from nt:base - if (!ntDef.isMixin() && !QName.NT_BASE.equals(ntDef.getQName()) - && !est.includesNodeType(QName.NT_BASE)) { + if (!ntDef.isMixin() && !NameConstants.NT_BASE.equals(ntDef.getName()) + && !est.includesNodeType(NameConstants.NT_BASE)) { String msg = "[" + name + "] all primary node types except" + " nt:base itself must be (directly or indirectly) derived from nt:base"; log.debug(msg); @@ -205,7 +209,7 @@ } } else { // no supertypes specified: has to be either a mixin type or nt:base - if (!ntDef.isMixin() && !QName.NT_BASE.equals(ntDef.getQName())) { + if (!ntDef.isMixin() && !NameConstants.NT_BASE.equals(ntDef.getName())) { String msg = "[" + name + "] all primary node types except nt:base itself must be (directly or indirectly) derived from nt:base"; log.debug(msg); @@ -224,20 +228,20 @@ * make sure declaring node type matches name of node type definition */ if (!name.equals(pd.getDeclaringNodeType())) { - String msg = "[" + name + "#" + pd.getQName() + "] invalid declaring node type specified"; + String msg = "[" + name + "#" + pd.getName() + "] invalid declaring node type specified"; log.debug(msg); throw new InvalidNodeTypeDefException(msg); } - checkNamespace(pd.getQName()); + checkNamespace(pd.getName()); // check that auto-created properties specify a name if (pd.definesResidual() && pd.isAutoCreated()) { - String msg = "[" + name + "#" + pd.getQName() + "] auto-created properties must specify a name"; + String msg = "[" + name + "#" + pd.getName() + "] auto-created properties must specify a name"; log.debug(msg); throw new InvalidNodeTypeDefException(msg); } // check that auto-created properties specify a type if (pd.getRequiredType() == PropertyType.UNDEFINED && pd.isAutoCreated()) { - String msg = "[" + name + "#" + pd.getQName() + "] auto-created properties must specify a type"; + String msg = "[" + name + "#" + pd.getName() + "] auto-created properties must specify a type"; log.debug(msg); throw new InvalidNodeTypeDefException(msg); } @@ -263,10 +267,11 @@ if (pd.getRequiredType() == PropertyType.REFERENCE) { for (int j = 0; j < constraints.length; j++) { - QName ntName = QName.valueOf(constraints[j]); + // TODO improve. don't rely on a specific factory impl + Name ntName = NameFactoryImpl.getInstance().create(constraints[j]); /* compare to given ntd map and not registered nts only */ if (!name.equals(ntName) && !validatedDefs.containsKey(ntName)) { - String msg = "[" + name + "#" + pd.getQName() + String msg = "[" + name + "#" + pd.getName() + "] invalid REFERENCE value constraint '" + ntName + "' (unknown node type)"; log.debug(msg); @@ -283,15 +288,15 @@ QNodeDefinition cnd = cnda[i]; /* make sure declaring node type matches name of node type definition */ if (!name.equals(cnd.getDeclaringNodeType())) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] invalid declaring node type specified"; log.debug(msg); throw new InvalidNodeTypeDefException(msg); } - checkNamespace(cnd.getQName()); + checkNamespace(cnd.getName()); // check that auto-created child-nodes specify a name if (cnd.definesResidual() && cnd.isAutoCreated()) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] auto-created child-nodes must specify a name"; log.debug(msg); throw new InvalidNodeTypeDefException(msg); @@ -299,13 +304,13 @@ // check that auto-created child-nodes specify a default primary type if (cnd.getDefaultPrimaryType() == null && cnd.isAutoCreated()) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] auto-created child-nodes must specify a default primary type"; log.debug(msg); throw new InvalidNodeTypeDefException(msg); } // check default primary type - QName dpt = cnd.getDefaultPrimaryType(); + Name dpt = cnd.getDefaultPrimaryType(); checkNamespace(dpt); boolean referenceToSelf = false; EffectiveNodeType defaultENT = null; @@ -319,7 +324,7 @@ * exception: the node type just being registered */ if (!name.equals(dpt) && !validatedDefs.containsKey(dpt)) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] invalid default primary type '" + dpt + "'"; log.debug(msg); throw new InvalidNodeTypeDefException(msg); @@ -330,7 +335,7 @@ */ try { if (!referenceToSelf) { - defaultENT = entProvider.getEffectiveNodeType(new QName[] {dpt}, validatedDefs); + defaultENT = entProvider.getEffectiveNodeType(new Name[] {dpt}, validatedDefs); } else { /** * the default primary type is identical with the node @@ -351,12 +356,12 @@ checkForCircularNodeAutoCreation(defaultENT, definingNTs, validatedDefs); } } catch (NodeTypeConflictException ntce) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] failed to validate default primary type"; log.debug(msg); throw new InvalidNodeTypeDefException(msg, ntce); } catch (NoSuchNodeTypeException nsnte) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] failed to validate default primary type"; log.debug(msg); throw new InvalidNodeTypeDefException(msg, nsnte); @@ -364,10 +369,10 @@ } // check required primary types - QName[] reqTypes = cnd.getRequiredPrimaryTypes(); + Name[] reqTypes = cnd.getRequiredPrimaryTypes(); if (reqTypes != null && reqTypes.length > 0) { for (int n = 0; n < reqTypes.length; n++) { - QName rpt = reqTypes[n]; + Name rpt = reqTypes[n]; checkNamespace(rpt); referenceToSelf = false; /** @@ -382,7 +387,7 @@ * notable exception: the node type just being registered */ if (!name.equals(rpt) && !validatedDefs.containsKey(rpt)) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] invalid required primary type: " + rpt; log.debug(msg); throw new InvalidNodeTypeDefException(msg); @@ -392,7 +397,7 @@ * primary type constraint */ if (defaultENT != null && !defaultENT.includesNodeType(rpt)) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] default primary type does not satisfy required primary type constraint " + rpt; log.debug(msg); @@ -404,7 +409,7 @@ */ try { if (!referenceToSelf) { - entProvider.getEffectiveNodeType(new QName[] {rpt}, validatedDefs); + entProvider.getEffectiveNodeType(new Name[] {rpt}, validatedDefs); } else { /** * the required primary type is identical with the @@ -416,12 +421,12 @@ } } } catch (NodeTypeConflictException ntce) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] failed to validate required primary type constraint"; log.debug(msg); throw new InvalidNodeTypeDefException(msg, ntce); } catch (NoSuchNodeTypeException nsnte) { - String msg = "[" + name + "#" + cnd.getQName() + String msg = "[" + name + "#" + cnd.getName() + "] failed to validate required primary type constraint"; log.debug(msg); throw new InvalidNodeTypeDefException(msg, nsnte); @@ -459,10 +464,10 @@ * @throws InvalidNodeTypeDefException * @throws RepositoryException */ - private void checkForCircularInheritance(QName[] supertypes, Stack inheritanceChain, Map ntdMap) + private void checkForCircularInheritance(Name[] supertypes, Stack inheritanceChain, Map ntdMap) throws InvalidNodeTypeDefException, RepositoryException { for (int i = 0; i < supertypes.length; i++) { - QName stName = supertypes[i]; + Name stName = supertypes[i]; int pos = inheritanceChain.lastIndexOf(stName); if (pos >= 0) { StringBuffer buf = new StringBuffer(); @@ -479,7 +484,7 @@ } if (ntdMap.containsKey(stName)) { - QName[] sta = ((QNodeTypeDefinition)ntdMap.get(stName)).getSupertypes(); + Name[] sta = ((QNodeTypeDefinition)ntdMap.get(stName)).getSupertypes(); if (sta.length > 0) { // check recursively inheritanceChain.push(stName); @@ -504,9 +509,9 @@ throws InvalidNodeTypeDefException { // check for circularity through default node types of auto-created child nodes // (node type 'a' defines auto-created child node with default node type 'a') - QName[] childNodeNTs = childNodeENT.getAllNodeTypes(); + Name[] childNodeNTs = childNodeENT.getAllNodeTypes(); for (int i = 0; i < childNodeNTs.length; i++) { - QName nt = childNodeNTs[i]; + Name nt = childNodeNTs[i]; int pos = definingParentNTs.lastIndexOf(nt); if (pos >= 0) { StringBuffer buf = new StringBuffer(); @@ -528,22 +533,22 @@ QNodeDefinition[] nodeDefs = childNodeENT.getAutoCreateQNodeDefinitions(); for (int i = 0; i < nodeDefs.length; i++) { - QName dnt = nodeDefs[i].getDefaultPrimaryType(); - QName definingNT = nodeDefs[i].getDeclaringNodeType(); + Name dnt = nodeDefs[i].getDefaultPrimaryType(); + Name definingNT = nodeDefs[i].getDeclaringNodeType(); try { if (dnt != null) { // check recursively definingParentNTs.push(definingNT); - EffectiveNodeType ent = entProvider.getEffectiveNodeType(new QName[] {dnt}, ntdMap); + EffectiveNodeType ent = entProvider.getEffectiveNodeType(new Name[] {dnt}, ntdMap); checkForCircularNodeAutoCreation(ent, definingParentNTs, ntdMap); definingParentNTs.pop(); } } catch (NoSuchNodeTypeException e) { - String msg = definingNT + " defines invalid default node type for child node " + nodeDefs[i].getQName(); + String msg = definingNT + " defines invalid default node type for child node " + nodeDefs[i].getName(); log.debug(msg); throw new InvalidNodeTypeDefException(msg, e); } catch (NodeTypeConflictException e) { - String msg = definingNT + " defines invalid default node type for child node " + nodeDefs[i].getQName(); + String msg = definingNT + " defines invalid default node type for child node " + nodeDefs[i].getName(); log.debug(msg); throw new InvalidNodeTypeDefException(msg, e); } @@ -551,13 +556,13 @@ } /** - * Utility method for verifying that the namespace of a QName + * Utility method for verifying that the namespace of a Name * is registered; a null argument is silently ignored. * @param name name whose namespace is to be checked * @throws RepositoryException if the namespace of the given name is not * registered or if an unspecified error occured */ - private void checkNamespace(QName name) throws RepositoryException { + private void checkNamespace(Name name) throws RepositoryException { if (name != null) { // make sure namespace uri denotes a registered namespace nsRegistry.getPrefix(name.getNamespaceURI()); Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeType.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeType.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeType.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeType.java Thu Oct 18 11:41:45 2007 @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.jcr2spi.nodetype; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.spi.QNodeDefinition; import org.apache.jackrabbit.spi.QPropertyDefinition; @@ -28,11 +28,11 @@ */ public interface EffectiveNodeType { - public QName[] getAllNodeTypes(); + public Name[] getAllNodeTypes(); - public QName[] getInheritedNodeTypes(); + public Name[] getInheritedNodeTypes(); - public QName[] getMergedNodeTypes(); + public Name[] getMergedNodeTypes(); /** * Determines whether this effective node type representation includes @@ -42,7 +42,7 @@ * @return true if the given node type is included, otherwise * false */ - public boolean includesNodeType(QName nodeTypeName); + public boolean includesNodeType(Name nodeTypeName); /** * Determines whether this effective node type representation includes @@ -52,7 +52,7 @@ * @return true if all of the given node types are included, * otherwise false */ - public boolean includesNodeTypes(QName[] nodeTypeNames); + public boolean includesNodeTypes(Name[] nodeTypeNames); public QNodeDefinition[] getAllQNodeDefinitions(); @@ -66,9 +66,9 @@ public QPropertyDefinition[] getMandatoryQPropertyDefinitions(); - public QNodeDefinition[] getNamedQNodeDefinitions(QName name); + public QNodeDefinition[] getNamedQNodeDefinitions(Name name); - public QPropertyDefinition[] getNamedQPropertyDefinitions(QName name); + public QPropertyDefinition[] getNamedQPropertyDefinitions(Name name); public QNodeDefinition[] getUnnamedQNodeDefinitions(); @@ -79,7 +79,7 @@ * @param definitionProvider * @throws ConstraintViolationException */ - public void checkAddNodeConstraints(QName name, ItemDefinitionProvider definitionProvider) + public void checkAddNodeConstraints(Name name, ItemDefinitionProvider definitionProvider) throws ConstraintViolationException; /** @@ -89,12 +89,12 @@ * @throws ConstraintViolationException * @throws NoSuchNodeTypeException */ - public void checkAddNodeConstraints(QName name, QName nodeTypeName, ItemDefinitionProvider definitionProvider) + public void checkAddNodeConstraints(Name name, Name nodeTypeName, ItemDefinitionProvider definitionProvider) throws ConstraintViolationException, NoSuchNodeTypeException; /** * @param name * @throws ConstraintViolationException */ - public void checkRemoveItemConstraints(QName name) throws ConstraintViolationException; + public void checkRemoveItemConstraints(Name name) throws ConstraintViolationException; } Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java Thu Oct 18 11:41:45 2007 @@ -16,7 +16,7 @@ */ package org.apache.jackrabbit.jcr2spi.nodetype; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.jcr2spi.util.Dumpable; /** @@ -61,14 +61,14 @@ * @param ntNames the array of node type names for the effective node type * @return the key to an effective node type. */ - Key getKey(QName[] ntNames); + Key getKey(Name[] ntNames); /** * Removes all effective node types that are aggregated with the node type * of the given name. * @param name the name of the node type. */ - void invalidate(QName name); + void invalidate(Name name); /** * {@inheritDoc} @@ -101,7 +101,7 @@ * Returns the node type names of this key. * @return the node type names of this key. */ - QName[] getNames(); + Name[] getNames(); /** * Checks if the otherKey is contained in this one. I.e. if Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeImpl.java Thu Oct 18 11:41:45 2007 @@ -19,8 +19,9 @@ import org.apache.jackrabbit.spi.QItemDefinition; import org.apache.jackrabbit.spi.QNodeDefinition; import org.apache.jackrabbit.spi.QPropertyDefinition; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.spi.QNodeTypeDefinition; +import org.apache.jackrabbit.nodetype.NodeTypeConflictException; import org.slf4j.LoggerFactory; import org.slf4j.Logger; @@ -86,7 +87,7 @@ throws NodeTypeConflictException, NoSuchNodeTypeException { // create empty effective node type instance EffectiveNodeTypeImpl ent = new EffectiveNodeTypeImpl(); - QName ntName = ntd.getQName(); + Name ntName = ntd.getName(); // prepare new instance ent.mergedNodeTypes.add(ntName); @@ -108,7 +109,7 @@ msg = ntName + " contains ambiguous residual child node definitions"; } else { msg = ntName + " contains ambiguous definitions for child node named " - + cnda[i].getQName(); + + cnda[i].getName(); } log.debug(msg); throw new NodeTypeConflictException(msg); @@ -120,7 +121,7 @@ ent.unnamedItemDefs.add(cnda[i]); } else { // named node definition - QName name = cnda[i].getQName(); + Name name = cnda[i].getName(); List defs = (List) ent.namedItemDefs.get(name); if (defs == null) { defs = new ArrayList(); @@ -156,7 +157,7 @@ msg = ntName + " contains ambiguous residual property definitions"; } else { msg = ntName + " contains ambiguous definitions for property named " - + pda[i].getQName(); + + pda[i].getName(); } log.debug(msg); throw new NodeTypeConflictException(msg); @@ -168,7 +169,7 @@ ent.unnamedItemDefs.add(pda[i]); } else { // named property definition - QName name = pda[i].getQName(); + Name name = pda[i].getName(); List defs = (List) ent.namedItemDefs.get(name); if (defs == null) { defs = new ArrayList(); @@ -195,7 +196,7 @@ } // resolve supertypes recursively - QName[] supertypes = ntd.getSupertypes(); + Name[] supertypes = ntd.getSupertypes(); if (supertypes.length > 0) { EffectiveNodeTypeImpl effSuperType = (EffectiveNodeTypeImpl)entProvider.getEffectiveNodeType(supertypes, ntdMap); ent.internalMerge(effSuperType, true); @@ -218,22 +219,22 @@ /** * @see EffectiveNodeType#getInheritedNodeTypes() */ - public QName[] getInheritedNodeTypes() { - return (QName[]) inheritedNodeTypes.toArray(new QName[inheritedNodeTypes.size()]); + public Name[] getInheritedNodeTypes() { + return (Name[]) inheritedNodeTypes.toArray(new Name[inheritedNodeTypes.size()]); } /** * @see EffectiveNodeType#getAllNodeTypes() */ - public QName[] getAllNodeTypes() { - return (QName[]) allNodeTypes.toArray(new QName[allNodeTypes.size()]); + public Name[] getAllNodeTypes() { + return (Name[]) allNodeTypes.toArray(new Name[allNodeTypes.size()]); } /** * @see EffectiveNodeType#getMergedNodeTypes() */ - public QName[] getMergedNodeTypes() { - return (QName[]) mergedNodeTypes.toArray(new QName[mergedNodeTypes.size()]); + public Name[] getMergedNodeTypes() { + return (Name[]) mergedNodeTypes.toArray(new Name[mergedNodeTypes.size()]); } /** @@ -409,9 +410,9 @@ } /** - * @see EffectiveNodeType#getNamedQNodeDefinitions(QName) + * @see EffectiveNodeType#getNamedQNodeDefinitions(Name) */ - public QNodeDefinition[] getNamedQNodeDefinitions(QName name) { + public QNodeDefinition[] getNamedQNodeDefinitions(Name name) { List list = (List) namedItemDefs.get(name); if (list == null || list.size() == 0) { return QNodeDefinition.EMPTY_ARRAY; @@ -452,9 +453,9 @@ } /** - * @see EffectiveNodeType#getNamedQPropertyDefinitions(QName) + * @see EffectiveNodeType#getNamedQPropertyDefinitions(Name) */ - public QPropertyDefinition[] getNamedQPropertyDefinitions(QName name) { + public QPropertyDefinition[] getNamedQPropertyDefinitions(Name name) { List list = (List) namedItemDefs.get(name); if (list == null || list.size() == 0) { return QPropertyDefinition.EMPTY_ARRAY; @@ -497,22 +498,22 @@ /** * @inheritDoc */ - public boolean includesNodeType(QName nodeTypeName) { + public boolean includesNodeType(Name nodeTypeName) { return allNodeTypes.contains(nodeTypeName); } /** * @inheritDoc */ - public boolean includesNodeTypes(QName[] nodeTypeNames) { + public boolean includesNodeTypes(Name[] nodeTypeNames) { return allNodeTypes.containsAll(Arrays.asList(nodeTypeNames)); } /** * @inheritDoc - * @see EffectiveNodeType#checkAddNodeConstraints(QName, ItemDefinitionProvider) + * @see EffectiveNodeType#checkAddNodeConstraints(Name, ItemDefinitionProvider) */ - public void checkAddNodeConstraints(QName name, ItemDefinitionProvider definitionProvider) + public void checkAddNodeConstraints(Name name, ItemDefinitionProvider definitionProvider) throws ConstraintViolationException { try { definitionProvider.getQNodeDefinition(this, name, null); @@ -525,9 +526,9 @@ /** * @inheritDoc - * @see EffectiveNodeType#checkAddNodeConstraints(QName, ItemDefinitionProvider) + * @see EffectiveNodeType#checkAddNodeConstraints(Name, ItemDefinitionProvider) */ - public void checkAddNodeConstraints(QName name, QName nodeTypeName, ItemDefinitionProvider definitionProvider) + public void checkAddNodeConstraints(Name name, Name nodeTypeName, ItemDefinitionProvider definitionProvider) throws ConstraintViolationException, NoSuchNodeTypeException { QNodeDefinition nd = definitionProvider.getQNodeDefinition(this, name, nodeTypeName); if (nd.isProtected()) { @@ -540,9 +541,9 @@ /** * @inheritDoc - * @see EffectiveNodeType#checkRemoveItemConstraints(QName) + * @see EffectiveNodeType#checkRemoveItemConstraints(Name) */ - public void checkRemoveItemConstraints(QName name) throws ConstraintViolationException { + public void checkRemoveItemConstraints(Name name) throws ConstraintViolationException { /** * as there might be multiple definitions with the same name and we * don't know which one is applicable, we check all of them @@ -577,7 +578,7 @@ return (QItemDefinition[]) defs.toArray(new QItemDefinition[defs.size()]); } - private QItemDefinition[] getNamedItemDefs(QName name) { + private QItemDefinition[] getNamedItemDefs(Name name) { List list = (List) namedItemDefs.get(name); if (list == null || list.size() == 0) { return QNodeDefinition.EMPTY_ARRAY; @@ -626,7 +627,7 @@ */ private synchronized void internalMerge(EffectiveNodeTypeImpl other, boolean supertype) throws NodeTypeConflictException { - QName[] nta = other.getAllNodeTypes(); + Name[] nta = other.getAllNodeTypes(); int includedCount = 0; for (int i = 0; i < nta.length; i++) { if (includesNodeType(nta[i])) { @@ -648,7 +649,7 @@ // ignore redundant definitions continue; } - QName name = qDef.getQName(); + Name name = qDef.getName(); List existingDefs = (List) namedItemDefs.get(name); if (existingDefs != null) { if (existingDefs.size() > 0) { Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeProvider.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeProvider.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeProvider.java Thu Oct 18 11:41:45 2007 @@ -16,8 +16,9 @@ */ package org.apache.jackrabbit.jcr2spi.nodetype; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.jcr2spi.state.NodeState; +import org.apache.jackrabbit.nodetype.NodeTypeConflictException; import javax.jcr.nodetype.NoSuchNodeTypeException; import javax.jcr.nodetype.ConstraintViolationException; @@ -36,7 +37,7 @@ * @return * @throws NoSuchNodeTypeException */ - public EffectiveNodeType getEffectiveNodeType(QName ntName) + public EffectiveNodeType getEffectiveNodeType(Name ntName) throws NoSuchNodeTypeException; /** @@ -48,7 +49,7 @@ * @throws NodeTypeConflictException * @throws NoSuchNodeTypeException */ - public EffectiveNodeType getEffectiveNodeType(QName[] ntNames) + public EffectiveNodeType getEffectiveNodeType(Name[] ntNames) throws NodeTypeConflictException, NoSuchNodeTypeException; /** @@ -58,7 +59,7 @@ * @throws NodeTypeConflictException * @throws NoSuchNodeTypeException */ - public EffectiveNodeType getEffectiveNodeType(QName[] ntNames, Map ntdMap) + public EffectiveNodeType getEffectiveNodeType(Name[] ntNames, Map ntdMap) throws NodeTypeConflictException, NoSuchNodeTypeException; /** Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionImpl.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionImpl.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionImpl.java Thu Oct 18 11:41:45 2007 @@ -16,21 +16,20 @@ */ package org.apache.jackrabbit.jcr2spi.nodetype; -import org.apache.jackrabbit.name.NamespaceResolver; -import org.apache.jackrabbit.name.NoPrefixDeclaredException; -import org.apache.jackrabbit.name.NameFormat; import org.apache.jackrabbit.spi.QItemDefinition; +import org.apache.jackrabbit.conversion.NamePathResolver; import org.slf4j.LoggerFactory; import org.slf4j.Logger; import javax.jcr.nodetype.ItemDefinition; import javax.jcr.nodetype.NoSuchNodeTypeException; import javax.jcr.nodetype.NodeType; +import javax.jcr.NamespaceException; /** * This class implements the ItemDefinition interface. * All method calls are delegated to the wrapped {@link QItemDefinition}, - * performing the translation from QNames to JCR names + * performing the translation from Names to JCR names * (and vice versa) where necessary. */ abstract class ItemDefinitionImpl implements ItemDefinition { @@ -53,7 +52,7 @@ /** * The namespace resolver used to translate qualified names to JCR names. */ - protected final NamespaceResolver nsResolver; + protected final NamePathResolver resolver; /** * The wrapped item definition. @@ -65,13 +64,13 @@ * * @param itemDef item definition * @param ntMgr node type manager - * @param nsResolver namespace resolver + * @param resolver */ ItemDefinitionImpl(QItemDefinition itemDef, NodeTypeManagerImpl ntMgr, - NamespaceResolver nsResolver) { + NamePathResolver resolver) { this.itemDef = itemDef; this.ntMgr = ntMgr; - this.nsResolver = nsResolver; + this.resolver = resolver; } //-------------------------------------------------------< ItemDefinition > @@ -96,13 +95,12 @@ return ANY_NAME; } else { try { - return NameFormat.format(itemDef.getQName(), nsResolver); - } catch (NoPrefixDeclaredException npde) { + return resolver.getJCRName(itemDef.getName()); + } catch (NamespaceException e) { // should never get here - log.error("encountered unregistered namespace in property name", - npde); + log.error("encountered unregistered namespace in property name", e); // not correct, but an acceptable fallback - return itemDef.getQName().toString(); + return itemDef.getName().toString(); } } } Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProvider.java Thu Oct 18 11:41:45 2007 @@ -20,7 +20,7 @@ import org.apache.jackrabbit.spi.QNodeDefinition; import org.apache.jackrabbit.jcr2spi.state.NodeState; import org.apache.jackrabbit.jcr2spi.state.PropertyState; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import javax.jcr.RepositoryException; import javax.jcr.nodetype.NoSuchNodeTypeException; @@ -47,7 +47,7 @@ * @throws ConstraintViolationException if no applicable child node definition * could be found */ - public QNodeDefinition getQNodeDefinition(NodeState parentState, QName name, QName nodeTypeName) + public QNodeDefinition getQNodeDefinition(NodeState parentState, Name name, Name nodeTypeName) throws NoSuchNodeTypeException, ConstraintViolationException; /** @@ -62,7 +62,7 @@ * @throws ConstraintViolationException if no applicable child node definition * could be found */ - public QNodeDefinition getQNodeDefinition(EffectiveNodeType ent, QName name, QName nodeTypeName) + public QNodeDefinition getQNodeDefinition(EffectiveNodeType ent, Name name, Name nodeTypeName) throws NoSuchNodeTypeException, ConstraintViolationException; public QPropertyDefinition getQPropertyDefinition(PropertyState propertyState) throws RepositoryException; @@ -83,8 +83,8 @@ * @throws ConstraintViolationException if no applicable property definition * could be found */ - public QPropertyDefinition getQPropertyDefinition(QName ntName, - QName propName, int type, + public QPropertyDefinition getQPropertyDefinition(Name ntName, + Name propName, int type, boolean multiValued) throws ConstraintViolationException, NoSuchNodeTypeException; @@ -107,7 +107,7 @@ * could be found */ public QPropertyDefinition getQPropertyDefinition(NodeState parentState, - QName name, int type, + Name name, int type, boolean multiValued) throws ConstraintViolationException, NoSuchNodeTypeException; @@ -115,7 +115,7 @@ * Returns the applicable property definition for a property with the * specified name and type. The multiValued flag is not taken into account * in the selection algorithm. Other than - * {@link #getApplicablePropertyDefinition(QName, int, boolean)} + * {@link #getApplicablePropertyDefinition(Name, int, boolean)} * this method does not take the multiValued flag into account in the * selection algorithm. If there more than one applicable definitions then * the following rules are applied: @@ -133,6 +133,6 @@ * @throws ConstraintViolationException if no applicable property definition * could be found */ - public QPropertyDefinition getQPropertyDefinition(NodeState parentState, QName name, int type) + public QPropertyDefinition getQPropertyDefinition(NodeState parentState, Name name, int type) throws ConstraintViolationException, NoSuchNodeTypeException; } Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/ItemDefinitionProviderImpl.java Thu Oct 18 11:41:45 2007 @@ -26,7 +26,7 @@ import org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry; import org.apache.jackrabbit.jcr2spi.state.NodeState; import org.apache.jackrabbit.jcr2spi.state.PropertyState; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import javax.jcr.RepositoryException; import javax.jcr.PropertyType; @@ -85,11 +85,9 @@ */ EffectiveNodeType ent = entProvider.getEffectiveNodeType(nodeState.getParent().getNodeTypeNames()); EffectiveNodeType entTarget = getEffectiveNodeType(nodeState.getNodeTypeName()); - definition = getQNodeDefinition(ent, entTarget, nodeState.getQName()); + definition = getQNodeDefinition(ent, entTarget, nodeState.getName()); } catch (RepositoryException e) { definition = service.getNodeDefinition(sessionInfo, nodeState.getNodeEntry().getWorkspaceId()); - } catch (NodeTypeConflictException e) { - definition = service.getNodeDefinition(sessionInfo, nodeState.getNodeEntry().getWorkspaceId()); } return definition; } @@ -97,7 +95,7 @@ /** * @inheritDoc */ - public QNodeDefinition getQNodeDefinition(NodeState parentState, QName name, QName nodeTypeName) + public QNodeDefinition getQNodeDefinition(NodeState parentState, Name name, Name nodeTypeName) throws NoSuchNodeTypeException, ConstraintViolationException { EffectiveNodeType ent = entProvider.getEffectiveNodeType(parentState); EffectiveNodeType entTarget = getEffectiveNodeType(nodeTypeName); @@ -107,7 +105,7 @@ /** * @inheritDoc */ - public QNodeDefinition getQNodeDefinition(EffectiveNodeType ent, QName name, QName nodeTypeName) throws NoSuchNodeTypeException, ConstraintViolationException { + public QNodeDefinition getQNodeDefinition(EffectiveNodeType ent, Name name, Name nodeTypeName) throws NoSuchNodeTypeException, ConstraintViolationException { EffectiveNodeType entTarget = getEffectiveNodeType(nodeTypeName); return getQNodeDefinition(ent, entTarget, name); } @@ -129,11 +127,9 @@ evaluated upon creating the workspace state. */ EffectiveNodeType ent = entProvider.getEffectiveNodeType(propertyState.getParent().getNodeTypeNames()); - definition = getQPropertyDefinition(ent, propertyState.getQName(), propertyState.getType(), propertyState.isMultiValued(), true); + definition = getQPropertyDefinition(ent, propertyState.getName(), propertyState.getType(), propertyState.isMultiValued(), true); } catch (RepositoryException e) { definition = service.getPropertyDefinition(sessionInfo, ((PropertyEntry) propertyState.getHierarchyEntry()).getWorkspaceId()); - } catch (NodeTypeConflictException e) { - definition = service.getPropertyDefinition(sessionInfo, ((PropertyEntry) propertyState.getHierarchyEntry()).getWorkspaceId()); } return definition; } @@ -141,7 +137,7 @@ /** * @inheritDoc */ - public QPropertyDefinition getQPropertyDefinition(QName ntName, QName propName, + public QPropertyDefinition getQPropertyDefinition(Name ntName, Name propName, int type, boolean multiValued) throws ConstraintViolationException, NoSuchNodeTypeException { EffectiveNodeType ent = entProvider.getEffectiveNodeType(ntName); @@ -152,7 +148,7 @@ * @inheritDoc */ public QPropertyDefinition getQPropertyDefinition(NodeState parentState, - QName name, int type, + Name name, int type, boolean multiValued) throws ConstraintViolationException, NoSuchNodeTypeException { EffectiveNodeType ent = entProvider.getEffectiveNodeType(parentState); @@ -163,14 +159,14 @@ * @inheritDoc */ public QPropertyDefinition getQPropertyDefinition(NodeState parentState, - QName name, int type) + Name name, int type) throws ConstraintViolationException, NoSuchNodeTypeException { EffectiveNodeType ent = entProvider.getEffectiveNodeType(parentState); return getQPropertyDefinition(ent, name, type); } //-------------------------------------------------------------------------- - private EffectiveNodeType getEffectiveNodeType(QName ntName) throws NoSuchNodeTypeException { + private EffectiveNodeType getEffectiveNodeType(Name ntName) throws NoSuchNodeTypeException { if (ntName != null) { return entProvider.getEffectiveNodeType(ntName); } else { @@ -188,7 +184,7 @@ */ static QNodeDefinition getQNodeDefinition(EffectiveNodeType ent, EffectiveNodeType entTarget, - QName name) + Name name) throws ConstraintViolationException { // try named node definitions first @@ -247,7 +243,7 @@ * @throws ConstraintViolationException */ private static QPropertyDefinition getQPropertyDefinition(EffectiveNodeType ent, - QName name, int type, + Name name, int type, boolean multiValued, boolean throwWhenAmbiguous) throws ConstraintViolationException { // try named property definitions first @@ -278,7 +274,7 @@ * @throws ConstraintViolationException */ private static QPropertyDefinition getQPropertyDefinition(EffectiveNodeType ent, - QName name, int type) + Name name, int type) throws ConstraintViolationException { // try named property definitions first QPropertyDefinition[] defs = ent.getNamedQPropertyDefinitions(name); Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeDefinitionImpl.java Thu Oct 18 11:41:45 2007 @@ -16,9 +16,10 @@ */ package org.apache.jackrabbit.jcr2spi.nodetype; -import org.apache.jackrabbit.name.NamespaceResolver; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.spi.QNodeDefinition; +import org.apache.jackrabbit.conversion.NamePathResolver; +import org.apache.jackrabbit.name.NameConstants; import org.slf4j.LoggerFactory; import org.slf4j.Logger; @@ -29,7 +30,7 @@ /** * This class implements the NodeDefinition interface. * All method calls are delegated to the wrapped {@link QNodeDefinition}, - * performing the translation from QNames to JCR names + * performing the translation from Names to JCR names * where necessary. */ public class NodeDefinitionImpl extends ItemDefinitionImpl implements NodeDefinition { @@ -44,11 +45,11 @@ * * @param nodeDef child node definition * @param ntMgr node type manager - * @param nsResolver namespace resolver + * @param resolver */ NodeDefinitionImpl(QNodeDefinition nodeDef, NodeTypeManagerImpl ntMgr, - NamespaceResolver nsResolver) { - super(nodeDef, ntMgr, nsResolver); + NamePathResolver resolver) { + super(nodeDef, ntMgr, resolver); } //-------------------------------------------------------< NodeDefinition > @@ -56,7 +57,7 @@ * {@inheritDoc} */ public NodeType getDefaultPrimaryType() { - QName ntName = ((QNodeDefinition) itemDef).getDefaultPrimaryType(); + Name ntName = ((QNodeDefinition) itemDef).getDefaultPrimaryType(); if (ntName == null) { return null; } @@ -73,11 +74,11 @@ * {@inheritDoc} */ public NodeType[] getRequiredPrimaryTypes() { - QName[] ntNames = ((QNodeDefinition) itemDef).getRequiredPrimaryTypes(); + Name[] ntNames = ((QNodeDefinition) itemDef).getRequiredPrimaryTypes(); try { if (ntNames == null || ntNames.length == 0) { // return "nt:base" - return new NodeType[] { ntMgr.getNodeType(QName.NT_BASE) }; + return new NodeType[] { ntMgr.getNodeType(NameConstants.NT_BASE) }; } else { NodeType[] nodeTypes = new NodeType[ntNames.length]; for (int i = 0; i < ntNames.length; i++) { Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeCache.java Thu Oct 18 11:41:45 2007 @@ -17,7 +17,7 @@ package org.apache.jackrabbit.jcr2spi.nodetype; import org.apache.commons.collections.map.ReferenceMap; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.spi.QNodeTypeDefinition; import org.apache.jackrabbit.spi.RepositoryService; @@ -42,7 +42,7 @@ private static final Map CACHES_PER_SERVICE = new WeakHashMap(); /** - * Maps node type QNames to QNodeTypeDefinition + * Maps node type Names to QNodeTypeDefinition */ private final Map nodeTypes = new HashMap(); @@ -91,7 +91,7 @@ Map allNts = new HashMap(); for (Iterator it = storage.getAllDefinitions(); it.hasNext(); ) { QNodeTypeDefinition def = (QNodeTypeDefinition) it.next(); - allNts.put(def.getQName(), def); + allNts.put(def.getName(), def); } // update the cache synchronized (nodeTypes) { @@ -111,7 +111,7 @@ * @throws javax.jcr.nodetype.NoSuchNodeTypeException * @throws RepositoryException */ - public Iterator getDefinitions(NodeTypeStorage storage, QName[] nodeTypeNames) + public Iterator getDefinitions(NodeTypeStorage storage, Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException { List nts = new ArrayList(); List missing = null; @@ -129,13 +129,13 @@ } } if (missing != null) { - QName[] ntNames = (QName[]) missing.toArray(new QName[missing.size()]); + Name[] ntNames = (Name[]) missing.toArray(new Name[missing.size()]); Iterator it = storage.getDefinitions(ntNames); synchronized (nodeTypes) { while (it.hasNext()) { QNodeTypeDefinition def = (QNodeTypeDefinition) it.next(); nts.add(def); - nodeTypes.put(def.getQName(), def); + nodeTypes.put(def.getName(), def); } } } @@ -155,7 +155,7 @@ } public void unregisterNodeTypes(NodeTypeStorage storage, - QName[] nodeTypeNames) + Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException { throw new UnsupportedOperationException("NodeType registration not yet defined by the SPI"); } @@ -173,7 +173,7 @@ public Iterator getAllDefinitions() throws RepositoryException { return NodeTypeCache.this.getAllDefinitions(storage); } - public Iterator getDefinitions(QName[] nodeTypeNames) + public Iterator getDefinitions(Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException { return NodeTypeCache.this.getDefinitions(storage, nodeTypeNames); } @@ -185,7 +185,7 @@ throws NoSuchNodeTypeException, RepositoryException { NodeTypeCache.this.reregisterNodeTypes(storage, nodeTypeDefs); } - public void unregisterNodeTypes(QName[] nodeTypeNames) + public void unregisterNodeTypes(Name[] nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException { NodeTypeCache.this.unregisterNodeTypes(storage, nodeTypeNames); } Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeImpl.java Thu Oct 18 11:41:45 2007 @@ -16,13 +16,9 @@ */ package org.apache.jackrabbit.jcr2spi.nodetype; -import org.apache.jackrabbit.name.IllegalNameException; -import org.apache.jackrabbit.name.NamespaceResolver; -import org.apache.jackrabbit.name.NoPrefixDeclaredException; -import org.apache.jackrabbit.name.UnknownPrefixException; -import org.apache.jackrabbit.name.NameException; -import org.apache.jackrabbit.name.QName; -import org.apache.jackrabbit.name.NameFormat; +import org.apache.jackrabbit.conversion.NameException; +import org.apache.jackrabbit.conversion.NamePathResolver; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.spi.QNodeDefinition; import org.apache.jackrabbit.spi.QPropertyDefinition; import org.apache.jackrabbit.spi.QNodeTypeDefinition; @@ -31,6 +27,7 @@ import org.apache.jackrabbit.value.ValueHelper; import org.apache.jackrabbit.value.ValueFormat; import org.apache.jackrabbit.jcr2spi.ManagerProvider; +import org.apache.jackrabbit.namespace.NamespaceResolver; import org.slf4j.LoggerFactory; import org.slf4j.Logger; @@ -38,6 +35,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Value; import javax.jcr.ValueFactory; +import javax.jcr.NamespaceException; import javax.jcr.nodetype.ConstraintViolationException; import javax.jcr.nodetype.NoSuchNodeTypeException; import javax.jcr.nodetype.NodeDefinition; @@ -67,7 +65,7 @@ * @param ent the effective (i.e. merged and resolved) node type representation * @param ntd the definition of this node type * @param ntMgr the node type manager associated with this node type - * @param nsResolver namespace resolver + * @param mgrProvider */ NodeTypeImpl(EffectiveNodeType ent, QNodeTypeDefinition ntd, NodeTypeManagerImpl ntMgr, ManagerProvider mgrProvider) { @@ -81,6 +79,10 @@ return mgrProvider.getNamespaceResolver(); } + private NamePathResolver resolver() { + return mgrProvider.getNamePathResolver(); + } + private ItemDefinitionProvider definitionProvider() { return mgrProvider.getItemDefinitionProvider(); } @@ -115,7 +117,7 @@ * @throws RepositoryException if no applicable property definition * could be found */ - private QPropertyDefinition getApplicablePropDef(QName propertyName, int type, boolean multiValued) + private QPropertyDefinition getApplicablePropDef(Name propertyName, int type, boolean multiValued) throws RepositoryException { return definitionProvider().getQPropertyDefinition(getQName(), propertyName, type, multiValued); } @@ -128,8 +130,8 @@ * @return true if this node type is equal or directly or indirectly derived * from the specified node type, otherwise false. */ - public boolean isNodeType(QName nodeTypeName) { - return getQName().equals(nodeTypeName) || ent.includesNodeType(nodeTypeName); + public boolean isNodeType(Name nodeTypeName) { + return getName().equals(nodeTypeName) || ent.includesNodeType(nodeTypeName); } /** @@ -156,8 +158,8 @@ * * @return the qualified name */ - private QName getQName() { - return ntd.getQName(); + private Name getQName() { + return ntd.getName(); } //-----------------------------------------------------------< NodeType >--- @@ -166,11 +168,11 @@ */ public String getName() { try { - return NameFormat.format(ntd.getQName(), nsResolver()); - } catch (NoPrefixDeclaredException npde) { + return resolver().getJCRName(ntd.getName()); + } catch (NamespaceException e) { // should never get here - log.error("encountered unregistered namespace in node type name", npde); - return ntd.getQName().toString(); + log.error("encountered unregistered namespace in node type name", e); + return ntd.getName().toString(); } } @@ -179,16 +181,16 @@ */ public String getPrimaryItemName() { try { - QName piName = ntd.getPrimaryItemName(); + Name piName = ntd.getPrimaryItemName(); if (piName != null) { - return NameFormat.format(piName, nsResolver()); + return resolver().getJCRName(piName); } else { return null; } - } catch (NoPrefixDeclaredException npde) { + } catch (NamespaceException e) { // should never get here - log.error("encountered unregistered namespace in name of primary item", npde); - return ntd.getQName().toString(); + log.error("encountered unregistered namespace in name of primary item", e); + return ntd.getName().toString(); } } @@ -203,14 +205,14 @@ * {@inheritDoc} */ public boolean isNodeType(String nodeTypeName) { - QName ntName; + Name ntName; try { - ntName = NameFormat.parse(nodeTypeName, nsResolver()); - } catch (IllegalNameException ine) { - log.warn("invalid node type name: " + nodeTypeName, ine); + ntName = resolver().getQName(nodeTypeName); + } catch (NamespaceException e) { + log.warn("invalid node type name: " + nodeTypeName, e); return false; - } catch (UnknownPrefixException upe) { - log.warn("invalid node type name: " + nodeTypeName, upe); + } catch (NameException e) { + log.warn("invalid node type name: " + nodeTypeName, e); return false; } return isNodeType(ntName); @@ -227,7 +229,7 @@ * {@inheritDoc} */ public NodeType[] getSupertypes() { - QName[] ntNames = ent.getInheritedNodeTypes(); + Name[] ntNames = ent.getInheritedNodeTypes(); NodeType[] supertypes = new NodeType[ntNames.length]; for (int i = 0; i < ntNames.length; i++) { try { @@ -269,7 +271,7 @@ * {@inheritDoc} */ public NodeType[] getDeclaredSupertypes() { - QName[] ntNames = ntd.getSupertypes(); + Name[] ntNames = ntd.getSupertypes(); NodeType[] supertypes = new NodeType[ntNames.length]; for (int i = 0; i < ntNames.length; i++) { try { @@ -304,7 +306,7 @@ return canRemoveItem(propertyName); } try { - QName name = NameFormat.parse(propertyName, nsResolver()); + Name name = resolver().getQName(propertyName); QPropertyDefinition def; try { // try to get definition that matches the given value type @@ -329,12 +331,12 @@ v = value; } // create QValue from Value - QValue qValue = ValueFormat.getQValue(v, nsResolver(), qValueFactory()); + QValue qValue = ValueFormat.getQValue(v, resolver(), qValueFactory()); checkSetPropertyValueConstraints(def, new QValue[]{qValue}); return true; - } catch (NameException be) { - // implementation specific exception, fall through - } catch (RepositoryException re) { + } catch (NameException re) { + // fall through + } catch (RepositoryException e) { // fall through } return false; @@ -349,7 +351,7 @@ return canRemoveItem(propertyName); } try { - QName name = NameFormat.parse(propertyName, nsResolver()); + Name name = resolver().getQName(propertyName); // determine type of values int type = PropertyType.UNDEFINED; for (int i = 0; i < values.length; i++) { @@ -397,7 +399,7 @@ // create QValue from Value and perform // type conversion as necessary Value v = ValueHelper.convert(values[i], targetType, valueFactory()); - QValue qValue = ValueFormat.getQValue(v, nsResolver(), qValueFactory()); + QValue qValue = ValueFormat.getQValue(v, resolver(), qValueFactory()); list.add(qValue); } } @@ -417,7 +419,7 @@ */ public boolean canAddChildNode(String childNodeName) { try { - ent.checkAddNodeConstraints(NameFormat.parse(childNodeName, nsResolver()), definitionProvider()); + ent.checkAddNodeConstraints(resolver().getQName(childNodeName), definitionProvider()); return true; } catch (NameException be) { // implementation specific exception, fall through @@ -432,8 +434,8 @@ */ public boolean canAddChildNode(String childNodeName, String nodeTypeName) { try { - ent.checkAddNodeConstraints(NameFormat.parse(childNodeName, nsResolver()), - NameFormat.parse(nodeTypeName, nsResolver()), definitionProvider()); + ent.checkAddNodeConstraints(resolver().getQName(childNodeName), + resolver().getQName(nodeTypeName), definitionProvider()); return true; } catch (NameException be) { // implementation specific exception, fall through @@ -448,7 +450,7 @@ */ public boolean canRemoveItem(String itemName) { try { - ent.checkRemoveItemConstraints(NameFormat.parse(itemName, nsResolver())); + ent.checkRemoveItemConstraints(resolver().getQName(itemName)); return true; } catch (NameException be) { // implementation specific exception, fall through Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java Thu Oct 18 11:41:45 2007 @@ -17,12 +17,10 @@ package org.apache.jackrabbit.jcr2spi.nodetype; import org.apache.commons.collections.map.ReferenceMap; -import org.apache.jackrabbit.name.IllegalNameException; -import org.apache.jackrabbit.name.NamespaceResolver; -import org.apache.jackrabbit.name.UnknownPrefixException; -import org.apache.jackrabbit.name.NameException; -import org.apache.jackrabbit.name.QName; -import org.apache.jackrabbit.name.NameFormat; +import org.apache.jackrabbit.namespace.NamespaceResolver; +import org.apache.jackrabbit.conversion.NameException; +import org.apache.jackrabbit.conversion.NamePathResolver; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.util.IteratorHelper; import org.apache.jackrabbit.jcr2spi.util.Dumpable; import org.apache.jackrabbit.jcr2spi.ManagerProvider; @@ -36,6 +34,7 @@ import javax.jcr.PropertyType; import javax.jcr.Value; import javax.jcr.ValueFactory; +import javax.jcr.NamespaceException; import javax.jcr.version.OnParentVersionAction; import javax.jcr.nodetype.NoSuchNodeTypeException; import javax.jcr.nodetype.NodeType; @@ -118,6 +117,10 @@ return mgrProvider.getNamespaceResolver(); } + private NamePathResolver resolver() { + return mgrProvider.getNamePathResolver(); + } + private EffectiveNodeTypeProvider entProvider() { return mgrProvider.getEffectiveNodeTypeProvider(); } @@ -127,7 +130,7 @@ * @return * @throws NoSuchNodeTypeException */ - public NodeTypeImpl getNodeType(QName name) throws NoSuchNodeTypeException { + public NodeTypeImpl getNodeType(Name name) throws NoSuchNodeTypeException { synchronized (ntCache) { NodeTypeImpl nt = (NodeTypeImpl) ntCache.get(name); if (nt == null) { @@ -145,7 +148,7 @@ * @param nodeTypeName * @return */ - public boolean hasNodeType(QName nodeTypeName) { + public boolean hasNodeType(Name nodeTypeName) { boolean isRegistered = ntCache.containsKey(nodeTypeName); if (!isRegistered) { isRegistered = ntReg.isRegistered(nodeTypeName); @@ -164,7 +167,7 @@ synchronized (ndCache) { NodeDefinition ndi = (NodeDefinition) ndCache.get(def); if (ndi == null) { - ndi = new NodeDefinitionImpl(def, this, nsResolver()); + ndi = new NodeDefinitionImpl(def, this, resolver()); ndCache.put(def, ndi); } return ndi; @@ -182,7 +185,7 @@ synchronized (pdCache) { PropertyDefinition pdi = (PropertyDefinition) pdCache.get(def); if (pdi == null) { - pdi = new PropertyDefinitionImpl(def, this, nsResolver(), valueFactory); + pdi = new PropertyDefinitionImpl(def, this, resolver(), valueFactory); pdCache.put(def, pdi); } return pdi; @@ -199,18 +202,18 @@ /** * {@inheritDoc} */ - public void nodeTypeRegistered(QName ntName) { + public void nodeTypeRegistered(Name ntName) { // not interested, ignore } /** * {@inheritDoc} */ - public void nodeTypeReRegistered(QName ntName) { + public void nodeTypeReRegistered(Name ntName) { // flush all affected cache entries ntCache.remove(ntName); try { - String name = NameFormat.format(ntName, nsResolver()); + String name = resolver().getJCRName(ntName); synchronized (pdCache) { Iterator iter = pdCache.values().iterator(); while (iter.hasNext()) { @@ -229,7 +232,7 @@ } } } - } catch (NameException e) { + } catch (NamespaceException e) { log.warn(e.getMessage() + " -> clear definition cache." ); synchronized (pdCache) { pdCache.clear(); @@ -243,11 +246,11 @@ /** * {@inheritDoc} */ - public void nodeTypeUnregistered(QName ntName) { + public void nodeTypeUnregistered(Name ntName) { // flush all affected cache entries ntCache.remove(ntName); try { - String name = NameFormat.format(ntName, nsResolver()); + String name = resolver().getJCRName(ntName); synchronized (pdCache) { Iterator iter = pdCache.values().iterator(); while (iter.hasNext()) { @@ -266,7 +269,7 @@ } } } - } catch (NameException e) { + } catch (NamespaceException e) { log.warn(e.getMessage() + " -> clear definition cache." ); synchronized (pdCache) { pdCache.clear(); @@ -282,7 +285,7 @@ * {@inheritDoc} */ public NodeTypeIterator getAllNodeTypes() throws RepositoryException { - QName[] ntNames = ntReg.getRegisteredNodeTypes(); + Name[] ntNames = ntReg.getRegisteredNodeTypes(); ArrayList list = new ArrayList(ntNames.length); for (int i = 0; i < ntNames.length; i++) { list.add(getNodeType(ntNames[i])); @@ -294,7 +297,7 @@ * {@inheritDoc} */ public NodeTypeIterator getPrimaryNodeTypes() throws RepositoryException { - QName[] ntNames = ntReg.getRegisteredNodeTypes(); + Name[] ntNames = ntReg.getRegisteredNodeTypes(); ArrayList list = new ArrayList(ntNames.length); for (int i = 0; i < ntNames.length; i++) { NodeType nt = getNodeType(ntNames[i]); @@ -309,7 +312,7 @@ * {@inheritDoc} */ public NodeTypeIterator getMixinNodeTypes() throws RepositoryException { - QName[] ntNames = ntReg.getRegisteredNodeTypes(); + Name[] ntNames = ntReg.getRegisteredNodeTypes(); ArrayList list = new ArrayList(ntNames.length); for (int i = 0; i < ntNames.length; i++) { NodeType nt = getNodeType(ntNames[i]); @@ -326,12 +329,12 @@ public NodeType getNodeType(String nodeTypeName) throws NoSuchNodeTypeException { try { - QName qName = NameFormat.parse(nodeTypeName, nsResolver()); + Name qName = resolver().getQName(nodeTypeName); return getNodeType(qName); - } catch (UnknownPrefixException upe) { - throw new NoSuchNodeTypeException(nodeTypeName, upe); - } catch (IllegalNameException ine) { - throw new NoSuchNodeTypeException(nodeTypeName, ine); + } catch (NamespaceException e) { + throw new NoSuchNodeTypeException(nodeTypeName, e); + } catch (NameException e) { + throw new NoSuchNodeTypeException(nodeTypeName, e); } } Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java?rev=586065&r1=586064&r2=586065&view=diff ============================================================================== --- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java (original) +++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistry.java Thu Oct 18 11:41:45 2007 @@ -16,8 +16,9 @@ */ package org.apache.jackrabbit.jcr2spi.nodetype; -import org.apache.jackrabbit.name.QName; +import org.apache.jackrabbit.spi.Name; import org.apache.jackrabbit.spi.QNodeTypeDefinition; +import org.apache.jackrabbit.nodetype.InvalidNodeTypeDefException; import javax.jcr.nodetype.NoSuchNodeTypeException; import javax.jcr.RepositoryException; @@ -37,7 +38,7 @@ * @throws NoSuchNodeTypeException if a node type with the given name * does not exist */ - QNodeTypeDefinition getNodeTypeDefinition(QName nodeTypeName) + QNodeTypeDefinition getNodeTypeDefinition(Name nodeTypeName) throws NoSuchNodeTypeException; /** @@ -59,7 +60,7 @@ * @param ntName * @return */ - boolean isRegistered(QName ntName); + boolean isRegistered(Name ntName); /** * Returns the names of all registered node types. That includes primary @@ -67,7 +68,7 @@ * * @return the names of all registered node types. */ - public QName[] getRegisteredNodeTypes() throws RepositoryException; + public Name[] getRegisteredNodeTypes() throws RepositoryException; /** * Validates the NodeTypeDef and returns @@ -131,22 +132,22 @@ * @throws NoSuchNodeTypeException * @throws RepositoryException */ - public void unregisterNodeType(QName nodeTypeName) + public void unregisterNodeType(Name nodeTypeName) throws NoSuchNodeTypeException, RepositoryException; /** - * Same as {@link #unregisterNodeType(QName)} except + * Same as {@link #unregisterNodeType(Name)} except * that a set of node types is unregistered instead of just one. *

* This method can be used to unregister a set of node types that depend on * each other. * - * @param nodeTypeNames a collection of QName objects denoting the + * @param nodeTypeNames a collection of Name objects denoting the * node types to be unregistered * @throws NoSuchNodeTypeException if any of the specified names does not * denote a registered node type. * @throws RepositoryException if another error occurs - * @see #unregisterNodeType(QName) + * @see #unregisterNodeType(Name) */ public void unregisterNodeTypes(Collection nodeTypeNames) throws NoSuchNodeTypeException, RepositoryException;