[exo-jcr-commits] exo-jcr SVN: r3987 - core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Feb 18 03:30:00 EST 2011


Author: dkuleshov
Date: 2011-02-18 03:30:00 -0500 (Fri, 18 Feb 2011)
New Revision: 3987

Modified:
   core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
Log:
EXOJCR-1149: added scriptPath loading with ConfigurationManager

Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java	2011-02-18 08:29:15 UTC (rev 3986)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java	2011-02-18 08:30:00 UTC (rev 3987)
@@ -21,6 +21,7 @@
 import org.exoplatform.commons.utils.PrivilegedFileHelper;
 import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.container.configuration.ConfigurationException;
+import org.exoplatform.container.configuration.ConfigurationManager;
 import org.exoplatform.container.xml.InitParams;
 import org.exoplatform.container.xml.PropertiesParam;
 import org.exoplatform.container.xml.Property;
@@ -106,8 +107,10 @@
     * 
     * @param params
     *          Initializations parameters
+    * @configurationManager 
+    *          configuration manager instance          
     */
-   public DBCreator(InitParams params) throws ConfigurationException
+   public DBCreator(InitParams params, ConfigurationManager configurationManager) throws ConfigurationException
    {
       if (params == null)
       {
@@ -162,14 +165,23 @@
          String scriptPath = prop.getProperty(DB_SCRIPT_PATH);
          if (scriptPath != null)
          {
+            String dbScript;
             try
             {
-               dbScript = readScriptResource(scriptPath);
+               dbScript = readScriptResource(configurationManager.getInputStream(scriptPath));
             }
-            catch (IOException e)
+            catch (Exception e)
             {
-               throw new ConfigurationException("Can't read script resource " + scriptPath, e);
+               try
+               {
+                  dbScript = readScriptResource(PrivilegedFileHelper.fileInputStream(scriptPath));
+               }
+               catch (IOException ioe)
+               {
+                  throw new ConfigurationException("Can't read script resource " + scriptPath, e);
+               }
             }
+            this.dbScript = dbScript;
          }
          else
          {
@@ -438,11 +450,10 @@
    }
 
    /**
-    * Read SQL script from file resource.
+    * Read SQL script from {@link InputStream}.
     */
-   protected String readScriptResource(String path) throws IOException
+   protected String readScriptResource(InputStream is) throws IOException
    {
-      InputStream is = PrivilegedFileHelper.fileInputStream(path);
       InputStreamReader isr = new InputStreamReader(is);
       try
       {



More information about the exo-jcr-commits mailing list