You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/09/21 14:09:56 UTC

[1/2] syncope git commit: Graceful handling of InvalidEntityExceptions for non-standard entities

Repository: syncope
Updated Branches:
  refs/heads/2_0_X 29f9c5e39 -> 381625c7c
  refs/heads/master 3aba0a577 -> 86e593bda


Graceful handling of InvalidEntityExceptions for non-standard entities


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/381625c7
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/381625c7
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/381625c7

Branch: refs/heads/2_0_X
Commit: 381625c7c0bdc6dc2b6722aa870a458f9892f717
Parents: 29f9c5e
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Sep 21 16:09:37 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Sep 21 16:09:37 2017 +0200

----------------------------------------------------------------------
 .../core/rest/cxf/RestServiceExceptionMapper.java | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/381625c7/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
index 718216e..2e77b37 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
@@ -206,11 +206,19 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception> {
         }
 
         if (iee != null) {
-            ClientExceptionType exType = iee.getEntityClassSimpleName().endsWith("Policy")
-                    ? ClientExceptionType.InvalidPolicy
-                    : iee.getEntityClassSimpleName().equals(PlainAttr.class.getSimpleName())
-                    ? ClientExceptionType.InvalidValues
-                    : ClientExceptionType.valueOf("Invalid" + iee.getEntityClassSimpleName());
+            ClientExceptionType exType;
+            if (iee.getEntityClassSimpleName().endsWith("Policy")) {
+                exType = ClientExceptionType.InvalidPolicy;
+            } else if (iee.getEntityClassSimpleName().equals(PlainAttr.class.getSimpleName())) {
+                exType = ClientExceptionType.InvalidValues;
+            } else {
+                try {
+                    exType = ClientExceptionType.valueOf("Invalid" + iee.getEntityClassSimpleName());
+                } catch (IllegalArgumentException e) {
+                    // ignore
+                    exType = ClientExceptionType.InvalidEntity;
+                }
+            }
 
             ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
             builder.header(RESTHeaders.ERROR_CODE, exType.name());


[2/2] syncope git commit: Graceful handling of InvalidEntityExceptions for non-standard entities

Posted by il...@apache.org.
Graceful handling of InvalidEntityExceptions for non-standard entities


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/86e593bd
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/86e593bd
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/86e593bd

Branch: refs/heads/master
Commit: 86e593bda7389025b681e19168bd4a0dff77784a
Parents: 3aba0a5
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Sep 21 16:09:37 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Sep 21 16:09:48 2017 +0200

----------------------------------------------------------------------
 .../core/rest/cxf/RestServiceExceptionMapper.java | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/86e593bd/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
index 9b97000..db834e3 100644
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
+++ b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/RestServiceExceptionMapper.java
@@ -206,11 +206,19 @@ public class RestServiceExceptionMapper implements ExceptionMapper<Exception> {
         }
 
         if (iee != null) {
-            ClientExceptionType exType = iee.getEntityClassSimpleName().endsWith("Policy")
-                    ? ClientExceptionType.InvalidPolicy
-                    : iee.getEntityClassSimpleName().equals(PlainAttr.class.getSimpleName())
-                    ? ClientExceptionType.InvalidValues
-                    : ClientExceptionType.valueOf("Invalid" + iee.getEntityClassSimpleName());
+            ClientExceptionType exType;
+            if (iee.getEntityClassSimpleName().endsWith("Policy")) {
+                exType = ClientExceptionType.InvalidPolicy;
+            } else if (iee.getEntityClassSimpleName().equals(PlainAttr.class.getSimpleName())) {
+                exType = ClientExceptionType.InvalidValues;
+            } else {
+                try {
+                    exType = ClientExceptionType.valueOf("Invalid" + iee.getEntityClassSimpleName());
+                } catch (IllegalArgumentException e) {
+                    // ignore
+                    exType = ClientExceptionType.InvalidEntity;
+                }
+            }
 
             ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST);
             builder.header(RESTHeaders.ERROR_CODE, exType.name());