jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r496140 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ observation/ query/ query/lucene/ version/
Date Sun, 14 Jan 2007 20:40:07 GMT
Author: jukka
Date: Sun Jan 14 12:40:06 2007
New Revision: 496140

URL: http://svn.apache.org/viewvc?view=rev&rev=496140
Log:
JCR-688: Apply the new Resolver interfaces in jackrabbit-core.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LocalNamespaceMappings.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java Sun Jan 14 12:40:06 2007
@@ -33,6 +33,7 @@
 import org.apache.jackrabbit.core.state.StaleItemStateException;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.version.VersionManager;
+import org.apache.jackrabbit.name.NameException;
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.PathFormat;
@@ -1368,15 +1369,7 @@
     public String getPath() throws RepositoryException {
         // check state of this instance
         sanityCheck();
-
-        try {
-            return PathFormat.format(getPrimaryPath(), session.getNamespaceResolver());
-        } catch (NoPrefixDeclaredException npde) {
-            // should never get here...
-            String msg = "internal error: encountered unregistered namespace";
-            log.debug(msg);
-            throw new RepositoryException(msg, npde);
-        }
+        return session.getJCRPath(getPrimaryPath());
     }
 
     /**
@@ -1415,7 +1408,7 @@
         }
         if (otherItem instanceof ItemImpl) {
             ItemImpl other = (ItemImpl) otherItem;
-            return id.equals(other.id) 
+            return id.equals(other.id)
                     && session.getWorkspace().getName().equals(
                             other.getSession().getWorkspace().getName());
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemManager.java Sun Jan 14 12:40:06 2007
@@ -42,6 +42,7 @@
 
 import javax.jcr.AccessDeniedException;
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.NamespaceException;
 import javax.jcr.NodeIterator;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.PropertyIterator;
@@ -611,8 +612,8 @@
      */
     String safeGetJCRPath(Path path) {
         try {
-            return PathFormat.format(path, session.getNamespaceResolver());
-        } catch (NoPrefixDeclaredException npde) {
+            return session.getJCRPath(path);
+        } catch (NamespaceException e) {
             log.error("failed to convert " + path.toString() + " to JCR path.");
             // return string representation of internal path as a fallback
             return path.toString();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LocalNamespaceMappings.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LocalNamespaceMappings.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LocalNamespaceMappings.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/LocalNamespaceMappings.java Sun Jan 14 12:40:06 2007
@@ -17,8 +17,13 @@
 package org.apache.jackrabbit.core;
 
 import org.apache.jackrabbit.name.AbstractNamespaceResolver;
+import org.apache.jackrabbit.name.NameException;
+import org.apache.jackrabbit.name.NameResolver;
 import org.apache.jackrabbit.name.NamespaceListener;
 import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.ParsingNameResolver;
+import org.apache.jackrabbit.name.ParsingPathResolver;
+import org.apache.jackrabbit.name.PathResolver;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.NameCache;
 import org.apache.jackrabbit.util.XMLChar;
@@ -55,6 +60,10 @@
     /** URI to prefix mappings of local namespaces. */
     private final HashMap uriToPrefix = new HashMap();
 
+    private final NameResolver nameResolver;
+
+    private final PathResolver pathResolver;
+
     /**
      * Creates a local namespace manager with the given underlying
      * namespace registry.
@@ -64,6 +73,8 @@
     LocalNamespaceMappings(NamespaceRegistryImpl nsReg) {
         this.nsReg = nsReg;
         this.nsReg.addListener(this);
+        nameResolver = new ParsingNameResolver(this);
+        pathResolver = new ParsingPathResolver(nameResolver);
     }
 
     /**
@@ -157,44 +168,58 @@
         nsReg.removeListener(this);
     }
 
+    public NameResolver getNameResolver() {
+        if (prefixToURI.isEmpty()) {
+            return nsReg.getNameResolver();
+        } else {
+            return nameResolver;
+        }
+    }
+
+    public PathResolver getPathResolver() {
+        if (prefixToURI.isEmpty()) {
+            return nsReg.getPathResolver();
+        } else {
+            return pathResolver;
+        }
+    }
+
     //-------------------------------------------------------------< NameCache >
 
     /**
      * {@inheritDoc}
      */
     public QName retrieveName(String jcrName) {
-        if (prefixToURI.size() == 0) {
-            return nsReg.retrieveName(jcrName);
+        try {
+            return getNameResolver().getQName(jcrName);
+        } catch (NameException e) {
+            return null;
+        } catch (NamespaceException e) {
+            return null;
         }
-        return null;
     }
 
     /**
      * {@inheritDoc}
      */
     public String retrieveName(QName name) {
-        if (prefixToURI.size() == 0
-                || !uriToPrefix.containsKey(name.getNamespaceURI())) {
-            return nsReg.retrieveName(name);
+        try {
+            return getNameResolver().getJCRName(name);
+        } catch (NamespaceException e) {
+            return null;
         }
-        return null;
     }
 
     /**
      * {@inheritDoc}
      */
     public void cacheName(String jcrName, QName name) {
-        if (prefixToURI.size() == 0
-                || !uriToPrefix.containsKey(name.getNamespaceURI())) {
-            nsReg.cacheName(jcrName, name);
-        }
     }
 
     /**
      * {@inheritDoc}
      */
     public void evictAllNames() {
-        nsReg.evictAllNames();
     }
 
     //-----------------------------------------------------< NamespaceResolver >

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NamespaceRegistryImpl.java Sun Jan 14 12:40:06 2007
@@ -22,10 +22,13 @@
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.name.AbstractNamespaceResolver;
 import org.apache.jackrabbit.name.CachingNameResolver;
+import org.apache.jackrabbit.name.CachingPathResolver;
 import org.apache.jackrabbit.name.NameCache;
 import org.apache.jackrabbit.name.NameException;
 import org.apache.jackrabbit.name.NameResolver;
 import org.apache.jackrabbit.name.ParsingNameResolver;
+import org.apache.jackrabbit.name.ParsingPathResolver;
+import org.apache.jackrabbit.name.PathResolver;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.util.XMLChar;
 import org.slf4j.Logger;
@@ -87,7 +90,9 @@
 
     private int lastIndex = 0;
 
-    private NameResolver resolver;
+    private NameResolver nameResolver;
+
+    private PathResolver pathResolver;
 
     private final FileSystem nsRegStore;
 
@@ -106,8 +111,8 @@
             throws RepositoryException {
         super(true); // enable listener support
         this.nsRegStore = nsRegStore;
-        resolver = new CachingNameResolver(new ParsingNameResolver(this));
         load();
+        evictAllNames();
     }
 
     /**
@@ -285,6 +290,14 @@
         }
     }
 
+    public NameResolver getNameResolver() {
+        return nameResolver;
+    }
+
+    public PathResolver getPathResolver() {
+        return pathResolver;
+    }
+
     /**
      * Returns a prefix that is unique among the already registered prefixes.
      *
@@ -447,6 +460,9 @@
         // add new prefix mapping
         map(prefix, uri);
 
+        // Clear cache
+        evictAllNames();
+
         if (eventChannel != null) {
             eventChannel.remapped(oldPrefix, prefix, uri);
         }
@@ -529,7 +545,7 @@
      */
     public QName retrieveName(String jcrName) {
         try {
-            return resolver.getQName(jcrName);
+            return nameResolver.getQName(jcrName);
         } catch (NameException e) {
             return null;
         } catch (NamespaceException e) {
@@ -539,7 +555,7 @@
 
     public String retrieveName(QName name) {
         try {
-            return resolver.getJCRName(name);
+            return nameResolver.getJCRName(name);
         } catch (NamespaceException e) {
             return null;
         }
@@ -549,6 +565,9 @@
     }
 
     public void evictAllNames() {
+        nameResolver = new CachingNameResolver(new ParsingNameResolver(this));
+        pathResolver =
+            new CachingPathResolver(new ParsingPathResolver(nameResolver));
     }
 
     //-----------------------------------------------< NamespaceEventListener >
@@ -576,6 +595,9 @@
 
         // add new prefix mapping
         map(newPrefix, uri);
+
+        // Clear cache
+        evictAllNames();
 
         // persist mappings
         store();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java Sun Jan 14 12:40:06 2007
@@ -62,6 +62,7 @@
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.ItemVisitor;
 import javax.jcr.MergeException;
+import javax.jcr.NamespaceException;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -162,7 +163,7 @@
              * have to build & resolve absolute path)
              */
             if (relPath.indexOf('/') == -1) {
-                QName propName = NameFormat.parse(relPath, session.getNamespaceResolver());
+                QName propName = session.getQName(relPath);
                 // check if property entry exists
                 NodeState thisState = (NodeState) state;
                 if (thisState.hasPropertyName(propName)) {
@@ -175,8 +176,9 @@
             /**
              * build and resolve absolute path
              */
-            Path p = PathFormat.parse(getPrimaryPath(), relPath,
-                    session.getNamespaceResolver()).getCanonicalPath();
+            Path p =
+                Path.create(getPrimaryPath(), session.getQPath(relPath), false)
+                .getCanonicalPath();
             ItemId id = session.getHierarchyManager().resolvePath(p);
             if (id == null) {
                 // path not found
@@ -214,7 +216,7 @@
              * first check if relPath is just a name (in which case we don't
              * have to build & resolve absolute path)
              */
-            Path p = PathFormat.parse(relPath, session.getNamespaceResolver());
+            Path p = session.getQPath(relPath);
             if (p.getLength() == 1) {
                 Path.PathElement pe = p.getNameElement();
                 if (pe.denotesName()) {
@@ -249,7 +251,7 @@
                 // not a node
                 return null;
             }
-        } catch (MalformedPathException e) {
+        } catch (NameException e) {
             String msg = "failed to resolve path " + relPath + " relative to " + safeGetJCRPath();
             log.debug(msg);
             throw new RepositoryException(msg, e);
@@ -394,13 +396,13 @@
                                                boolean exactTypeMatch,
                                                BitSet status)
             throws ConstraintViolationException, RepositoryException {
-        QName qName;
         try {
-            qName = NameFormat.parse(name, session.getNamespaceResolver());
+            return getOrCreateProperty(
+                    session.getQName(name), type,
+                    multiValued, exactTypeMatch, status);
         } catch (NameException e) {
             throw new RepositoryException("invalid property name: " + name, e);
         }
-        return getOrCreateProperty(qName, type, multiValued, exactTypeMatch, status);
     }
 
     /**
@@ -580,14 +582,12 @@
     }
 
     protected void removeChildProperty(String propName) throws RepositoryException {
-        QName qName;
         try {
-            qName = NameFormat.parse(propName, session.getNamespaceResolver());
+            removeChildProperty(session.getQName(propName));
         } catch (NameException e) {
             throw new RepositoryException(
                     "invalid property name: " + propName, e);
         }
-        removeChildProperty(qName);
     }
 
     protected void removeChildProperty(QName propName) throws RepositoryException {
@@ -700,8 +700,8 @@
         Path parentPath;
         try {
             nodePath =
-                    PathFormat.parse(getPrimaryPath(), relPath,
-                            session.getNamespaceResolver()).getCanonicalPath();
+                Path.create(getPrimaryPath(), session.getQPath(relPath), false)
+                .getCanonicalPath();
             if (nodePath.getNameElement().getIndex() != 0) {
                 String msg = "illegal subscript specified: " + nodePath;
                 log.debug(msg);
@@ -709,7 +709,7 @@
             }
             nodeName = nodePath.getNameElement().getName();
             parentPath = nodePath.getAncestor(1);
-        } catch (MalformedPathException e) {
+        } catch (NameException e) {
             String msg = "failed to resolve path " + relPath + " relative to "
                     + safeGetJCRPath();
             log.debug(msg);
@@ -1748,8 +1748,11 @@
         if (!hasNode(srcName.getName(), srcName.getIndex())) {
             String name;
             try {
-                name = srcName.toJCRName(session.getNamespaceResolver());
-            } catch (NoPrefixDeclaredException npde) {
+                Path.PathElement[] path = new Path.PathElement[] { srcName };
+                name = session.getJCRPath(new Path.PathBuilder(path).getPath());
+            } catch (NameException e) {
+                name = srcName.toString();
+            } catch (NamespaceException e) {
                 name = srcName.toString();
             }
             throw new ItemNotFoundException(safeGetJCRPath()
@@ -1758,8 +1761,11 @@
         if (dstName != null && !hasNode(dstName.getName(), dstName.getIndex())) {
             String name;
             try {
-                name = dstName.toJCRName(session.getNamespaceResolver());
-            } catch (NoPrefixDeclaredException npde) {
+                Path.PathElement[] path = new Path.PathElement[] { dstName };
+                name = session.getJCRPath(new Path.PathBuilder(path).getPath());
+            } catch (NameException e) {
+                name = dstName.toString();
+            } catch (NamespaceException e) {
                 name = dstName.toString();
             }
             throw new ItemNotFoundException(safeGetJCRPath()
@@ -1862,16 +1868,7 @@
             return "";
         }
 
-        QName name = session.getHierarchyManager().getName(id);
-        try {
-            return NameFormat.format(name, session.getNamespaceResolver());
-        } catch (NoPrefixDeclaredException npde) {
-            // should never get here...
-            String msg = "internal error: encountered unregistered namespace "
-                    + name.getNamespaceURI();
-            log.debug(msg);
-            throw new RepositoryException(msg, npde);
-        }
+        return session.getJCRName(session.getHierarchyManager().getName(id));
     }
 
     /**
@@ -1940,13 +1937,13 @@
 
         Path.PathElement insertName;
         try {
-            Path p = PathFormat.parse(srcName, session.getNamespaceResolver());
+            Path p = session.getQPath(srcName);
             // p must be a relative path of length==depth==1 (to eliminate e.g. "..")
             if (p.isAbsolute() || p.getLength() != 1 || p.getDepth() != 1) {
                 throw new RepositoryException("invalid name: " + srcName);
             }
             insertName = p.getNameElement();
-        } catch (MalformedPathException e) {
+        } catch (NameException e) {
             String msg = "invalid name: " + srcName;
             log.debug(msg);
             throw new RepositoryException(msg, e);
@@ -1955,13 +1952,13 @@
         Path.PathElement beforeName;
         if (destName != null) {
             try {
-                Path p = PathFormat.parse(destName, session.getNamespaceResolver());
+                Path p = session.getQPath(destName);
                 // p must be a relative path of length==depth==1 (to eliminate e.g. "..")
                 if (p.isAbsolute() || p.getLength() != 1 || p.getDepth() != 1) {
                     throw new RepositoryException("invalid name: " + destName);
                 }
                 beforeName = p.getNameElement();
-            } catch (MalformedPathException e) {
+            } catch (NameException e) {
                 String msg = "invalid name: " + destName;
                 log.debug(msg);
                 throw new RepositoryException(msg, e);
@@ -2552,25 +2549,12 @@
      * {@inheritDoc}
      */
     public boolean isNodeType(String nodeTypeName) throws RepositoryException {
-
-        // try shortcut first (avoids parsing of name)...
         try {
-            if (NameFormat.format(primaryTypeName, session.getNamespaceResolver())
-                    .equals(nodeTypeName)) {
-                return true;
-            }
-        } catch (NoPrefixDeclaredException npde) {
-            throw new RepositoryException("invalid node type name: " + nodeTypeName, npde);
-        }
-
-        QName ntName;
-        try {
-            ntName = NameFormat.parse(nodeTypeName, session.getNamespaceResolver());
+            return isNodeType(session.getQName(nodeTypeName));
         } catch (NameException e) {
             throw new RepositoryException(
                     "invalid node type name: " + nodeTypeName, e);
         }
-        return isNodeType(ntName);
     }
 
     /**
@@ -2609,15 +2593,12 @@
     public void addMixin(String mixinName)
             throws NoSuchNodeTypeException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
-        QName ntName;
         try {
-            ntName = NameFormat.parse(mixinName, session.getNamespaceResolver());
+            addMixin(session.getQName(mixinName));
         } catch (NameException e) {
             throw new RepositoryException(
                     "invalid mixin type name: " + mixinName, e);
         }
-
-        addMixin(ntName);
     }
 
     /**
@@ -2626,15 +2607,12 @@
     public void removeMixin(String mixinName)
             throws NoSuchNodeTypeException, VersionException,
             ConstraintViolationException, LockException, RepositoryException {
-        QName ntName;
         try {
-            ntName = NameFormat.parse(mixinName, session.getNamespaceResolver());
+            removeMixin(session.getQName(mixinName));
         } catch (NameException e) {
             throw new RepositoryException(
                     "invalid mixin type name: " + mixinName, e);
         }
-
-        removeMixin(ntName);
     }
 
     /**
@@ -2664,7 +2642,7 @@
 
         QName ntName;
         try {
-            ntName = NameFormat.parse(mixinName, session.getNamespaceResolver());
+            ntName = session.getQName(mixinName);
         } catch (NameException e) {
             throw new RepositoryException(
                     "invalid mixin type name: " + mixinName, e);
@@ -2861,7 +2839,7 @@
             try {
                 Path p = m1.getPrimaryPath().computeRelativePath(getPrimaryPath());
                 // use prefix mappings of srcSession
-                relPath = PathFormat.format(p, srcSession.getNamespaceResolver());
+                relPath = session.getJCRPath(p);
             } catch (NameException be) {
                 // should never get here...
                 String msg = "internal error: failed to determine relative path";
@@ -3094,16 +3072,16 @@
                 node = (NodeImpl) session.getNodeByUUID(fn.getFrozenUUID());
                 if (removeExisting) {
                     try {
-                        Path dstPath = PathFormat.parse(getPrimaryPath(),
-                                relPath, session.getNamespaceResolver()).getCanonicalPath();
+                        Path relative = session.getQPath(relPath);
+                        Path dstPath =
+                            Path.create(getPrimaryPath(), relative, false)
+                            .getCanonicalPath();
                         // move to respective location
-                        session.move(node.getPath(), PathFormat.format(dstPath, session.getNamespaceResolver()));
+                        session.move(node.getPath(), session.getJCRPath(dstPath));
                         // need to refetch ?
                         node = (NodeImpl) session.getNodeByUUID(fn.getFrozenUUID());
-                    } catch (MalformedPathException e) {
+                    } catch (NameException e) {
                         throw new RepositoryException(e);
-                    } catch (NoPrefixDeclaredException e) {
-                        throw new RepositoryException("InternalError.", e);
                     }
                 } else {
                     throw new ItemExistsException("Unable to restore version. Versionable node already exists.");
@@ -3259,7 +3237,7 @@
             try {
                 Path p = m1.getPrimaryPath().computeRelativePath(getPrimaryPath());
                 // use prefix mappings of srcSession
-                relPath = PathFormat.format(p, srcSession.getNamespaceResolver());
+                relPath = session.getJCRPath(p);
             } catch (NameException be) {
                 // should never get here...
                 String msg = "internal error: failed to determine relative path";

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/PropertyImpl.java Sun Jan 14 12:40:06 2007
@@ -171,27 +171,11 @@
 
             case PropertyType.NAME:
                 QName name = (QName) value.internalValue();
-                try {
-                    return NameFormat.format(name, session.getNamespaceResolver()).length();
-                } catch (NoPrefixDeclaredException npde) {
-                    // should never happen...
-                    String msg = safeGetJCRPath()
-                            + ": the value represents an invalid name";
-                    log.debug(msg);
-                    throw new RepositoryException(msg, npde);
-                }
+                return session.getJCRName(name).length();
 
             case PropertyType.PATH:
                 Path path = (Path) value.internalValue();
-                try {
-                    return PathFormat.format(path, session.getNamespaceResolver()).length();
-                } catch (NoPrefixDeclaredException npde) {
-                    // should never happen...
-                    String msg = safeGetJCRPath()
-                            + ": the value represents an invalid path";
-                    log.debug(msg);
-                    throw new RepositoryException(msg, npde);
-                }
+                return session.getJCRPath(path).length();
 
             case PropertyType.BINARY:
                 BLOBFileValue blob = (BLOBFileValue) value.internalValue();
@@ -1152,16 +1136,7 @@
     public String getName() throws RepositoryException {
         // check state of this instance
         sanityCheck();
-
-        QName name = ((PropertyId) id).getName();
-        try {
-            return NameFormat.format(name, session.getNamespaceResolver());
-        } catch (NoPrefixDeclaredException npde) {
-            // should never get here...
-            String msg = "internal error: encountered unregistered namespace " + name.getNamespaceURI();
-            log.debug(msg);
-            throw new RepositoryException(msg, npde);
-        }
+        return session.getJCRName(((PropertyId) id).getName());
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java Sun Jan 14 12:40:06 2007
@@ -636,23 +636,17 @@
     private SearchManager getSystemSearchManager(String wspName)
             throws RepositoryException {
         if (systemSearchMgr == null) {
-            try {
-                if (repConfig.getSearchConfig() != null) {
-                    SystemSession defSysSession = getSystemSession(wspName);
-                    systemSearchMgr = new SearchManager(repConfig.getSearchConfig(),
-                            nsReg, ntReg, defSysSession.getItemStateManager(),
-                            SYSTEM_ROOT_NODE_ID, null, null);
-                    ObservationManager obsMgr = defSysSession.getWorkspace().getObservationManager();
-                    obsMgr.addEventListener(systemSearchMgr, Event.NODE_ADDED
-                            | Event.NODE_REMOVED | Event.PROPERTY_ADDED
-                            | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED,
-                            "/" + NameFormat.format(QName.JCR_SYSTEM, defSysSession.getNamespaceResolver()),
-                            true, null, null, false);
-                } else {
-                    systemSearchMgr = null;
-                }
-            } catch (NoPrefixDeclaredException e) {
-                throw new RepositoryException(e);
+            if (repConfig.getSearchConfig() != null) {
+                SystemSession defSysSession = getSystemSession(wspName);
+                systemSearchMgr = new SearchManager(repConfig.getSearchConfig(),
+                        nsReg, ntReg, defSysSession.getItemStateManager(),
+                        SYSTEM_ROOT_NODE_ID, null, null);
+                ObservationManager obsMgr = defSysSession.getWorkspace().getObservationManager();
+                obsMgr.addEventListener(systemSearchMgr, Event.NODE_ADDED
+                        | Event.NODE_REMOVED | Event.PROPERTY_ADDED
+                        | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED,
+                        "/" + defSysSession.getJCRName(QName.JCR_SYSTEM),
+                        true, null, null, false);
             }
         }
         return systemSearchMgr;
@@ -1179,7 +1173,7 @@
             throw new RepositoryException(msg, e);
         }
     }
-    
+
     /**
      * Creates a <code>SharedItemStateManager</code> or derivative.
      *
@@ -1192,7 +1186,7 @@
      * @param cacheFactory   cache factory
      * @return item state manager
      * @throws ItemStateException if an error occurs
-     */ 
+     */
     protected SharedItemStateManager createItemStateManager(PersistenceManager persistMgr,
                                                             NodeId rootNodeId,
                                                             NodeTypeRegistry ntReg,

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/SessionImpl.java Sun Jan 14 12:40:06 2007
@@ -39,8 +39,13 @@
 import org.apache.jackrabbit.core.util.Dumpable;
 import org.apache.jackrabbit.core.lock.LockManager;
 import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.NameException;
+import org.apache.jackrabbit.name.NameResolver;
 import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.name.ParsingNameResolver;
+import org.apache.jackrabbit.name.ParsingPathResolver;
 import org.apache.jackrabbit.name.Path;
+import org.apache.jackrabbit.name.PathResolver;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.PathFormat;
 import org.apache.jackrabbit.uuid.UUID;
@@ -100,7 +105,8 @@
 /**
  * A <code>SessionImpl</code> ...
  */
-public class SessionImpl implements Session, Dumpable {
+public class SessionImpl
+        implements Session, NameResolver, PathResolver, Dumpable {
 
     private static Logger log = LoggerFactory.getLogger(SessionImpl.class);
 
@@ -573,6 +579,26 @@
         listeners.remove(listener);
     }
 
+    //--------------------------------------------------------< NameResolver >
+
+    public String getJCRName(QName name) throws NamespaceException {
+        return nsMappings.getNameResolver().getJCRName(name);
+    }
+
+    public QName getQName(String name) throws NameException, NamespaceException {
+        return nsMappings.getNameResolver().getQName(name);
+    }
+
+    //--------------------------------------------------------< PathResolver >
+
+    public String getJCRPath(Path path) throws NamespaceException {
+        return nsMappings.getPathResolver().getJCRPath(path);
+    }
+
+    public Path getQPath(String path) throws NameException, NamespaceException {
+        return nsMappings.getPathResolver().getQPath(path);
+    }
+
     //--------------------------------------------------------------< Session >
     /**
      * {@inheritDoc}
@@ -591,11 +617,11 @@
 
         Path targetPath;
         try {
-            targetPath = PathFormat.parse(absPath, getNamespaceResolver()).getNormalizedPath();
-        } catch (MalformedPathException mpe) {
+            targetPath = getQPath(absPath).getNormalizedPath();
+        } catch (NameException e) {
             String msg = "invalid path: " + absPath;
-            log.debug(msg, mpe);
-            throw new RepositoryException(msg);
+            log.debug(msg, e);
+            throw new RepositoryException(msg, e);
         }
         if (!targetPath.isAbsolute()) {
             throw new RepositoryException("not an absolute path: " + absPath);
@@ -773,17 +799,17 @@
         sanityCheck();
 
         try {
-            Path p = PathFormat.parse(absPath, getNamespaceResolver()).getNormalizedPath();
+            Path p = getQPath(absPath).getNormalizedPath();
             if (!p.isAbsolute()) {
                 throw new RepositoryException("not an absolute path: " + absPath);
             }
             return getItemManager().getItem(p);
         } catch (AccessDeniedException ade) {
             throw new PathNotFoundException(absPath);
-        } catch (MalformedPathException mpe) {
+        } catch (NameException e) {
             String msg = "invalid path:" + absPath;
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
     }
 
@@ -795,15 +821,15 @@
         sanityCheck();
 
         try {
-            Path p = PathFormat.parse(absPath, getNamespaceResolver()).getNormalizedPath();
+            Path p = getQPath(absPath).getNormalizedPath();
             if (!p.isAbsolute()) {
                 throw new RepositoryException("not an absolute path: " + absPath);
             }
             return getItemManager().itemExists(p);
-        } catch (MalformedPathException mpe) {
+        } catch (NameException e) {
             String msg = "invalid path:" + absPath;
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
     }
 
@@ -864,7 +890,7 @@
         NodeImpl targetNode;
         NodeImpl srcParentNode;
         try {
-            srcPath = PathFormat.parse(srcAbsPath, getNamespaceResolver()).getNormalizedPath();
+            srcPath = getQPath(srcAbsPath).getNormalizedPath();
             if (!srcPath.isAbsolute()) {
                 throw new RepositoryException("not an absolute path: " + srcAbsPath);
             }
@@ -878,10 +904,10 @@
             srcParentNode = (NodeImpl) getItemManager().getItem(srcParentPath);
         } catch (AccessDeniedException ade) {
             throw new PathNotFoundException(srcAbsPath);
-        } catch (MalformedPathException mpe) {
+        } catch (NameException e) {
             String msg = srcAbsPath + ": invalid path";
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
 
         Path destPath;
@@ -889,7 +915,7 @@
         Path destParentPath;
         NodeImpl destParentNode;
         try {
-            destPath = PathFormat.parse(destAbsPath, getNamespaceResolver()).getNormalizedPath();
+            destPath = getQPath(destAbsPath).getNormalizedPath();
             if (!destPath.isAbsolute()) {
                 throw new RepositoryException("not an absolute path: " + destAbsPath);
             }
@@ -903,10 +929,10 @@
             destParentNode = (NodeImpl) getItemManager().getItem(destParentPath);
         } catch (AccessDeniedException ade) {
             throw new PathNotFoundException(destAbsPath);
-        } catch (MalformedPathException mpe) {
+        } catch (NameException e) {
             String msg = destAbsPath + ": invalid path";
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
         int ind = destName.getIndex();
         if (ind > 0) {
@@ -1027,15 +1053,15 @@
 
         Item item;
         try {
-            Path p = PathFormat.parse(parentAbsPath, getNamespaceResolver()).getNormalizedPath();
+            Path p = getQPath(parentAbsPath).getNormalizedPath();
             if (!p.isAbsolute()) {
                 throw new RepositoryException("not an absolute path: " + parentAbsPath);
             }
             item = getItemManager().getItem(p);
-        } catch (MalformedPathException mpe) {
+        } catch (NameException e) {
             String msg = parentAbsPath + ": invalid path";
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         } catch (AccessDeniedException ade) {
             throw new PathNotFoundException(parentAbsPath);
         }
@@ -1395,4 +1421,5 @@
         ps.println();
         itemStateMgr.dump(ps);
     }
+
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/WorkspaceImpl.java Sun Jan 14 12:40:06 2007
@@ -32,6 +32,7 @@
 import org.apache.jackrabbit.core.xml.Importer;
 import org.apache.jackrabbit.core.xml.WorkspaceImporter;
 import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.NameException;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.PathFormat;
 import org.slf4j.Logger;
@@ -257,11 +258,11 @@
 
         Path srcPath;
         try {
-            srcPath = PathFormat.parse(srcAbsPath, session.getNamespaceResolver()).getNormalizedPath();
-        } catch (MalformedPathException mpe) {
+            srcPath = session.getQPath(srcAbsPath).getNormalizedPath();
+        } catch (NameException e) {
             String msg = "invalid path: " + srcAbsPath;
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
         if (!srcPath.isAbsolute()) {
             throw new RepositoryException("not an absolute path: " + srcAbsPath);
@@ -269,11 +270,11 @@
 
         Path destPath;
         try {
-            destPath = PathFormat.parse(destAbsPath, session.getNamespaceResolver()).getNormalizedPath();
-        } catch (MalformedPathException mpe) {
+            destPath = session.getQPath(destAbsPath).getNormalizedPath();
+        } catch (NameException e) {
             String msg = "invalid path: " + destAbsPath;
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
         if (!destPath.isAbsolute()) {
             throw new RepositoryException("not an absolute path: " + destAbsPath);
@@ -484,11 +485,11 @@
 
         Path srcPath;
         try {
-            srcPath = PathFormat.parse(srcAbsPath, session.getNamespaceResolver()).getNormalizedPath();
-        } catch (MalformedPathException mpe) {
+            srcPath = session.getQPath(srcAbsPath).getNormalizedPath();
+        } catch (NameException e) {
             String msg = "invalid path: " + srcAbsPath;
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
         if (!srcPath.isAbsolute()) {
             throw new RepositoryException("not an absolute path: " + srcAbsPath);
@@ -496,11 +497,11 @@
 
         Path destPath;
         try {
-            destPath = PathFormat.parse(destAbsPath, session.getNamespaceResolver()).getNormalizedPath();
-        } catch (MalformedPathException mpe) {
+            destPath = session.getQPath(destAbsPath).getNormalizedPath();
+        } catch (NameException e) {
             String msg = "invalid path: " + destAbsPath;
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
         if (!destPath.isAbsolute()) {
             throw new RepositoryException("not an absolute path: " + destAbsPath);
@@ -700,11 +701,11 @@
 
         Path parentPath;
         try {
-            parentPath = PathFormat.parse(parentAbsPath, session.getNamespaceResolver()).getNormalizedPath();
-        } catch (MalformedPathException mpe) {
+            parentPath = session.getQPath(parentAbsPath).getNormalizedPath();
+        } catch (NameException e) {
             String msg = "invalid path: " + parentAbsPath;
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
         if (!parentPath.isAbsolute()) {
             throw new RepositoryException("not an absolute path: " + parentAbsPath);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/EventImpl.java Sun Jan 14 12:40:06 2007
@@ -91,13 +91,9 @@
             } else {
                 p = Path.create(eventState.getParentPath(), eventState.getChildRelPath().getName(), false);
             }
-            return PathFormat.format(p, session.getNamespaceResolver());
+            return session.getJCRPath(p);
         } catch (MalformedPathException e) {
             String msg = "internal error: malformed path for event";
-            log.debug(msg);
-            throw new RepositoryException(msg, e);
-        } catch (NoPrefixDeclaredException e) {
-            String msg = "internal error: encountered unregistered namespace in path";
             log.debug(msg);
             throw new RepositoryException(msg, e);
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/observation/ObservationManagerImpl.java Sun Jan 14 12:40:06 2007
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl;
 import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.NameException;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.PathFormat;
 import org.slf4j.Logger;
@@ -117,11 +118,11 @@
 
         Path path;
         try {
-            path = PathFormat.parse(absPath, session.getNamespaceResolver()).getNormalizedPath();
-        } catch (MalformedPathException mpe) {
+            path = session.getQPath(absPath).getNormalizedPath();
+        } catch (NameException e) {
             String msg = "invalid path syntax: " + absPath;
             log.debug(msg);
-            throw new RepositoryException(msg, mpe);
+            throw new RepositoryException(msg, e);
         }
         NodeId[] ids = null;
         if (uuid != null) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/QueryImpl.java Sun Jan 14 12:40:06 2007
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.core.ItemManager;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.name.MalformedPathException;
+import org.apache.jackrabbit.name.NameException;
 import org.apache.jackrabbit.name.NamespaceResolver;
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.Path;
@@ -117,16 +118,12 @@
         this.node = node;
         this.handler = handler;
 
-        try {
-            if (!node.isNodeType(NameFormat.format(QName.NT_QUERY, session.getNamespaceResolver()))) {
-                throw new InvalidQueryException("node is not of type nt:query");
-            }
-            statement = node.getProperty(NameFormat.format(QName.JCR_STATEMENT, session.getNamespaceResolver())).getString();
-            language = node.getProperty(NameFormat.format(QName.JCR_LANGUAGE, session.getNamespaceResolver())).getString();
-            query = handler.createExecutableQuery(session, itemMgr, statement, language);
-        } catch (NoPrefixDeclaredException e) {
-            throw new RepositoryException(e.getMessage(), e);
+        if (!node.isNodeType(session.getJCRName(QName.NT_QUERY))) {
+            throw new InvalidQueryException("node is not of type nt:query");
         }
+        statement = node.getProperty(session.getJCRName(QName.JCR_STATEMENT)).getString();
+        language = node.getProperty(session.getJCRName(QName.JCR_LANGUAGE)).getString();
+        query = handler.createExecutableQuery(session, itemMgr, statement, language);
         initialized = true;
     }
 
@@ -193,23 +190,20 @@
 
         checkInitialized();
         try {
-            NamespaceResolver resolver = session.getNamespaceResolver();
-            Path p = PathFormat.parse(absPath, resolver).getNormalizedPath();
+            Path p = session.getQPath(absPath).getNormalizedPath();
             if (!p.isAbsolute()) {
                 throw new RepositoryException(absPath + " is not an absolute path");
             }
 
-            String relPath = PathFormat.format(p, resolver).substring(1);
-            Node queryNode = session.getRootNode().addNode(relPath,
-                    NameFormat.format(QName.NT_QUERY, resolver));
+            String relPath = session.getJCRPath(p).substring(1);
+            Node queryNode = session.getRootNode().addNode(
+                    relPath, session.getJCRName(QName.NT_QUERY));
             // set properties
-            queryNode.setProperty(NameFormat.format(QName.JCR_LANGUAGE, resolver), language);
-            queryNode.setProperty(NameFormat.format(QName.JCR_STATEMENT, resolver), statement);
+            queryNode.setProperty(session.getJCRName(QName.JCR_LANGUAGE), language);
+            queryNode.setProperty(session.getJCRName(QName.JCR_STATEMENT), statement);
             node = queryNode;
             return node;
-        } catch (MalformedPathException e) {
-            throw new RepositoryException(e.getMessage(), e);
-        } catch (NoPrefixDeclaredException e) {
+        } catch (NameException e) {
             throw new RepositoryException(e.getMessage(), e);
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/LuceneQueryBuilder.java Sun Jan 14 12:40:06 2007
@@ -256,7 +256,7 @@
             String primaryTypeField = NameFormat.format(QName.JCR_PRIMARYTYPE, nsMappings);
 
             NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
-            NodeType base = ntMgr.getNodeType(NameFormat.format(node.getValue(), session.getNamespaceResolver()));
+            NodeType base = ntMgr.getNodeType(session.getJCRName(node.getValue()));
 
             if (base.isMixin()) {
                 // search for nodes where jcr:mixinTypes is set to this mixin
@@ -884,12 +884,12 @@
                 case PropertyType.PATH:
                     // try to translate path
                     try {
-                        Path p = PathFormat.parse(literal, session.getNamespaceResolver());
+                        Path p = session.getQPath(literal);
                         values.add(PathFormat.format(p, nsMappings));
                         log.debug("Coerced " + literal + " into PATH.");
-                    } catch (MalformedPathException e) {
+                    } catch (NameException e) {
                         log.warn("Unable to coerce '" + literal + "' into a PATH: " + e.toString());
-                    } catch (NoPrefixDeclaredException e) {
+                    } catch (NamespaceException e) {
                         log.warn("Unable to coerce '" + literal + "' into a PATH: " + e.toString());
                     }
                     break;
@@ -938,8 +938,7 @@
                 // might be a path
                 try {
                     values.add(PathFormat.format(
-                            PathFormat.parse(literal, session.getNamespaceResolver()),
-                            nsMappings));
+                            session.getQPath(literal), nsMappings));
                     log.debug("Coerced " + literal + " into PATH.");
                 } catch (Exception e) {
                     // not a path

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java?view=diff&rev=496140&r1=496139&r2=496140
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/VersionHistoryImpl.java Sun Jan 14 12:40:06 2007
@@ -104,7 +104,7 @@
     public Version getVersion(String versionName)
             throws VersionException, RepositoryException {
         try {
-            QName name = NameFormat.parse(versionName, session.getNamespaceResolver());
+            QName name = session.getQName(versionName);
             InternalVersion v = getInternalVersionHistory().getVersion(name);
             if (v == null) {
                 throw new VersionException("No version with name '" + versionName + "' exists in this version history.");
@@ -120,8 +120,9 @@
      */
     public Version getVersionByLabel(String label) throws RepositoryException {
         try {
-            QName qLabel = NameFormat.parse(label, session.getNamespaceResolver());
-            InternalVersion v = getInternalVersionHistory().getVersionByLabel(qLabel);
+            QName qLabel = session.getQName(label);
+            InternalVersion v =
+                getInternalVersionHistory().getVersionByLabel(qLabel);
             if (v == null) {
                 throw new VersionException("No version with label '" + label + "' exists in this version history.");
             }
@@ -137,10 +138,9 @@
     public void addVersionLabel(String versionName, String label, boolean move)
             throws VersionException, RepositoryException {
         try {
-            session.getVersionManager().setVersionLabel(this,
-                    NameFormat.parse(versionName, session.getNamespaceResolver()),
-                    NameFormat.parse(label, session.getNamespaceResolver()),
-                    move);
+            session.getVersionManager().setVersionLabel(
+                    this, session.getQName(versionName),
+                    session.getQName(label), move);
         } catch (NameException e) {
             throw new VersionException(e);
         }
@@ -151,10 +151,8 @@
      */
     public void removeVersionLabel(String label) throws RepositoryException {
         try {
-            Version existing = session.getVersionManager().setVersionLabel(this,
-                    null,
-                    NameFormat.parse(label, session.getNamespaceResolver()),
-                    true);
+            Version existing = session.getVersionManager().setVersionLabel(
+                    this, null, session.getQName(label), true);
             if (existing == null) {
                 throw new VersionException("No version with label '" + label + "' exists in this version history.");
             }
@@ -168,16 +166,12 @@
      * @see javax.jcr.version.VersionHistory#getVersionLabels
      */
     public String[] getVersionLabels() throws RepositoryException {
-        try {
-            QName[] labels = getInternalVersionHistory().getVersionLabels();
-            String[] ret = new String[labels.length];
-            for (int i = 0; i < labels.length; i++) {
-                ret[i] = NameFormat.format(labels[i], session.getNamespaceResolver());
-            }
-            return ret;
-        } catch (NoPrefixDeclaredException e) {
-            throw new IllegalArgumentException("Unable to resolve label name: " + e.toString());
+        QName[] labels = getInternalVersionHistory().getVersionLabels();
+        String[] ret = new String[labels.length];
+        for (int i = 0; i < labels.length; i++) {
+            ret[i] = session.getJCRName(labels[i]);
         }
+        return ret;
     }
 
     /**
@@ -186,16 +180,12 @@
     public String[] getVersionLabels(Version version)
             throws VersionException, RepositoryException {
         checkOwnVersion(version);
-        try {
-            QName[] labels = ((VersionImpl) version).getInternalVersion().getLabels();
-            String[] ret = new String[labels.length];
-            for (int i = 0; i < labels.length; i++) {
-                ret[i] = NameFormat.format(labels[i], session.getNamespaceResolver());
-            }
-            return ret;
-        } catch (NoPrefixDeclaredException e) {
-            throw new IllegalArgumentException("Unable to resolve label name: " + e.toString());
+        QName[] labels = ((VersionImpl) version).getInternalVersion().getLabels();
+        String[] ret = new String[labels.length];
+        for (int i = 0; i < labels.length; i++) {
+            ret[i] = session.getJCRName(labels[i]);
         }
+        return ret;
     }
 
     /**
@@ -203,7 +193,7 @@
      */
     public boolean hasVersionLabel(String label) throws RepositoryException {
         try {
-            QName qLabel = NameFormat.parse(label, session.getNamespaceResolver());
+            QName qLabel = session.getQName(label);
             return getInternalVersionHistory().getVersionByLabel(qLabel) != null;
         } catch (NameException e) {
             throw new IllegalArgumentException("Unable to resolve label: " + e);
@@ -217,7 +207,7 @@
             throws VersionException, RepositoryException {
         checkOwnVersion(version);
         try {
-            QName qLabel = NameFormat.parse(label, session.getNamespaceResolver());
+            QName qLabel = session.getQName(label);
             return ((VersionImpl) version).getInternalVersion().hasLabel(qLabel);
         } catch (NameException e) {
             throw new VersionException(e);
@@ -231,8 +221,8 @@
             throws UnsupportedRepositoryOperationException, VersionException,
             RepositoryException {
         try {
-            session.getVersionManager().removeVersion(this,
-                    NameFormat.parse(versionName, session.getNamespaceResolver()));
+            session.getVersionManager().removeVersion(
+                    this, session.getQName(versionName));
         } catch (NameException e) {
             throw new RepositoryException(e);
         }



Mime
View raw message