jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r586065 [7/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 GMT
Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QItemDefinitionImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QItemDefinitionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QItemDefinitionImpl.java Thu Oct 18 11:41:45 2007
@@ -17,13 +17,14 @@
 package org.apache.jackrabbit.spi2dav;
 
 import org.w3c.dom.Element;
-import org.apache.jackrabbit.name.NamespaceResolver;
-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.name.NameFactoryImpl;
+import org.apache.jackrabbit.name.NameConstants;
 import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.webdav.jcr.nodetype.NodeTypeConstants;
 
 import javax.jcr.version.OnParentVersionAction;
@@ -39,17 +40,17 @@
     /**
      * The special wildcard name used as the name of residual item definitions.
      */
-    public static final QName ANY_NAME = new QName("", "*");
+    public static final Name ANY_NAME = NameFactoryImpl.getInstance().create("", "*");
 
     /**
      * The name of the child item.
      */
-    private final QName name;
+    private final Name name;
 
     /**
      * The name of the declaring node type.
      */
-    private final QName declaringNodeType;
+    private final Name declaringNodeType;
 
     /**
      * The 'autoCreated' flag.
@@ -80,15 +81,15 @@
      *
      * @param declaringNodeType
      * @param itemDefElement
-     * @param nsResolver
+     * @param resolver
      * @throws RepositoryException
      */
-    QItemDefinitionImpl(QName declaringNodeType, Element itemDefElement, NamespaceResolver nsResolver)
+    QItemDefinitionImpl(Name declaringNodeType, Element itemDefElement, NamePathResolver resolver)
         throws RepositoryException {
         try {
             String attr = itemDefElement.getAttribute(DECLARINGNODETYPE_ATTRIBUTE);
             if (attr != null) {
-                QName dnt = NameFormat.parse(attr, nsResolver);
+                Name dnt = resolver.getQName(attr);
                 if (declaringNodeType != null && !declaringNodeType.equals(dnt)) {
                     throw new RepositoryException("Declaring nodetype mismatch: In element = '" + dnt + "', Declaring nodetype = '" + declaringNodeType + "'");
                 }
@@ -100,9 +101,9 @@
             if (itemDefElement.hasAttribute(NAME_ATTRIBUTE)) {
                 String nAttr = itemDefElement.getAttribute(NAME_ATTRIBUTE);
                 if (nAttr.length() > 0) {
-                    name = (isAnyName(nAttr)) ? ANY_NAME : NameFormat.parse(nAttr, nsResolver);
+                    name = (isAnyName(nAttr)) ? ANY_NAME : resolver.getQName(nAttr);
                 } else {
-                    name = QName.ROOT;
+                    name = NameConstants.ROOT;
                 }
             } else {
                 // TODO: check if correct..
@@ -139,14 +140,14 @@
     /**
      * {@inheritDoc}
      */
-    public QName getDeclaringNodeType() {
+    public Name getDeclaringNodeType() {
         return declaringNodeType;
     }
 
     /**
      * {@inheritDoc}
      */
-    public QName getQName() {
+    public Name getName() {
         return name;
     }
 
@@ -205,7 +206,7 @@
             return (declaringNodeType == null
                     ? other.getDeclaringNodeType() == null
                     : declaringNodeType.equals(other.getDeclaringNodeType()))
-                    && (name == null ? other.getQName() == null : name.equals(other.getQName()))
+                    && (name == null ? other.getName() == null : name.equals(other.getName()))
                     && autoCreated == other.isAutoCreated()
                     && onParentVersion == other.getOnParentVersion()
                     && writeProtected == other.isProtected()

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeDefinitionImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeDefinitionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeDefinitionImpl.java Thu Oct 18 11:41:45 2007
@@ -17,11 +17,11 @@
 package org.apache.jackrabbit.spi2dav;
 
 import org.w3c.dom.Element;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NameException;
+import org.apache.jackrabbit.conversion.NameException;
+import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.QNodeDefinition;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.name.NameConstants;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 
@@ -40,12 +40,12 @@
     /**
      * The name of the default primary type.
      */
-    private final QName defaultPrimaryType;
+    private final Name defaultPrimaryType;
 
     /**
      * The names of the required primary types.
      */
-    private final QName[] requiredPrimaryTypes;
+    private final Name[] requiredPrimaryTypes;
 
     /**
      * The 'allowsSameNameSiblings' flag.
@@ -57,18 +57,18 @@
      *
      * @param declaringNodeType
      * @param ndefElement
-     * @param nsResolver
+     * @param resolver
      * @throws RepositoryException
      */
-    QNodeDefinitionImpl(QName declaringNodeType, Element ndefElement, NamespaceResolver nsResolver)
+    QNodeDefinitionImpl(Name declaringNodeType, Element ndefElement, NamePathResolver resolver)
         throws RepositoryException  {
-        super(declaringNodeType, ndefElement, nsResolver);
+        super(declaringNodeType, ndefElement, resolver);
         // TODO: webdav server sends jcr names -> nsResolver required. improve this.
         // NOTE: the server should send the namespace-mappings as addition ns-defininitions
         try {
 
             if (ndefElement.hasAttribute(DEFAULTPRIMARYTYPE_ATTRIBUTE)) {
-                defaultPrimaryType = NameFormat.parse(ndefElement.getAttribute(DEFAULTPRIMARYTYPE_ATTRIBUTE), nsResolver);
+                defaultPrimaryType = resolver.getQName(ndefElement.getAttribute(DEFAULTPRIMARYTYPE_ATTRIBUTE));
             } else {
                 defaultPrimaryType = null;
             }
@@ -78,11 +78,11 @@
                 List qNames = new ArrayList();
                 ElementIterator it = DomUtil.getChildren(reqPrimaryTypes, REQUIREDPRIMARYTYPE_ELEMENT, null);
                 while (it.hasNext()) {
-                    qNames.add(NameFormat.parse(DomUtil.getTextTrim(it.nextElement()), nsResolver));
+                    qNames.add(resolver.getQName(DomUtil.getTextTrim(it.nextElement())));
                 }
-                requiredPrimaryTypes = (QName[]) qNames.toArray(new QName[qNames.size()]);
+                requiredPrimaryTypes = (Name[]) qNames.toArray(new Name[qNames.size()]);
             } else {
-                requiredPrimaryTypes = new QName[] { QName.NT_BASE };
+                requiredPrimaryTypes = new Name[] { NameConstants.NT_BASE };
             }
 
             if (ndefElement.hasAttribute(SAMENAMESIBLINGS_ATTRIBUTE)) {
@@ -99,14 +99,14 @@
     /**
      * {@inheritDoc}
      */
-    public QName getDefaultPrimaryType() {
+    public Name getDefaultPrimaryType() {
         return defaultPrimaryType;
     }
 
     /**
      * {@inheritDoc}
      */
-    public QName[] getRequiredPrimaryTypes() {
+    public Name[] getRequiredPrimaryTypes() {
         return requiredPrimaryTypes;
     }
 
@@ -170,12 +170,12 @@
             if (definesResidual()) {
                 sb.append('*');
             } else {
-                sb.append(getQName().toString());
+                sb.append(getName().toString());
             }
             sb.append('/');
             // set of required node type names, sorted in ascending order
             TreeSet set = new TreeSet();
-            QName[] names = getRequiredPrimaryTypes();
+            Name[] names = getRequiredPrimaryTypes();
             for (int i = 0; i < names.length; i++) {
                 set.add(names[i]);
             }

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeTypeDefinitionImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeTypeDefinitionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeTypeDefinitionImpl.java Thu Oct 18 11:41:45 2007
@@ -20,14 +20,15 @@
 import org.apache.jackrabbit.webdav.jcr.nodetype.NodeTypeConstants;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NameException;
+import org.apache.jackrabbit.conversion.NameException;
+import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.Name;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -47,11 +48,11 @@
 
     private static Logger log = LoggerFactory.getLogger(QNodeTypeDefinitionImpl.class);
 
-    private final QName name;
-    private final QName[] supertypes;
+    private final Name name;
+    private final Name[] supertypes;
     private final boolean mixin;
     private final boolean orderableChildNodes;
-    private final QName primaryItemName;
+    private final Name primaryItemName;
     private final QPropertyDefinition[] propDefs;
     private final QNodeDefinition[] nodeDefs;
     private Set dependencies;
@@ -59,20 +60,20 @@
     /**
      * Default constructor.
      */
-    public QNodeTypeDefinitionImpl(Element ntdElement, NamespaceResolver nsResolver,
+    public QNodeTypeDefinitionImpl(Element ntdElement, NamePathResolver resolver,
                                    QValueFactory qValueFactory)
         throws RepositoryException {
         // TODO: webdav-server currently sends jcr-names -> conversion needed
         // NOTE: the server should send the namespace-mappings as addition ns-defininitions
         try {
         if (ntdElement.hasAttribute(NAME_ATTRIBUTE)) {
-            name = NameFormat.parse(ntdElement.getAttribute(NAME_ATTRIBUTE), nsResolver);
+            name = resolver.getQName(ntdElement.getAttribute(NAME_ATTRIBUTE));
         } else {
             name = null;
         }
 
         if (ntdElement.hasAttribute(PRIMARYITEMNAME_ATTRIBUTE)) {
-            primaryItemName = NameFormat.parse(ntdElement.getAttribute(PRIMARYITEMNAME_ATTRIBUTE), nsResolver);
+            primaryItemName = resolver.getQName(ntdElement.getAttribute(PRIMARYITEMNAME_ATTRIBUTE));
         } else {
             primaryItemName = null;
         }
@@ -82,12 +83,12 @@
             ElementIterator stIter = DomUtil.getChildren(child, SUPERTYPE_ELEMENT, null);
             List qNames = new ArrayList();
             while (stIter.hasNext()) {
-                QName st = NameFormat.parse(DomUtil.getTextTrim(stIter.nextElement()), nsResolver);
+                Name st = resolver.getQName(DomUtil.getTextTrim(stIter.nextElement()));
                 qNames.add(st);
             }
-            supertypes = (QName[]) qNames.toArray(new QName[qNames.size()]);
+            supertypes = (Name[]) qNames.toArray(new Name[qNames.size()]);
         } else {
-            supertypes = QName.EMPTY_ARRAY;
+            supertypes = Name.EMPTY_ARRAY;
         }
         if (ntdElement.hasAttribute(ISMIXIN_ATTRIBUTE)) {
             mixin = Boolean.valueOf(ntdElement.getAttribute(ISMIXIN_ATTRIBUTE)).booleanValue();
@@ -104,7 +105,7 @@
         ElementIterator it = DomUtil.getChildren(ntdElement, CHILDNODEDEFINITION_ELEMENT, null);
         List itemDefs = new ArrayList();
         while (it.hasNext()) {
-            itemDefs.add(new QNodeDefinitionImpl(name, it.nextElement(), nsResolver));
+            itemDefs.add(new QNodeDefinitionImpl(name, it.nextElement(), resolver));
         }
         nodeDefs = (QNodeDefinition[]) itemDefs.toArray(new QNodeDefinition[itemDefs.size()]);
 
@@ -113,7 +114,7 @@
         it = DomUtil.getChildren(ntdElement, PROPERTYDEFINITION_ELEMENT, null);
         itemDefs = new ArrayList();
         while (it.hasNext()) {
-            itemDefs.add(new QPropertyDefinitionImpl(name, it.nextElement(), nsResolver, qValueFactory));
+            itemDefs.add(new QPropertyDefinitionImpl(name, it.nextElement(), resolver, qValueFactory));
         }
         propDefs = (QPropertyDefinition[]) itemDefs.toArray(new QPropertyDefinition[itemDefs.size()]);
         } catch (NameException e) {
@@ -124,21 +125,21 @@
 
     //------------------------------------------------< QNodeTypeDefinition >---
     /**
-     * @see QNodeTypeDefinition#getQName() 
+     * @see QNodeTypeDefinition#getName()
      */
-    public QName getQName() {
+    public Name getName() {
         return name;
     }
 
     /**
      * @see QNodeTypeDefinition#getSupertypes()
      */
-    public QName[] getSupertypes() {
+    public Name[] getSupertypes() {
         if (supertypes.length > 0
-                || isMixin() || QName.NT_BASE.equals(getQName())) {
+                || isMixin() || NameConstants.NT_BASE.equals(getName())) {
             return supertypes;
         } else {
-            return new QName[] { QName.NT_BASE };
+            return new Name[] { NameConstants.NT_BASE };
         }
     }
 
@@ -159,7 +160,7 @@
     /**
      * @see QNodeTypeDefinition#getPrimaryItemName()
      */
-    public QName getPrimaryItemName() {
+    public Name getPrimaryItemName() {
         return primaryItemName;
     }
 
@@ -190,12 +191,12 @@
             // child node definitions
             for (int i = 0; i < nodeDefs.length; i++) {
                 // default primary type
-                QName ntName = nodeDefs[i].getDefaultPrimaryType();
+                Name ntName = nodeDefs[i].getDefaultPrimaryType();
                 if (ntName != null && !name.equals(ntName)) {
                     dependencies.add(ntName);
                 }
                 // required primary type
-                QName[] ntNames = nodeDefs[i].getRequiredPrimaryTypes();
+                Name[] ntNames = nodeDefs[i].getRequiredPrimaryTypes();
                 for (int j = 0; j < ntNames.length; j++) {
                     if (ntNames[j] != null && !name.equals(ntNames[j])) {
                         dependencies.add(ntNames[j]);
@@ -209,7 +210,8 @@
                     String[] ca = propDefs[i].getValueConstraints();
                     if (ca != null) {
                         for (int j = 0; j < ca.length; j++) {
-                            QName ntName = QName.valueOf(ca[j]);
+                            // TODO: don't rely on a specific factory
+                            Name ntName = NameFactoryImpl.getInstance().create(ca[j]);
                             if (!name.equals(ntName)) {
                                 dependencies.add(ntName);
                             }
@@ -231,7 +233,7 @@
         }
         if (obj instanceof QNodeTypeDefinition) {
             QNodeTypeDefinition other = (QNodeTypeDefinition) obj;
-            return (name == null ? other.getQName() == null : name.equals(other.getQName()))
+            return (name == null ? other.getName() == null : name.equals(other.getName()))
                 && (primaryItemName == null ? other.getPrimaryItemName() == null : primaryItemName.equals(other.getPrimaryItemName()))
                 && Arrays.equals(supertypes, other.getSupertypes())
                 && mixin == other.isMixin()

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java Thu Oct 18 11:41:45 2007
@@ -17,15 +17,15 @@
 package org.apache.jackrabbit.spi2dav;
 
 import org.w3c.dom.Element;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.apache.jackrabbit.value.ValueFormat;
 import org.apache.jackrabbit.value.ValueFactoryImplEx;
+import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -70,12 +70,12 @@
     /**
      * Default constructor.
      */
-    QPropertyDefinitionImpl(QName declaringNodeType, Element pdefElement,
-                            NamespaceResolver nsResolver, QValueFactory qValueFactory)
+    QPropertyDefinitionImpl(Name declaringNodeType, Element pdefElement,
+                            NamePathResolver resolver, QValueFactory qValueFactory)
         throws RepositoryException {
         // TODO: webdav server sends jcr names -> nsResolver required. improve this.
         // NOTE: the server should send the namespace-mappings as addition ns-defininitions
-        super(declaringNodeType, pdefElement, nsResolver);
+        super(declaringNodeType, pdefElement, resolver);
 
         if (pdefElement.hasAttribute(REQUIREDTYPE_ATTRIBUTE)) {
             requiredType = PropertyType.valueFromName(pdefElement.getAttribute(REQUIREDTYPE_ATTRIBUTE));
@@ -102,9 +102,9 @@
                 if (requiredType == PropertyType.BINARY) {
                     // TODO: improve
                     Value v = ValueFactoryImplEx.getInstance().createValue(jcrVal, requiredType);
-                    qValue = ValueFormat.getQValue(v, nsResolver, qValueFactory);
+                    qValue = ValueFormat.getQValue(v, resolver, qValueFactory);
                 } else {
-                    qValue = ValueFormat.getQValue(jcrVal, requiredType, nsResolver, qValueFactory);
+                    qValue = ValueFormat.getQValue(jcrVal, requiredType, resolver, qValueFactory);
                 }
                 vs.add(qValue);
             }
@@ -123,7 +123,7 @@
                 // in case of name and path constraint, the value must be
                 // converted to be in qualified format
                 if (constType == PropertyType.NAME || constType == PropertyType.PATH) {
-                   qValue = ValueFormat.getQValue(qValue, constType, nsResolver, qValueFactory).getString();
+                   qValue = ValueFormat.getQValue(qValue, constType, resolver, qValueFactory).getString();
                 }
                 vc.add(qValue);
             }
@@ -210,7 +210,7 @@
             if (definesResidual()) {
                 sb.append('*');
             } else {
-                sb.append(getQName().toString());
+                sb.append(getName().toString());
             }
             sb.append('/');
             sb.append(getRequiredType());

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryInfoImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryInfoImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryInfoImpl.java Thu Oct 18 11:41:45 2007
@@ -25,16 +25,14 @@
 import javax.jcr.Value;
 import javax.jcr.RangeIterator;
 
-import org.apache.jackrabbit.name.NameException;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.name.NameConstants;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.QueryInfo;
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.QueryResultRow;
 import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.MultiStatus;
@@ -43,6 +41,8 @@
 import org.apache.jackrabbit.webdav.property.DavProperty;
 import org.apache.jackrabbit.webdav.property.DavPropertySet;
 import org.apache.jackrabbit.value.ValueFormat;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.conversion.NameException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,24 +58,24 @@
 
     private static final double UNDEFINED_SCORE = -1;
 
-    private final QName[] columnNames;
+    private final Name[] columnNames;
     private int scoreIndex = -1;
     private final Map results = new LinkedHashMap();
 
     public QueryInfoImpl(MultiStatus ms, SessionInfo sessionInfo, URIResolver uriResolver,
-                         NamespaceResolver nsResolver, ValueFactory valueFactory,
+                         NamePathResolver resolver, ValueFactory valueFactory,
                          QValueFactory qValueFactory)
         throws RepositoryException {
 
         String responseDescription = ms.getResponseDescription();
         if (responseDescription != null) {
             String[] cn = responseDescription.split(" ");
-            this.columnNames = new QName[cn.length];
+            this.columnNames = new Name[cn.length];
             for (int i = 0; i < cn.length; i++) {
                 String jcrColumnNames = ISO9075.decode(cn[i]);
                 try {
-                    columnNames[i] = NameFormat.parse(jcrColumnNames, nsResolver);
-                    if (QName.JCR_SCORE.equals(columnNames[i])) {
+                    columnNames[i] = resolver.getQName(jcrColumnNames);
+                    if (NameConstants.JCR_SCORE.equals(columnNames[i])) {
                         scoreIndex = i;
                     }
                 } catch (NameException e) {
@@ -98,7 +98,7 @@
             QValue[] qValues = new QValue[values.length];
             for (int j = 0; j < values.length; j++) {
                 try {
-                    qValues[j] = (values[j] == null) ?  null : ValueFormat.getQValue(values[j], nsResolver, qValueFactory);
+                    qValues[j] = (values[j] == null) ?  null : ValueFormat.getQValue(values[j], resolver, qValueFactory);
                 } catch (RepositoryException e) {
                     // should not occur
                     log.error("Malformed value: " + values[j].toString());
@@ -120,7 +120,7 @@
     /**
      * @see QueryInfo#getColumnNames()
      */
-    public QName[] getColumnNames() {
+    public Name[] getColumnNames() {
         return columnNames;
     }
 

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java Thu Oct 18 11:41:45 2007
@@ -99,16 +99,17 @@
 import org.apache.jackrabbit.webdav.jcr.property.NamespacesProperty;
 import org.apache.jackrabbit.webdav.jcr.observation.SubscriptionImpl;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.NameException;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.UnknownPrefixException;
-import org.apache.jackrabbit.name.AbstractNamespaceResolver;
-import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.namespace.NamespaceResolver;
+import org.apache.jackrabbit.namespace.AbstractNamespaceResolver;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.conversion.NameException;
+import org.apache.jackrabbit.conversion.ParsingNameResolver;
+import org.apache.jackrabbit.conversion.NameResolver;
+import org.apache.jackrabbit.conversion.PathResolver;
+import org.apache.jackrabbit.conversion.ParsingPathResolver;
+import org.apache.jackrabbit.conversion.IllegalNameException;
+import org.apache.jackrabbit.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.Batch;
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.SessionInfo;
@@ -130,6 +131,10 @@
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.EventFilterImpl;
 import org.apache.jackrabbit.spi.commons.EventBundleImpl;
 import org.apache.jackrabbit.spi.commons.ChildInfoImpl;
@@ -198,6 +203,8 @@
     private static final SubscriptionInfo S_INFO = new SubscriptionInfo(ALL_EVENTS, true, DavConstants.INFINITE_TIMEOUT);
 
     private final IdFactory idFactory;
+    private final NameFactory nameFactory;
+    private final PathFactory pathFactory;
     private final ValueFactory valueFactory;
 
     private final Document domFactory;
@@ -212,7 +219,10 @@
 
     private Map descriptors;
 
-    public RepositoryServiceImpl(String uri, IdFactory idFactory, ValueFactory valueFactory) throws RepositoryException {
+    public RepositoryServiceImpl(String uri, IdFactory idFactory,
+                                 NameFactory nameFactory,
+                                 PathFactory pathFactory,
+                                 ValueFactory valueFactory) throws RepositoryException {
         if (uri == null || "".equals(uri)) {
             throw new RepositoryException("Invalid repository uri '" + uri + "'.");
         }
@@ -220,6 +230,8 @@
             throw new RepositoryException("IdFactory and ValueFactory may not be null.");
         }
         this.idFactory = idFactory;
+        this.nameFactory = nameFactory;
+        this.pathFactory = pathFactory;
         this.valueFactory = valueFactory;
 
         try {
@@ -234,7 +246,7 @@
             hostConfig.setHost(repositoryUri);
 
             nsCache = new NamespaceCache();
-            uriResolver = new URIResolverImpl(repositoryUri, this, nsCache, domFactory);
+            uriResolver = new URIResolverImpl(repositoryUri, this, new NamePathResolverImpl(nsCache), domFactory);
 
         } catch (URIException e) {
             throw new RepositoryException(e);
@@ -314,14 +326,10 @@
         return uriResolver.getItemUri(itemId, sessionInfo.getWorkspaceName(), sessionInfo);
     }
 
-    private String getItemUri(NodeId parentId, QName childName, SessionInfo sessionInfo) throws RepositoryException {
+    private String getItemUri(NodeId parentId, Name childName, SessionInfo sessionInfo) throws RepositoryException {
         String parentUri = uriResolver.getItemUri(parentId, sessionInfo.getWorkspaceName(), sessionInfo);
-        try {
-            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
-            return parentUri + "/" + Text.escape(NameFormat.format(childName, resolver));
-        } catch (NoPrefixDeclaredException e) {
-            throw new RepositoryException(e);
-        }
+        NamePathResolver resolver = new NamePathResolverImpl(sessionInfo);
+        return parentUri + "/" + Text.escape(resolver.getJCRName(childName));
     }
 
     private NodeId getParentId(DavPropertySet propSet, SessionInfo sessionInfo)
@@ -345,19 +353,19 @@
         }
     }
 
-    QName getQName(DavPropertySet propSet, NamespaceResolver nsResolver) throws RepositoryException {
+    Name getQName(DavPropertySet propSet, NamePathResolver resolver) throws RepositoryException {
         DavProperty nameProp = propSet.get(ItemResourceConstants.JCR_NAME);
         if (nameProp != null && nameProp.getValue() != null) {
             // not root node. Note that 'unespacing' is not required since
             // the jcr:name property does not provide the value in escaped form.
             String jcrName = nameProp.getValue().toString();
             try {
-                return NameFormat.parse(jcrName, nsResolver);
-            } catch (NameException e) {
+                return resolver.getQName(jcrName);
+            } catch (org.apache.jackrabbit.conversion.NameException e) {
                 throw new RepositoryException(e);
             }
         } else {
-            return QName.ROOT;
+            return NameConstants.ROOT;
         }
     }
 
@@ -404,6 +412,20 @@
         return idFactory;
     }
 
+    /**
+     * @see RepositoryService#getNameFactory()
+     */
+    public NameFactory getNameFactory() {
+        return nameFactory;
+    }
+
+    /**
+     * @see RepositoryService#getPathFactory()
+     */
+    public PathFactory getPathFactory() {
+        return pathFactory;
+    }
+
     public QValueFactory getQValueFactory() {
         return QValueFactoryImpl.getInstance();
     }
@@ -657,7 +679,7 @@
                 throw new RepositoryException("Internal error: requested node definition and got property definition.");
             }
 
-            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
+            NamePathResolver resolver = new NamePathResolverImpl(sessionInfo);
 
             // build the definition
             QItemDefinition definition = null;
@@ -761,7 +783,7 @@
                 throw new ItemNotFoundException("No node for id " + nodeId);
             }
 
-            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
+            NamePathResolver resolver = new NamePathResolverImpl(sessionInfo);
             NodeId parentId = getParentId(propSet, sessionInfo);
 
             NodeInfoImpl nInfo = buildNodeInfo(nodeResponse, parentId, propSet, sessionInfo, resolver);
@@ -783,7 +805,7 @@
             throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
-        } catch (MalformedPathException e) {
+        } catch (NameException e) {
             throw new RepositoryException(e);
         } finally {
             if (method != null) {
@@ -807,7 +829,7 @@
     private NodeInfoImpl buildNodeInfo(MultiStatusResponse nodeResponse,
                                        NodeId parentId, DavPropertySet propSet,
                                        SessionInfo sessionInfo,
-                                       NamespaceResolver resolver) throws MalformedPathException, RepositoryException {
+                                       NamePathResolver resolver) throws NameException, RepositoryException {
         NodeId id = uriResolver.buildNodeId(parentId, nodeResponse, sessionInfo.getWorkspaceName());
         NodeInfoImpl nInfo = new NodeInfoImpl(id, parentId, propSet, resolver);
         if (propSet.contains(ItemResourceConstants.JCR_REFERENCES)) {
@@ -853,7 +875,7 @@
                 return Collections.EMPTY_LIST.iterator();
             }
 
-            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
+            NamePathResolver resolver = new NamePathResolverImpl(sessionInfo);
 
             List childEntries = new ArrayList();
             for (int i = 0; i < responses.length; i++) {
@@ -863,7 +885,7 @@
                     if (childProps.contains(DavPropertyName.RESOURCETYPE) &&
                         childProps.get(DavPropertyName.RESOURCETYPE).getValue() != null) {
 
-                        QName qName = getQName(childProps, resolver);
+                        Name qName = getQName(childProps, resolver);
                         int index = getIndex(childProps);
                         String uuid = getUniqueID(childProps);
 
@@ -914,7 +936,7 @@
             NodeId parentId = getParentId(propSet, sessionInfo);
             PropertyId id = uriResolver.buildPropertyId(parentId, responses[0], sessionInfo.getWorkspaceName());
 
-            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
+            NamePathResolver resolver = new NamePathResolverImpl(sessionInfo);
             PropertyInfo pInfo = new PropertyInfoImpl(id, parentId, propSet,
                     resolver, valueFactory, getQValueFactory());
             return pInfo;
@@ -922,7 +944,7 @@
             throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
-        } catch (MalformedPathException e) {
+        } catch (NameException e) {
             throw new RepositoryException(e);
         } finally {
             if (method != null) {
@@ -988,7 +1010,7 @@
      */
     public void importXml(SessionInfo sessionInfo, NodeId parentId, InputStream xmlStream, int uuidBehaviour) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
         // TODO: improve. currently random name is built instead of retrieving name of new resource from top-level xml element within stream
-        QName nodeName = new QName(QName.NS_DEFAULT_URI, UUID.randomUUID().toString());
+        Name nodeName = getNameFactory().create(Name.NS_DEFAULT_URI, UUID.randomUUID().toString());
         String uri = getItemUri(parentId, nodeName, sessionInfo);
         MkColMethod method = new MkColMethod(uri);
         method.addRequestHeader(ItemResourceConstants.IMPORT_UUID_BEHAVIOR, new Integer(uuidBehaviour).toString());
@@ -997,9 +1019,9 @@
     }
 
     /**
-     * @see RepositoryService#move(SessionInfo, NodeId, NodeId, QName)
+     * @see RepositoryService#move(SessionInfo, NodeId, NodeId, Name)
      */
-    public void move(SessionInfo sessionInfo, NodeId srcNodeId, NodeId destParentNodeId, QName destName) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+    public void move(SessionInfo sessionInfo, NodeId srcNodeId, NodeId destParentNodeId, Name destName) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
         String uri = getItemUri(srcNodeId, sessionInfo);
         String destUri = getItemUri(destParentNodeId, destName, sessionInfo);
         MoveMethod method = new MoveMethod(uri, destUri, true);
@@ -1007,9 +1029,9 @@
     }
 
     /**
-     * @see RepositoryService#copy(SessionInfo, String, NodeId, NodeId, QName)
+     * @see RepositoryService#copy(SessionInfo, String, NodeId, NodeId, Name)
      */
-    public void copy(SessionInfo sessionInfo, String srcWorkspaceName, NodeId srcNodeId, NodeId destParentNodeId, QName destName) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
+    public void copy(SessionInfo sessionInfo, String srcWorkspaceName, NodeId srcNodeId, NodeId destParentNodeId, Name destName) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
         String uri = uriResolver.getItemUri(srcNodeId, srcWorkspaceName, sessionInfo);
         String destUri = getItemUri(destParentNodeId, destName, sessionInfo);
         CopyMethod method = new CopyMethod(uri, destUri, true, false);
@@ -1027,9 +1049,9 @@
     }
 
     /**
-     * @see RepositoryService#clone(SessionInfo, String, NodeId, NodeId, QName, boolean)
+     * @see RepositoryService#clone(SessionInfo, String, NodeId, NodeId, Name, boolean)
      */
-    public void clone(SessionInfo sessionInfo, String srcWorkspaceName, NodeId srcNodeId, NodeId destParentNodeId, QName destName, boolean removeExisting) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
+    public void clone(SessionInfo sessionInfo, String srcWorkspaceName, NodeId srcNodeId, NodeId destParentNodeId, Name destName, boolean removeExisting) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
         // TODO: missing implementation
         throw new UnsupportedOperationException("Missing implementation");
     }
@@ -1290,34 +1312,30 @@
     }
 
     /**
-     * @see RepositoryService#addVersionLabel(SessionInfo,NodeId,NodeId,QName,boolean)
+     * @see RepositoryService#addVersionLabel(SessionInfo,NodeId,NodeId,Name,boolean)
      */
-    public void addVersionLabel(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId, QName label, boolean moveLabel) throws VersionException, RepositoryException {
+    public void addVersionLabel(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId, Name label, boolean moveLabel) throws VersionException, RepositoryException {
         try {
             String uri = getItemUri(versionId, sessionInfo);
-            String strLabel = NameFormat.format(label, new NamespaceResolverImpl(sessionInfo));
+            String strLabel = new NamePathResolverImpl(sessionInfo).getJCRName(label);
             LabelMethod method = new LabelMethod(uri, strLabel, (moveLabel) ? LabelInfo.TYPE_SET : LabelInfo.TYPE_ADD);
             execute(method, sessionInfo);
         } catch (IOException e) {
             throw new RepositoryException(e);
-        } catch (NoPrefixDeclaredException e) {
-            throw new RepositoryException(e);
         }
     }
 
     /**
-     * @see RepositoryService#removeVersionLabel(SessionInfo,NodeId,NodeId,QName)
+     * @see RepositoryService#removeVersionLabel(SessionInfo,NodeId,NodeId,Name)
      */
-    public void removeVersionLabel(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId, QName label) throws VersionException, RepositoryException {
+    public void removeVersionLabel(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId, Name label) throws VersionException, RepositoryException {
         try {
             String uri = getItemUri(versionId, sessionInfo);
-            String strLabel = NameFormat.format(label, new NamespaceResolverImpl(sessionInfo));
+            String strLabel = new NamePathResolverImpl(sessionInfo).getJCRName(label);
             LabelMethod method = new LabelMethod(uri, strLabel, LabelInfo.TYPE_REMOVE);
             execute(method, sessionInfo);
         } catch (IOException e) {
             throw new RepositoryException(e);
-        } catch (NoPrefixDeclaredException e) {
-            throw new RepositoryException(e);
         }
     }
 
@@ -1364,9 +1382,8 @@
             method.checkSuccess();
 
             MultiStatus ms = method.getResponseBodyAsMultiStatus();
-            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
-            return new QueryInfoImpl(ms, sessionInfo, uriResolver,
-                resolver, valueFactory, getQValueFactory());
+            NamePathResolver resolver = new NamePathResolverImpl(sessionInfo);
+            return new QueryInfoImpl(ms, sessionInfo, uriResolver, resolver, valueFactory, getQValueFactory());
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {
@@ -1379,14 +1396,14 @@
     }
 
     /**
-     * @see RepositoryService#createEventFilter(SessionInfo, int, org.apache.jackrabbit.name.Path, boolean, String[], org.apache.jackrabbit.name.QName[], boolean)
+     * @see RepositoryService#createEventFilter(SessionInfo, int, Path, boolean, String[], Name[], boolean)
      */
     public EventFilter createEventFilter(SessionInfo sessionInfo,
                                          int eventTypes,
                                          Path absPath,
                                          boolean isDeep,
                                          String[] uuids,
-                                         QName[] nodeTypeNames,
+                                         Name[] nodeTypeNames,
                                          boolean noLocal)
             throws UnsupportedRepositoryOperationException, RepositoryException {
         // resolve node type names
@@ -1469,13 +1486,13 @@
         }
     }
 
-    private void resolveNodeType(Set resolved, QName ntName) {
+    private void resolveNodeType(Set resolved, Name ntName) {
         if (!resolved.add(ntName)) {
             return;
         }
         QNodeTypeDefinition def = (QNodeTypeDefinition) nodeTypeDefinitions.get(ntName);
         if (def != null) {
-            QName[] supertypes = def.getSupertypes();
+            Name[] supertypes = def.getSupertypes();
             for (int i = 0; i < supertypes.length; i++) {
                 resolveNodeType(resolved, supertypes[i]);
             }
@@ -1753,15 +1770,15 @@
     /**
      * {@inheritDoc}
      */
-    public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, QName[] nodetypeNames) throws RepositoryException {
+    public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, Name[] nodetypeNames) throws RepositoryException {
         ReportMethod method = null;
         try {
-            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
+            NamePathResolver resolver = new NamePathResolverImpl(sessionInfo);
 
             ReportInfo info = new ReportInfo(NodeTypesReport.NODETYPES_REPORT, DEPTH_0);
             for (int i = 0; i < nodetypeNames.length; i++) {
                 Element el = DomUtil.createElement(domFactory, NodeTypeConstants.XML_NODETYPE, NodeTypeConstants.NAMESPACE);
-                String jcrName = NameFormat.format(nodetypeNames[i], resolver);
+                String jcrName = resolver.getJCRName(nodetypeNames[i]);
                 DomUtil.addChildElement(el, NodeTypeConstants.XML_NODETYPENAME, NodeTypeConstants.NAMESPACE, jcrName);
                 info.setContentElement(el);
             }
@@ -1777,8 +1794,6 @@
             throw new RepositoryException(e);
         } catch (DavException e) {
             throw ExceptionConverter.generate(e);
-        } catch (NoPrefixDeclaredException e) {
-            throw new RepositoryException(e);
         } finally {
             if (method != null) {
                 method.releaseConnection();
@@ -1796,7 +1811,7 @@
     private Iterator retrieveQNodeTypeDefinitions(SessionInfo sessionInfo, Document reportDoc) throws RepositoryException {
         ElementIterator it = DomUtil.getChildren(reportDoc.getDocumentElement(), NodeTypeConstants.NODETYPE_ELEMENT, null);
             List ntDefs = new ArrayList();
-            NamespaceResolver resolver = new NamespaceResolverImpl(sessionInfo);
+            NamePathResolver resolver = new NamePathResolverImpl(sessionInfo);
             while (it.hasNext()) {
                 ntDefs.add(new QNodeTypeDefinitionImpl(it.nextElement(), resolver, getQValueFactory()));
             }
@@ -1805,7 +1820,7 @@
                 nodeTypeDefinitions.clear();
                 for (Iterator defIt = ntDefs.iterator(); defIt.hasNext(); ) {
                     QNodeTypeDefinition def = (QNodeTypeDefinition) defIt.next();
-                    nodeTypeDefinitions.put(def.getQName(), def);
+                    nodeTypeDefinitions.put(def.getName(), def);
                 }
             }
             return ntDefs.iterator();
@@ -1814,7 +1829,7 @@
     /**
      * The XML elements and attributes used in serialization
      */
-    private static final Namespace SV_NAMESPACE = Namespace.getNamespace(QName.NS_SV_PREFIX, QName.NS_SV_URI);
+    private static final Namespace SV_NAMESPACE = Namespace.getNamespace(Name.NS_SV_PREFIX, Name.NS_SV_URI);
     private static final String NODE_ELEMENT = "node";
     private static final String PROPERTY_ELEMENT = "property";
     private static final String VALUE_ELEMENT = "value";
@@ -1827,7 +1842,7 @@
         private final SessionInfo sessionInfo;
         private final ItemId targetId;
         private final List methods = new ArrayList();
-        private final NamespaceResolver nsResolver;
+        private final NamePathResolver resolver;
 
         private String batchId;
 
@@ -1836,7 +1851,7 @@
         private BatchImpl(ItemId targetId, SessionInfo sessionInfo) {
             this.targetId = targetId;
             this.sessionInfo = sessionInfo;
-            this.nsResolver = new NamespaceResolverImpl(sessionInfo);
+            this.resolver = new NamePathResolverImpl(sessionInfo);
         }
 
         private HttpClient start() throws RepositoryException {
@@ -1916,32 +1931,35 @@
 
         //----------------------------------------------------------< Batch >---
         /**
-         * @see Batch#addNode(NodeId, QName, QName, String)
+         * @see Batch#addNode(NodeId, Name, Name, String)
          */
-        public void addNode(NodeId parentId, QName nodeName, QName nodetypeName, String uuid) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, NoSuchNodeTypeException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+        public void addNode(NodeId parentId, Name nodeName, Name nodetypeName, String uuid) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, NoSuchNodeTypeException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
             checkConsumed();
             try {
                 // TODO: TOBEFIXED. WebDAV does not allow MKCOL for existing resource -> problem with SNS
                 // use fake name instead (see also #importXML)
-                QName fakeName = new QName(QName.NS_DEFAULT_URI, UUID.randomUUID().toString());
+                Name fakeName = getNameFactory().create(Name.NS_DEFAULT_URI, UUID.randomUUID().toString());
                 String uri = getItemUri(parentId, fakeName, sessionInfo);
                 MkColMethod method = new MkColMethod(uri);
 
                 // build 'sys-view' for the node to create and append it as request body
                 Document body = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
                 Element nodeElement = DomUtil.addChildElement(body, NODE_ELEMENT, SV_NAMESPACE);
-                String nameAttr = NameFormat.format(nodeName, nsResolver);
+                String nameAttr = resolver.getJCRName(nodeName);
                 DomUtil.setAttribute(nodeElement, NAME_ATTRIBUTE, SV_NAMESPACE, nameAttr);
 
                 // nodetype must never be null
                 Element propElement = DomUtil.addChildElement(nodeElement, PROPERTY_ELEMENT, SV_NAMESPACE);
-                DomUtil.setAttribute(propElement, NAME_ATTRIBUTE, SV_NAMESPACE, NameFormat.format(QName.JCR_PRIMARYTYPE, nsResolver));
+                String name = resolver.getJCRName(NameConstants.JCR_PRIMARYTYPE);
+                DomUtil.setAttribute(propElement, NAME_ATTRIBUTE, SV_NAMESPACE, name);
                 DomUtil.setAttribute(propElement, TYPE_ATTRIBUTE, SV_NAMESPACE, PropertyType.nameFromValue(PropertyType.NAME));
-                DomUtil.addChildElement(propElement, VALUE_ELEMENT, SV_NAMESPACE, NameFormat.format(nodetypeName, nsResolver));
+                name = resolver.getJCRName(nodetypeName);
+                DomUtil.addChildElement(propElement, VALUE_ELEMENT, SV_NAMESPACE, name);
                 // optional uuid
                 if (uuid != null) {
                     propElement = DomUtil.addChildElement(nodeElement, PROPERTY_ELEMENT, SV_NAMESPACE);
-                    DomUtil.setAttribute(propElement, NAME_ATTRIBUTE, SV_NAMESPACE, NameFormat.format(QName.JCR_UUID, nsResolver));
+                    name = resolver.getJCRName(NameConstants.JCR_UUID);
+                    DomUtil.setAttribute(propElement, NAME_ATTRIBUTE, SV_NAMESPACE, name);
                     DomUtil.setAttribute(propElement, TYPE_ATTRIBUTE, SV_NAMESPACE, PropertyType.nameFromValue(PropertyType.STRING));
                     DomUtil.addChildElement(propElement, VALUE_ELEMENT, SV_NAMESPACE, uuid);
                 }
@@ -1952,35 +1970,33 @@
                 throw new RepositoryException(e);
             } catch (ParserConfigurationException e) {
                 throw new RepositoryException(e);
-            } catch (NoPrefixDeclaredException e) {
-                throw new RepositoryException(e);
             }
         }
 
         /**
-         * @see Batch#addProperty(NodeId, QName, QValue)
+         * @see Batch#addProperty(NodeId, Name, QValue)
          */
-        public void addProperty(NodeId parentId, QName propertyName, QValue value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+        public void addProperty(NodeId parentId, Name propertyName, QValue value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
             checkConsumed();
-            Value jcrValue = ValueFormat.getJCRValue(value, nsResolver, valueFactory);
+            Value jcrValue = ValueFormat.getJCRValue(value, resolver, valueFactory);
             ValuesProperty vp = new ValuesProperty(jcrValue);
             internalAddProperty(parentId, propertyName, vp);
         }
 
         /**
-         * @see Batch#addProperty(NodeId, QName, QValue[])
+         * @see Batch#addProperty(NodeId, Name, QValue[])
          */
-        public void addProperty(NodeId parentId, QName propertyName, QValue[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+        public void addProperty(NodeId parentId, Name propertyName, QValue[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
             checkConsumed();
             Value[] jcrValues = new Value[values.length];
             for (int i = 0; i < values.length; i++) {
-                jcrValues[i] = ValueFormat.getJCRValue(values[i], nsResolver, valueFactory);
+                jcrValues[i] = ValueFormat.getJCRValue(values[i], resolver, valueFactory);
             }
             ValuesProperty vp = new ValuesProperty(jcrValues);
             internalAddProperty(parentId, propertyName, vp);
         }
 
-        private void internalAddProperty(NodeId parentId, QName propertyName, ValuesProperty vp) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+        private void internalAddProperty(NodeId parentId, Name propertyName, ValuesProperty vp) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, PathNotFoundException, ItemExistsException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
             try {
                 String uri = getItemUri(parentId, propertyName, sessionInfo);
                 PutMethod method = new PutMethod(uri);
@@ -2004,7 +2020,7 @@
                 remove(propertyId);
             } else {
                 // qualified value must be converted to jcr value
-                Value jcrValue = ValueFormat.getJCRValue(value, nsResolver, valueFactory);
+                Value jcrValue = ValueFormat.getJCRValue(value, resolver, valueFactory);
                 ValuesProperty vp = new ValuesProperty(jcrValue);
                 setProperties.add(vp);
             }
@@ -2024,7 +2040,7 @@
                 // qualified values must be converted to jcr values
                 Value[] jcrValues = new Value[values.length];
                 for (int i = 0; i < values.length; i++) {
-                    jcrValues[i] = ValueFormat.getJCRValue(values[i], nsResolver, valueFactory);
+                    jcrValues[i] = ValueFormat.getJCRValue(values[i], resolver, valueFactory);
                 }
                 setProperties.add(new ValuesProperty(jcrValues));
             }
@@ -2092,9 +2108,9 @@
         }
 
         /**
-         * @see Batch#setMixins(NodeId, QName[])
+         * @see Batch#setMixins(NodeId, Name[])
          */
-        public void setMixins(NodeId nodeId, QName[] mixinNodeTypeIds) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+        public void setMixins(NodeId nodeId, Name[] mixinNodeTypeIds) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
             checkConsumed();
             try {
                 DavPropertySet setProperties;
@@ -2106,7 +2122,7 @@
                 } else {
                     String[] ntNames = new String[mixinNodeTypeIds.length];
                     for (int i = 0; i < mixinNodeTypeIds.length; i++) {
-                        ntNames[i] = NameFormat.format(mixinNodeTypeIds[i], nsResolver);
+                        ntNames[i] = resolver.getJCRName(mixinNodeTypeIds[i]);
                     }
                     setProperties = new DavPropertySet();
                     setProperties.add(new NodeTypeProperty(ItemResourceConstants.JCR_MIXINNODETYPES, ntNames, false));
@@ -2119,16 +2135,13 @@
                 methods.add(method);
             } catch (IOException e) {
                 throw new RepositoryException(e);
-            } catch (NoPrefixDeclaredException e) {
-                // should not occur.
-                throw new RepositoryException(e);
             }
         }
 
         /**
-         * @see Batch#move(NodeId, NodeId, QName)
+         * @see Batch#move(NodeId, NodeId, Name)
          */
-        public void move(NodeId srcNodeId, NodeId destParentNodeId, QName destName) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+        public void move(NodeId srcNodeId, NodeId destParentNodeId, Name destName) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
             checkConsumed();
             String uri = getItemUri(srcNodeId, sessionInfo);
             String destUri = getItemUri(destParentNodeId, destName, sessionInfo);
@@ -2138,11 +2151,7 @@
         }
     }
 
-    //----------------------------------------------< NamespaceResolverImpl >---
 
-    /**
-     * Implements a namespace resolver based on a session info.
-     */
     private class NamespaceResolverImpl implements NamespaceResolver {
 
         private final SessionInfo sessionInfo;
@@ -2152,7 +2161,7 @@
          *
          * @param sessionInfo the session info to contact the repository.
          */
-        NamespaceResolverImpl(SessionInfo sessionInfo) {
+        private NamespaceResolverImpl(SessionInfo sessionInfo) {
             this.sessionInfo = sessionInfo;
         }
 
@@ -2179,19 +2188,54 @@
                 throw new NamespaceException(msg, e);
             }
         }
+    }
+
+    //-----------------------------------------------< NamePathResolverImpl >---
+    /**
+     * Implements a namespace resolver based on a session info.
+     */
+    private class NamePathResolverImpl implements NamePathResolver {
+
+        private final NameResolver nResolver;
+        private final PathResolver pResolver;
+
+        private NamePathResolverImpl(SessionInfo sessionInfo) {
+            NamespaceResolver nsResolver = new NamespaceResolverImpl(sessionInfo);
+            this.nResolver = new ParsingNameResolver(getNameFactory(), nsResolver);
+            this.pResolver = new ParsingPathResolver(getPathFactory(), nResolver);
+        }
+
+        private NamePathResolverImpl(NamespaceResolver nsResolver) {
+            this.nResolver = new ParsingNameResolver(getNameFactory(), nsResolver);
+            this.pResolver = new ParsingPathResolver(getPathFactory(), nResolver);
+        }
+
+        /**
+         * @inheritDoc
+         */
+        public Name getQName(String jcrName) throws IllegalNameException, NamespaceException {
+            return nResolver.getQName(jcrName);
+        }
+
+        /**
+         * @inheritDoc
+         */
+        public String getJCRName(Name qName) throws NamespaceException {
+            return nResolver.getJCRName(qName);
+        }
 
         /**
          * @inheritDoc
          */
-        public QName getQName(String jcrName) throws IllegalNameException, UnknownPrefixException {
-            return NameFormat.parse(jcrName, this);
+        public Path getQPath(String path) throws MalformedPathException, IllegalNameException, NamespaceException {
+            return pResolver.getQPath(path);
         }
 
         /**
          * @inheritDoc
          */
-        public String getJCRName(QName qName) throws NoPrefixDeclaredException {
-            return NameFormat.format(qName, this);
+        public String getJCRPath(Path path) throws NamespaceException {
+            return pResolver.getJCRPath(path);
         }
     }
 

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolver.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolver.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolver.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolver.java Thu Oct 18 11:41:45 2007
@@ -18,7 +18,7 @@
 
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.PropertyId;
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.SessionInfo;
 
 import javax.jcr.RepositoryException;

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java Thu Oct 18 11:41:45 2007
@@ -18,18 +18,14 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.PathFormat;
-import org.apache.jackrabbit.name.MalformedPathException;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.NameException;
-import org.apache.jackrabbit.name.NoPrefixDeclaredException;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.conversion.NameException;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
 import org.apache.jackrabbit.webdav.property.DavPropertySet;
@@ -45,6 +41,7 @@
 import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.version.report.ReportInfo;
+import org.apache.jackrabbit.name.NameConstants;
 import org.apache.commons.httpclient.URI;
 import org.w3c.dom.Document;
 
@@ -63,7 +60,7 @@
 
     private final URI repositoryUri;
     private final RepositoryServiceImpl service;
-    private final NamespaceResolver nsResolver;
+    private final NamePathResolver resolver;
     private final Document domFactory;
 
     // TODO: to-be-fixed. uri/id-caches don't get updated
@@ -71,10 +68,10 @@
     private final Map idURICaches = new HashMap();
 
     URIResolverImpl(URI repositoryUri, RepositoryServiceImpl service,
-                    NamespaceResolver nsResolver, Document domFactory) {
+                    NamePathResolver resolver, Document domFactory) {
         this.repositoryUri = repositoryUri;
         this.service = service;
-        this.nsResolver = nsResolver;
+        this.resolver = resolver;
         this.domFactory = domFactory;
     }
 
@@ -158,15 +155,11 @@
             }
             // resolve relative-path part unless it denotes the root-item
             if (path != null && !path.denotesRoot()) {
-                try {
-                    String jcrPath = PathFormat.format(path, nsResolver);
-                    if (!path.isAbsolute() && !uriBuffer.toString().endsWith("/")) {
-                        uriBuffer.append("/");
-                    }
-                    uriBuffer.append(Text.escapePath(jcrPath));
-                } catch (NoPrefixDeclaredException e) {
-                    throw new RepositoryException(e);
+                String jcrPath = resolver.getJCRPath(path);
+                if (!path.isAbsolute() && !uriBuffer.toString().endsWith("/")) {
+                    uriBuffer.append("/");
                 }
+                uriBuffer.append(Text.escapePath(jcrPath));
             }
             String itemUri = uriBuffer.toString();
             if (!cache.containsItemId(itemId)) {
@@ -187,12 +180,12 @@
         if (uniqueID != null) {
             nodeId = service.getIdFactory().createNodeId(uniqueID);
         } else {
-            QName qName = service.getQName(propSet, nsResolver);
-            if (qName == QName.ROOT) {
-                nodeId = service.getIdFactory().createNodeId((String) null, Path.ROOT);
+            Name qName = service.getQName(propSet, resolver);
+            if (NameConstants.ROOT.equals(qName)) {
+                nodeId = service.getIdFactory().createNodeId((String) null, service.getPathFactory().getRootPath());
             } else {
                 int index = service.getIndex(propSet);
-                nodeId = service.getIdFactory().createNodeId(parentId, Path.create(qName, index));
+                nodeId = service.getIdFactory().createNodeId(parentId, service.getPathFactory().create(qName, index));
             }
         }
         // cache
@@ -212,7 +205,7 @@
 
         try {
             DavPropertySet propSet = response.getProperties(DavServletResponse.SC_OK);
-            QName name = NameFormat.parse(propSet.get(ItemResourceConstants.JCR_NAME).getValue().toString(), nsResolver);
+            Name name = resolver.getQName(propSet.get(ItemResourceConstants.JCR_NAME).getValue().toString());
             PropertyId propertyId = service.getIdFactory().createPropertyId(parentId, name);
 
             cache.add(response.getHref(), propertyId);
@@ -242,8 +235,8 @@
             jcrPath = uri;
         }
         try {
-            return PathFormat.parse(Text.unescape(jcrPath), nsResolver);
-        } catch (MalformedPathException e) {
+            return resolver.getQPath(Text.unescape(jcrPath));
+        } catch (NameException e) {
             throw new RepositoryException(e);
         }
     }
@@ -316,7 +309,8 @@
         NodeId parentId = getNodeId(parentUri, sessionInfo);
         // build property id
         try {
-            PropertyId propertyId = service.getIdFactory().createPropertyId(parentId, NameFormat.parse(propName, nsResolver));
+            Name name = resolver.getQName(propName);
+            PropertyId propertyId = service.getIdFactory().createPropertyId(parentId, name);
             cache.add(uri, propertyId);
 
             return propertyId;

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/BatchReadConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/BatchReadConfig.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/BatchReadConfig.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/BatchReadConfig.java Thu Oct 18 11:41:45 2007
@@ -13,7 +13,7 @@
  */
 package org.apache.jackrabbit.spi2jcr;
 
-import org.apache.jackrabbit.name.QName;
+import org.apache.jackrabbit.spi.Name;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -42,7 +42,7 @@
      * in this configuration, the default depth {@link #DEPTH_DEFAULT 0} will
      * be returned.
      */
-    public int getDepth(QName ntName) {
+    public int getDepth(Name ntName) {
         if (depthMap.containsKey(ntName)) {
             return ((Integer) (depthMap.get(ntName))).intValue();
         } else {
@@ -56,7 +56,7 @@
      * @param ntName
      * @param depth
      */
-    public void setDepth(QName ntName, int depth) {
+    public void setDepth(Name ntName, int depth) {
         if (ntName == null || depth < DEPTH_INFINITE) {
             throw new IllegalArgumentException();
         }

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/ChildInfoImpl.java Thu Oct 18 11:41:45 2007
@@ -16,14 +16,13 @@
  */
 package org.apache.jackrabbit.spi2jcr;
 
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.UnknownPrefixException;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.conversion.NameException;
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.NamespaceException;
 
 /**
  * <code>ChildInfoImpl</code> implements a <code>ChildInfo</code> and provides
@@ -35,17 +34,17 @@
      * Creates a new <code>ChildInfoImpl</code> for <code>node</code>.
      *
      * @param node       the JCR node.
-     * @param nsResolver the namespace resolver in use.
+     * @param resolver
      * @throws RepositoryException    if an error occurs while reading from
      *                                <code>node</code>.
-     * @throws IllegalNameException   if the <code>node</code> name is illegal.
-     * @throws UnknownPrefixException if the name of the <code>node</code>
+     * @throws NameException   if the <code>node</code> name is illegal.
+     * @throws NamespaceException if the name of the <code>node</code>
      *                                contains a prefix not known to
      *                                <code>nsResolver</code>.
      */
-    public ChildInfoImpl(Node node, NamespaceResolver nsResolver)
-            throws RepositoryException, IllegalNameException, UnknownPrefixException {
-        super(NameFormat.parse(node.getName(), nsResolver),
+    public ChildInfoImpl(Node node, NamePathResolver resolver)
+            throws NamespaceException, NameException, RepositoryException {
+        super(resolver.getQName(node.getName()),
                 getUniqueId(node), node.getIndex());
     }
 

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/EventSubscription.java Thu Oct 18 11:41:45 2007
@@ -22,15 +22,13 @@
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.commons.EventImpl;
 import org.apache.jackrabbit.spi.commons.EventBundleImpl;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.Path;
-import org.apache.jackrabbit.name.PathFormat;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.UnknownPrefixException;
+import org.apache.jackrabbit.conversion.NameException;
+import org.apache.jackrabbit.conversion.NameResolver;
+import org.apache.jackrabbit.conversion.NamePathResolver;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -38,6 +36,7 @@
 import javax.jcr.Session;
 import javax.jcr.Node;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.NamespaceException;
 import javax.jcr.nodetype.NodeType;
 import java.util.ArrayList;
 import java.util.List;
@@ -69,12 +68,12 @@
 
     private final SessionInfoImpl sessionInfo;
 
-    private final NamespaceResolver nsResolver;
+    private final NamePathResolver resolver;
 
     EventSubscription(IdFactory idFactory, SessionInfoImpl sessionInfo) {
         this.idFactory = idFactory;
         this.sessionInfo = sessionInfo;
-        this.nsResolver = sessionInfo.getNamespaceResolver();
+        this.resolver = sessionInfo.getNamePathResolver();
     }
 
     /**
@@ -145,7 +144,7 @@
             try {
                 Session session = sessionInfo.getSession();
                 javax.jcr.observation.Event e = events.nextEvent();
-                Path p = PathFormat.parse(e.getPath(), nsResolver);
+                Path p = resolver.getQPath(e.getPath());
                 Path parent = p.getAncestor(1);
                 NodeId parentId = idFactory.createNodeId((String) null, parent);
                 ItemId itemId = null;
@@ -164,18 +163,16 @@
                                 p.getNameElement().getName());
                         break;
                 }
-                QName nodeTypeName = null;
-                QName[] mixinTypes = new QName[0];
+                Name nodeTypeName = null;
+                Name[] mixinTypes = new Name[0];
                 if (node != null) {
                     try {
                         parentId = idFactory.createNodeId(node.getUUID(), null);
                     } catch (UnsupportedRepositoryOperationException ex) {
                         // not referenceable
                     }
-                    nodeTypeName = NameFormat.parse(
-                            node.getPrimaryNodeType().getName(), nsResolver);
-                    mixinTypes = getNodeTypeNames(
-                            node.getMixinNodeTypes(), nsResolver);
+                    nodeTypeName = resolver.getQName(node.getPrimaryNodeType().getName());
+                    mixinTypes = getNodeTypeNames(node.getMixinNodeTypes(), resolver);
                 }
                 Event spiEvent = new EventImpl(e.getType(), p, itemId, parentId,
                         nodeTypeName, mixinTypes, e.getUserID());
@@ -196,18 +193,17 @@
      * resolver to parse the names.
      *
      * @param nt         the node types
-     * @param nsResolver the namespace resolver.
+     * @param resolver
      * @return the qualified names of the node types.
-     * @throws IllegalNameException   if a node type returns an illegal name.
-     * @throws UnknownPrefixException if the nameo of a node type contains a
-     *                                prefix that is not known to <code>nsResolver</code>.
-     */
-    private static QName[] getNodeTypeNames(NodeType[] nt,
-                                     NamespaceResolver nsResolver)
-            throws IllegalNameException, UnknownPrefixException {
-        QName[] names = new QName[nt.length];
+     * @throws NameException if a node type returns an illegal name.
+     * @throws NamespaceException if the name of a node type contains a
+     * prefix that is not known to <code>resolver</code>.
+     */
+    private static Name[] getNodeTypeNames(NodeType[] nt, NameResolver resolver)
+            throws NameException, NamespaceException {
+        Name[] names = new Name[nt.length];
         for (int i = 0; i < nt.length; i++) {
-            QName ntName = NameFormat.parse(nt[i].getName(), nsResolver);
+            Name ntName = resolver.getQName(nt[i].getName());
             names[i] = ntName;
         }
         return names;

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/IdFactoryImpl.java Thu Oct 18 11:41:45 2007
@@ -16,15 +16,15 @@
  */
 package org.apache.jackrabbit.spi2jcr;
 
-import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.PathFactoryImpl;
+import org.apache.jackrabbit.name.PathBuilder;
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.spi.NodeId;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.MalformedPathException;
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.NameException;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.conversion.NameException;
 import org.apache.jackrabbit.identifier.AbstractIdFactory;
 
 import javax.jcr.Node;
@@ -45,18 +45,21 @@
         return INSTANCE;
     }
 
+    protected PathFactory getPathFactory() {
+        return PathFactoryImpl.getInstance();
+    }
     /**
      * Creates a <code>NodeId</code> for the given <code>node</code>.
      *
      * @param node       the JCR Node.
-     * @param nsResolver the namespace resolver in use.
+     * @param resolver
      * @return the <code>NodeId</code> for <code>node</code>.
      * @throws RepositoryException if an error occurs while reading from
      *                             <code>node</code>.
      */
-    public NodeId createNodeId(Node node, NamespaceResolver nsResolver)
+    public NodeId createNodeId(Node node, NamePathResolver resolver)
             throws RepositoryException {
-        Path.PathBuilder builder = new Path.PathBuilder();
+        PathBuilder builder = new PathBuilder();
         int pathElements = 0;
         String uniqueId = null;
         while (uniqueId == null) {
@@ -68,12 +71,12 @@
                 String jcrName = node.getName();
                 if (jcrName.equals("")) {
                     // root node
-                    builder.addFirst(QName.ROOT);
+                    builder.addRoot();
                     break;
                 } else {
-                    QName name;
+                    Name name;
                     try {
-                        name = NameFormat.parse(node.getName(), nsResolver);
+                        name = resolver.getQName(node.getName());
                     } catch (NameException ex) {
                        throw new RepositoryException(ex.getMessage(), ex);
                     }
@@ -87,11 +90,7 @@
             }
         }
         if (pathElements > 0) {
-            try {
-                return createNodeId(uniqueId, builder.getPath());
-            } catch (MalformedPathException e) {
-                throw new RepositoryException(e.getMessage(), e);
-            }
+            return createNodeId(uniqueId, builder.getPath());
         } else {
             return createNodeId(uniqueId);
         }
@@ -101,20 +100,20 @@
      * Creates a <code>PropertyId</code> for the given <code>property</code>.
      *
      * @param property   the JCR Property.
-     * @param nsResolver the namespace resolver in use.
+     * @param resolver
      * @return the <code>PropertyId</code> for <code>property</code>.
      * @throws RepositoryException if an error occurs while reading from
      *                             <code>property</code>.
      */
     public PropertyId createPropertyId(Property property,
-                                       NamespaceResolver nsResolver)
+                                       NamePathResolver resolver)
             throws RepositoryException {
         Node parent = property.getParent();
-        NodeId nodeId = createNodeId(parent, nsResolver);
+        NodeId nodeId = createNodeId(parent, resolver);
         String jcrName = property.getName();
-        QName name;
+        Name name;
         try {
-            name = NameFormat.parse(jcrName, nsResolver);
+            name = resolver.getQName(jcrName);
         } catch (NameException e) {
             throw new RepositoryException(e.getMessage(), e);
         }

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/LockInfoImpl.java Thu Oct 18 11:41:45 2007
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.spi2jcr;
 
-import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.conversion.NamePathResolver;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.lock.Lock;
@@ -32,17 +32,17 @@
      *
      * @param lock       the lock.
      * @param idFactory  the id factory.
-     * @param nsResolver the namespace resolver in use.
+     * @param resolver
      * @throws RepositoryException if an error occurs while reading from
      *                             <code>node</code> or if <code>node</code> is
      *                             not locked.
      */
     public LockInfoImpl(Lock lock,
                         IdFactoryImpl idFactory,
-                        NamespaceResolver nsResolver)
+                        NamePathResolver resolver)
             throws RepositoryException {
         super(lock.getLockToken(), lock.getLockOwner(),
                 lock.isDeep(), lock.isSessionScoped(),
-                idFactory.createNodeId(lock.getNode(), nsResolver));
+                idFactory.createNodeId(lock.getNode(), resolver));
     }
 }

Modified: jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java?rev=586065&r1=586064&r2=586065&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java (original)
+++ jackrabbit/trunk/contrib/spi/spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/NodeInfoImpl.java Thu Oct 18 11:41:45 2007
@@ -16,17 +16,15 @@
  */
 package org.apache.jackrabbit.spi2jcr;
 
-import org.apache.jackrabbit.name.NamespaceResolver;
-import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.NameFormat;
-import org.apache.jackrabbit.name.IllegalNameException;
-import org.apache.jackrabbit.name.UnknownPrefixException;
-import org.apache.jackrabbit.name.PathFormat;
-import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.conversion.NamePathResolver;
+import org.apache.jackrabbit.conversion.NameException;
+import org.apache.jackrabbit.name.NameConstants;
+import org.apache.jackrabbit.spi.Name;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Node;
 import javax.jcr.PropertyIterator;
+import javax.jcr.NamespaceException;
 import javax.jcr.nodetype.NodeType;
 import java.util.List;
 import java.util.ArrayList;
@@ -43,22 +41,22 @@
      *
      * @param node       the JCR node.
      * @param idFactory  the id factory.
-     * @param nsResolver the namespace resolver in use.
+     * @param resolver
      * @throws RepositoryException if an error occurs while reading from
      *                             <code>node</code>.
      */
     public NodeInfoImpl(Node node,
                         IdFactoryImpl idFactory,
-                        NamespaceResolver nsResolver)
-            throws RepositoryException, IllegalNameException, UnknownPrefixException, MalformedPathException {
-        super(node.getName().length() == 0 ? null : idFactory.createNodeId(node.getParent(), nsResolver),
-                node.getName().length() == 0 ? QName.ROOT : NameFormat.parse(node.getName(), nsResolver),
-                PathFormat.parse(node.getPath(), nsResolver),
-                idFactory.createNodeId(node, nsResolver), node.getIndex(),
-                NameFormat.parse(node.getPrimaryNodeType().getName(), nsResolver),
-                getNodeTypeNames(node.getMixinNodeTypes(), nsResolver),
-                getPropertyIds(node.getReferences(), nsResolver, idFactory),
-                getPropertyIds(node.getProperties(), nsResolver, idFactory));
+                        NamePathResolver resolver)
+            throws RepositoryException, NameException {
+        super(node.getName().length() == 0 ? null : idFactory.createNodeId(node.getParent(), resolver),
+                node.getName().length() == 0 ? NameConstants.ROOT : resolver.getQName(node.getName()),
+                resolver.getQPath(node.getPath()),
+                idFactory.createNodeId(node, resolver), node.getIndex(),
+                resolver.getQName(node.getPrimaryNodeType().getName()),
+                getNodeTypeNames(node.getMixinNodeTypes(), resolver),
+                getPropertyIds(node.getReferences(), resolver, idFactory),
+                getPropertyIds(node.getProperties(), resolver, idFactory));
     }
 
     /**
@@ -66,18 +64,18 @@
      * resolver to parse the names.
      *
      * @param nt         the node types
-     * @param nsResolver the namespace resolver.
+     * @param resolver
      * @return the qualified names of the node types.
-     * @throws IllegalNameException   if a node type returns an illegal name.
-     * @throws UnknownPrefixException if the nameo of a node type contains a
-     *                                prefix that is not known to <code>nsResolver</code>.
+     * @throws NameException   if a node type returns an illegal name.
+     * @throws NamespaceException if the name of a node type contains a
+     *                            prefix that is not known to <code>resolver</code>.
      */
-    private static QName[] getNodeTypeNames(NodeType[] nt,
-                                     NamespaceResolver nsResolver)
-            throws IllegalNameException, UnknownPrefixException {
-        QName[] names = new QName[nt.length];
+    private static Name[] getNodeTypeNames(NodeType[] nt,
+                                           NamePathResolver resolver)
+            throws NameException, NamespaceException {
+        Name[] names = new Name[nt.length];
         for (int i = 0; i < nt.length; i++) {
-            QName ntName = NameFormat.parse(nt[i].getName(), nsResolver);
+            Name ntName = resolver.getQName(nt[i].getName());
             names[i] = ntName;
         }
         return names;
@@ -87,19 +85,19 @@
      * Returns property ids for the passed JCR properties.
      *
      * @param props      the JCR properties.
-     * @param nsResolver the namespace resolver.
+     * @param resolver
      * @param idFactory  the id factory.
      * @return the property ids for the passed JCR properties.
      * @throws RepositoryException if an error occurs while reading from the
      *                             properties.
      */
     private static Iterator getPropertyIds(PropertyIterator props,
-                                              NamespaceResolver nsResolver,
+                                              NamePathResolver resolver,
                                               IdFactoryImpl idFactory)
             throws RepositoryException {
         List references = new ArrayList();
         while (props.hasNext()) {
-            references.add(idFactory.createPropertyId(props.nextProperty(), nsResolver));
+            references.add(idFactory.createPropertyId(props.nextProperty(), resolver));
         }
         return references.iterator();
     }



Mime
View raw message