syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/3] git commit: Fixing connector and resource exception handling
Date Fri, 31 Oct 2014 11:09:33 GMT
Repository: syncope
Updated Branches:
  refs/heads/1_2_X 9329c54fd -> 6f309b645
  refs/heads/master 1073966f4 -> dca2c53c9


Fixing connector and resource exception handling


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

Branch: refs/heads/1_2_X
Commit: 6f309b645f8b7652ce5dc253d02ef405a9853102
Parents: 9329c54
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Fri Oct 31 12:09:16 2014 +0100
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Fri Oct 31 12:09:16 2014 +0100

----------------------------------------------------------------------
 .../syncope/common/types/ClientExceptionType.java   |  1 -
 .../core/rest/controller/ConnectorController.java   | 16 ++++++++++------
 .../core/rest/controller/ResourceController.java    | 16 ++++++++++------
 3 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/6f309b64/common/src/main/java/org/apache/syncope/common/types/ClientExceptionType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/syncope/common/types/ClientExceptionType.java
b/common/src/main/java/org/apache/syncope/common/types/ClientExceptionType.java
index f635811..4113ff9 100644
--- a/common/src/main/java/org/apache/syncope/common/types/ClientExceptionType.java
+++ b/common/src/main/java/org/apache/syncope/common/types/ClientExceptionType.java
@@ -31,7 +31,6 @@ public enum ClientExceptionType {
     InvalidSecurityAnswer(Response.Status.BAD_REQUEST),
     InvalidLogger(Response.Status.BAD_REQUEST),
     InvalidConnInstance(Response.Status.BAD_REQUEST),
-    InvalidResource(Response.Status.BAD_REQUEST),
     InvalidConnIdConf(Response.Status.BAD_REQUEST),
     InvalidPolicy(Response.Status.BAD_REQUEST),
     InvalidSyncopeConf(Response.Status.BAD_REQUEST),

http://git-wip-us.apache.org/repos/asf/syncope/blob/6f309b64/core/src/main/java/org/apache/syncope/core/rest/controller/ConnectorController.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/controller/ConnectorController.java
b/core/src/main/java/org/apache/syncope/core/rest/controller/ConnectorController.java
index c538f20..52cfec3 100644
--- a/core/src/main/java/org/apache/syncope/core/rest/controller/ConnectorController.java
+++ b/core/src/main/java/org/apache/syncope/core/rest/controller/ConnectorController.java
@@ -75,10 +75,12 @@ public class ConnectorController extends AbstractTransactionalController<ConnIns
         ConnInstance connInstance = binder.getConnInstance(connInstanceTO);
         try {
             connInstance = connInstanceDAO.save(connInstance);
+        } catch (SyncopeClientException e) {
+            throw e;
         } catch (Exception e) {
-            SyncopeClientException exception = SyncopeClientException.build(ClientExceptionType.InvalidConnInstance);
-            exception.getElements().add(e.getMessage());
-            throw exception;
+            SyncopeClientException ex = SyncopeClientException.build(ClientExceptionType.InvalidConnInstance);
+            ex.getElements().add(e.getMessage());
+            throw ex;
         }
 
         return binder.getConnInstanceTO(connInstance);
@@ -89,10 +91,12 @@ public class ConnectorController extends AbstractTransactionalController<ConnIns
         ConnInstance connInstance = binder.updateConnInstance(connInstanceTO.getId(), connInstanceTO);
         try {
             connInstance = connInstanceDAO.save(connInstance);
+        } catch (SyncopeClientException e) {
+            throw e;
         } catch (Exception e) {
-            SyncopeClientException exception = SyncopeClientException.build(ClientExceptionType.InvalidConnInstance);
-            exception.getElements().add(e.getMessage());
-            throw exception;
+            SyncopeClientException ex = SyncopeClientException.build(ClientExceptionType.InvalidConnInstance);
+            ex.getElements().add(e.getMessage());
+            throw ex;
         }
 
         return binder.getConnInstanceTO(connInstance);

http://git-wip-us.apache.org/repos/asf/syncope/blob/6f309b64/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
b/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
index 3a84824..b61afcc 100644
--- a/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
+++ b/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java
@@ -104,10 +104,12 @@ public class ResourceController extends AbstractTransactionalController<Resource
         ExternalResource resource = null;
         try {
             resource = resourceDAO.save(binder.create(resourceTO));
+        } catch (SyncopeClientException e) {
+            throw e;
         } catch (Exception e) {
-            SyncopeClientException exception = SyncopeClientException.build(ClientExceptionType.InvalidResource);
-            exception.getElements().add(e.getMessage());
-            throw exception;
+            SyncopeClientException ex = SyncopeClientException.build(ClientExceptionType.InvalidExternalResource);
+            ex.getElements().add(e.getMessage());
+            throw ex;
         }
 
         return binder.getResourceTO(resource);
@@ -123,10 +125,12 @@ public class ResourceController extends AbstractTransactionalController<Resource
         resource = binder.update(resource, resourceTO);
         try {
             resource = resourceDAO.save(resource);
+        } catch (SyncopeClientException e) {
+            throw e;
         } catch (Exception e) {
-            SyncopeClientException exception = SyncopeClientException.build(ClientExceptionType.InvalidResource);
-            exception.getElements().add(e.getMessage());
-            throw exception;
+            SyncopeClientException ex = SyncopeClientException.build(ClientExceptionType.InvalidExternalResource);
+            ex.getElements().add(e.getMessage());
+            throw ex;
         }
 
         return binder.getResourceTO(resource);


Mime
View raw message