Author: tolusha
Date: 2010-06-11 03:38:35 -0400 (Fri, 11 Jun 2010)
New Revision: 2545
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java
Log:
EXOJCR-756: doPrivileged() TreeFileIOChannel
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java 2010-06-11
07:33:56 UTC (rev 2544)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/TreeFileIOChannel.java 2010-06-11
07:38:35 UTC (rev 2545)
@@ -23,6 +23,9 @@
import java.io.File;
import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.concurrent.Semaphore;
/**
@@ -52,10 +55,33 @@
@Override
protected File getFile(final String propertyId, final int orderNumber) throws
IOException
{
- final TreeFile tfile =
- new TreeFile(rootDir.getAbsolutePath() + makeFilePath(propertyId, orderNumber),
cleaner, rootDir);
- mkdirs(tfile.getParentFile()); // make dirs on path
- return tfile;
+ PrivilegedExceptionAction<Object> action = new
PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ final TreeFile tfile =
+ new TreeFile(rootDir.getAbsolutePath() + makeFilePath(propertyId,
orderNumber), cleaner, rootDir);
+ mkdirs(tfile.getParentFile()); // make dirs on path
+
+ return tfile;
+ }
+ };
+ try
+ {
+ return (File)AccessController.doPrivileged(action);
+ }
+ catch (PrivilegedActionException pae)
+ {
+ Throwable cause = pae.getCause();
+ if (cause instanceof IOException)
+ {
+ throw (IOException)cause;
+ }
+ else
+ {
+ throw new RuntimeException(cause);
+ }
+ }
}
@Override