[exo-jcr-commits] exo-jcr SVN: r2651 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services: jcr/impl/dataflow/persistent and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Jun 17 05:29:12 EDT 2010
Author: tolusha
Date: 2010-06-17 05:29:12 -0400 (Thu, 17 Jun 2010)
New Revision: 2651
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Log:
EXOJCR-756: replace operations on privileged operations
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java 2010-06-17 09:24:40 UTC (rev 2650)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java 2010-06-17 09:29:12 UTC (rev 2651)
@@ -29,6 +29,9 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.List;
import java.util.Map;
@@ -55,17 +58,17 @@
* The nested cache loader
*/
private final CacheLoader cl;
-
+
/**
* The related cache
*/
private CacheSPI cache;
-
+
/**
* The configuration of the current cache loader
*/
private IndividualCacheLoaderConfig config;
-
+
/**
* The default constructor
* @param cl the cache loader that will be managed by the controller
@@ -73,14 +76,38 @@
public ControllerCacheLoader(CacheLoader cl)
{
this.cl = cl;
- }
+ }
/**
* @see org.jboss.cache.loader.CacheLoader#commit(java.lang.Object)
*/
- public void commit(Object tx) throws Exception
+ public void commit(final Object tx) throws Exception
{
- cl.commit(tx);
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ cl.commit(tx);
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+
+ if (cause instanceof Exception)
+ {
+ throw (Exception)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**
@@ -96,13 +123,13 @@
if (node != null)
{
// The node already exists in the local cache, so we return true
- return true;
+ return true;
}
else
{
// The node doesn't exist in the local cache, so we need to check through the nested
// cache loader
- return cl.exists(name);
+ return cl.exists(name);
}
}
// All the data is loaded at startup, so no need to call the nested cache loader for another
@@ -123,13 +150,13 @@
if (node != null)
{
// The node already exists in the local cache, so we return the corresponding data
- return node.getDataDirect();
+ return node.getDataDirect();
}
else
{
// The node doesn't exist in the local cache, so we need to check through the nested
// cache loader
- return cl.get(name);
+ return cl.get(name);
}
}
// All the data is loaded at startup, so no need to call the nested cache loader for another
@@ -145,11 +172,11 @@
if (cache.getCacheStatus() == CacheStatus.STARTING)
{
// Try to get the list of children name from the nested cache loader
- return cl.getChildrenNames(fqn);
+ return cl.getChildrenNames(fqn);
}
// All the data is loaded at startup, so no need to call the nested cache loader for another
// cache status other than CacheStatus.STARTING
- return null;
+ return null;
}
/**
@@ -179,9 +206,34 @@
/**
* @see org.jboss.cache.loader.CacheLoader#prepare(java.lang.Object, java.util.List, boolean)
*/
- public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
+ public void prepare(final Object tx, final List<Modification> modifications, final boolean onePhase)
+ throws Exception
{
- cl.prepare(tx, modifications, onePhase);
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ cl.prepare(tx, modifications, onePhase);
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+
+ if (cause instanceof Exception)
+ {
+ throw (Exception)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
/**
@@ -205,14 +257,14 @@
*/
public Object put(final Fqn name, final Object key, final Object value) throws Exception
{
-
+
return SecurityHelper.doPriviledgedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
{
- public Object run() throws Exception
- {
- return cl.put(name, key, value);
- }
- });
+ return cl.put(name, key, value);
+ }
+ });
}
/**
@@ -242,9 +294,17 @@
/**
* @see org.jboss.cache.loader.CacheLoader#rollback(java.lang.Object)
*/
- public void rollback(Object tx)
+ public void rollback(final Object tx)
{
- cl.rollback(tx);
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ cl.rollback(tx);
+ return null;
+ }
+ };
+ AccessController.doPrivileged(action);
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java 2010-06-17 09:24:40 UTC (rev 2650)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TxIsolatedOperation.java 2010-06-17 09:29:12 UTC (rev 2651)
@@ -4,6 +4,10 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
import javax.jcr.InvalidItemStateException;
import javax.jcr.ItemExistsException;
import javax.jcr.RepositoryException;
@@ -49,12 +53,94 @@
protected void commitTx() throws SecurityException, IllegalStateException, RollbackException,
HeuristicMixedException, HeuristicRollbackException, SystemException
{
- txManager.commit(); // commit global tx
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ txManager.commit(); // commit global tx
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof RollbackException)
+ {
+ throw (RollbackException)cause;
+ }
+ else if (cause instanceof HeuristicMixedException)
+ {
+ throw (HeuristicMixedException)cause;
+ }
+ else if (cause instanceof HeuristicRollbackException)
+ {
+ throw (HeuristicRollbackException)cause;
+ }
+ else 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);
+ }
+ }
}
protected void rollbackTx() throws NotSupportedException, SystemException
{
- txManager.rollback(); // rollback global tx
+ PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ txManager.rollback(); // rollback global tx
+ 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);
+ }
+ }
}
/**
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-17 09:24:40 UTC (rev 2650)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-06-17 09:29:12 UTC (rev 2651)
@@ -356,54 +356,7 @@
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
SecurityException, IllegalStateException, SystemException
{
- PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- tm.commit();
- return null;
- }
- };
- try
- {
- AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof RollbackException)
- {
- throw (RollbackException)cause;
- }
- else if (cause instanceof HeuristicMixedException)
- {
- throw (HeuristicMixedException)cause;
- }
- else if (cause instanceof HeuristicRollbackException)
- {
- throw (HeuristicRollbackException)cause;
- }
- else 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);
- }
- }
+ tm.commit();
}
/**
@@ -435,42 +388,7 @@
*/
public void rollback() throws IllegalStateException, SecurityException, SystemException
{
- 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);
- }
- }
+ tm.rollback();
}
/**
More information about the exo-jcr-commits
mailing list