Author: tolusha
Date: 2010-06-11 09:06:51 -0400 (Fri, 11 Jun 2010)
New Revision: 2555
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/util/io/FileCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java
Log:
EXOJCR-756: fix
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-11
11:48:08 UTC (rev 2554)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-06-11
13:06:51 UTC (rev 2555)
@@ -195,7 +195,8 @@
/**
* {@inheritDoc}
*/
- public void configWorkspace(WorkspaceEntry wsConfig) throws
RepositoryConfigurationException, RepositoryException
+ public void configWorkspace(final WorkspaceEntry wsConfig) throws
RepositoryConfigurationException,
+ RepositoryException
{
// Need privileges to manage repository.
SecurityManager security = System.getSecurityManager();
@@ -212,7 +213,38 @@
try
{
- repositoryContainer.registerWorkspace(wsConfig);
+ PrivilegedExceptionAction<Object> action = new
PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ repositoryContainer.registerWorkspace(wsConfig);
+ return null;
+ }
+ };
+ try
+ {
+ AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof RepositoryException)
+ {
+ throw (RepositoryException)cause;
+ }
+ else if (cause instanceof RepositoryConfigurationException)
+ {
+ throw (RepositoryConfigurationException)cause;
+ }
+ else if (cause instanceof RuntimeException)
+ {
+ throw (RuntimeException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
catch (RepositoryConfigurationException e)
{
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java 2010-06-11
11:48:08 UTC (rev 2554)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java 2010-06-11
13:06:51 UTC (rev 2555)
@@ -23,6 +23,8 @@
import org.exoplatform.services.log.Log;
import java.io.File;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
@@ -68,7 +70,16 @@
if (start)
start();
- registerShutdownHook();
+ PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ registerShutdownHook();
+ return null;
+ }
+ };
+ AccessController.doPrivileged(action);
+
if (log.isDebugEnabled())
{
log.debug("FileCleaner instantiated name= " + getName() + "
timeout= " + timeout);
@@ -86,6 +97,7 @@
}
}
+ @Override
public void halt()
{
try
@@ -105,6 +117,7 @@
/**
* @see org.exoplatform.services.jcr.impl.proccess.WorkerThread#callPeriodically()
*/
+ @Override
protected void callPeriodically() throws Exception
{
File file = null;
@@ -142,6 +155,7 @@
{
Runtime.getRuntime().addShutdownHook(new Thread()
{
+ @Override
public void run()
{
File file = null;
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-11
11:48:08 UTC (rev 2554)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/jbosscache/GenericTransactionService.java 2010-06-11
13:06:51 UTC (rev 2555)
@@ -25,6 +25,10 @@
import org.exoplatform.services.transaction.TransactionService;
import org.jboss.cache.transaction.TransactionManagerLookup;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.InvalidTransactionException;
@@ -223,7 +227,7 @@
* Created by The eXo Platform SAS
* Author : Nicolas Filotto
* nicolas.filotto(a)exoplatform.com
- * 1 f�vr. 2010
+ * 1 f�vr. 2010
*/
private static class TransactionManagerTxTimeoutAware implements TransactionManager
{
@@ -280,7 +284,54 @@
public void commit() throws RollbackException, HeuristicMixedException,
HeuristicRollbackException,
SecurityException, IllegalStateException, SystemException
{
- tm.commit();
+ 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);
+ }
+ }
}
/**
Show replies by date