Skip to content
Browse files

BZ-781626 -ext: make sure terminate and delete button are safe as well

  • Loading branch information...
1 parent 74b5c31 commit c74e9fc63420e590aa6c774d4c4525f383090a49 @mswiderski mswiderski committed
View
13 gui/app-base/src/main/java/org/jboss/bpm/console/client/process/DeleteInstanceAction.java
@@ -25,10 +25,13 @@
import com.google.gwt.http.client.Response;
import com.mvc4g.client.Controller;
import com.mvc4g.client.Event;
+
+import org.gwt.mosaic.ui.client.MessageBox;
import org.jboss.bpm.console.client.URLBuilder;
import org.jboss.bpm.console.client.common.AbstractRESTAction;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.client.util.ConsoleLog;
/**
* @author Heiko.Braun <heiko.braun@jboss.com>
@@ -67,4 +70,14 @@ public void handleSuccessfulResponse(final Controller controller, final Object e
)
);
}
+
+ protected void handleError(String url, Throwable t) {
+
+ String message = t.getMessage();
+ // remove the default prefix for errors added by AbstractRESTAction
+ message = message.replaceFirst("HTTP \\d*: ","");
+
+ ConsoleLog.warn("Server reported following warning: " + message + " for url " + url);
+ MessageBox.alert("Status information", message);
+ }
}
View
22 gui/app-base/src/main/java/org/jboss/bpm/console/client/process/InstanceListView.java
@@ -332,15 +332,19 @@ public void onResult(boolean doIt)
if (doIt)
{
- ProcessInstanceRef selection = getSelection();
- selection.setState(ProcessInstanceRef.STATE.ENDED);
-
- controller.handleEvent(
- new Event(
- DeleteInstanceAction.ID,
- selection
- )
- );
+ try {
+ ProcessInstanceRef selection = getSelection();
+ selection.setState(ProcessInstanceRef.STATE.ENDED);
+
+ controller.handleEvent(
+ new Event(
+ DeleteInstanceAction.ID,
+ selection
+ )
+ );
+ } catch (Exception e) {
+ MessageBox.alert("Warning", e.getMessage());
+ }
}
}
});
View
13 gui/app-base/src/main/java/org/jboss/bpm/console/client/process/StateChangeAction.java
@@ -25,10 +25,13 @@
import com.google.gwt.http.client.Response;
import com.mvc4g.client.Controller;
import com.mvc4g.client.Event;
+
+import org.gwt.mosaic.ui.client.MessageBox;
import org.jboss.bpm.console.client.URLBuilder;
import org.jboss.bpm.console.client.common.AbstractRESTAction;
import org.jboss.bpm.console.client.model.ProcessDefinitionRef;
import org.jboss.bpm.console.client.model.ProcessInstanceRef;
+import org.jboss.bpm.console.client.util.ConsoleLog;
/**
* Starts a new process instance.
@@ -67,5 +70,15 @@ public void handleSuccessfulResponse(final Controller controller, final Object e
// force reload instance list
controller.handleEvent( new Event(UpdateInstancesAction.ID, def));
}
+
+ protected void handleError(String url, Throwable t) {
+
+ String message = t.getMessage();
+ // remove the default prefix for errors added by AbstractRESTAction
+ message = message.replaceFirst("HTTP \\d*: ","");
+
+ ConsoleLog.warn("Server reported following warning: " + message + " for url " + url);
+ MessageBox.alert("Status information", message);
+ }
}
View
48 server/war-base/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
@@ -230,7 +230,7 @@ public Response getInstanceData(
StringBuffer sb = payload2XML.convert(instanceId, javaPayload);
return Response.ok(sb.toString()).build();
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Error when getting instance data", e);
ResponseBuilder builder = Response.fromResponse(Response.ok(e.getMessage()).build());
builder.status(Status.INTERNAL_SERVER_ERROR);
@@ -249,10 +249,18 @@ public Response changeState(
@PathParam("next")
String next)
{
- ProcessInstanceRef.STATE state = ProcessInstanceRef.STATE.valueOf(next);
- log.debug("Change instance (ID "+executionId+") to state " +state);
- getProcessManagement().setProcessState(executionId, state);
- return Response.ok().type("application/json").build();
+ try {
+ ProcessInstanceRef.STATE state = ProcessInstanceRef.STATE.valueOf(next);
+ log.debug("Change instance (ID "+executionId+") to state " +state);
+ getProcessManagement().setProcessState(executionId, state);
+ return Response.ok().type("application/json").build();
+ } catch (Exception e) {
+ log.error("Error when getting changing state of process instance", e);
+ ResponseBuilder builder = Response.fromResponse(Response.ok(e.getMessage()).build());
+ builder.status(Status.INTERNAL_SERVER_ERROR);
+
+ return builder.build();
+ }
}
@POST
@@ -264,10 +272,18 @@ public Response endInstance(
@PathParam("result")
String resultValue)
{
- ProcessInstanceRef.RESULT result = ProcessInstanceRef.RESULT.valueOf(resultValue);
- log.debug("Change instance (ID "+executionId+") to state " + ProcessInstanceRef.STATE.ENDED);
- getProcessManagement().endInstance(executionId, result);
- return Response.ok().type("application/json").build();
+ try {
+ ProcessInstanceRef.RESULT result = ProcessInstanceRef.RESULT.valueOf(resultValue);
+ log.debug("Change instance (ID "+executionId+") to state " + ProcessInstanceRef.STATE.ENDED);
+ getProcessManagement().endInstance(executionId, result);
+ return Response.ok().type("application/json").build();
+ } catch (Exception e) {
+ log.error("Error when getting ending of process instance", e);
+ ResponseBuilder builder = Response.fromResponse(Response.ok(e.getMessage()).build());
+ builder.status(Status.INTERNAL_SERVER_ERROR);
+
+ return builder.build();
+ }
}
@POST
@@ -279,9 +295,17 @@ public Response deleteInstance(
String executionId
)
{
- log.debug("Delete instance (ID "+executionId+")");
- getProcessManagement().deleteInstance(executionId);
- return Response.ok().type("application/json").build();
+ try {
+ log.debug("Delete instance (ID "+executionId+")");
+ getProcessManagement().deleteInstance(executionId);
+ return Response.ok().type("application/json").build();
+ } catch (Exception e) {
+ log.error("Error when getting ending of process instance", e);
+ ResponseBuilder builder = Response.fromResponse(Response.ok(e.getMessage()).build());
+ builder.status(Status.INTERNAL_SERVER_ERROR);
+
+ return builder.build();
+ }
}
@POST

0 comments on commit c74e9fc

Please sign in to comment.
Something went wrong with that request. Please try again.