Lior Vernia has uploaded a new change for review. Change subject: webadmin: Simplified failure handling code in Frontend ......................................................................
webadmin: Simplified failure handling code in Frontend Changed the name of a variable to better represent what it means, and extracted some common code out of conditional clauses. This also exposed some dead code - there was some logic setting an alternative error message in case the failure isn't on canDoAction(), but it was located in a conditional clause where it had already been established that the failure had been on canDoAction(). Change-Id: I19a0fc10841c9d400ad381f5f9f5fbaaf55fe871 Signed-off-by: Lior Vernia <lver...@redhat.com> --- M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java 1 file changed, 10 insertions(+), 33 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/27804/1 diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java index 527d2bf..c48da28 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java @@ -886,21 +886,6 @@ getOperationManager().retrieveFromHttpSession(key, callback); } - // TODO: Externalize to a better location, should support translation via - // resource bundle file. - /** - * Return the first message from the list of passed in messages. - * @param messages A list of message, which can be empty. - * @return The first message from the list or 'No Message' if the list is empty. - */ - private String getRunActionErrorMessage(final List<String> messages) { - if (messages.size() < 1) { - return "No Message"; //$NON-NLS-1$ - } else { - return messages.iterator().next(); - } - } - /** * Handle the result(s) of an action. * @param actionType The action type. @@ -916,30 +901,22 @@ logger.log(Level.FINER, "Retrieved action result from RunAction."); //$NON-NLS-1$ FrontendActionAsyncResult f = new FrontendActionAsyncResult(actionType, parameters, result, state); - boolean success = false; - if (!result.getCanDoAction()) { + boolean failedOnCanDoAction = !result.getCanDoAction(); + if (failedOnCanDoAction) { result.setCanDoActionMessages((ArrayList<String>) translateError(result)); - callback.executed(f); } else if (showErrorDialog && result.getIsSyncronious() && !result.getSucceeded()) { runActionExecutionFailed(actionType, result.getFault()); - callback.executed(f); - - // Prevent another (untranslated) error message pop-up display - // ('runActionExecutionFailed' invokes an error pop-up displaying, - // therefore calling 'failureEventHandler' is redundant) - success = true; - } else { - success = true; - callback.executed(f); } + callback.executed(f); - if ((!success) && (getEventsHandler() != null) + // 'runActionExecutionFailed' invokes an error pop-up displaying, therefore calling 'failureEventHandler' is + // only needed for canDoAction failure + if (failedOnCanDoAction && (getEventsHandler() != null) && (getEventsHandler().isRaiseErrorModalPanel(actionType, result.getFault()))) { - if (result.getCanDoActionMessages().size() <= 1) { - String errorMessage = !result.getCanDoAction() || !result.getCanDoActionMessages().isEmpty() - ? getRunActionErrorMessage(result.getCanDoActionMessages()) : result.getFault().getMessage(); - - failureEventHandler(result.getDescription(), errorMessage); + if (result.getCanDoActionMessages().isEmpty()) { + // TODO: Externalize to a better location, should support translation via + // resource bundle file. + failureEventHandler(result.getDescription(), "No Message"); //$NON-NLS-1$ } else { failureEventHandler(result.getDescription(), result.getCanDoActionMessages()); } -- To view, visit http://gerrit.ovirt.org/27804 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I19a0fc10841c9d400ad381f5f9f5fbaaf55fe871 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Lior Vernia <lver...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches