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/03/14 08:20:35 UTC
[2/2] syncope git commit: [SYNCOPE-1045] Properly managing exceptions
when updating workflow definition from Activiti Modeler
[SYNCOPE-1045] Properly managing exceptions when updating workflow definition from Activiti Modeler
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/750c789a
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/750c789a
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/750c789a
Branch: refs/heads/master
Commit: 750c789aa2e79559ce0f5f875082473c11be8153
Parents: a0ffad7
Author: Francesco Chicchiricc� <il...@apache.org>
Authored: Tue Mar 14 09:20:06 2017 +0100
Committer: Francesco Chicchiricc� <il...@apache.org>
Committed: Tue Mar 14 09:20:23 2017 +0100
----------------------------------------------------------------------
.../resources/WorkflowDefPUTResource.java | 24 +++++++++++++++-----
1 file changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/750c789a/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java
index 1446ee1..9eeab54 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/resources/WorkflowDefPUTResource.java
@@ -21,6 +21,7 @@ package org.apache.syncope.client.console.resources;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.apache.cxf.common.util.UrlUtils;
import org.apache.syncope.client.console.rest.WorkflowRestClient;
import org.apache.wicket.request.resource.AbstractResource;
@@ -39,6 +40,8 @@ public class WorkflowDefPUTResource extends AbstractResource {
private static final Logger LOG = LoggerFactory.getLogger(WorkflowDefPUTResource.class);
+ private final WorkflowRestClient restClient = new WorkflowRestClient();
+
@Override
protected ResourceResponse newResourceResponse(final Attributes attributes) {
String definition = null;
@@ -53,14 +56,23 @@ public class WorkflowDefPUTResource extends AbstractResource {
}
}
} catch (IOException e) {
- LOG.error("Could not extract workflow definition from request", e);
+ LOG.error("Could not extract workflow definition", e);
+ }
+ if (definition == null) {
+ return new ResourceResponse().setStatusCode(Response.Status.BAD_REQUEST.getStatusCode()).
+ setError(Response.Status.BAD_REQUEST.getStatusCode(),
+ "Could not extract workflow definition");
}
- new WorkflowRestClient().updateDefinition(MediaType.APPLICATION_JSON_TYPE, definition);
-
- ResourceResponse response = new ResourceResponse();
- response.setStatusCode(204);
- return response;
+ try {
+ restClient.updateDefinition(MediaType.APPLICATION_JSON_TYPE, definition);
+ return new ResourceResponse().setStatusCode(Response.Status.NO_CONTENT.getStatusCode());
+ } catch (Exception e) {
+ LOG.error("While updating workflow definition", e);
+ return new ResourceResponse().setStatusCode(Response.Status.BAD_REQUEST.getStatusCode()).
+ setError(Response.Status.BAD_REQUEST.getStatusCode(),
+ "While updating workflow definition: " + e.getMessage());
+ }
}
}