Author: tolusha
Date: 2010-06-15 09:37:48 -0400 (Tue, 15 Jun 2010)
New Revision: 2603
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionsService.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/RepositoryImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-06-15
13:24:09 UTC (rev 2602)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-06-15
13:37:48 UTC (rev 2603)
@@ -45,6 +45,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
@@ -293,7 +294,7 @@
return;
}
- WorkspaceContainer wsContainer =
repositoryContainer.getWorkspaceContainer(workspaceName);
+ final WorkspaceContainer wsContainer =
repositoryContainer.getWorkspaceContainer(workspaceName);
if (wsContainer == null)
throw new RepositoryException("Workspace " + workspaceName
@@ -301,8 +302,17 @@
repositoryContainer.getWorkspaceContainer(workspaceName).getWorkspaceInitializer().initWorkspace();
- wsContainer.start();
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ wsContainer.start();
+ return null;
+ }
+ };
+ AccessController.doPrivileged(action);
+
LOG.info("Workspace " + workspaceName + "@" + this.name +
" is initialized");
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-06-15
13:24:09 UTC (rev 2602)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-06-15
13:37:48 UTC (rev 2603)
@@ -56,7 +56,6 @@
import org.exoplatform.services.naming.InitialContextInitializer;
import org.exoplatform.services.transaction.TransactionService;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
@@ -72,6 +71,7 @@
import java.security.AccessController;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.sql.Connection;
@@ -258,38 +258,28 @@
cache = factory.createCache(config.getLockManager());
- PrivilegedExceptionAction<Object> action = new
PrivilegedExceptionAction<Object>()
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
{
- public Object run() throws Exception
+ public Object run()
{
cache.create();
- // Add the cache loader needed to prevent TimeoutException
- addCacheLoader();
- cache.start();
-
return null;
}
};
- try
+ AccessController.doPrivileged(action);
+
+ // Add the cache loader needed to prevent TimeoutException
+ addCacheLoader();
+
+ action = new PrivilegedAction<Object>()
{
- AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof CacheException)
+ public Object run()
{
- throw (CacheException)cause;
+ cache.start();
+ return null;
}
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
+ };
+ AccessController.doPrivileged(action);
createStructuredNode(lockRoot);
@@ -839,7 +829,16 @@
lockRemover.halt();
lockRemover.interrupt();
sessionLockManagers.clear();
- cache.stop();
+
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ cache.stop();
+ return null;
+ }
+ };
+ AccessController.doPrivileged(action);
}
/**
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-06-15
13:24:09 UTC (rev 2602)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-06-15
13:37:48 UTC (rev 2603)
@@ -36,8 +36,7 @@
import java.io.Serializable;
import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedAction;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -216,34 +215,15 @@
*/
public void create() throws CacheException
{
- PrivilegedExceptionAction<Object> action = new
PrivilegedExceptionAction<Object>()
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
{
- public Object run() throws Exception
+ public Object run()
{
parentCache.create();
return null;
}
};
- try
- {
- AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof CacheException)
- {
- throw (CacheException)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
+ AccessController.doPrivileged(action);
}
/* (non-Javadoc)
@@ -648,34 +628,15 @@
*/
public void start() throws CacheException
{
- PrivilegedExceptionAction<Object> action = new
PrivilegedExceptionAction<Object>()
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
{
- public Object run() throws Exception
+ public Object run()
{
parentCache.start();
return null;
}
};
- try
- {
- AccessController.doPrivileged(action);
- }
- catch (PrivilegedActionException pae)
- {
- Throwable cause = pae.getCause();
- if (cause instanceof CacheException)
- {
- throw (CacheException)cause;
- }
- else if (cause instanceof RuntimeException)
- {
- throw (RuntimeException)cause;
- }
- else
- {
- throw new RuntimeException(cause);
- }
- }
+ AccessController.doPrivileged(action);
}
/* (non-Javadoc)
@@ -691,7 +652,15 @@
*/
public void stop()
{
- parentCache.stop();
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ parentCache.stop();
+ return null;
+ }
+ };
+ AccessController.doPrivileged(action);
}
public TransactionManager getTransactionManager()
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java 2010-06-15
13:24:09 UTC (rev 2602)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java 2010-06-15
13:37:48 UTC (rev 2603)
@@ -77,7 +77,7 @@
public synchronized void acquire(Object holder) throws FileNotFoundException
{
if (users == null)
- throw new FileNotFoundException("File was deleted " +
getAbsolutePath());
+ throw new FileNotFoundException("File was deleted " +
PrivilegedFileHelper.getAbsolutePath(this));
users.put(holder, System.currentTimeMillis());
}
@@ -85,7 +85,7 @@
public synchronized void release(Object holder) throws FileNotFoundException
{
if (users == null)
- throw new FileNotFoundException("File was deleted " +
getAbsolutePath());
+ throw new FileNotFoundException("File was deleted " +
PrivilegedFileHelper.getAbsolutePath(this));
users.remove(holder);
}
@@ -93,7 +93,7 @@
public synchronized boolean inUse() throws FileNotFoundException
{
if (users == null)
- throw new FileNotFoundException("File was deleted " +
getAbsolutePath());
+ throw new FileNotFoundException("File was deleted " +
PrivilegedFileHelper.getAbsolutePath(this));
return users.size() > 0;
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionsService.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionsService.java 2010-06-15
13:24:09 UTC (rev 2602)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/JBossTransactionsService.java 2010-06-15
13:37:48 UTC (rev 2603)
@@ -23,6 +23,9 @@
import org.exoplatform.container.xml.InitParams;
import org.jboss.cache.transaction.TransactionManagerLookup;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
import javax.transaction.UserTransaction;
import javax.transaction.xa.Xid;
@@ -35,15 +38,15 @@
*/
public class JBossTransactionsService extends GenericTransactionService
{
-
+
public JBossTransactionsService(TransactionManagerLookup tmLookup)
{
super(tmLookup);
}
-
+
public JBossTransactionsService(TransactionManagerLookup tmLookup, InitParams params)
{
- super(tmLookup, params);
+ super(tmLookup, params);
}
/**
@@ -61,6 +64,13 @@
@Override
public UserTransaction getUserTransaction()
{
- return com.arjuna.ats.jta.UserTransaction.userTransaction();
+ PrivilegedAction<UserTransaction> action = new
PrivilegedAction<UserTransaction>()
+ {
+ public UserTransaction run()
+ {
+ return com.arjuna.ats.jta.UserTransaction.userTransaction();
+ }
+ };
+ return AccessController.doPrivileged(action);
}
}
Show replies by date