[exo-jcr-commits] exo-jcr SVN: r4455 - in jcr/trunk: exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl and 24 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue May 31 02:54:07 EDT 2011


Author: dkuleshov
Date: 2011-05-31 02:54:06 -0400 (Tue, 31 May 2011)
New Revision: 4455

Modified:
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/InternalQName.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
   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/infinispan/ISPNCacheableLockManagerImpl.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/core/lock/jbosscache/ControllerCacheLoader.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/XmlNodeTypeDataPersister.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/LocalIndexChangesFilter.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RedoLog.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.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/dataflow/serialization/SerializationSpoolFile.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
   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/HSQLDBMultiDbJDBCConnection.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.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/io/FileCleaner.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/jcr/impl/util/io/SwapFile.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/jcr/infinispan/ISPNCacheFactory.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/PrivilegedISPNCacheHelper.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/PrivilegedJBossCacheHelper.java
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/ActionNonTxAware.java
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyClassLoaderProvider.java
   jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java
   jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java
Log:
EXOJCR-1365: reworkerd source code to improve performance

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/InternalQName.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/InternalQName.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/InternalQName.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -40,14 +40,9 @@
     */
    public InternalQName(String namespace, String name)
    {
-      super(safeIntern(namespace), name);
+      super(namespace, name);
    }
 
-   private static String safeIntern(String s)
-   {
-      return s != null ? s.intern() : null;
-   }
-
    /**
     * Parse qname in form of eXo-JCR names conversion string. E.g. [name_space]item_name,
     * [http://www.jcp.org/jcr/nt/1.0]:base.

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -69,6 +69,8 @@
 import org.exoplatform.services.log.Log;
 
 import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.List;
 
 import javax.jcr.NamespaceRegistry;
@@ -268,16 +270,16 @@
 
       try
       {
-         final boolean isSystem = config.getSystemWorkspaceName().equals(wsConfig.getName());
-
-         if (getWorkspaceContainer(wsConfig.getName()) != null)
-            throw new RepositoryException("Workspace " + wsConfig.getName() + " already registered");
-
-         final WorkspaceContainer workspaceContainer = new WorkspaceContainer(this, wsConfig);
-         SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
+         SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
          {
-            public Void run()
+            public Void run() throws RepositoryException, RepositoryConfigurationException
             {
+               final boolean isSystem = config.getSystemWorkspaceName().equals(wsConfig.getName());
+
+               if (getWorkspaceContainer(wsConfig.getName()) != null)
+                  throw new RepositoryException("Workspace " + wsConfig.getName() + " already registered");
+
+               final WorkspaceContainer workspaceContainer = new WorkspaceContainer(RepositoryContainer.this, wsConfig);
                registerComponentInstance(wsConfig.getName(), workspaceContainer);
 
                wsConfig.setUniqueName(getName() + "_" + wsConfig.getName());
@@ -285,35 +287,21 @@
                workspaceContainer.registerComponentInstance(wsConfig);
 
                workspaceContainer.registerComponentImplementation(StandaloneStoragePluginProvider.class);
-               return null;
-            }
-         });
-         try
-         {
-            final Class<?> containerType = Class.forName(wsConfig.getContainer().getType());
-            SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
-            {
-               public Void run()
+               try
                {
+                  final Class<?> containerType = Class.forName(wsConfig.getContainer().getType());
                   workspaceContainer.registerComponentImplementation(containerType);
                   if (isSystem)
                   {
                      registerComponentInstance(new SystemDataContainerHolder((WorkspaceDataContainer)workspaceContainer
                         .getComponentInstanceOfType(WorkspaceDataContainer.class)));
                   }
-                  return null;
                }
-            });
-         }
-         catch (ClassNotFoundException e)
-         {
-            throw new RepositoryConfigurationException("Class not found for workspace data container "
-               + wsConfig.getUniqueName() + " : " + e);
-         }
-         SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
-         {
-            public Void run()
-            {
+               catch (ClassNotFoundException e)
+               {
+                  throw new RepositoryConfigurationException("Class not found for workspace data container "
+                     + wsConfig.getUniqueName() + " : " + e);
+               }
                // cache type
                try
                {
@@ -335,68 +323,40 @@
                workspaceContainer.registerComponentImplementation(CacheableWorkspaceDataManager.class);
                workspaceContainer.registerComponentImplementation(LocalWorkspaceDataManagerStub.class);
                workspaceContainer.registerComponentImplementation(ObservationManagerRegistry.class);
-               return null;
-            }
-         });
 
-         // Lock manager and Lock persister is a optional parameters
-         if (wsConfig.getLockManager() != null && wsConfig.getLockManager().getPersister() != null)
-         {
-            try
-            {
-               final Class<?> lockPersister = Class.forName(wsConfig.getLockManager().getPersister().getType());
-               SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
+               // Lock manager and Lock persister is a optional parameters
+               if (wsConfig.getLockManager() != null && wsConfig.getLockManager().getPersister() != null)
                {
-                  public Void run()
+                  try
                   {
+                     final Class<?> lockPersister = Class.forName(wsConfig.getLockManager().getPersister().getType());
                      workspaceContainer.registerComponentImplementation(lockPersister);
-                     return null;
                   }
-               });
-            }
-            catch (ClassNotFoundException e)
-            {
-               throw new RepositoryConfigurationException("Class not found for workspace lock persister "
-                  + wsConfig.getLockManager().getPersister().getType() + ", container " + wsConfig.getUniqueName()
-                  + " : " + e);
-            }
-         }
+                  catch (ClassNotFoundException e)
+                  {
+                     throw new RepositoryConfigurationException("Class not found for workspace lock persister "
+                        + wsConfig.getLockManager().getPersister().getType() + ", container " + wsConfig.getUniqueName()
+                        + " : " + e);
+                  }
+               }
 
-         if (wsConfig.getLockManager() != null && wsConfig.getLockManager().getType() != null)
-         {
-            try
-            {
-               final Class<?> lockManagerType = Class.forName(wsConfig.getLockManager().getType());
-               SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
+               if (wsConfig.getLockManager() != null && wsConfig.getLockManager().getType() != null)
                {
-                  public Void run()
+                  try
                   {
+                     final Class<?> lockManagerType = Class.forName(wsConfig.getLockManager().getType());
                      workspaceContainer.registerComponentImplementation(lockManagerType);
-                     return null;
                   }
-               });
-            }
-            catch (ClassNotFoundException e)
-            {
-               throw new RepositoryConfigurationException("Class not found for workspace lock manager "
-                  + wsConfig.getLockManager().getType() + ", container " + wsConfig.getUniqueName() + " : " + e);
-            }
-         }
-         else
-         {
-            SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
-            {
-               public Void run()
+                  catch (ClassNotFoundException e)
+                  {
+                     throw new RepositoryConfigurationException("Class not found for workspace lock manager "
+                        + wsConfig.getLockManager().getType() + ", container " + wsConfig.getUniqueName() + " : " + e);
+                  }
+               }
+               else
                {
                   workspaceContainer.registerComponentImplementation(LockManagerImpl.class);
-                  return null;
                }
-            });
-         }
-         SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
-         {
-            public Void run()
-            {
                // Query handler
                if (wsConfig.getQueryHandler() != null)
                {
@@ -409,109 +369,105 @@
                      workspaceContainer.registerComponentImplementation(SystemSearchManager.class);
                   }
                }
-               return null;
-            }
-         });
 
-         // access manager
-         if (wsConfig.getAccessManager() != null && wsConfig.getAccessManager().getType() != null)
-         {
-            try
-            {
-               final Class<?> am = Class.forName(wsConfig.getAccessManager().getType());
-               SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
+               // access manager
+               if (wsConfig.getAccessManager() != null && wsConfig.getAccessManager().getType() != null)
                {
-                  public Void run()
+                  try
                   {
+                     final Class<?> am = Class.forName(wsConfig.getAccessManager().getType());
                      workspaceContainer.registerComponentImplementation(am);
-                     return null;
                   }
-               });
-            }
-            catch (ClassNotFoundException e)
-            {
-               throw new RepositoryConfigurationException("Class not found for workspace access manager "
-                  + wsConfig.getAccessManager().getType() + ", container " + wsConfig.getUniqueName() + " : " + e);
-            }
-         }
+                  catch (ClassNotFoundException e)
+                  {
+                     throw new RepositoryConfigurationException("Class not found for workspace access manager "
+                        + wsConfig.getAccessManager().getType() + ", container " + wsConfig.getUniqueName() + " : " + e);
+                  }
+               }
 
-         // initializer
-         final Class<?> initilizerType;
-         if (wsConfig.getInitializer() != null && wsConfig.getInitializer().getType() != null)
-         {
-            // use user defined
-            try
-            {
-               initilizerType = Class.forName(wsConfig.getInitializer().getType());
-            }
-            catch (ClassNotFoundException e)
-            {
-               throw new RepositoryConfigurationException("Class not found for workspace initializer "
-                  + wsConfig.getInitializer().getType() + ", container " + wsConfig.getUniqueName() + " : " + e);
-            }
-         }
-         else
-         {
-            // use default
-            initilizerType = ScratchWorkspaceInitializer.class;
-         }
-         SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
-         {
-            public Void run()
-            {
+               // initializer
+               final Class<?> initilizerType;
+               if (wsConfig.getInitializer() != null && wsConfig.getInitializer().getType() != null)
+               {
+                  // use user defined
+                  try
+                  {
+                     initilizerType = Class.forName(wsConfig.getInitializer().getType());
+                  }
+                  catch (ClassNotFoundException e)
+                  {
+                     throw new RepositoryConfigurationException("Class not found for workspace initializer "
+                        + wsConfig.getInitializer().getType() + ", container " + wsConfig.getUniqueName() + " : " + e);
+                  }
+               }
+               else
+               {
+                  // use default
+                  initilizerType = ScratchWorkspaceInitializer.class;
+               }
                workspaceContainer.registerComponentImplementation(initilizerType);
                workspaceContainer.registerComponentImplementation(TransactionableResourceManager.class);
                workspaceContainer.registerComponentImplementation(SessionFactory.class);
-               return null;
-            }
-         });         
-         final LocalWorkspaceDataManagerStub wsDataManager =
-            (LocalWorkspaceDataManagerStub)workspaceContainer
-               .getComponentInstanceOfType(LocalWorkspaceDataManagerStub.class);
+               final LocalWorkspaceDataManagerStub wsDataManager =
+                  (LocalWorkspaceDataManagerStub)workspaceContainer
+                     .getComponentInstanceOfType(LocalWorkspaceDataManagerStub.class);
 
-         if (isSystem)
-         {
-            // system workspace
-            systemDataManager = wsDataManager;
-            SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
-            {
-               public Void run()
+               if (isSystem)
                {
+                  // system workspace
+                  systemDataManager = wsDataManager;
                   registerComponentInstance(systemDataManager);
-                  return null;
                }
-            });
-         }
 
-         wsDataManager.setSystemDataManager(systemDataManager);
+               wsDataManager.setSystemDataManager(systemDataManager);
 
-         if (!config.getWorkspaceEntries().contains(wsConfig))
-            config.getWorkspaceEntries().add(wsConfig);
+               if (!config.getWorkspaceEntries().contains(wsConfig))
+                  config.getWorkspaceEntries().add(wsConfig);
+               return null;
+            }
+         });
 
       }
-      catch (RuntimeException e)
+      catch (PrivilegedActionException pae)
       {
-         int depth = 0;
-         Throwable retval = e;
-         while (retval.getCause() != null && depth < 100)
+         Throwable cause = pae.getCause();
+         if (cause instanceof RepositoryConfigurationException)
          {
-            retval = retval.getCause();
-            if (retval instanceof RepositoryException)
+            throw (RepositoryConfigurationException)cause;
+         }
+         else if (cause instanceof RepositoryException)
+         {
+            throw (RepositoryException)cause;
+         }
+         else if (cause instanceof RuntimeException)
+         {
+            RuntimeException e = (RuntimeException)cause;
+            int depth = 0;
+            Throwable retval = e;
+            while (retval.getCause() != null && depth < 100)
             {
-               throw new RepositoryException(retval.getMessage(), e);
+               retval = retval.getCause();
+               if (retval instanceof RepositoryException)
+               {
+                  throw new RepositoryException(retval.getMessage(), e);
+               }
+               else if (retval instanceof RepositoryConfigurationException)
+               {
+                  throw new RepositoryConfigurationException(retval.getMessage(), e);
+               }
+               else if (retval instanceof NameNotFoundException)
+               {
+                  throw new RepositoryException(retval.getMessage(), e);
+               }
+               depth++;
             }
-            else if (retval instanceof RepositoryConfigurationException)
-            {
-               throw new RepositoryConfigurationException(retval.getMessage(), e);
-            }
-            else if (retval instanceof NameNotFoundException)
-            {
-               throw new RepositoryException(retval.getMessage(), e);
-            }
-            depth++;
+            throw e;            
          }
-         throw e;
-      }
+         else
+         {
+            throw new RepositoryException(cause);
+         }
+      }      
    }
 
    // Components access methods -------
@@ -636,73 +592,77 @@
 
    private void registerRepositoryComponents() throws RepositoryConfigurationException, RepositoryException
    {
-      SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
+      try
       {
-         public Void run()
+         SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
          {
+            public Void run() throws RepositoryConfigurationException, RepositoryException
+            {
 
-            registerComponentImplementation(RepositorySuspendController.class);
-            registerComponentImplementation(IdGenerator.class);
+               registerComponentImplementation(RepositorySuspendController.class);
+               registerComponentImplementation(IdGenerator.class);
 
-            registerComponentImplementation(RepositoryIndexSearcherHolder.class);
+               registerComponentImplementation(RepositoryIndexSearcherHolder.class);
 
-            registerComponentImplementation(LocationFactory.class);
-            registerComponentImplementation(ValueFactoryImpl.class);
+               registerComponentImplementation(LocationFactory.class);
+               registerComponentImplementation(ValueFactoryImpl.class);
 
-            registerComponentInstance(new AddNamespacePluginHolder(addNamespacePlugins));
+               registerComponentInstance(new AddNamespacePluginHolder(addNamespacePlugins));
 
-            registerComponentImplementation(JCRNodeTypeDataPersister.class);
-            registerComponentImplementation(NamespaceDataPersister.class);
-            registerComponentImplementation(NamespaceRegistryImpl.class);
+               registerComponentImplementation(JCRNodeTypeDataPersister.class);
+               registerComponentImplementation(NamespaceDataPersister.class);
+               registerComponentImplementation(NamespaceRegistryImpl.class);
 
-            registerComponentImplementation(NodeTypeManagerImpl.class);
-            registerComponentImplementation(NodeTypeDataManagerImpl.class);
+               registerComponentImplementation(NodeTypeManagerImpl.class);
+               registerComponentImplementation(NodeTypeDataManagerImpl.class);
 
-            registerComponentImplementation(DefaultAccessManagerImpl.class);
+               registerComponentImplementation(DefaultAccessManagerImpl.class);
 
-            registerComponentImplementation(SessionRegistry.class);
+               registerComponentImplementation(SessionRegistry.class);
 
-            String systemWsname = config.getSystemWorkspaceName();
-            WorkspaceEntry systemWsEntry = getWorkspaceEntry(systemWsname);
+               String systemWsname = config.getSystemWorkspaceName();
+               WorkspaceEntry systemWsEntry = getWorkspaceEntry(systemWsname);
 
-            if (systemWsEntry != null && systemWsEntry.getQueryHandler() != null)
-            {
-               SystemSearchManager systemSearchManager =
-                  (SystemSearchManager)getWorkspaceContainer(systemWsname).getComponentInstanceOfType(
-                     SystemSearchManager.class);
-               registerComponentInstance(new SystemSearchManagerHolder(systemSearchManager));
-            }
-            return null;
-         }
-      });
+               if (systemWsEntry != null && systemWsEntry.getQueryHandler() != null)
+               {
+                  SystemSearchManager systemSearchManager =
+                     (SystemSearchManager)getWorkspaceContainer(systemWsname).getComponentInstanceOfType(
+                        SystemSearchManager.class);
+                  registerComponentInstance(new SystemSearchManagerHolder(systemSearchManager));
+               }
+               try
+               {
+                  final Class<?> authenticationPolicyClass = Class.forName(config.getAuthenticationPolicy());
+                  registerComponentImplementation(authenticationPolicyClass);
+               }
+               catch (ClassNotFoundException e)
+               {
+                  throw new RepositoryConfigurationException("Class not found for repository authentication policy: " + e);
+               }
 
-      try
-      {
-         final Class<?> authenticationPolicyClass = Class.forName(config.getAuthenticationPolicy());
-         SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
-         {
-            public Void run()
-            {
-               registerComponentImplementation(authenticationPolicyClass);
+               // Repository
+               final RepositoryImpl repository = new RepositoryImpl(RepositoryContainer.this);
+               registerComponentInstance(repository);
                return null;
             }
          });
       }
-      catch (ClassNotFoundException e)
+      catch (PrivilegedActionException pae)
       {
-         throw new RepositoryConfigurationException("Class not found for repository authentication policy: " + e);
-      }
-
-      // Repository
-      final RepositoryImpl repository = new RepositoryImpl(this);
-      SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
-      {
-         public Void run()
+         Throwable cause = pae.getCause();
+         if (cause instanceof RepositoryConfigurationException)
          {
-            registerComponentInstance(repository);
-            return null;
+            throw (RepositoryConfigurationException)cause;
          }
-      });
+         else if (cause instanceof RepositoryException)
+         {
+            throw (RepositoryException)cause;
+         }
+         else
+         {
+            throw new RepositoryException(cause);
+         }
+      }
    }
 
    private void registerWorkspacesComponents() throws RepositoryException, RepositoryConfigurationException

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	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -48,7 +48,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -597,7 +596,7 @@
       };
       try
       {
-         state = AccessController.doPrivileged(action);
+         state = SecurityHelper.doPrivilegedExceptionAction(action);
       }
       catch (PrivilegedActionException pae)
       {

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/infinispan/ISPNCacheableLockManagerImpl.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -17,6 +17,7 @@
  */
 package org.exoplatform.services.jcr.impl.core.lock.infinispan;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.container.configuration.ConfigurationManager;
 import org.exoplatform.management.annotations.Managed;
 import org.exoplatform.management.jmx.annotations.NameTemplate;
@@ -41,7 +42,6 @@
 import org.infinispan.lifecycle.ComponentStatus;
 
 import java.io.Serializable;
-import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
@@ -233,7 +233,7 @@
                };
                try
                {
-                  jdbcConn = AccessController.doPrivileged(action);
+                  jdbcConn = SecurityHelper.doPrivilegedExceptionAction(action);
                }
                catch (PrivilegedActionException pae)
                {

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	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -52,7 +52,6 @@
 import org.jboss.cache.lock.TimeoutException;
 
 import java.io.Serializable;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -337,7 +336,7 @@
                };
                try
                {
-                  jdbcConn = AccessController.doPrivileged(action);
+                  jdbcConn = SecurityHelper.doPrivilegedExceptionAction(action);
                }
                catch (PrivilegedActionException pae)
                {
@@ -602,7 +601,7 @@
                return cache.getRoot().addChild(fqn);
             }
          };
-         node = AccessController.doPrivileged(action);
+         node = SecurityHelper.doPrivilegedAction(action);
       }
       node.setResident(true);
    }

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	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/ControllerCacheLoader.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -16,7 +16,6 @@
  */
 package org.exoplatform.services.jcr.impl.core.lock.jbosscache;
 
-import org.exoplatform.commons.utils.SecurityHelper;
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.CacheStatus;
 import org.jboss.cache.Fqn;
@@ -29,10 +28,6 @@
 
 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;
 import java.util.Set;
@@ -83,31 +78,7 @@
     */
    public void commit(final Object tx) throws Exception
    {
-      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);
-         }
-      }
+      cl.commit(tx);
    }
 
    /**
@@ -202,31 +173,7 @@
    public void prepare(final Object tx, final List<Modification> modifications, final boolean onePhase)
       throws Exception
    {
-      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);
-         }
-      }
+      cl.prepare(tx, modifications, onePhase);
    }
 
    /**
@@ -234,14 +181,7 @@
     */
    public void put(final List<Modification> modifications) throws Exception
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>()
-      {
-         public Void run() throws Exception
-         {
-            cl.put(modifications);
-            return null;
-         }
-      });
+      cl.put(modifications);
    }
 
    /**
@@ -249,14 +189,7 @@
     */
    public void put(final Fqn name, final Map<Object, Object> attributes) throws Exception
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>()
-      {
-         public Void run() throws Exception
-         {
-            cl.put(name, attributes);
-            return null;
-         }
-      });
+      cl.put(name, attributes);
    }
 
    /**
@@ -264,13 +197,7 @@
     */
    public Object put(final Fqn name, final Object key, final Object value) throws Exception
    {
-      return SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
-      {
-         public Object run() throws Exception
-         {
-            return cl.put(name, key, value);
-         }
-      });
+      return cl.put(name, key, value);
    }
 
    /**
@@ -278,14 +205,7 @@
     */
    public void remove(final Fqn fqn) throws Exception
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>()
-      {
-         public Void run() throws Exception
-         {
-            cl.remove(fqn);
-            return null;
-         }
-      });
+      cl.remove(fqn);
    }
 
    /**
@@ -293,13 +213,7 @@
     */
    public Object remove(final Fqn fqn, final Object key) throws Exception
    {
-      return SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
-      {
-         public Object run() throws Exception
-         {
-            return cl.remove(fqn, key);
-         }
-      });
+      return cl.remove(fqn, key);
    }
 
    /**
@@ -307,14 +221,7 @@
     */
    public void removeData(final Fqn fqn) throws Exception
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>()
-      {
-         public Void run() throws Exception
-         {
-            cl.removeData(fqn);
-            return null;
-         }
-      });
+      cl.removeData(fqn);
    }
 
    /**
@@ -322,15 +229,7 @@
     */
    public void rollback(final Object tx)
    {
-      PrivilegedAction<Object> action = new PrivilegedAction<Object>()
-      {
-         public Object run()
-         {
-            cl.rollback(tx);
-            return null;
-         }
-      };
-      AccessController.doPrivileged(action);
+      cl.rollback(tx);
    }
 
    /**

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/XmlNodeTypeDataPersister.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/XmlNodeTypeDataPersister.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/XmlNodeTypeDataPersister.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -18,6 +18,7 @@
  */
 package org.exoplatform.services.jcr.impl.core.nodetype.registration;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
 import org.exoplatform.services.jcr.core.nodetype.NodeTypeValuesList;
 import org.exoplatform.services.jcr.datamodel.InternalQName;
@@ -30,7 +31,6 @@
 
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.List;
@@ -148,7 +148,7 @@
          };
          try
          {
-            factory = AccessController.doPrivileged(action);
+            factory = SecurityHelper.doPrivilegedExceptionAction(action);
          }
          catch (PrivilegedActionException pae)
          {

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -22,6 +22,7 @@
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.WildcardQuery;
 import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.container.ExoContainerContext;
 import org.exoplatform.container.configuration.ConfigurationManager;
 import org.exoplatform.management.annotations.Managed;
@@ -87,6 +88,8 @@
 import java.io.Serializable;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -1433,7 +1436,35 @@
 
       if (handler instanceof Suspendable)
       {
-         ((Suspendable)handler).resume();
+         PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
+         {
+            public Object run() throws Exception
+            {
+               ((Suspendable)handler).resume();
+               return null;
+            }
+         };
+         try
+         {
+            SecurityHelper.doPrivilegedExceptionAction(action);
+         }
+         catch (PrivilegedActionException pae)
+         {
+            Throwable cause = pae.getCause();
+
+            if (cause instanceof ResumeException)
+            {
+               throw (ResumeException)cause;
+            }
+            else if (cause instanceof RuntimeException)
+            {
+               throw (RuntimeException)cause;
+            }
+            else
+            {
+               throw new RuntimeException(cause);
+            }
+         }         
       }
 
       isSuspended = false;

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/ISPNIndexChangesFilter.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -28,7 +28,6 @@
 import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
 import org.exoplatform.services.jcr.impl.core.query.SearchManager;
 import org.exoplatform.services.jcr.infinispan.ISPNCacheFactory;
-import org.exoplatform.services.jcr.infinispan.PrivilegedISPNCacheHelper;
 import org.exoplatform.services.jcr.util.IdGenerator;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
@@ -117,7 +116,7 @@
    {
       ChangesKey changesKey = new ChangesKey(wsId, IdGenerator.generate());
       cache.getAdvancedCache().withFlags(Flag.SKIP_LOCKING);
-      PrivilegedISPNCacheHelper.put(cache, changesKey, changes);
+      cache.put(changesKey, changes);
    }
 
    /**

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ispn/LocalIndexChangesFilter.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -28,7 +28,6 @@
 import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
 import org.exoplatform.services.jcr.impl.core.query.SearchManager;
 import org.exoplatform.services.jcr.infinispan.ISPNCacheFactory;
-import org.exoplatform.services.jcr.infinispan.PrivilegedISPNCacheHelper;
 import org.exoplatform.services.jcr.util.IdGenerator;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
@@ -110,6 +109,6 @@
    {
       ChangesKey changesKey = new ChangesKey(wsId, IdGenerator.generate());
       cache.getAdvancedCache().withFlags(Flag.SKIP_LOCKING);
-      PrivilegedISPNCacheHelper.put(cache, changesKey, changes);
+      cache.put(changesKey, changes);
    }
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -191,7 +191,7 @@
    protected void doUpdateIndex(ChangesFilterListsWrapper changes)
    {
       String id = IdGenerator.generate();
-      PrivilegedJBossCacheHelper.put(cache, Fqn.fromRelativeElements(rootFqn, id), LISTWRAPPER, changes);
+      cache.put(Fqn.fromRelativeElements(rootFqn, id), LISTWRAPPER, changes);
    }
 
    /**

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/LocalIndexChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/LocalIndexChangesFilter.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/LocalIndexChangesFilter.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -170,7 +170,7 @@
    protected void doUpdateIndex(ChangesFilterListsWrapper changes)
    {
       String id = IdGenerator.generate();
-      PrivilegedJBossCacheHelper.put(cache, Fqn.fromRelativeElements(rootFqn, id), LISTWRAPPER, changes);
+      cache.put(Fqn.fromRelativeElements(rootFqn, id), LISTWRAPPER, changes);
    }
    
    /**

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -25,7 +25,6 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Similarity;
 import org.apache.lucene.store.Directory;
-import org.exoplatform.commons.utils.SecurityHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,8 +32,6 @@
 import java.io.OutputStream;
 import java.io.PrintStream;
 import java.io.StringReader;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedExceptionAction;
 import java.util.BitSet;
 import java.util.Iterator;
 
@@ -134,23 +131,15 @@
       this.cache = cache;
       this.indexingQueue = indexingQueue;
 
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
-      {
-         public Object run() throws Exception
-         {
-            AbstractIndex.this.isExisting = IndexReader.indexExists(directory);
+      AbstractIndex.this.isExisting = IndexReader.indexExists(directory);
 
-            if (!isExisting)
-            {
-               indexWriter = new IndexWriter(directory, analyzer, IndexWriter.MaxFieldLength.LIMITED);
-               // immediately close, now that index has been created
-               indexWriter.close();
-               indexWriter = null;
-            }
-            return null;
-         }
-      });
-
+      if (!isExisting)
+      {
+         indexWriter = new IndexWriter(directory, analyzer, IndexWriter.MaxFieldLength.LIMITED);
+         // immediately close, now that index has been created
+         indexWriter.close();
+         indexWriter = null;
+      }
    }
 
    /**
@@ -184,65 +173,58 @@
     */
    void addDocuments(final Document[] docs) throws IOException
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+      final IndexWriter writer = getIndexWriter();
+      DynamicPooledExecutor.Command[] commands = new DynamicPooledExecutor.Command[docs.length];
+      for (int i = 0; i < docs.length; i++)
       {
-         public Object run() throws Exception
+         // check if text extractor completed its work
+         final Document doc = getFinishedDocument(docs[i]);
+         // create a command for inverting the document
+         commands[i] = new DynamicPooledExecutor.Command()
          {
-            final IndexWriter writer = getIndexWriter();
-            DynamicPooledExecutor.Command[] commands = new DynamicPooledExecutor.Command[docs.length];
-            for (int i = 0; i < docs.length; i++)
+            public Object call() throws Exception
             {
-               // check if text extractor completed its work
-               final Document doc = getFinishedDocument(docs[i]);
-               // create a command for inverting the document
-               commands[i] = new DynamicPooledExecutor.Command()
-               {
-                  public Object call() throws Exception
-                  {
-                     long time = System.currentTimeMillis();
-                     writer.addDocument(doc);
-                     return new Long(System.currentTimeMillis() - time);
-                  }
-               };
+               long time = System.currentTimeMillis();
+               writer.addDocument(doc);
+               return new Long(System.currentTimeMillis() - time);
             }
-            DynamicPooledExecutor.Result[] results = EXECUTOR.executeAndWait(commands);
-            invalidateSharedReader();
-            IOException ex = null;
-            for (int i = 0; i < results.length; i++)
+         };
+      }
+      DynamicPooledExecutor.Result[] results = EXECUTOR.executeAndWait(commands);
+      invalidateSharedReader();
+      IOException ex = null;
+      for (int i = 0; i < results.length; i++)
+      {
+         if (results[i].getException() != null)
+         {
+            Throwable cause = results[i].getException().getCause();
+            if (ex == null)
             {
-               if (results[i].getException() != null)
+               // only throw the first exception
+               if (cause instanceof IOException)
                {
-                  Throwable cause = results[i].getException().getCause();
-                  if (ex == null)
-                  {
-                     // only throw the first exception
-                     if (cause instanceof IOException)
-                     {
-                        ex = (IOException)cause;
-                     }
-                     else
-                     {
-                        throw Util.createIOException(cause);
-                     }
-                  }
-                  else
-                  {
-                     // all others are logged
-                     log.warn("Exception while inverting document", cause);
-                  }
+                  ex = (IOException)cause;
                }
                else
                {
-                  log.debug("Inverted document in {} ms", results[i].get());
+                  throw Util.createIOException(cause);
                }
             }
-            if (ex != null)
+            else
             {
-               throw ex;
+               // all others are logged
+               log.warn("Exception while inverting document", cause);
             }
-            return null;
          }
-      });
+         else
+         {
+            log.debug("Inverted document in {} ms", results[i].get());
+         }
+      }
+      if (ex != null)
+      {
+         throw ex;
+      }
    }
 
    /**
@@ -256,13 +238,7 @@
     */
    int removeDocument(final Term idTerm) throws IOException
    {
-      return SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return getIndexReader().deleteDocuments(idTerm);
-         }
-      });
+      return getIndexReader().deleteDocuments(idTerm);
    }
 
    /**
@@ -274,25 +250,19 @@
     */
    protected synchronized CommittableIndexReader getIndexReader() throws IOException
    {
-      return SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<CommittableIndexReader>()
+      if (indexWriter != null)
       {
-         public CommittableIndexReader run() throws Exception
-         {
-            if (indexWriter != null)
-            {
-               indexWriter.close();
-               log.debug("closing IndexWriter.");
-               indexWriter = null;
-            }
+         indexWriter.close();
+         log.debug("closing IndexWriter.");
+         indexWriter = null;
+      }
 
-            if (indexReader == null || !indexReader.isCurrent())
-            {
-               IndexReader reader = IndexReader.open(getDirectory(), null, false, termInfosIndexDivisor);
-               indexReader = new CommittableIndexReader(reader);
-            }
-            return indexReader;
-         }
-      });
+      if (indexReader == null || !indexReader.isCurrent())
+      {
+         IndexReader reader = IndexReader.open(getDirectory(), null, false, termInfosIndexDivisor);
+         indexReader = new CommittableIndexReader(reader);
+      }
+      return indexReader;
    }
 
    /**
@@ -308,63 +278,57 @@
     */
    synchronized ReadOnlyIndexReader getReadOnlyIndexReader(final boolean initCache) throws IOException
    {
-      return SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<ReadOnlyIndexReader>()
+      // get current modifiable index reader
+      CommittableIndexReader modifiableReader = getIndexReader();
+      long modCount = modifiableReader.getModificationCount();
+      if (readOnlyReader != null)
       {
-         public ReadOnlyIndexReader run() throws Exception
+         if (readOnlyReader.getDeletedDocsVersion() == modCount)
          {
-            // get current modifiable index reader
-            CommittableIndexReader modifiableReader = getIndexReader();
-            long modCount = modifiableReader.getModificationCount();
-            if (readOnlyReader != null)
+            // reader up-to-date
+            readOnlyReader.acquire();
+            return readOnlyReader;
+         }
+         else
+         {
+            // reader outdated
+            if (readOnlyReader.getRefCount() == 1)
             {
-               if (readOnlyReader.getDeletedDocsVersion() == modCount)
-               {
-                  // reader up-to-date
-                  readOnlyReader.acquire();
-                  return readOnlyReader;
-               }
-               else
-               {
-                  // reader outdated
-                  if (readOnlyReader.getRefCount() == 1)
-                  {
-                     // not in use, except by this index
-                     // update the reader
-                     readOnlyReader.updateDeletedDocs(modifiableReader);
-                     readOnlyReader.acquire();
-                     return readOnlyReader;
-                  }
-                  else
-                  {
-                     // cannot update reader, it is still in use
-                     // need to create a new instance
-                     readOnlyReader.release();
-                     readOnlyReader = null;
-                  }
-               }
+               // not in use, except by this index
+               // update the reader
+               readOnlyReader.updateDeletedDocs(modifiableReader);
+               readOnlyReader.acquire();
+               return readOnlyReader;
             }
-            // if we get here there is no up-to-date read-only reader
-            // capture snapshot of deleted documents
-            BitSet deleted = new BitSet(modifiableReader.maxDoc());
-            for (int i = 0; i < modifiableReader.maxDoc(); i++)
+            else
             {
-               if (modifiableReader.isDeleted(i))
-               {
-                  deleted.set(i);
-               }
+               // cannot update reader, it is still in use
+               // need to create a new instance
+               readOnlyReader.release();
+               readOnlyReader = null;
             }
-            if (sharedReader == null)
-            {
-               // create new shared reader
-               IndexReader reader = IndexReader.open(getDirectory(), null, true, termInfosIndexDivisor);
-               CachingIndexReader cr = new CachingIndexReader(reader, cache, initCache);
-               sharedReader = new SharedIndexReader(cr);
-            }
-            readOnlyReader = new ReadOnlyIndexReader(sharedReader, deleted, modCount);
-            readOnlyReader.acquire();
-            return readOnlyReader;
          }
-      });
+      }
+      // if we get here there is no up-to-date read-only reader
+      // capture snapshot of deleted documents
+      BitSet deleted = new BitSet(modifiableReader.maxDoc());
+      for (int i = 0; i < modifiableReader.maxDoc(); i++)
+      {
+         if (modifiableReader.isDeleted(i))
+         {
+            deleted.set(i);
+         }
+      }
+      if (sharedReader == null)
+      {
+         // create new shared reader
+         IndexReader reader = IndexReader.open(getDirectory(), null, true, termInfosIndexDivisor);
+         CachingIndexReader cr = new CachingIndexReader(reader, cache, initCache);
+         sharedReader = new SharedIndexReader(cr);
+      }
+      readOnlyReader = new ReadOnlyIndexReader(sharedReader, deleted, modCount);
+      readOnlyReader.acquire();
+      return readOnlyReader;
    }
 
    /**
@@ -388,26 +352,20 @@
     */
    protected synchronized IndexWriter getIndexWriter() throws IOException
    {
-      return SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<IndexWriter>()
+      if (indexReader != null)
       {
-         public IndexWriter run() throws Exception
-         {
-            if (indexReader != null)
-            {
-               indexReader.close();
-               log.debug("closing IndexReader.");
-               indexReader = null;
-            }
-            if (indexWriter == null)
-            {
-               indexWriter = new IndexWriter(getDirectory(), analyzer, new IndexWriter.MaxFieldLength(maxFieldLength));
-               indexWriter.setSimilarity(similarity);
-               indexWriter.setUseCompoundFile(useCompoundFile);
-               indexWriter.setInfoStream(STREAM_LOGGER);
-            }
-            return indexWriter;
-         }
-      });
+         indexReader.close();
+         log.debug("closing IndexReader.");
+         indexReader = null;
+      }
+      if (indexWriter == null)
+      {
+         indexWriter = new IndexWriter(getDirectory(), analyzer, new IndexWriter.MaxFieldLength(maxFieldLength));
+         indexWriter.setSimilarity(similarity);
+         indexWriter.setUseCompoundFile(useCompoundFile);
+         indexWriter.setInfoStream(STREAM_LOGGER);
+      }
+      return indexWriter;
    }
 
    /**
@@ -428,31 +386,24 @@
     */
    protected synchronized void commit(final boolean optimize) throws IOException
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+      if (indexReader != null)
       {
-         public Object run() throws Exception
-         {
-            if (indexReader != null)
-            {
-               log.debug("committing IndexReader.");
-               indexReader.flush();
-            }
-            if (indexWriter != null)
-            {
-               log.debug("committing IndexWriter.");
-               indexWriter.commit();
-            }
-            // optimize if requested
-            if (optimize)
-            {
-               IndexWriter writer = getIndexWriter();
-               writer.optimize();
-               writer.close();
-               indexWriter = null;
-            }
-            return null;
-         }
-      });
+         log.debug("committing IndexReader.");
+         indexReader.flush();
+      }
+      if (indexWriter != null)
+      {
+         log.debug("committing IndexWriter.");
+         indexWriter.commit();
+      }
+      // optimize if requested
+      if (optimize)
+      {
+         IndexWriter writer = getIndexWriter();
+         writer.optimize();
+         writer.close();
+         indexWriter = null;
+      }
    }
 
    /**
@@ -460,25 +411,18 @@
     */
    synchronized void close()
    {
-      SecurityHelper.doPrivilegedAction(new PrivilegedAction<Object>()
+      releaseWriterAndReaders();
+      if (directory != null)
       {
-         public Object run()
+         try
          {
-            releaseWriterAndReaders();
-            if (directory != null)
-            {
-               try
-               {
-                  directory.close();
-               }
-               catch (IOException e)
-               {
-                  directory = null;
-               }
-            }
-            return null;
+            directory.close();
          }
-      });
+         catch (IOException e)
+         {
+            directory = null;
+         }
+      }
    }
 
    /**
@@ -486,61 +430,54 @@
     */
    protected void releaseWriterAndReaders()
    {
-      SecurityHelper.doPrivilegedAction(new PrivilegedAction<Object>()
+      if (indexWriter != null)
       {
-         public Object run()
+         try
          {
-            if (indexWriter != null)
-            {
-               try
-               {
-                  indexWriter.close();
-               }
-               catch (IOException e)
-               {
-                  log.warn("Exception closing index writer: " + e.toString());
-               }
-               indexWriter = null;
-            }
-            if (indexReader != null)
-            {
-               try
-               {
-                  indexReader.close();
-               }
-               catch (IOException e)
-               {
-                  log.warn("Exception closing index reader: " + e.toString());
-               }
-               indexReader = null;
-            }
-            if (readOnlyReader != null)
-            {
-               try
-               {
-                  readOnlyReader.release();
-               }
-               catch (IOException e)
-               {
-                  log.warn("Exception closing index reader: " + e.toString());
-               }
-               readOnlyReader = null;
-            }
-            if (sharedReader != null)
-            {
-               try
-               {
-                  sharedReader.release();
-               }
-               catch (IOException e)
-               {
-                  log.warn("Exception closing index reader: " + e.toString());
-               }
-               sharedReader = null;
-            }
-            return null;
+            indexWriter.close();
          }
-      });
+         catch (IOException e)
+         {
+            log.warn("Exception closing index writer: " + e.toString());
+         }
+         indexWriter = null;
+      }
+      if (indexReader != null)
+      {
+         try
+         {
+            indexReader.close();
+         }
+         catch (IOException e)
+         {
+            log.warn("Exception closing index reader: " + e.toString());
+         }
+         indexReader = null;
+      }
+      if (readOnlyReader != null)
+      {
+         try
+         {
+            readOnlyReader.release();
+         }
+         catch (IOException e)
+         {
+            log.warn("Exception closing index reader: " + e.toString());
+         }
+         readOnlyReader = null;
+      }
+      if (sharedReader != null)
+      {
+         try
+         {
+            sharedReader.release();
+         }
+         catch (IOException e)
+         {
+            log.warn("Exception closing index reader: " + e.toString());
+         }
+         sharedReader = null;
+      }
    }
 
    /**
@@ -565,25 +502,18 @@
     */
    protected synchronized void invalidateSharedReader() throws IOException
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+      // also close the read-only reader
+      if (readOnlyReader != null)
       {
-         public Object run() throws Exception
-         {
-            // also close the read-only reader
-            if (readOnlyReader != null)
-            {
-               readOnlyReader.release();
-               readOnlyReader = null;
-            }
-            // invalidate shared reader
-            if (sharedReader != null)
-            {
-               sharedReader.release();
-               sharedReader = null;
-            }
-            return null;
-         }
-      });
+         readOnlyReader.release();
+         readOnlyReader = null;
+      }
+      // invalidate shared reader
+      if (sharedReader != null)
+      {
+         sharedReader.release();
+         sharedReader = null;
+      }
    }
 
    /**

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -56,11 +56,11 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Queue;
 import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.Map.Entry;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -1523,44 +1523,51 @@
     */
    public void flush() throws IOException
    {
-      synchronized (this)
+      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Void>()
       {
-         // commit volatile index
-         executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
-         commitVolatileIndex();
-
-         // commit persistent indexes
-         for (int i = indexes.size() - 1; i >= 0; i--)
+         public Void run() throws Exception
          {
-            PersistentIndex index = indexes.get(i);
-            // only commit indexes we own
-            // index merger also places PersistentIndex instances in
-            // indexes,
-            // but does not make them public by registering the name in
-            // indexNames
-            if (indexNames.contains(index.getName()))
+            synchronized (this)
             {
-               index.commit();
-               // check if index still contains documents
-               if (index.getNumDocuments() == 0)
+               // commit volatile index
+               executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
+               commitVolatileIndex();
+
+               // commit persistent indexes
+               for (int i = indexes.size() - 1; i >= 0; i--)
                {
-                  executeAndLog(new DeleteIndex(getTransactionId(), index.getName()));
+                  PersistentIndex index = indexes.get(i);
+                  // only commit indexes we own
+                  // index merger also places PersistentIndex instances in
+                  // indexes,
+                  // but does not make them public by registering the name in
+                  // indexNames
+                  if (indexNames.contains(index.getName()))
+                  {
+                     index.commit();
+                     // check if index still contains documents
+                     if (index.getNumDocuments() == 0)
+                     {
+                        executeAndLog(new DeleteIndex(getTransactionId(), index.getName()));
+                     }
+                  }
                }
-            }
-         }
-         executeAndLog(new Commit(getTransactionId()));
+             executeAndLog(new Commit(getTransactionId()));
+ 
+             indexNames.write();
 
-         indexNames.write();
+             // reset redo log
+             redoLog.clear();
 
-         // reset redo log
-         redoLog.clear();
+             lastFlushTime = System.currentTimeMillis();
+             lastFileSystemFlushTime = System.currentTimeMillis();
+          }
 
-         lastFlushTime = System.currentTimeMillis();
-         lastFileSystemFlushTime = System.currentTimeMillis();
-      }
-
-      // delete obsolete indexes
-      attemptDelete();
+          // delete obsolete indexes
+          attemptDelete();
+          return null;
+        }
+     });
    }
 
    /**
@@ -1578,24 +1585,17 @@
     */
    void releaseMultiReader() throws IOException
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+      if (multiReader != null)
       {
-         public Object run() throws Exception
+         try
          {
-            if (multiReader != null)
-            {
-               try
-               {
-                  multiReader.release();
-               }
-               finally
-               {
-                  multiReader = null;
-               }
-            }
-            return null;
+            multiReader.release();
          }
-      });
+         finally
+         {
+            multiReader = null;
+         }
+      }
    }
 
    // -------------------------< internal >-------------------------------------
@@ -1707,23 +1707,17 @@
     */
    private Action executeAndLog(final Action a) throws IOException
    {
-      return SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Action>()
+      a.execute(MultiIndex.this);
+      redoLog.append(a);
+      // please note that flushing the redo log is only required on
+      // commit, but we also want to keep track of new indexes for sure.
+      // otherwise it might happen that unused index folders are orphaned
+      // after a crash.
+      if (a.getType() == Action.TYPE_COMMIT || a.getType() == Action.TYPE_ADD_INDEX)
       {
-         public Action run() throws Exception
-         {
-            a.execute(MultiIndex.this);
-            redoLog.append(a);
-            // please note that flushing the redo log is only required on
-            // commit, but we also want to keep track of new indexes for sure.
-            // otherwise it might happen that unused index folders are orphaned
-            // after a crash.
-            if (a.getType() == Action.TYPE_COMMIT || a.getType() == Action.TYPE_ADD_INDEX)
-            {
-               redoLog.flush();
-            }
-            return a;
-         }
-      });
+         redoLog.flush();
+      }
+      return a;
    }
 
    /**
@@ -3730,4 +3724,4 @@
       }
       return true;
    }
-}
\ No newline at end of file
+}

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -43,9 +43,6 @@
 import java.io.InputStream;
 import java.io.Reader;
 import java.io.StringReader;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
@@ -235,34 +232,7 @@
          {
             addPropertyName(doc, prop.getQPath().getName());
          }
-
-         try
-         {
-            AccessController.doPrivileged((new PrivilegedExceptionAction<Object>()
-            {
-               public Object run() throws Exception
-               {
-                  addValues(doc, prop);
-                  return null;
-               }
-            }));
-         }
-         catch (PrivilegedActionException pae)
-         {
-            Throwable cause = pae.getCause();
-            if (cause instanceof RepositoryException)
-            {
-               throw (RepositoryException)cause;
-            }
-            else if (cause instanceof RuntimeException)
-            {
-               throw (RuntimeException)cause;
-            }
-            else
-            {
-               throw new RuntimeException(cause);
-            }
-         }
+         addValues(doc, prop);
       }
 
       // now add fields that are not used in excerpt (must go at the end)

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RedoLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RedoLog.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RedoLog.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -17,7 +17,6 @@
 package org.exoplatform.services.jcr.impl.core.query.lucene;
 
 import org.apache.lucene.store.Directory;
-import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.impl.core.query.lucene.directory.IndexInputStream;
 import org.exoplatform.services.jcr.impl.core.query.lucene.directory.IndexOutputStream;
 import org.slf4j.Logger;
@@ -31,7 +30,6 @@
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
-import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -147,16 +145,9 @@
     */
    void append(final MultiIndex.Action action) throws IOException
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
-      {
-         public Object run() throws Exception
-         {
-            initOut();
-            out.write(action.toString() + "\n");
-            entryCount++;
-            return null;
-         }
-      });
+      initOut();
+      out.write(action.toString() + "\n");
+      entryCount++;
    }
 
    /**
@@ -165,17 +156,10 @@
     */
    void flush() throws IOException
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+      if (out != null)
       {
-         public Object run() throws Exception
-         {
-            if (out != null)
-            {
-               out.flush();
-            }
-            return null;
-         }
-      });
+         out.flush();
+      }
    }
 
    /**
@@ -184,28 +168,21 @@
     */
    synchronized void clear() throws IOException
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+      if (out != null)
       {
-         public Object run() throws Exception
-         {
-            if (out != null)
-            {
-               out.close();
-               out = null;
-            }
-            try
-            {
-               dir.deleteFile(REDO_LOG);
-            }
-            catch (Exception e)
-            {
-               log.error(e.getLocalizedMessage(), e);
-               throw e;
-            }
-            entryCount = 0;
-            return null;
-         }
-      });
+         out.close();
+         out = null;
+      }
+      try
+      {
+         dir.deleteFile(REDO_LOG);
+      }
+      catch (IOException e)
+      {
+         log.error(e.getLocalizedMessage(), e);
+         throw e;
+      }
+      entryCount = 0;
    }
 
    /**
@@ -215,18 +192,11 @@
     */
    private synchronized void initOut() throws IOException
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+      if (out == null)
       {
-         public Object run() throws Exception
-         {
-            if (out == null)
-            {
-               OutputStream os = new IndexOutputStream(dir.createOutput(REDO_LOG));
-               out = new BufferedWriter(new OutputStreamWriter(os));
-            }
-            return null;
-         }
-      });
+         OutputStream os = new IndexOutputStream(dir.createOutput(REDO_LOG));
+         out = new BufferedWriter(new OutputStreamWriter(os));
+      }
    }
 
    /**
@@ -238,48 +208,41 @@
     */
    private void read(final ActionCollector collector) throws IOException
    {
-      SecurityHelper.doPrivilegedIOExceptionAction(new PrivilegedExceptionAction<Object>()
+      if (!dir.fileExists(REDO_LOG))
       {
-         public Object run() throws Exception
+         return;
+      }
+      InputStream in = new IndexInputStream(dir.openInput(REDO_LOG));
+      try
+      {
+         BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+         String line;
+         while ((line = reader.readLine()) != null)
          {
-            if (!dir.fileExists(REDO_LOG))
+            try
             {
-               return null;
+               collector.collect(MultiIndex.Action.fromString(line));
             }
-            InputStream in = new IndexInputStream(dir.openInput(REDO_LOG));
+            catch (IllegalArgumentException e)
+            {
+               log.warn("Malformed redo entry: " + e.getMessage());
+            }
+         }
+      }
+      finally
+      {
+         if (in != null)
+         {
             try
             {
-               BufferedReader reader = new BufferedReader(new InputStreamReader(in));
-               String line;
-               while ((line = reader.readLine()) != null)
-               {
-                  try
-                  {
-                     collector.collect(MultiIndex.Action.fromString(line));
-                  }
-                  catch (IllegalArgumentException e)
-                  {
-                     log.warn("Malformed redo entry: " + e.getMessage());
-                  }
-               }
+               in.close();
             }
-            finally
+            catch (IOException e)
             {
-               if (in != null)
-               {
-                  try
-                  {
-                     in.close();
-                  }
-                  catch (IOException e)
-                  {
-                     log.warn("Exception while closing redo log: " + e.toString());
-                  }
-               }
+               log.warn("Exception while closing redo log: " + e.toString());
             }
-            return null;
          }
-      });
+      }
    }
 
    //-----------------------< internal >---------------------------------------

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -75,7 +75,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -588,7 +587,7 @@
 
          try
          {
-            AccessController.doPrivileged((new PrivilegedExceptionAction<Object>()
+            SecurityHelper.doPrivilegedExceptionAction((new PrivilegedExceptionAction<Object>()
             {
                public Object run() throws Exception
                {

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -31,7 +31,6 @@
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
-import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.util.Iterator;
 import java.util.regex.Pattern;
@@ -60,33 +59,26 @@
     */
    public static void disposeDocument(final Document old)
    {
-      SecurityHelper.doPrivilegedAction(new PrivilegedAction<Object>()
+      for (Iterator it = old.getFields().iterator(); it.hasNext();)
       {
-         public Object run()
+         Fieldable f = (Fieldable)it.next();
+         try
          {
-            for (Iterator it = old.getFields().iterator(); it.hasNext();)
+            if (f.readerValue() != null)
             {
-               Fieldable f = (Fieldable)it.next();
-               try
-               {
-                  if (f.readerValue() != null)
-                  {
-                     f.readerValue().close();
-                  }
-                  else if (f instanceof LazyTextExtractorField)
-                  {
-                     LazyTextExtractorField field = (LazyTextExtractorField)f;
-                     field.dispose();
-                  }
-               }
-               catch (IOException ex)
-               {
-                  log.warn("Exception while disposing index document: " + ex);
-               }
+               f.readerValue().close();
             }
-            return null;
+            else if (f instanceof LazyTextExtractorField)
+            {
+               LazyTextExtractorField field = (LazyTextExtractorField)f;
+               field.dispose();
+            }
          }
-      });
+         catch (IOException ex)
+         {
+            log.warn("Exception while disposing index document: " + ex);
+         }
+      }
    }
 
    /**

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -557,7 +557,7 @@
     * {@inheritDoc}
     */
    @Override
-   public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException
+   public ItemData getItemData(final NodeData parentData, final QPathEntry name, final ItemType itemType) throws RepositoryException
    {
       if (cache.isEnabled())
       {
@@ -577,7 +577,13 @@
                data = getCachedItemData(parentData, name, itemType);
                if (data == null)
                {
-                  data = getPersistedItemData(parentData, name, itemType);
+                  data = executeAction(new PrivilegedExceptionAction<ItemData>()
+                  {
+                     public ItemData run() throws RepositoryException
+                     {
+                        return getPersistedItemData(parentData, name, itemType);
+                     }
+                  });
                }
             }
             finally
@@ -608,7 +614,7 @@
     * {@inheritDoc}
     */
    @Override
-   public ItemData getItemData(String identifier) throws RepositoryException
+   public ItemData getItemData(final String identifier) throws RepositoryException
    {
       if (cache.isEnabled())
       {
@@ -628,7 +634,13 @@
                data = getCachedItemData(identifier);
                if (data == null)
                {
-                  data = getPersistedItemData(identifier);
+                  data = executeAction(new PrivilegedExceptionAction<ItemData>()
+                  {
+                     public ItemData run() throws RepositoryException
+                     {
+                        return getPersistedItemData(identifier);
+                     }
+                  });
                }
             }
             finally
@@ -694,7 +706,6 @@
    /**
     * {@inheritDoc}
     */
-   @Override
    public void save(final ItemStateChangesLog changesLog) throws RepositoryException
    {
       if (isSuspended)
@@ -936,7 +947,7 @@
     * @throws RepositoryException
     *           Repository error
     */
-   protected List<NodeData> getChildNodesData(NodeData nodeData, boolean forcePersistentRead)
+   protected List<NodeData> getChildNodesData(final NodeData nodeData, boolean forcePersistentRead)
       throws RepositoryException
    {
 
@@ -964,17 +975,23 @@
                return childNodes;
             }
          }
-         childNodes = super.getChildNodesData(nodeData);
-         if (cache.isEnabled())
+         return executeAction(new PrivilegedExceptionAction<List<NodeData>>()
          {
-            NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
+            public List<NodeData> run() throws RepositoryException
+            {
+               List<NodeData> childNodes = CacheableWorkspaceDataManager.super.getChildNodesData(nodeData);
+               if (cache.isEnabled())
+               {
+                  NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
 
-            if (parentData != null)
-            {
-               cache.addChildNodes(parentData, childNodes);
+                  if (parentData != null)
+                  {
+                     cache.addChildNodes(parentData, childNodes);
+                  }
+               }
+               return childNodes;
             }
-         }
-         return childNodes;
+         });
       }
       finally
       {
@@ -1159,7 +1176,7 @@
     * @throws RepositoryException
     *           Repository error
     */
-   protected List<PropertyData> getReferencedPropertiesData(String identifier) throws RepositoryException
+   protected List<PropertyData> getReferencedPropertiesData(final String identifier) throws RepositoryException
    {
       List<PropertyData> refProps = null;
       if (cache.isEnabled())
@@ -1185,12 +1202,18 @@
                return refProps;
             }
          }
-         refProps = super.getReferencesData(identifier, false);
-         if (cache.isEnabled())
+         return executeAction(new PrivilegedExceptionAction<List<PropertyData>>()
          {
-            cache.addReferencedProperties(identifier, refProps);
-         }
-         return refProps;
+            public List<PropertyData> run() throws RepositoryException
+            {
+               List<PropertyData> refProps = CacheableWorkspaceDataManager.super.getReferencesData(identifier, false);
+               if (cache.isEnabled())
+               {
+                  cache.addReferencedProperties(identifier, refProps);
+               }
+               return refProps;
+            }
+         });
       }
       finally
       {
@@ -1209,7 +1232,7 @@
     * @throws RepositoryException
     *           Repository error
     */
-   protected List<PropertyData> getChildPropertiesData(NodeData nodeData, boolean forcePersistentRead)
+   protected List<PropertyData> getChildPropertiesData(final NodeData nodeData, boolean forcePersistentRead)
       throws RepositoryException
    {
 
@@ -1237,19 +1260,25 @@
                return childProperties;
             }
          }
-
-         childProperties = super.getChildPropertiesData(nodeData);
-         // TODO childProperties.size() > 0 for SDB
-         if (childProperties.size() > 0 && cache.isEnabled())
+         return executeAction(new PrivilegedExceptionAction<List<PropertyData>>()
          {
-            NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
+            public List<PropertyData> run() throws RepositoryException
+            {
+               List<PropertyData> childProperties =
+                  CacheableWorkspaceDataManager.super.getChildPropertiesData(nodeData);
+               // TODO childProperties.size() > 0 for SDB
+               if (childProperties.size() > 0 && cache.isEnabled())
+               {
+                  NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
 
-            if (parentData != null)
-            {
-               cache.addChildProperties(parentData, childProperties);
+                  if (parentData != null)
+                  {
+                     cache.addChildProperties(parentData, childProperties);
+                  }
+               }
+               return childProperties;
             }
-         }
-         return childProperties;
+         });
       }
       finally
       {
@@ -1816,4 +1845,28 @@
          rpcService.registerTopologyChangeListener(this);
       }
    }
+   
+   private <T> T executeAction(PrivilegedExceptionAction<T> action) throws RepositoryException
+   {
+      try
+      {
+         return SecurityHelper.doPrivilegedExceptionAction(action);
+      }
+      catch (PrivilegedActionException pae)
+      {
+         Throwable cause = pae.getCause();
+         if (cause instanceof RepositoryException)
+         {
+            throw (RepositoryException)cause;
+         }
+         else if (cause instanceof RuntimeException)
+         {
+            throw (RuntimeException)cause;
+         }
+         else
+         {
+            throw new RuntimeException(cause);
+         }
+      }      
+   }
 }
\ No newline at end of file

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/infinispan/BufferedISPNCache.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -18,6 +18,7 @@
  */
 package org.exoplatform.services.jcr.impl.dataflow.persistent.infinispan;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.datamodel.ItemData;
 import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
 import org.exoplatform.services.log.ExoLogger;
@@ -31,7 +32,6 @@
 import org.infinispan.manager.CacheContainer;
 import org.infinispan.util.concurrent.NotifyingFuture;
 
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Collection;
 import java.util.HashMap;
@@ -905,14 +905,7 @@
       changesContainer.add(new PutObjectContainer(key, value, parentCache, changesContainer.getHistoryIndex(), local
          .get(), allowLocalChanges));
 
-      PrivilegedAction<Object> action = new PrivilegedAction<Object>()
-      {
-         public Object run()
-         {
-            return withReturnValue ? parentCache.get(key) : null;
-         }
-      };
-      return AccessController.doPrivileged(action);
+      return withReturnValue ? parentCache.get(key) : null;
    }
 
    /**
@@ -957,7 +950,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    /**
@@ -973,7 +966,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    /**
@@ -1028,15 +1021,7 @@
       try
       {
          final List<ChangesContainer> containers = changesContainer.getSortedList();
-         PrivilegedAction<Void> action = new PrivilegedAction<Void>()
-         {
-            public Void run()
-            {
-               commitChanges(tm, containers);
-               return null;
-            }
-         };
-         AccessController.doPrivileged(action);         
+         commitChanges(tm, containers);
       }
       finally
       {

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	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -20,7 +20,7 @@
 
 import org.exoplatform.services.jcr.datamodel.ItemData;
 import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
-import org.exoplatform.services.jcr.jbosscache.PrivilegedJBossCacheHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
 import org.jboss.cache.Cache;
@@ -38,7 +38,6 @@
 import org.jgroups.Address;
 
 import java.io.Serializable;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -114,15 +113,7 @@
       try
       {
          final List<ChangesContainer> containers = changesContainer.getSortedList();
-         PrivilegedAction<Void> action = new PrivilegedAction<Void>()
-         {
-            public Void run()
-            {
-               commitChanges(containers);
-               return null;
-            }
-         };
-         AccessController.doPrivileged(action);         
+         commitChanges(containers);
       }
       finally
       {
@@ -301,7 +292,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    /* (non-Javadoc)
@@ -740,7 +731,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    /* (non-Javadoc)
@@ -764,7 +755,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    public TransactionManager getTransactionManager()
@@ -1282,7 +1273,7 @@
       public void apply()
       {
          setCacheLocalMode();
-         PrivilegedJBossCacheHelper.removeNode(cache, fqn);
+         cache.removeNode(fqn);
       }
    }
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/SerializationSpoolFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/SerializationSpoolFile.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/SerializationSpoolFile.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -18,11 +18,11 @@
  */
 package org.exoplatform.services.jcr.impl.dataflow.serialization;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.impl.util.io.SpoolFile;
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 /**
@@ -89,7 +89,7 @@
                   return SerializationSpoolFile.super.delete();
                }
             };
-            boolean result = AccessController.doPrivileged(action);
+            boolean result = SecurityHelper.doPrivilegedAction(action);
 
             if (result)
             {

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/GenericConnectionFactory.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -18,7 +18,6 @@
  */
 package org.exoplatform.services.jcr.impl.storage.jdbc.db;
 
-import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
 import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
@@ -26,7 +25,6 @@
 import org.exoplatform.services.log.Log;
 
 import java.io.File;
-import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
@@ -228,15 +226,9 @@
    {
       try
       {
-         final Connection conn =
-            SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
-            {
-               public Connection run() throws Exception
-               {
-                  return dbDataSource != null ? dbDataSource.getConnection() : (dbUserName != null ? DriverManager
-                     .getConnection(dbUrl, dbUserName, dbPassword) : DriverManager.getConnection(dbUrl));
-               }
-            });
+         Connection conn =
+            dbDataSource != null ? dbDataSource.getConnection() : (dbUserName != null ? DriverManager.getConnection(
+               dbUrl, dbUserName, dbPassword) : DriverManager.getConnection(dbUrl));
          if (readOnly)
          {
             // set this feature only if it asked

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -16,18 +16,11 @@
  */
 package org.exoplatform.services.jcr.impl.storage.jdbc.db;
 
-import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
 
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
-import java.sql.ResultSet;
 import java.sql.SQLException;
 
 /**
@@ -86,263 +79,4 @@
       FIND_NODES_COUNT_BY_PARENTID = "select count(ID) from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1";
       FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=2" + " order by ID";
    }
-
-   @Override
-   protected int addNodeRecord(final NodeData data) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.addNodeRecord(data);
-         }
-      });
-   }
-
-   @Override
-   protected int addPropertyRecord(final PropertyData data) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.addPropertyRecord(data);
-         }
-      });
-   }
-
-   @Override
-   protected int addReference(final PropertyData data) throws SQLException, IOException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.addReference(data);
-         }
-      });
-   }
-
-   @Override
-   protected int addValueData(final String cid, final int orderNumber, final InputStream stream,
-      final int streamLength, final String storageDesc) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.addValueData(cid, orderNumber, stream, streamLength, storageDesc);
-
-         }
-      });
-   }
-
-   @Override
-   protected int deleteItemByIdentifier(final String identifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.deleteItemByIdentifier(identifier);
-         }
-      });
-   }
-
-   @Override
-   protected int deleteReference(final String propertyIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.deleteReference(propertyIdentifier);
-
-         }
-      });
-   }
-
-   @Override
-   protected int deleteValueData(final String cid) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.deleteValueData(cid);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findChildNodesByParentIdentifier(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findChildNodesByParentIdentifier(parentIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findLastOrderNumberByParentIdentifier(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findLastOrderNumberByParentIdentifier(parentIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findChildNodesCountByParentIdentifier(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findChildNodesCountByParentIdentifier(parentIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findChildPropertiesByParentIdentifier(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findChildPropertiesByParentIdentifier(parentIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findItemByIdentifier(final String identifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findItemByIdentifier(identifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findItemByName(final String parentId, final String name, final int index) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findItemByName(parentId, name, index);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findPropertyByName(final String parentId, final String name) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findPropertyByName(parentId, name);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findReferences(final String nodeIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findReferences(nodeIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findValueByPropertyIdOrderNumber(final String cid, final int orderNumb) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findValueByPropertyIdOrderNumber(cid, orderNumb);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findValuesByPropertyId(final String cid) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findValuesByPropertyId(cid);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findValuesStorageDescriptorsByPropertyId(final String cid) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findValuesStorageDescriptorsByPropertyId(cid);
-
-         }
-      });
-   }
-
-   @Override
-   protected int renameNode(final NodeData data) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.renameNode(data);
-
-         }
-      });
-   }
-
-   @Override
-   protected int updateNodeByIdentifier(final int version, final int index, final int orderNumb, final String identifier)
-      throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.updateNodeByIdentifier(version, index, orderNumb, identifier);
-         }
-      });
-   }
-
-   @Override
-   protected int updatePropertyByIdentifier(final int version, final int type, final String identifier)
-      throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.updatePropertyByIdentifier(version, type, identifier);
-         }
-      });
-   }
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -16,16 +16,10 @@
  */
 package org.exoplatform.services.jcr.impl.storage.jdbc.db;
 
-import org.exoplatform.commons.utils.SecurityHelper;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
 
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -111,14 +105,7 @@
       findItemByName.setString(3, name);
       findItemByName.setInt(4, index);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findItemByName.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findItemByName.executeQuery();
    }
 
    /**
@@ -136,14 +123,7 @@
       findPropertyByName.setString(2, containerName);
       findPropertyByName.setString(3, name);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findPropertyByName.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findPropertyByName.executeQuery();
    }
 
    /**
@@ -160,14 +140,7 @@
       findNodesByParentId.setString(1, parentCid);
       findNodesByParentId.setString(2, containerName);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findNodesByParentId.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findNodesByParentId.executeQuery();
    }
 
    /**
@@ -184,14 +157,7 @@
       findLastOrderNumberByParentId.setString(1, parentIdentifier);
       findLastOrderNumberByParentId.setString(2, containerName);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findLastOrderNumberByParentId.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findLastOrderNumberByParentId.executeQuery();
    }
 
    /**
@@ -208,14 +174,7 @@
       findNodesCountByParentId.setString(1, parentCid);
       findNodesCountByParentId.setString(2, containerName);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findNodesCountByParentId.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findNodesCountByParentId.executeQuery();
    }
 
    /**
@@ -232,257 +191,6 @@
       findPropertiesByParentId.setString(1, parentCid);
       findPropertiesByParentId.setString(2, containerName);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findPropertiesByParentId.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findPropertiesByParentId.executeQuery();
    }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int addNodeRecord(final NodeData data) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.addNodeRecord(data);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int addPropertyRecord(final PropertyData prop) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.addPropertyRecord(prop);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findItemByIdentifier(final String identifier) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findItemByIdentifier(identifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int addReference(final PropertyData data) throws SQLException, IOException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.addReference(data);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int renameNode(final NodeData data) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.renameNode(data);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int deleteReference(final String propertyIdentifier) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.deleteReference(propertyIdentifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findReferences(final String nodeIdentifier) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findReferences(nodeIdentifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int deleteItemByIdentifier(final String identifier) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.deleteItemByIdentifier(identifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int updateNodeByIdentifier(final int version, final int index, final int orderNumb, final String identifier)
-      throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.updateNodeByIdentifier(version, index, orderNumb, identifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int updatePropertyByIdentifier(final int version, final int type, final String identifier)
-      throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.updatePropertyByIdentifier(version, type, identifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   // -------- values processing ------------
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int addValueData(final String cid, final int orderNumber, final InputStream stream,
-      final int streamLength, final String storageId) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.addValueData(cid, orderNumber, stream, streamLength, storageId);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int deleteValueData(final String cid) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.deleteValueData(cid);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findValuesByPropertyId(final String cid) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findValuesByPropertyId(cid);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findValuesStorageDescriptorsByPropertyId(final String cid) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findValuesStorageDescriptorsByPropertyId(cid);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findValueByPropertyIdOrderNumber(final String cid, final int orderNumb) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findValueByPropertyIdOrderNumber(cid, orderNumb);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/CQJDBCStorageConnection.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -18,7 +18,6 @@
  */
 package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation;
 
-import org.exoplatform.commons.utils.PrivilegedFileHelper;
 import org.exoplatform.services.jcr.access.AccessControlEntry;
 import org.exoplatform.services.jcr.access.AccessControlList;
 import org.exoplatform.services.jcr.dataflow.ItemState;
@@ -444,7 +443,7 @@
                   swapFile.spoolDone();
                }
 
-               long vlen = PrivilegedFileHelper.length(swapFile);
+               long vlen = swapFile.length();
                if (vlen <= Integer.MAX_VALUE)
                {
                   streamLength = (int)vlen;

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	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/GenericCQConnectionFactory.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -24,9 +24,6 @@
 import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
 
 import java.io.File;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
@@ -197,37 +194,9 @@
    {
       try
       {
-         Connection conn = null;
+         Connection conn = dbDataSource != null ? dbDataSource.getConnection() : (dbUserName != null ? DriverManager
+            .getConnection(dbUrl, dbUserName, dbPassword) : DriverManager.getConnection(dbUrl));
 
-         PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
-         {
-            public Object run() throws Exception
-            {
-               return dbDataSource != null ? dbDataSource.getConnection() : (dbUserName != null ? DriverManager
-                  .getConnection(dbUrl, dbUserName, dbPassword) : DriverManager.getConnection(dbUrl));
-            }
-         };
-         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);
-            }
-         }
-
          if (readOnly)
          {
             // set this feature only if it asked

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBMultiDbJDBCConnection.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -16,22 +16,16 @@
  */
 package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
 
-import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
 import org.exoplatform.services.jcr.datamodel.QPath;
 import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
 
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
-import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.ResultSet;
 import java.util.List;
 
 import javax.jcr.InvalidItemStateException;
@@ -101,7 +95,6 @@
             + " V.ORDER_NUM, V.DATA, V.STORAGE_DESC from JCR_MITEM I LEFT OUTER JOIN JCR_MVALUE V ON (V.PROPERTY_ID=I.ID)"
             + " where I.PARENT_ID=? and I.I_CLASS=2 order by I.NAME";
    }
-
    /**
     * Use simple queries since it is much faster
     */
@@ -111,115 +104,6 @@
       return traverseQPathSQ(cpid);
    }
 
-   @Override
-   protected int addNodeRecord(final NodeData data) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.addNodeRecord(data);
-         }
-      });
-   }
-
-   @Override
-   protected int addPropertyRecord(final PropertyData data) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.addPropertyRecord(data);
-         }
-      });
-   }
-
-   @Override
-   protected int addReference(final PropertyData data) throws SQLException, IOException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.addReference(data);
-         }
-      });
-   }
-
-   @Override
-   protected int addValueData(final String cid, final int orderNumber, final InputStream stream,
-      final int streamLength, final String storageDesc) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.addValueData(cid, orderNumber, stream, streamLength, storageDesc);
-         }
-      });
-   }
-
-   @Override
-   protected int deleteItemByIdentifier(final String identifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.deleteItemByIdentifier(identifier);
-         }
-      });
-   }
-
-   @Override
-   protected int deleteReference(final String propertyIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.deleteReference(propertyIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected int deleteValueData(final String cid) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.deleteValueData(cid);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findChildNodesByParentIdentifier(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findChildNodesByParentIdentifier(parentIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findChildNodesByParentIdentifierCQ(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findChildNodesByParentIdentifierCQ(parentIdentifier);
-         }
-      });
-   }
-
    /**
     * {@inheritDoc}
     */
@@ -260,42 +144,6 @@
 
    }
 
-   @Override
-   protected ResultSet findLastOrderNumberByParentIdentifier(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findLastOrderNumberByParentIdentifier(parentIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findChildNodesCountByParentIdentifier(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findChildNodesCountByParentIdentifier(parentIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findChildPropertiesByParentIdentifier(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findChildPropertiesByParentIdentifier(parentIdentifier);
-         }
-      });
-   }
-
    /**
     * {@inheritDoc}
     */
@@ -308,7 +156,7 @@
          throw new SQLException("Pattern list is empty.");
       }
       else
-      {
+       {
          if (findPropertiesByParentIdAndComplexPatternCQ == null)
          {
             findPropertiesByParentIdAndComplexPatternCQ = dbConnection.createStatement();
@@ -330,162 +178,4 @@
          return findPropertiesByParentIdAndComplexPatternCQ.executeQuery(query.toString());
       }
    }
-
-   @Override
-   protected ResultSet findChildPropertiesByParentIdentifierCQ(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findChildPropertiesByParentIdentifierCQ(parentIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findItemByIdentifier(final String identifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findItemByIdentifier(identifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findItemByName(final String parentId, final String name, final int index) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findItemByName(parentId, name, index);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findItemQPathByIdentifierCQ(final String identifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findItemQPathByIdentifierCQ(identifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(final String parentIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findNodeMainPropertiesByParentIdentifierCQ(parentIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findPropertyByName(final String parentId, final String name) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findPropertyByName(parentId, name);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findReferences(final String nodeIdentifier) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findReferences(nodeIdentifier);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findValueByPropertyIdOrderNumber(final String cid, final int orderNumb) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findValueByPropertyIdOrderNumber(cid, orderNumb);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findValuesByPropertyId(final String cid) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findValuesByPropertyId(cid);
-         }
-      });
-   }
-
-   @Override
-   protected ResultSet findValuesStorageDescriptorsByPropertyId(final String cid) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.findValuesStorageDescriptorsByPropertyId(cid);
-         }
-      });
-   }
-
-   @Override
-   protected int renameNode(final NodeData data) throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.renameNode(data);
-         }
-      });
-   }
-
-   @Override
-   protected int updateNodeByIdentifier(final int version, final int index, final int orderNumb, final String identifier)
-      throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.updateNodeByIdentifier(version, index, orderNumb, identifier);
-         }
-      });
-   }
-
-   @Override
-   protected int updatePropertyByIdentifier(final int version, final int type, final String identifier)
-      throws SQLException
-   {
-      return SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBMultiDbJDBCConnection.super.updatePropertyByIdentifier(version, type, identifier);
-         }
-      });
-   }
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/optimisation/db/HSQLDBSingleDbJDBCConnection.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -16,19 +16,13 @@
  */
 package org.exoplatform.services.jcr.impl.storage.jdbc.optimisation.db;
 
-import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
 import org.exoplatform.services.jcr.datamodel.QPath;
 import org.exoplatform.services.jcr.impl.core.itemfilters.QPathEntryFilter;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
 
 import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -138,14 +132,7 @@
       findItemByName.setString(3, name);
       findItemByName.setInt(4, index);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findItemByName.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findItemByName.executeQuery();
    }
 
    /**
@@ -163,14 +150,7 @@
       findPropertyByName.setString(2, containerName);
       findPropertyByName.setString(3, name);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findPropertyByName.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findPropertyByName.executeQuery();
    }
 
    /**
@@ -187,14 +167,7 @@
       findNodesByParentId.setString(1, parentCid);
       findNodesByParentId.setString(2, containerName);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findNodesByParentId.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findNodesByParentId.executeQuery();
    }
 
    /**
@@ -211,14 +184,7 @@
       findLastOrderNumberByParentId.setString(1, parentIdentifier);
       findLastOrderNumberByParentId.setString(2, containerName);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findLastOrderNumberByParentId.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findLastOrderNumberByParentId.executeQuery();
    }
 
    /**
@@ -235,14 +201,7 @@
       findNodesCountByParentId.setString(1, parentCid);
       findNodesCountByParentId.setString(2, containerName);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findNodesCountByParentId.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findNodesCountByParentId.executeQuery();
    }
 
    /**
@@ -259,16 +218,9 @@
       findPropertiesByParentId.setString(1, parentCid);
       findPropertiesByParentId.setString(2, containerName);
 
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findPropertiesByParentId.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      return findPropertiesByParentId.executeQuery();
    }
-
+   
    /**
     * {@inheritDoc}
     */
@@ -283,17 +235,10 @@
       findNodesByParentIdCQ.setString(1, parentIdentifier);
       findNodesByParentIdCQ.setString(2, containerName);
       findNodesByParentIdCQ.setString(3, containerName);
-
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findNodesByParentIdCQ.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      
+      return findNodesByParentIdCQ.executeQuery();
    }
-
+  
    /**
     * {@inheritDoc}
     */
@@ -350,17 +295,10 @@
 
       findPropertiesByParentIdCQ.setString(1, parentIdentifier);
       findPropertiesByParentIdCQ.setString(2, containerName);
-
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return findPropertiesByParentIdCQ.executeQuery();
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
+      
+       return findPropertiesByParentIdCQ.executeQuery();
    }
-
+   
    /**
     * {@inheritDoc}
     */
@@ -397,280 +335,4 @@
          return findPropertiesByParentIdAndComplexPatternCQ.executeQuery(query.toString());
       }
    }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int addNodeRecord(final NodeData data) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.addNodeRecord(data);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int addPropertyRecord(final PropertyData prop) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.addPropertyRecord(prop);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findItemByIdentifier(final String identifier) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findItemByIdentifier(identifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int addReference(final PropertyData data) throws SQLException, IOException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.addReference(data);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int renameNode(final NodeData data) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.renameNode(data);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int deleteReference(final String propertyIdentifier) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.deleteReference(propertyIdentifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findReferences(final String nodeIdentifier) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findReferences(nodeIdentifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int deleteItemByIdentifier(final String identifier) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.deleteItemByIdentifier(identifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int updateNodeByIdentifier(final int version, final int index, final int orderNumb, final String identifier)
-      throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.updateNodeByIdentifier(version, index, orderNumb, identifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int updatePropertyByIdentifier(final int version, final int type, final String identifier)
-      throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.updatePropertyByIdentifier(version, type, identifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   // -------- values processing ------------
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int addValueData(final String cid, final int orderNumber, final InputStream stream,
-      final int streamLength, final String storageId) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.addValueData(cid, orderNumber, stream, streamLength, storageId);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected int deleteValueData(final String cid) throws SQLException
-   {
-      PrivilegedExceptionAction<Integer> action = new PrivilegedExceptionAction<Integer>()
-      {
-         public Integer run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.deleteValueData(cid);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findValuesByPropertyId(final String cid) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findValuesByPropertyId(cid);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findValuesStorageDescriptorsByPropertyId(final String cid) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findValuesStorageDescriptorsByPropertyId(cid);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findValueByPropertyIdOrderNumber(final String cid, final int orderNumb) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findValueByPropertyIdOrderNumber(cid, orderNumb);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findItemQPathByIdentifierCQ(final String identifier) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findItemQPathByIdentifierCQ(identifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
-
-   /**
-    * {@inheritDoc}
-    */
-   @Override
-   protected ResultSet findNodeMainPropertiesByParentIdentifierCQ(final String parentIdentifier) throws SQLException
-   {
-      PrivilegedExceptionAction<ResultSet> action = new PrivilegedExceptionAction<ResultSet>()
-      {
-         public ResultSet run() throws Exception
-         {
-            return HSQLDBSingleDbJDBCConnection.super.findNodeMainPropertiesByParentIdentifierCQ(parentIdentifier);
-         }
-      };
-      return SecurityHelper.doPrivilegedSQLExceptionAction(action);
-   }
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFile.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -19,12 +19,12 @@
 package org.exoplatform.services.jcr.impl.storage.value.fs;
 
 import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
 
 import java.io.File;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 /**
@@ -65,7 +65,7 @@
             return TreeFile.super.delete();
          }
       };
-      boolean res = AccessController.doPrivileged(action);
+      boolean res = SecurityHelper.doPrivilegedAction(action);
 
       if (res)
          deleteParent(new File(getParent()));

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	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileOperation.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -19,6 +19,7 @@
 package org.exoplatform.services.jcr.impl.storage.value.fs.operations;
 
 import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.impl.storage.value.ValueDataResourceHolder;
 import org.exoplatform.services.jcr.impl.storage.value.ValueOperation;
 import org.exoplatform.services.jcr.impl.storage.value.fs.FileLockException;
@@ -31,7 +32,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;
 
@@ -256,7 +256,7 @@
          };
          try
          {
-            local = AccessController.doPrivileged(action);
+            local = SecurityHelper.doPrivilegedExceptionAction(action);
          }
          catch (PrivilegedActionException pae)
          {

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	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/FileCleaner.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -19,13 +19,13 @@
 package org.exoplatform.services.jcr.impl.util.io;
 
 import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.container.ExoContainerContext;
 import org.exoplatform.services.jcr.impl.proccess.WorkerThread;
 import org.exoplatform.services.log.ExoLogger;
 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;
@@ -94,7 +94,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
 
       if (log.isDebugEnabled())
       {

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	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SpoolFile.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -19,13 +19,13 @@
 package org.exoplatform.services.jcr.impl.util.io;
 
 import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
 
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Map;
 import java.util.WeakHashMap;
@@ -119,7 +119,7 @@
                return sf.exists() ? SpoolFile.super.delete() : true;
             }
          };
-         return AccessController.doPrivileged(action);
+         return SecurityHelper.doPrivilegedAction(action);
 
       }
 

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/io/SwapFile.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -19,10 +19,10 @@
 package org.exoplatform.services.jcr.impl.util.io;
 
 import org.exoplatform.commons.utils.PrivilegedFileHelper;
+import org.exoplatform.commons.utils.SecurityHelper;
 
 import java.io.File;
 import java.io.IOException;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.HashMap;
 import java.util.Map;
@@ -168,7 +168,7 @@
                return sf.exists() ? SwapFile.super.delete() : true;
             }
          };
-         boolean res = AccessController.doPrivileged(action);
+         boolean res = SecurityHelper.doPrivilegedAction(action);
 
          if (res)
          {

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	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBInitializer.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -25,7 +25,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.sql.Connection;
@@ -120,7 +119,7 @@
             return this.getClass().getResourceAsStream(path);
          }
       };
-      final InputStream is = AccessController.doPrivileged(action);
+      final InputStream is = SecurityHelper.doPrivilegedAction(action);
 
       PrivilegedAction<InputStreamReader> actionGetReader = new PrivilegedAction<InputStreamReader>()
       {
@@ -129,7 +128,7 @@
             return new InputStreamReader(is);
          }
       };
-      InputStreamReader isr = AccessController.doPrivileged(actionGetReader);
+      InputStreamReader isr = SecurityHelper.doPrivilegedAction(actionGetReader);
 
       try
       {

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/ISPNCacheFactory.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -38,7 +38,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
@@ -154,7 +153,7 @@
             return manager.getCache(regionIdEscaped);
          }
       };
-      Cache<K, V> cache = AccessController.doPrivileged(action);
+      Cache<K, V> cache = SecurityHelper.doPrivilegedAction(action);
 
       return cache;
    }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/PrivilegedISPNCacheHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/PrivilegedISPNCacheHelper.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/infinispan/PrivilegedISPNCacheHelper.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -18,10 +18,10 @@
  */
 package org.exoplatform.services.jcr.infinispan;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.infinispan.Cache;
 
 import java.io.Serializable;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.concurrent.TimeUnit;
 
@@ -48,7 +48,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    /**
@@ -66,7 +66,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    /**
@@ -83,7 +83,7 @@
             return cache.putIfAbsent(key, value);
          }
       };
-      return AccessController.doPrivileged(action);
+      return SecurityHelper.doPrivilegedAction(action);
    }
 
    /**
@@ -100,7 +100,7 @@
             return cache.put(key, value);
          }
       };
-      return AccessController.doPrivileged(action);
+      return SecurityHelper.doPrivilegedAction(action);
    }
 
    /**
@@ -118,6 +118,6 @@
             return cache.put(key, value, lifespan, unit);
          }
       };
-      return AccessController.doPrivileged(action);
+      return SecurityHelper.doPrivilegedAction(action);
    }
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/ExoJBossCacheFactory.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -40,7 +40,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.HashMap;
 import java.util.Map;
@@ -175,7 +174,7 @@
             return factory.createCache(stream, false);
          }
       };
-      Cache<K, V> cache = AccessController.doPrivileged(action);
+      Cache<K, V> cache = SecurityHelper.doPrivilegedAction(action);
 
       // inject transaction manager if defined
       if (transactionManager != null)

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/PrivilegedJBossCacheHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/PrivilegedJBossCacheHelper.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/jbosscache/PrivilegedJBossCacheHelper.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -18,12 +18,12 @@
  */
 package org.exoplatform.services.jcr.jbosscache;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.jboss.cache.Cache;
 import org.jboss.cache.CacheException;
 import org.jboss.cache.Fqn;
 
 import java.io.Serializable;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -50,7 +50,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    /**
@@ -68,7 +68,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    /**
@@ -86,7 +86,7 @@
             return null;
          }
       };
-      AccessController.doPrivileged(action);
+      SecurityHelper.doPrivilegedAction(action);
    }
 
    /**
@@ -94,44 +94,6 @@
     * 
     * @param cache
     */
-   public static Object put(final Cache<Serializable, Object> cache, final String fqn, final Serializable key,
-      final Object value) throws CacheException
-   {
-      PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
-      {
-         public Object run() throws Exception
-         {
-            return cache.put(fqn, key, value);
-
-         }
-      };
-      try
-      {
-         return 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);
-         }
-      }
-   }
-
-   /**
-    * Put in JBoss cache in privileged mode.
-    * 
-    * @param cache
-    */
    public static Object put(final Cache<Serializable, Object> cache, final Fqn fqn, final Serializable key,
       final Object value) throws CacheException
    {
@@ -144,7 +106,7 @@
       };
       try
       {
-         return AccessController.doPrivileged(action);
+         return SecurityHelper.doPrivilegedExceptionAction(action);
       }
       catch (PrivilegedActionException pae)
       {
@@ -163,40 +125,4 @@
          }
       }
    }
-
-   /**
-    * Remove node in privileged mode.
-    * 
-    * @param cache
-    */
-   public static Object removeNode(final Cache<Serializable, Object> cache, final Fqn fqn) throws CacheException
-   {
-      PrivilegedExceptionAction<Object> action = new PrivilegedExceptionAction<Object>()
-      {
-         public Object run() throws Exception
-         {
-            return cache.removeNode(fqn);
-         }
-      };
-      try
-      {
-         return 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);
-         }
-      }
-   }
 }

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/ActionNonTxAware.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/ActionNonTxAware.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/transaction/ActionNonTxAware.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -18,12 +18,9 @@
  */
 package org.exoplatform.services.transaction;
 
-import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
 
-import java.security.PrivilegedExceptionAction;
-
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 
@@ -58,13 +55,7 @@
          {
             try
             {
-               tx = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Transaction>()
-               {
-                  public Transaction run() throws Exception
-                  {
-                     return tm.suspend();
-                  }
-               });
+               tx = tm.suspend();
             }
             catch (Exception e)
             {
@@ -79,15 +70,7 @@
          {
             try
             {
-               final Transaction privilegedTx = tx;
-               SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Object>()
-               {
-                  public Object run() throws Exception
-                  {
-                     tm.resume(privilegedTx);
-                     return null;
-                  }
-               });
+               tm.resume(tx);
             }
             catch (Exception e)
             {

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScript2RestLoader.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -20,6 +20,7 @@
 
 import org.apache.commons.fileupload.FileItem;
 import org.codehaus.groovy.control.CompilationFailedException;
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.container.component.ComponentPlugin;
 import org.exoplatform.container.configuration.ConfigurationManager;
 import org.exoplatform.container.xml.InitParams;
@@ -54,7 +55,6 @@
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
-import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
@@ -74,7 +74,6 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.observation.Event;
-import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
 import javax.ws.rs.Consumes;
@@ -595,7 +594,7 @@
       Document doc;
       try
       {
-         doc = AccessController.doPrivileged(new PrivilegedExceptionAction<Document>()
+         doc = SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Document>()
          {
             public Document run() throws ParserConfigurationException
             {

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/GroovyScriptAddRepoPlugin.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -19,6 +19,7 @@
 
 package org.exoplatform.services.jcr.ext.script.groovy;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.container.component.BaseComponentPlugin;
 import org.exoplatform.container.xml.InitParams;
 import org.exoplatform.container.xml.PropertiesParam;
@@ -28,7 +29,6 @@
 
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.Collection;
@@ -70,7 +70,7 @@
          final String path = p.getProperty("path");
          try
          {
-            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>()
+            SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>()
             {
                public Void run() throws MalformedURLException
                {

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyClassLoaderProvider.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyClassLoaderProvider.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyClassLoaderProvider.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -30,6 +30,7 @@
 import org.codehaus.groovy.control.SourceUnit;
 import org.codehaus.groovy.control.io.ReaderSource;
 import org.codehaus.groovy.control.io.URLReaderSource;
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.rest.ext.groovy.ExtendedGroovyClassLoader;
 import org.exoplatform.services.rest.ext.groovy.GroovyClassLoaderProvider;
 import org.exoplatform.services.rest.ext.groovy.SourceFile;
@@ -39,7 +40,6 @@
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.security.AccessController;
 import java.security.CodeSource;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -231,7 +231,7 @@
    
    public JcrGroovyClassLoaderProvider()
    {
-      super(AccessController.doPrivileged(new PrivilegedAction<JcrGroovyClassLoader>() {
+      super(SecurityHelper.doPrivilegedAction(new PrivilegedAction<JcrGroovyClassLoader>() {
          public JcrGroovyClassLoader run()
          {
             return new JcrGroovyClassLoader(JcrGroovyClassLoaderProvider.class.getClassLoader());
@@ -252,7 +252,7 @@
          roots[i] = sources[i].getPath();
 
       final GroovyClassLoader parent = getGroovyClassLoader();
-      JcrGroovyClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<JcrGroovyClassLoader>() {
+      JcrGroovyClassLoader classLoader = SecurityHelper.doPrivilegedAction(new PrivilegedAction<JcrGroovyClassLoader>() {
          public JcrGroovyClassLoader run()
          {
             return new JcrGroovyClassLoader(parent);

Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -22,6 +22,7 @@
 import groovy.lang.GroovyClassLoader;
 import groovy.lang.GroovyCodeSource;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.services.jcr.ext.resource.UnifiedNodeReference;
 import org.exoplatform.services.jcr.ext.script.groovy.JcrGroovyClassLoaderProvider.JcrGroovyClassLoader;
 import org.exoplatform.services.log.ExoLogger;
@@ -34,7 +35,6 @@
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -170,7 +170,7 @@
    @SuppressWarnings("rawtypes")
    private Class<?>[] doCompile(final JcrGroovyClassLoader cl, final SourceFile[] files) throws IOException
    {
-      Class[] classes = AccessController.doPrivileged(new PrivilegedAction<Class[]>() {
+      Class[] classes = SecurityHelper.doPrivilegedAction(new PrivilegedAction<Class[]>() {
          public Class[] run()
          {
             return cl.parseClasses(files);
@@ -194,7 +194,7 @@
    {
       try
       {
-         return AccessController.doPrivileged(new PrivilegedExceptionAction<URL[]>() {
+         return SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<URL[]>() {
             public URL[] run() throws IOException
             {
                return ((JcrGroovyClassLoader)classLoaderProvider.getGroovyClassLoader()).findDependencies(sources,
@@ -243,7 +243,7 @@
    @Deprecated
    protected GroovyCodeSource createCodeSource(final InputStream in, final String name)
    {
-      GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
+      GroovyCodeSource gcs = SecurityHelper.doPrivilegedAction(new PrivilegedAction<GroovyCodeSource>() {
          public GroovyCodeSource run()
          {
             return new GroovyCodeSource(in, name, "/groovy/script");

Modified: jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java
===================================================================
--- jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java	2011-05-31 06:49:58 UTC (rev 4454)
+++ jcr/trunk/exo.jcr.connectors.jca/src/main/java/org/exoplatform/connectors/jcr/impl/adapter/ManagedSessionFactory.java	2011-05-31 06:54:06 UTC (rev 4455)
@@ -18,6 +18,7 @@
  */
 package org.exoplatform.connectors.jcr.impl.adapter;
 
+import org.exoplatform.commons.utils.SecurityHelper;
 import org.exoplatform.container.ExoContainer;
 import org.exoplatform.container.ExoContainerContext;
 import org.exoplatform.container.PortalContainer;
@@ -30,7 +31,6 @@
 import org.exoplatform.services.log.Log;
 
 import java.io.PrintWriter;
-import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Iterator;
 import java.util.Set;
@@ -153,7 +153,7 @@
       CredentialsImpl credentials = null;
       if (subject != null)
       {
-         credentials = AccessController.doPrivileged(new PrivilegedAction<CredentialsImpl>()
+         credentials = SecurityHelper.doPrivilegedAction(new PrivilegedAction<CredentialsImpl>()
          {
             public CredentialsImpl run()
             {



More information about the exo-jcr-commits mailing list