jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r655574 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: WorkspaceManager.java name/NamespaceRegistryImpl.java name/NamespaceStorage.java
Date Mon, 12 May 2008 17:39:24 GMT
Author: jukka
Date: Mon May 12 10:39:24 2008
New Revision: 655574

URL: http://svn.apache.org/viewvc?rev=655574&view=rev
Log:
JCR-1564: JSR 283 namespace handling
    - No need for the NamespaceStorage interface, as 
      NamespaceRegistryImpl can just as well call RepositoryService directly

Removed:
    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/WorkspaceManager.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java

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=655574&r1=655573&r2=655574&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
Mon May 12 10:39:24 2008
@@ -23,7 +23,6 @@
 import org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProviderImpl;
 import org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider;
 import org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeCache;
-import org.apache.jackrabbit.jcr2spi.name.NamespaceStorage;
 import org.apache.jackrabbit.jcr2spi.name.NamespaceRegistryImpl;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
 import org.apache.jackrabbit.jcr2spi.state.ChangeLog;
@@ -88,7 +87,6 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.NamespaceRegistry;
-import javax.jcr.NamespaceException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.AccessDeniedException;
 import javax.jcr.PathNotFoundException;
@@ -119,7 +117,7 @@
 /**
  * <code>WorkspaceManager</code>...
  */
-public class WorkspaceManager implements UpdatableItemStateManager, NamespaceStorage, AccessManager
{
+public class WorkspaceManager implements UpdatableItemStateManager, AccessManager {
 
     private static Logger log = LoggerFactory.getLogger(WorkspaceManager.class);
 
@@ -172,7 +170,7 @@
         this.pathFactory = service.getPathFactory();
 
         idFactory = service.getIdFactory();
-        nsRegistry = new NamespaceRegistryImpl(this);
+        nsRegistry = new NamespaceRegistryImpl(service, sessionInfo);
         ntRegistry = createNodeTypeRegistry(nsRegistry);
         changeFeed = createChangeFeed(pollTimeout, enableObservation);
         definitionProvider = createDefinitionProvider(getEffectiveNodeTypeProvider());
@@ -623,40 +621,6 @@
         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

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java?rev=655574&r1=655573&r2=655574&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java
Mon May 12 10:39:24 2008
@@ -18,31 +18,37 @@
 
 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 {
 
-    private static Logger log = LoggerFactory.getLogger(NamespaceRegistryImpl.class);
+    /**
+     * Repository service.
+     */
+    private final RepositoryService service;
 
-    private final NamespaceStorage storage;
+    /**
+     * Session info.
+     */
+    private final SessionInfo info;
 
     /**
      * Create a new <code>NamespaceRegistryImpl</code>.
      *
-     * @param storage
+     * @param service repository service
+     * @param info session info
      */
-    public NamespaceRegistryImpl(NamespaceStorage storage) {
-        this.storage = storage;
+    public NamespaceRegistryImpl(RepositoryService service, SessionInfo info) {
+        this.service = service;
+        this.info = info;
     }
 
     //--------------------------------------------------< NamespaceRegistry >---
@@ -50,22 +56,23 @@
     /**
      * @see NamespaceRegistry#registerNamespace(String, String)
      */
-    public void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException,
RepositoryException {
-        storage.registerNamespace(prefix, uri);
+    public void registerNamespace(String prefix, String uri)
+            throws RepositoryException {
+        service.registerNamespace(info, prefix, uri);
     }
 
     /**
      * @see NamespaceRegistry#unregisterNamespace(String)
      */
-    public void unregisterNamespace(String prefix) throws NamespaceException, UnsupportedRepositoryOperationException,
RepositoryException {
-        storage.unregisterNamespace(prefix);
+    public void unregisterNamespace(String prefix) throws RepositoryException {
+        service.unregisterNamespace(info, getURI(prefix));
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getPrefixes()
      */
     public String[] getPrefixes() throws RepositoryException {
-        Collection prefixes = storage.getRegisteredNamespaces().keySet();
+        Collection prefixes = service.getRegisteredNamespaces(info).keySet();
         return (String[]) prefixes.toArray(new String[prefixes.size()]);
     }
 
@@ -73,36 +80,22 @@
      * @see javax.jcr.NamespaceRegistry#getURIs()
      */
     public String[] getURIs() throws RepositoryException {
-        Collection uris = storage.getRegisteredNamespaces().values();
+        Collection uris = service.getRegisteredNamespaces(info).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 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.");
-        }
+    public String getURI(String prefix) throws RepositoryException {
+        return service.getNamespaceURI(info, prefix);
     }
 
     /**
      * @see javax.jcr.NamespaceRegistry#getPrefix(String)
-     * @see org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver#getPrefix(String)
      */
-    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.");
-        }
+    public String getPrefix(String uri) throws RepositoryException {
+        return service.getNamespacePrefix(info, uri);
     }
 
 }



Mime
View raw message