tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlmonte...@apache.org
Subject svn commit: r1607041 - in /tomee/tomee/trunk/server/openejb-cxf-rs/src: main/java/org/apache/openejb/server/cxf/rs/ test/java/org/apache/openejb/server/cxf/rs/
Date Tue, 01 Jul 2014 10:59:21 GMT
Author: jlmonteiro
Date: Tue Jul  1 10:59:21 2014
New Revision: 1607041

URL: http://svn.apache.org/r1607041
Log:
Better EJB exception management

Added:
    tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapper.java
      - copied, changed from r1607025, tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapper.java
    tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapperTest.java
      - copied, changed from r1607025, tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapperTest.java
Removed:
    tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapper.java
    tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapperTest.java
Modified:
    tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java

Modified: tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java?rev=1607041&r1=1607040&r2=1607041&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
(original)
+++ tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
Tue Jul  1 10:59:21 2014
@@ -583,23 +583,25 @@ public class CxfRsHttpListener implement
         }
 
         // providers
-        Set<String> providersConfig = new HashSet<String>();
-        {
-            // add an exception mapper for EJBAccessException to convert into 403
-            providersConfig.add(SecurityExceptionMapper.class.getName());
-
-            // then add first global providers
-            if (GLOBAL_PROVIDERS != null) {
-                providersConfig.addAll(Arrays.asList(GLOBAL_PROVIDERS.split(",")));
-            }
+        Set<String> providersConfig = null;
 
-            // and finally user custom providers
+        {
             final String provider = serviceConfiguration.getProperties().getProperty(PROVIDERS_KEY);
             if (provider != null) {
+                providersConfig = new HashSet<String>();
                 for (final String p : Arrays.asList(provider.split(","))) {
                     providersConfig.add(p.trim());
                 }
             }
+
+            {
+                if (GLOBAL_PROVIDERS != null) {
+                    if (providersConfig == null) {
+                        providersConfig = new HashSet<String>();
+                    }
+                    providersConfig.addAll(Arrays.asList(GLOBAL_PROVIDERS.split(",")));
+                }
+            }
         }
 
         List<Object> providers = null;
@@ -608,7 +610,6 @@ public class CxfRsHttpListener implement
             if (providers != null && additionalProviders != null && !additionalProviders.isEmpty())
{
                 providers.addAll(providers(services, additionalProviders));
             }
-            factory.setProviders(providers);
         }
         if (providers == null) {
             providers = new ArrayList<Object>();
@@ -617,10 +618,13 @@ public class CxfRsHttpListener implement
             } else {
                 providers.addAll(defaultProviders());
             }
-            factory.setProviders(providers);
-        } else {
-            LOGGER.info("Using providers " + providers);
         }
+
+        // add the EJB access exception mapper
+        providers.add(EJBAccessExceptionMapper.INSTANCE);
+
+        LOGGER.info("Using providers " + providers);
+        factory.setProviders(providers);
     }
 
     private static List<Object> defaultProviders() {

Copied: tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapper.java
(from r1607025, tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapper.java)
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapper.java?p2=tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapper.java&p1=tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapper.java&r1=1607025&r2=1607041&rev=1607041&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapper.java
(original)
+++ tomee/tomee/trunk/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapper.java
Tue Jul  1 10:59:21 2014
@@ -20,7 +20,9 @@ import javax.ejb.EJBAccessException;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.ExceptionMapper;
 
-public class SecurityExceptionMapper implements ExceptionMapper<EJBAccessException>
{
+public class EJBAccessExceptionMapper implements ExceptionMapper<EJBAccessException>
{
+    public static final EJBAccessExceptionMapper INSTANCE = new EJBAccessExceptionMapper();
+
     @Override
     public Response toResponse(EJBAccessException throwable) {
         return Response.status(Response.Status.FORBIDDEN).build();

Copied: tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapperTest.java
(from r1607025, tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapperTest.java)
URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapperTest.java?p2=tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapperTest.java&p1=tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapperTest.java&r1=1607025&r2=1607041&rev=1607041&view=diff
==============================================================================
--- tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/SecurityExceptionMapperTest.java
(original)
+++ tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/EJBAccessExceptionMapperTest.java
Tue Jul  1 10:59:21 2014
@@ -41,7 +41,7 @@ import java.util.Properties;
 
 import static org.junit.Assert.assertEquals;
 
-public class SecurityExceptionMapperTest {
+public class EJBAccessExceptionMapperTest {
     private static EJBContainer container;
     private static RESTIsCool service;
 



Mime
View raw message