jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r705925 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: NamespaceRegistryImpl.java NamespaceStorage.java WorkspaceManager.java
Date Sat, 18 Oct 2008 21:24:41 GMT
Author: jukka
Date: Sat Oct 18 14:24:41 2008
New Revision: 705925

URL: http://svn.apache.org/viewvc?rev=705925&view=rev
Log:
JCR-1612: Reintroduce NamespaceStorage and namespace-caching

Reverted revision 655574.

Added:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
      - copied, changed from r655573, jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceStorage.java
Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java?rev=705925&r1=705924&r2=705925&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceRegistryImpl.java
Sat Oct 18 14:24:41 2008
@@ -18,37 +18,31 @@
 
 import java.util.Collection;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import javax.jcr.NamespaceRegistry;
+import javax.jcr.NamespaceException;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.RepositoryException;
 
-import org.apache.jackrabbit.spi.RepositoryService;
-import org.apache.jackrabbit.spi.SessionInfo;
-
 /**
  * <code>NamespaceRegistryImpl</code> implements the JCR client facing
  * NamespaceRegistry.
  */
 public class NamespaceRegistryImpl implements NamespaceRegistry {
 
-    /**
-     * Repository service.
-     */
-    private final RepositoryService service;
+    private static Logger log = LoggerFactory.getLogger(NamespaceRegistryImpl.class);
 
-    /**
-     * Session info.
-     */
-    private final SessionInfo info;
+    private final NamespaceStorage storage;
 
     /**
      * Create a new <code>NamespaceRegistryImpl</code>.
      *
-     * @param service repository service
-     * @param info session info
+     * @param storage
      */
-    public NamespaceRegistryImpl(RepositoryService service, SessionInfo info) {
-        this.service = service;
-        this.info = info;
+    public NamespaceRegistryImpl(NamespaceStorage storage) {
+        this.storage = storage;
     }
 
     //--------------------------------------------------< NamespaceRegistry >---
@@ -56,23 +50,22 @@
     /**
      * @see NamespaceRegistry#registerNamespace(String, String)
      */
-    public void registerNamespace(String prefix, String uri)
-            throws RepositoryException {
-        service.registerNamespace(info, prefix, uri);
+    public void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException,
RepositoryException {
+        storage.registerNamespace(prefix, uri);
     }
 
     /**
      * @see NamespaceRegistry#unregisterNamespace(String)
      */
-    public void unregisterNamespace(String prefix) throws RepositoryException {
-        service.unregisterNamespace(info, getURI(prefix));
+    public void unregisterNamespace(String prefix) throws NamespaceException, UnsupportedRepositoryOperationException,
RepositoryException {
+        storage.unregisterNamespace(prefix);
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getPrefixes()
      */
     public String[] getPrefixes() throws RepositoryException {
-        Collection prefixes = service.getRegisteredNamespaces(info).keySet();
+        Collection prefixes = storage.getRegisteredNamespaces().keySet();
         return (String[]) prefixes.toArray(new String[prefixes.size()]);
     }
 
@@ -80,22 +73,36 @@
      * @see javax.jcr.NamespaceRegistry#getURIs()
      */
     public String[] getURIs() throws RepositoryException {
-        Collection uris = service.getRegisteredNamespaces(info).values();
+        Collection uris = storage.getRegisteredNamespaces().values();
         return (String[]) uris.toArray(new String[uris.size()]);
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getURI(String)
+     * @see org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver#getURI(String)
      */
-    public String getURI(String prefix) throws RepositoryException {
-        return service.getNamespaceURI(info, prefix);
+    public String getURI(String prefix) throws NamespaceException {
+        // try to load the uri
+        try {
+            return storage.getURI(prefix);
+        } catch (RepositoryException ex) {
+            log.debug("Internal error while loading registered namespaces.");
+            throw new NamespaceException(prefix + ": is not a registered namespace prefix.");
+        }
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getPrefix(String)
+     * @see org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver#getPrefix(String)
      */
-    public String getPrefix(String uri) throws RepositoryException {
-        return service.getNamespacePrefix(info, uri);
+    public String getPrefix(String uri) throws NamespaceException {
+        // try to load the prefix
+        try {
+            return storage.getPrefix(uri);
+        } catch (RepositoryException ex) {
+            log.debug("Internal error while loading registered namespaces.");
+            throw new NamespaceException(uri + ": is not a registered namespace uri.");
+        }
     }
 
 }

Copied: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
(from r655573, jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceStorage.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java?p2=jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java&p1=jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceStorage.java&r1=655573&r2=705925&rev=705925&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceStorage.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NamespaceStorage.java
Sat Oct 18 14:24:41 2008
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.jcr2spi.name;
+package org.apache.jackrabbit.jcr2spi;
 
 import java.util.Map;
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?rev=705925&r1=705924&r2=705925&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Sat Oct 18 14:24:41 2008
@@ -90,6 +90,7 @@
 import javax.jcr.AccessDeniedException;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.NamespaceException;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.ItemExistsException;
 import javax.jcr.InvalidItemStateException;
@@ -116,7 +117,8 @@
 /**
  * <code>WorkspaceManager</code>...
  */
-public class WorkspaceManager implements UpdatableItemStateManager, AccessManager {
+public class WorkspaceManager
+        implements UpdatableItemStateManager, NamespaceStorage, AccessManager {
 
     private static Logger log = LoggerFactory.getLogger(WorkspaceManager.class);
 
@@ -169,7 +171,7 @@
         this.pathFactory = service.getPathFactory();
 
         idFactory = service.getIdFactory();
-        nsRegistry = new NamespaceRegistryImpl(service, sessionInfo);
+        nsRegistry = new NamespaceRegistryImpl(this);
         ntRegistry = createNodeTypeRegistry(nsRegistry);
         changeFeed = createChangeFeed(pollTimeout, enableObservation);
         definitionProvider = createDefinitionProvider(getEffectiveNodeTypeProvider());
@@ -620,6 +622,40 @@
         return false;
     }
 
+    //---------------------------------------------------< NamespaceStorage >---
+
+    public Map getRegisteredNamespaces() throws RepositoryException {
+        return service.getRegisteredNamespaces(sessionInfo);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getPrefix(String uri) throws NamespaceException, RepositoryException {
+        return service.getNamespacePrefix(sessionInfo, uri);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public String getURI(String prefix) throws NamespaceException, RepositoryException {
+        return service.getNamespaceURI(sessionInfo, prefix);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException,
AccessDeniedException, RepositoryException {
+        service.registerNamespace(sessionInfo, prefix, uri);
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public void unregisterNamespace(String uri) throws NamespaceException, UnsupportedRepositoryOperationException,
AccessDeniedException, RepositoryException {
+        service.unregisterNamespace(sessionInfo, uri);
+    }
+
     //--------------------------------------------------------------------------
     /**
      * Called when local or external events occured. This method is called after



Mime
View raw message