Author: tolusha
Date: 2010-06-15 05:58:52 -0400 (Tue, 15 Jun 2010)
New Revision: 2598
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Log:
EXOJCR-756: small refactoring
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java 2010-06-15
09:42:31 UTC (rev 2597)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java 2010-06-15
09:58:52 UTC (rev 2598)
@@ -197,6 +197,8 @@
{
try
{
+ Connection conn = null;
+
PrivilegedExceptionAction<Object> action = new
PrivilegedExceptionAction<Object>()
{
public Object run() throws Exception
@@ -207,15 +209,7 @@
};
try
{
- final Connection conn = (Connection)AccessController.doPrivileged(action);
-
- if (readOnly)
- {
- // set this feature only if it asked
- conn.setReadOnly(readOnly);
- }
-
- return conn;
+ conn = (Connection)AccessController.doPrivileged(action);
}
catch (PrivilegedActionException pae)
{
@@ -233,6 +227,14 @@
throw new RuntimeException(cause);
}
}
+
+ if (readOnly)
+ {
+ // set this feature only if it asked
+ conn.setReadOnly(readOnly);
+ }
+
+ return conn;
}
catch (SQLException e)
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java 2010-06-15
09:42:31 UTC (rev 2597)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java 2010-06-15
09:58:52 UTC (rev 2598)
@@ -31,9 +31,6 @@
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
/**
* Created by The eXo Platform SAS.
@@ -155,46 +152,16 @@
*/
public void unlock() throws IOException
{
+ if (lockFileStream != null)
+ lockFileStream.close();
- PrivilegedExceptionAction<Object> action = new
PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- if (lockFileStream != null)
- lockFileStream.close();
-
- if (!PrivilegedFileHelper.delete(lockFile))
- { // TODO don't use FileCleaner, delete should be enough
- LOG.warn("Cannot delete lock file " +
PrivilegedFileHelper.getAbsolutePath(lockFile)
- + ". Add to the FileCleaner");
- cleaner.addFile(lockFile);
- }
-
- return null;
- }
- };
- try
- {
- AccessController.doPrivileged(action);
+ if (!PrivilegedFileHelper.delete(lockFile))
+ { // TODO don't use FileCleaner, delete should be enough
+ LOG.warn("Cannot delete lock file " +
PrivilegedFileHelper.getAbsolutePath(lockFile)
+ + ". Add to the FileCleaner");
+ cleaner.addFile(lockFile);
}
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof IOException)
- {
- throw (IOException)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
}
-
}
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-15
09:42:31 UTC (rev 2597)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java 2010-06-15
09:58:52 UTC (rev 2598)
@@ -120,14 +120,14 @@
};
final InputStream is = AccessController.doPrivileged(action);
- PrivilegedAction<InputStreamReader> action_ = new
PrivilegedAction<InputStreamReader>()
+ PrivilegedAction<InputStreamReader> actionGetReader = new
PrivilegedAction<InputStreamReader>()
{
public InputStreamReader run()
{
return new InputStreamReader(is);
}
};
- InputStreamReader isr = AccessController.doPrivileged(action_);
+ InputStreamReader isr = AccessController.doPrivileged(actionGetReader);
try
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-06-15
09:42:31 UTC (rev 2597)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-06-15
09:58:52 UTC (rev 2598)
@@ -363,7 +363,42 @@
*/
public void rollback() throws IllegalStateException, SecurityException,
SystemException
{
- tm.rollback();
+ PrivilegedExceptionAction<Object> action = new
PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ tm.rollback();
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof SecurityException)
+ {
+ throw (SecurityException)cause;
+ }
+ else if (cause instanceof IllegalStateException)
+ {
+ throw (IllegalStateException)cause;
+ }
+ else if (cause instanceof SystemException)
+ {
+ throw (SystemException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**