[exo-jcr-commits] exo-jcr SVN: r223 - jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Oct 5 08:20:44 EDT 2009


Author: tolusha
Date: 2009-10-05 08:20:44 -0400 (Mon, 05 Oct 2009)
New Revision: 223

Modified:
   jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
   jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
Log:
EXOJCR-167: revert registerNodeType, addNamespace

Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java	2009-10-05 11:18:42 UTC (rev 222)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java	2009-10-05 12:20:44 UTC (rev 223)
@@ -105,33 +105,19 @@
    private final Log log = ExoLogger.getLogger("jcr.RepositoryContainer");
 
    /**
-    * NodeType plugins list.
-    */
-   private final List<ComponentPlugin> addNodeTypePlugins;
-
-   /**
-    * NameSpace plugins list.
-    */
-   private final List<ComponentPlugin> addNamespacesPlugins;
-
-   /**
     * RepositoryContainer constructor.
     * 
     * @param parent
     *          container
     * @param config
     *          Repository configuration
-    * @param addNodeTypePlugins
-    *          NodeType plugins list
-    * @param addNamespacesPlugins
-    *          NameSpace plugins list
     * @throws RepositoryException
     *           container initialization error
     * @throws RepositoryConfigurationException
     *           configuration error
     */
-   public RepositoryContainer(ExoContainer parent, RepositoryEntry config, List<ComponentPlugin> addNodeTypePlugins,
-      List<ComponentPlugin> addNamespacesPlugins) throws RepositoryException, RepositoryConfigurationException
+   public RepositoryContainer(ExoContainer parent, RepositoryEntry config) throws RepositoryException,
+      RepositoryConfigurationException
    {
 
       super(new MX4JComponentAdapterFactory(), parent);
@@ -141,8 +127,6 @@
          config.setAccessControl(AccessControlPolicy.OPTIONAL);
 
       this.config = config;
-      this.addNamespacesPlugins = addNamespacesPlugins;
-      this.addNodeTypePlugins = addNodeTypePlugins;
 
       registerComponents();
    }
@@ -505,101 +489,6 @@
       registerRepositoryComponents();
    }
 
-   private void addNamespaces() throws RepositoryException
-   {
-      NamespaceRegistry nsRegistry = (NamespaceRegistry)this.getComponentInstanceOfType(NamespaceRegistryImpl.class);
-      this.getComponentInstanceOfType(IdGenerator.class);
-
-      for (int j = 0; j < addNamespacesPlugins.size(); j++)
-      {
-         AddNamespacesPlugin plugin = (AddNamespacesPlugin)addNamespacesPlugins.get(j);
-         Map<String, String> namespaces = plugin.getNamespaces();
-         try
-         {
-            for (Map.Entry<String, String> namespace : namespaces.entrySet())
-            {
-
-               String prefix = namespace.getKey();
-               String uri = namespace.getValue();
-
-               // register namespace if not found
-               try
-               {
-                  nsRegistry.getURI(prefix);
-               }
-               catch (NamespaceException e)
-               {
-                  nsRegistry.registerNamespace(prefix, uri);
-               }
-               if (log.isDebugEnabled())
-                  log.debug("Namespace is registered " + prefix + " = " + uri);
-            }
-         }
-         catch (Exception e)
-         {
-            log.error("Error load namespaces ", e);
-         }
-      }
-   }
-
-   private void registerNodeTypes() throws RepositoryException
-   {
-      ConfigurationManager configService =
-         (ConfigurationManager)this.getParent().getComponentInstanceOfType(ConfigurationManager.class);
-
-      NodeTypeDataManagerImpl ntManager =
-         (NodeTypeDataManagerImpl)this.getComponentInstanceOfType(NodeTypeDataManagerImpl.class);
-      //
-      for (int j = 0; j < addNodeTypePlugins.size(); j++)
-      {
-         AddNodeTypePlugin plugin = (AddNodeTypePlugin)addNodeTypePlugins.get(j);
-         List<String> autoNodeTypesFiles = plugin.getNodeTypesFiles(AddNodeTypePlugin.AUTO_CREATED);
-         if (autoNodeTypesFiles != null && autoNodeTypesFiles.size() > 0)
-         {
-            for (String nodeTypeFilesName : autoNodeTypesFiles)
-            {
-
-               InputStream inXml;
-               try
-               {
-                  inXml = configService.getInputStream(nodeTypeFilesName);
-               }
-               catch (Exception e)
-               {
-                  throw new RepositoryException(e);
-               }
-               if (log.isDebugEnabled())
-                  log.debug("Trying register node types from xml-file " + nodeTypeFilesName);
-               ntManager.registerNodeTypes(inXml, ExtendedNodeTypeManager.IGNORE_IF_EXISTS,
-                  NodeTypeDataManager.TEXT_XML);
-               if (log.isDebugEnabled())
-                  log.debug("Node types is registered from xml-file " + nodeTypeFilesName);
-            }
-            List<String> defaultNodeTypesFiles = plugin.getNodeTypesFiles(this.getName());
-            if (defaultNodeTypesFiles != null && defaultNodeTypesFiles.size() > 0)
-            {
-               for (String nodeTypeFilesName : defaultNodeTypesFiles)
-               {
-
-                  InputStream inXml;
-                  try
-                  {
-                     inXml = configService.getInputStream(nodeTypeFilesName);
-                  }
-                  catch (Exception e)
-                  {
-                     throw new RepositoryException(e);
-                  }
-                  log.info("Trying register node types (" + this.getName() + ") from xml-file " + nodeTypeFilesName);
-                  ntManager.registerNodeTypes(inXml, ExtendedNodeTypeManager.IGNORE_IF_EXISTS,
-                     NodeTypeDataManager.TEXT_XML);
-                  log.info("Node types is registered (" + this.getName() + ") from xml-file " + nodeTypeFilesName);
-               }
-            }
-         }
-      }
-   }
-
    private void registerRepositoryComponents() throws RepositoryConfigurationException, RepositoryException
    {
 
@@ -611,20 +500,13 @@
       registerComponentImplementation(LocationFactory.class);
       registerComponentImplementation(ValueFactoryImpl.class);
 
-
       registerComponentImplementation(JcrNodeTypeDataPersister.class);
       registerComponentImplementation(NamespaceDataPersister.class);
       registerComponentImplementation(NamespaceRegistryImpl.class);
 
       registerComponentImplementation(NodeTypeManagerImpl.class);
       registerComponentImplementation(NodeTypeDataManagerImpl.class);
-      
-      
-      //node types first
-      addNamespaces();
-      registerNodeTypes();
-      
-      
+
       registerComponentImplementation(DefaultAccessManagerImpl.class);
 
       registerComponentImplementation(SessionRegistry.class);

Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java	2009-10-05 11:18:42 UTC (rev 222)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java	2009-10-05 12:20:44 UTC (rev 223)
@@ -145,8 +145,7 @@
       if (repositoryContainers.containsKey(rEntry.getName()))
          throw new RepositoryConfigurationException("Repository container " + rEntry.getName() + " already started");
 
-      RepositoryContainer repositoryContainer =
-         new RepositoryContainer(parentContainer, rEntry, addNodeTypePlugins, addNamespacesPlugins);
+      RepositoryContainer repositoryContainer = new RepositoryContainer(parentContainer, rEntry);
 
       // Storing and starting the repository container under
       // key=repository_name
@@ -159,7 +158,8 @@
          config.getRepositoryConfigurations().add(rEntry);
       }
 
-      // registration Namespaces and NodeTypes moved to RepositoryContainer [AB]
+      addNamespaces(rEntry.getName());
+      registerNodeTypes(rEntry.getName());
 
       // turn on Repository ONLINE
       ManageableRepository mr =
@@ -283,6 +283,53 @@
       managerStartChanges.cleanup();
    }
 
+   private void addNamespaces() throws RepositoryException
+   {
+
+      for (RepositoryEntry repoConfig : config.getRepositoryConfigurations())
+      {
+         addNamespaces(repoConfig.getName());
+      }
+   }
+
+   private void addNamespaces(String repositoryName) throws RepositoryException
+   {
+
+      ManageableRepository repository = getRepository(repositoryName);
+      NamespaceRegistry nsRegistry = repository.getNamespaceRegistry();
+
+      for (int j = 0; j < addNamespacesPlugins.size(); j++)
+      {
+         AddNamespacesPlugin plugin = (AddNamespacesPlugin)addNamespacesPlugins.get(j);
+         Map<String, String> namespaces = plugin.getNamespaces();
+         try
+         {
+            for (Map.Entry<String, String> namespace : namespaces.entrySet())
+            {
+
+               String prefix = namespace.getKey();
+               String uri = namespace.getValue();
+
+               // register namespace if not found
+               try
+               {
+                  nsRegistry.getURI(prefix);
+               }
+               catch (NamespaceException e)
+               {
+                  nsRegistry.registerNamespace(prefix, uri);
+               }
+               if (log.isDebugEnabled())
+                  log.debug("Namespace is registered " + prefix + " = " + uri);
+            }
+         }
+         catch (Exception e)
+         {
+            log.error("Error load namespaces ", e);
+         }
+      }
+   }
+
    private void init(ExoContainer container) throws RepositoryConfigurationException, RepositoryException
    {
       this.parentContainer = container;
@@ -295,6 +342,69 @@
       }
    }
 
+   private void registerNodeTypes() throws RepositoryException
+   {
+      for (RepositoryEntry repoConfig : config.getRepositoryConfigurations())
+      {
+         registerNodeTypes(repoConfig.getName());
+      }
+   }
+
+   private void registerNodeTypes(String repositoryName) throws RepositoryException
+   {
+      ConfigurationManager configService =
+         (ConfigurationManager)parentContainer.getComponentInstanceOfType(ConfigurationManager.class);
+
+      ExtendedNodeTypeManager ntManager = getRepository(repositoryName).getNodeTypeManager();
+      //
+      for (int j = 0; j < addNodeTypePlugins.size(); j++)
+      {
+         AddNodeTypePlugin plugin = (AddNodeTypePlugin)addNodeTypePlugins.get(j);
+         List<String> autoNodeTypesFiles = plugin.getNodeTypesFiles(AddNodeTypePlugin.AUTO_CREATED);
+         if (autoNodeTypesFiles != null && autoNodeTypesFiles.size() > 0)
+         {
+            for (String nodeTypeFilesName : autoNodeTypesFiles)
+            {
+
+               InputStream inXml;
+               try
+               {
+                  inXml = configService.getInputStream(nodeTypeFilesName);
+               }
+               catch (Exception e)
+               {
+                  throw new RepositoryException(e);
+               }
+               if (log.isDebugEnabled())
+                  log.debug("Trying register node types from xml-file " + nodeTypeFilesName);
+               ntManager.registerNodeTypes(inXml, ExtendedNodeTypeManager.IGNORE_IF_EXISTS);
+               if (log.isDebugEnabled())
+                  log.debug("Node types is registered from xml-file " + nodeTypeFilesName);
+            }
+            List<String> defaultNodeTypesFiles = plugin.getNodeTypesFiles(repositoryName);
+            if (defaultNodeTypesFiles != null && defaultNodeTypesFiles.size() > 0)
+            {
+               for (String nodeTypeFilesName : defaultNodeTypesFiles)
+               {
+
+                  InputStream inXml;
+                  try
+                  {
+                     inXml = configService.getInputStream(nodeTypeFilesName);
+                  }
+                  catch (Exception e)
+                  {
+                     throw new RepositoryException(e);
+                  }
+                  log.info("Trying register node types (" + repositoryName + ") from xml-file " + nodeTypeFilesName);
+                  ntManager.registerNodeTypes(inXml, ExtendedNodeTypeManager.IGNORE_IF_EXISTS);
+                  log.info("Node types is registered (" + repositoryName + ") from xml-file " + nodeTypeFilesName);
+               }
+            }
+         }
+      }
+   }
+
    /**
     * Manager start changes plugins.
     */



More information about the exo-jcr-commits mailing list