Author: tolusha
Date: 2010-06-18 05:04:49 -0400 (Fri, 18 Jun 2010)
New Revision: 2658
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/SecurityHelper.java
Log:
EXOJCR-756: add new privileged method
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/SecurityHelper.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/SecurityHelper.java 2010-06-18
06:39:37 UTC (rev 2657)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/SecurityHelper.java 2010-06-18
09:04:49 UTC (rev 2658)
@@ -23,6 +23,7 @@
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.sql.SQLException;
import javax.jcr.RepositoryException;
@@ -69,6 +70,38 @@
}
/**
+ * Launches action in privileged mode. Can throw only IO exception.
+ *
+ * @param <E>
+ * @param action
+ * @return
+ * @throws IOException
+ */
+ public static <E> E
doPriviledgedSQLExceptionAction(PrivilegedExceptionAction<E> action) throws
SQLException
+ {
+ try
+ {
+ return 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);
+ }
+ }
+ }
+
+ /**
* Launches action in privileged mode. Can throw only repository exception.
*
* @param <E>
@@ -101,7 +134,6 @@
}
}
-
/**
* Launches action in privileged mode. Can throw only runtime exceptions.
*
Show replies by date