jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r452081 - in /jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: WorkspaceManager.java name/NamespaceRegistryImpl.java
Date Mon, 02 Oct 2006 15:38:55 GMT
Author: angela
Date: Mon Oct  2 08:38:54 2006
New Revision: 452081

URL: http://svn.apache.org/viewvc?view=rev&rev=452081
Log:
work in progress

- resolve TODO in NamespaceRegistry. add flag indicating, if repository
  supports level2 (registration of new namespaces).

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?view=diff&rev=452081&r1=452080&r2=452081
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Mon Oct  2 08:38:54 2006
@@ -141,9 +141,11 @@
 
         cache = createItemStateManager();
 
-        nsRegistry = createNamespaceRegistry();
-        ntRegistry = createNodeTypeRegistry(nsRegistry);
-        externalChangeListener = createChangeListener();
+        Properties repositoryDescriptors = service.getRepositoryDescriptors();
+
+        nsRegistry = createNamespaceRegistry(repositoryDescriptors);
+        ntRegistry = createNodeTypeRegistry(nsRegistry, repositoryDescriptors);
+        externalChangeListener = createChangeListener(repositoryDescriptors);
     }
 
     public NamespaceRegistryImpl getNamespaceRegistryImpl() {
@@ -247,11 +249,25 @@
         return ism;
     }
 
-    private NamespaceRegistryImpl createNamespaceRegistry() throws RepositoryException {
-        return new NamespaceRegistryImpl(this, service.getRegisteredNamespaces(sessionInfo));
+    /**
+     *
+     * @param descriptors
+     * @return
+     * @throws RepositoryException
+     */
+    private NamespaceRegistryImpl createNamespaceRegistry(Properties descriptors) throws
RepositoryException {
+        boolean level2 = Boolean.valueOf(descriptors.getProperty(Repository.LEVEL_2_SUPPORTED)).booleanValue();
+        return new NamespaceRegistryImpl(this, service.getRegisteredNamespaces(sessionInfo),
level2);
     }
 
-    private NodeTypeRegistry createNodeTypeRegistry(NamespaceRegistry nsRegistry) throws
RepositoryException {
+    /**
+     *
+     * @param nsRegistry
+     * @param descriptors
+     * @return
+     * @throws RepositoryException
+     */
+    private NodeTypeRegistry createNodeTypeRegistry(NamespaceRegistry nsRegistry, Properties
descriptors) throws RepositoryException {
         QNodeDefinition rootNodeDef = service.getNodeDefinition(sessionInfo, service.getRootId(sessionInfo));
         QNodeTypeDefinitionIterator it = service.getNodeTypeDefinitions(sessionInfo);
         List ntDefs = new ArrayList();
@@ -265,13 +281,13 @@
      * Creates and registers an EventListener on the RepositoryService that
      * listens for external changes.
      *
+     * @param descriptors the repository descriptors
      * @return the listener or <code>null</code> if the underlying
      *         <code>RepositoryService</code> does not support observation.
      * @throws RepositoryException if an error occurs while registering the
      *                             event listener.
      */
-    private EventListener createChangeListener() throws RepositoryException {
-        Properties descriptors = service.getRepositoryDescriptors();
+    private EventListener createChangeListener(Properties descriptors) throws RepositoryException
{
         String desc = descriptors.getProperty(Repository.OPTION_OBSERVATION_SUPPORTED);
         EventListener l = null;
         if (Boolean.valueOf(desc).booleanValue()) {
@@ -368,7 +384,7 @@
             try {
                 service.removeEventListener(sessionInfo, service.getRootId(sessionInfo),
externalChangeListener);
             } catch (RepositoryException e) {
-                log.warn("exception while disposing workspace manager: " + e);
+                log.warn("Exception while disposing workspace manager: " + e);
             }
         }
     }

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java?view=diff&rev=452081&r1=452080&r2=452081
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/name/NamespaceRegistryImpl.java
Mon Oct  2 08:38:54 2006
@@ -70,11 +70,14 @@
     private final CachingNamespaceResolver resolver;
     private final NamespaceStorage storage;
 
-    public NamespaceRegistryImpl(NamespaceStorage storage, Properties nsValues) {
+    private final boolean level2Repository;
+
+    public NamespaceRegistryImpl(NamespaceStorage storage, Properties nsValues, boolean level2Repository)
{
         super(true); // enable listener support
         resolver = new CachingNamespaceResolver(this, 1000);
         this.storage = storage;
-	load(nsValues);
+        this.level2Repository = level2Repository;
+        load(nsValues);
     }
 
     private void load(Properties nsValues) {
@@ -93,8 +96,9 @@
      * @see NamespaceRegistry#registerNamespace(String, String)
      */
     public void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException,
RepositoryException {
-        // TODO: UnsupportedRepositoryOperationException in Level1-Repository
-
+        if (!level2Repository) {
+            throw new UnsupportedRepositoryOperationException("Repository is Level1 only.");
+        }
         // perform basic validation checks
         if (prefix == null || uri == null) {
             throw new IllegalArgumentException("prefix/uri can not be null");
@@ -165,7 +169,10 @@
      * @see NamespaceRegistry#unregisterNamespace(String)
      */
     public void unregisterNamespace(String prefix) throws NamespaceException, UnsupportedRepositoryOperationException,
RepositoryException {
-        // TODO: UnsupportedRepositoryOperationException in Level1-Repository
+        if (!level2Repository) {
+            throw new UnsupportedRepositoryOperationException("Repository is Level1 only.");
+        }
+
         if (reservedPrefixes.contains(prefix)) {
             throw new NamespaceException("reserved prefix: " + prefix);
         }



Mime
View raw message