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

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Mar 3 10:27:43 EST 2011


Author: tolusha
Date: 2011-03-03 10:27:43 -0500 (Thu, 03 Mar 2011)
New Revision: 4051

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
Log:
EXOJCR-1159: adopt to  mysql-connector version to 5.1.14

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java	2011-03-03 15:04:31 UTC (rev 4050)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/cas/JDBCValueContentAddressStorageImpl.java	2011-03-03 15:27:43 UTC (rev 4051)
@@ -18,6 +18,7 @@
  */
 package org.exoplatform.services.jcr.impl.storage.value.cas;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
 import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
 import org.exoplatform.services.jcr.impl.storage.jdbc.DialectDetecter;
@@ -155,38 +156,46 @@
 
       try
       {
-         dataSource = (DataSource)new InitialContext().lookup(sn);
+         PrivilegedExceptionAction<DataSource> action = new PrivilegedExceptionAction<DataSource>()
+         {
+            public DataSource run() throws Exception
+            {
+               return (DataSource)new InitialContext().lookup(sn);
+            }
+         };
+         try
+         {
+            dataSource = AccessController.doPrivileged(action);
+         }
+         catch (PrivilegedActionException pae)
+         {
+            Throwable cause = pae.getCause();
+            if (cause instanceof NamingException)
+            {
+               throw (NamingException)cause;
+            }
+            else if (cause instanceof RuntimeException)
+            {
+               throw (RuntimeException)cause;
+            }
+            else
+            {
+               throw new RuntimeException(cause);
+            }
+         }
+         
+
          Connection conn = null;
          Statement st = null;
          try
          {
-            PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+            conn = SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
             {
-               public Object run() throws Exception
+               public Connection run() throws Exception
                {
                   return dataSource.getConnection();
                }
-            };
-            try
-            {
-               conn = (Connection)AccessController.doPrivileged(action);
-            }
-            catch (PrivilegedActionException pae)
-            {
-               Throwable cause = pae.getCause();
-               if (cause instanceof SQLException)
-               {
-                  throw (SQLException)cause;
-               }
-               else if (cause instanceof RuntimeException)
-               {
-                  throw (RuntimeException)cause;
-               }
-               else
-               {
-                  throw new RuntimeException(cause);
-               }
-            }
+            });
 
             DatabaseMetaData dbMetaData = conn.getMetaData();
 



More information about the exo-jcr-commits mailing list