brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [13/19] git commit: add "New Policy" button to advanced tab (as well as policies tab) and refactor existing modals to follow policy modal style
Date Tue, 09 Sep 2014 22:49:16 GMT
add "New Policy" button to advanced tab (as well as policies tab) and refactor existing modals
to follow policy modal style


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/e75dc303
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/e75dc303
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/e75dc303

Branch: refs/heads/master
Commit: e75dc3031cc80958ae574697e12814d04f5b6681
Parents: 6df7de8
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Sep 9 11:56:07 2014 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Sep 9 12:13:21 2014 +0100

----------------------------------------------------------------------
 .../creation/BrooklynYamlTypeInstantiator.java  |  3 +-
 .../main/webapp/assets/js/libs/brooklyn-view.js |  2 +-
 .../webapp/assets/js/view/add-child-invoke.js   | 36 +++++++++----------
 .../webapp/assets/js/view/change-name-invoke.js | 37 ++++++++++----------
 .../webapp/assets/js/view/entity-advanced.js    | 29 ++++++++-------
 .../main/webapp/assets/js/view/policy-new.js    |  3 +-
 .../webapp/assets/tpl/apps/add-child-modal.html | 19 ++++------
 .../main/webapp/assets/tpl/apps/advanced.html   |  8 +++--
 .../assets/tpl/apps/change-name-modal.html      | 24 ++++---------
 .../main/webapp/assets/tpl/apps/policy-new.html |  6 ++--
 .../src/main/webapp/assets/tpl/apps/policy.html |  2 --
 .../brooklyn/rest/resources/EntityResource.java |  2 +-
 .../rest/util/DefaultExceptionMapper.java       | 32 +++++++++--------
 13 files changed, 95 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
index ad2b8d7..ae3fb31 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
@@ -97,7 +97,8 @@ public abstract class BrooklynYamlTypeInstantiator {
                 if (result.isAbsent()) result = data.getStringKeyMaybe("type");
             }
             
-            if (result.isAbsent()) return Maybe.absent("Missing key '"+getPreferredKeyName()+"'");
+            if (result.isAbsent() || result.get()==null) 
+                return Maybe.absent("Missing key '"+getPreferredKeyName()+"'");
             
             if (result.get() instanceof String) return Maybe.of((String)result.get());
             

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-view.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-view.js b/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-view.js
index c25ff25..f20fdec 100644
--- a/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-view.js
+++ b/usage/jsgui/src/main/webapp/assets/js/libs/brooklyn-view.js
@@ -193,7 +193,7 @@ define([
                         ? optionalTitle : this.options.title;
             this.$el.html(this.template({
                 title: title,
-                submitButtonText: this.options.submitButtonText || "Save",
+                submitButtonText: this.options.submitButtonText || "Apply",
                 cancelButtonText: this.options.cancelButtonText || "Cancel"
             }));
             this.options.body.render();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/js/view/add-child-invoke.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/add-child-invoke.js b/usage/jsgui/src/main/webapp/assets/js/view/add-child-invoke.js
index 905d356..b29f295 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/add-child-invoke.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/add-child-invoke.js
@@ -17,7 +17,7 @@
  * under the License.
 */
 /**
- * Render entity expungement as a modal
+ * Render as a modal
  */
 define([
     "underscore", "jquery", "backbone",
@@ -25,20 +25,19 @@ define([
 ], function(_, $, Backbone, AddChildModalHtml) {
     return Backbone.View.extend({
         template: _.template(AddChildModalHtml),
-        events: {
-            "click .invoke-operation": "invokeOperation",
-            "hide": "hide"
+        initialize: function() {
+            this.title = "Add Child to "+this.options.entity.get('name');
         },
         render: function() {
-            this.$el.html(this.template(this.model));
+            this.$el.html(this.template(this.options.entity.attributes));
             return this;
         },
-        invokeOperation: function() {
+        onSubmit: function (event) {
             var self = this;
             var childSpec = this.$("#child-spec").val();
-            var start = this.$("#child-autostart").is(":checked")
-            var url = this.model.links.children + (!start ? "?start=false" : "");
-            $.ajax({
+            var start = this.$("#child-autostart").is(":checked");
+            var url = this.options.entity.get('links').children + (!start ? "?start=false"
: "");
+            var ajax = $.ajax({
                 type: "POST",
                 url: url,
                 data: childSpec,
@@ -46,20 +45,17 @@ define([
                 success: function() {
                     self.options.target.reload();
                 },
-                error: function(data) {
-                    self.$el.fadeTo(100,1).delay(200).fadeTo(200,0.2).delay(200).fadeTo(200,1);
-                    // TODO render the error better than poor-man's flashing
-                    // (would just be connection error -- with timeout=0 we get a task even
for invalid input)
-
-                    log("ERROR invoking operation");
-                    log(data);
+                error: function(response) {
+                    var message = JSON.parse(response.responseText).message;
+                    self.showError(message);
                 }
             });
-            this.$el.fadeTo(500, 0.5);
-            this.$el.modal("hide");
+            return ajax;
         },
-        hide: function() {
-            this.undelegateEvents();
+        showError: function (message) {
+            this.$(".child-add-error-container").removeClass("hide");
+            this.$(".child-add-error-message").html(message);
         }
+
     });
 });

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/js/view/change-name-invoke.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/change-name-invoke.js b/usage/jsgui/src/main/webapp/assets/js/view/change-name-invoke.js
index 85cc45d..95d2abc 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/change-name-invoke.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/change-name-invoke.js
@@ -25,39 +25,40 @@ define([
 ], function(_, $, Backbone, ChangeNameModalHtml) {
     return Backbone.View.extend({
         template: _.template(ChangeNameModalHtml),
-        events: {
-            "click .invoke-operation": "invokeOperation",
-            "hide": "hide"
+        initialize: function() {
+            this.title = "Change Name of "+this.options.entity.get('name');
         },
         render: function() {
-            this.$el.html(this.template(this.model));
+            this.$el.html(this.template({ name: this.options.entity.get('name') }));
             return this;
         },
-        invokeOperation: function() {
+        onSubmit: function() {
             var self = this;
             var newName = this.$("#new-name").val();
-            var url = this.model.links.rename + "?name=" + encodeURIComponent(newName);
-            $.ajax({
+            var url = this.options.entity.get('links').rename + "?name=" + encodeURIComponent(newName);
+            var ajax = $.ajax({
                 type: "POST",
                 url: url,
                 contentType: "application/json",
                 success: function() {
                     self.options.target.reload();
                 },
-                error: function(data) {
-                    self.$el.fadeTo(100,1).delay(200).fadeTo(200,0.2).delay(200).fadeTo(200,1);
-                    // TODO render the error better than poor-man's flashing
-                    // (would just be connection error -- with timeout=0 we get a task even
for invalid input)
-
-                    log("ERROR invoking operation");
-                    log(data);
+                error: function(response) {
+                    var message = "Error contacting server";
+                    try {
+                        message = JSON.parse(response.responseText).message;
+                    } catch (e) {
+                        log("UNPARSEABLE RESPONSE");
+                        log(response);
+                    }
+                    self.showError(message);
                 }
             });
-            this.$el.fadeTo(500, 0.5);
-            this.$el.modal("hide");
+            return ajax;
         },
-        hide: function() {
-            this.undelegateEvents();
+        showError: function (message) {
+            this.$(".change-name-error-container").removeClass("hide");
+            this.$(".change-name-error-message").html(message);
         }
     });
 });

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/js/view/entity-advanced.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/entity-advanced.js b/usage/jsgui/src/main/webapp/assets/js/view/entity-advanced.js
index 43d6e66..b99ca26 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/entity-advanced.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/entity-advanced.js
@@ -22,14 +22,15 @@
  * @type {*}
  */
 define(["underscore", "jquery", "backbone", "brooklyn", "brooklyn-utils", "view/viewutils",
-    "text!tpl/apps/advanced.html", "view/entity-config", "view/change-name-invoke", "view/add-child-invoke"
+    "text!tpl/apps/advanced.html", "view/entity-config", "view/change-name-invoke", "view/add-child-invoke",
"view/policy-new"
 ], function(_, $, Backbone, Brooklyn, Util, ViewUtils,
-        AdvancedHtml, EntityConfigView, ChangeNameInvokeView, AddChildInvokeView) {
+        AdvancedHtml, EntityConfigView, ChangeNameInvokeView, AddChildInvokeView, NewPolicyView)
{
     var EntityAdvancedView = Backbone.View.extend({
         events: {
             "click button#change-name": "showChangeNameModal",
-            "click button#reset-problems": "doResetProblems",
             "click button#add-child": "showAddChildModal",
+            "click button#add-new-policy": "showNewPolicyModal",
+            "click button#reset-problems": "doResetProblems",
             "click button#expunge": "confirmExpunge",
             "click button#unmanage": "confirmUnmanage",
             "click #advanced-tab-error-closer": "closeAdvancedTabError"
@@ -57,27 +58,29 @@ define(["underscore", "jquery", "backbone", "brooklyn", "brooklyn-utils",
"view/
             this.model.fetch();
         },
         
-        showModel: function(modal) {
+        showModal: function(modal) {
             if (this.activeModal)
-                this.activeModal.$el.html("");
-            // not sure why opacity is needed, but it seems to be, else jumping around makes
it opacity 0.5
-            modal.render().$el.modal("show").css('opacity', 1.0);
+                this.activeModal.close();
             this.activeModal = modal;
+            Brooklyn.view.showModalWith(modal);
         },
         showChangeNameModal: function() {
-            this.showModel(new ChangeNameInvokeView({
-                el:"#change-name-modal",
-                model:this.model.attributes,
+            this.showModal(new ChangeNameInvokeView({
+                entity: this.model,
                 target:this
             }));
         },
         showAddChildModal: function() {
-            this.showModel(new AddChildInvokeView({
-                el:"#add-child-modal",
-                model:this.model.attributes,
+            this.showModal(new AddChildInvokeView({
+                entity: this.model,
                 target:this
             }));
         },
+        showNewPolicyModal: function () {
+            this.showModal(new NewPolicyView({
+                entity: this.model,
+            }));
+        },
         doResetProblems: function() {
             this.post(this.model.get('links').sensors+"/"+"service.notUp.indicators", {});
             this.post(this.model.get('links').sensors+"/"+"service.problems", {});

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/js/view/policy-new.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/policy-new.js b/usage/jsgui/src/main/webapp/assets/js/view/policy-new.js
index 465433e..3b88290 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/policy-new.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/policy-new.js
@@ -26,12 +26,13 @@ define([
 
     return Backbone.View.extend({
         template: _.template(NewPolicyHtml),
-        title: "Attach a policy",
+        title: "Attach New Policy",
 
         initialize: function () {
             if (!this.options.entity) {
                 throw new Error("NewPolicy view requires entity to know where to post result");
             }
+            this.title = "Attach New Policy to "+this.options.entity.get('name');
         },
 
         render: function() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/tpl/apps/add-child-modal.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/add-child-modal.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/add-child-modal.html
index 47792e0..05b8c8c 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/add-child-modal.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/add-child-modal.html
@@ -20,20 +20,13 @@ under the License.
 
 <!-- modal to render effector-->
 
-<div class="modal-header">
-    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
-    <h3>Add Child to <%= name %></h3>
+    <h4 style="margin-bottom: 9px;">YAML Specification</h4>
+    <p>Add a child or children to this entity by providing a YAML blueprint</p>
 
-    <br/>
-    <p>Add a child or children to this entity by providing a YAML blueprint:</p>
-</div>
-
-<div class="modal-body">
     <textarea id="child-spec" style="width: 100%; height: 120px;"/>
     <input type="checkbox" id="child-autostart" checked="checked"> Auto-start
-</div>
 
-<div class="modal-footer">
-    <button type="button" class="btn btn-info btn-mini" data-dismiss="modal">Cancel</button>
-    <button type="button" class="btn btn-danger btn-mini invoke-operation">Invoke</button>
-</div>
\ No newline at end of file
+    <div class="hide alert alert-error child-add-error-container" style="margin-top: 9px;">
+        <strong>Error</strong>
+        <span class="child-add-error-message"></span>
+    </div>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/tpl/apps/advanced.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/advanced.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/advanced.html
index 3e75a6c..ea71981 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/advanced.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/advanced.html
@@ -20,12 +20,13 @@ under the License.
 
 <div id="advanced-summary">
   <h3><span id="entity-name">Entity</span>
-  <button id="change-name" class="btn change-name pull-right">Change Name</button><br/>
+  <button id="change-name" class="btn pull-right">Change Name</button><br/>
   </h3>
 
 <div style="text-align: right; padding-top: 24px;">
-  <button id="reset-problems" class="btn">Reset Problems</button>
   <button id="add-child" class="btn">Add Child</button>
+  <button id="add-new-policy" class="btn">Attach New Policy</button>
+  <button id="reset-problems" class="btn">Reset Problems</button>
 <!-- TODO:
   <button id="set-config" class="btn">Set Config</button>
   <button id="edit-sensor" class="btn">Set Sensor</button>
@@ -33,9 +34,10 @@ under the License.
   <button id="expunge" class="btn">Expunge</button>
   <button id="unmanage" class="btn">Unmanage</button>
 </div>
+
 <div id="change-name-modal" class="modal hide fade"></div>
 <div id="add-child-modal" class="modal hide fade"></div>
-<div id="edit-config-modal" class="modal hide fade"></div>
+<div id="policy-modal" class="modal hide fade"></div>
 
 <div id="advanced-tab-error-section" class="hide" style="margin-top: 36px; color: red;">
   <div id="advanced-tab-error-closer" style="float: right;"><button type="button"
class="close" data-dismiss="modal">x</button></div>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/tpl/apps/change-name-modal.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/change-name-modal.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/change-name-modal.html
index 23fc17b..49cec81 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/change-name-modal.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/change-name-modal.html
@@ -18,22 +18,12 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<!-- modal to render effector-->
+    <h4 style="margin-bottom: 9px;">New Name</h4>
+    <p>Change the display name of an entity</p>
 
-<div class="modal-header">
-    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
-    <h3>Rename <%= name %></h3>
+    <input type="text" id="new-name" style="width: 100%;" value="<%= name %>"></input>
 
-    <br/>
-    <p>Change the name of an entity</p>
-</div>
-
-<div class="modal-body">
-    <span>New name:</span>
-    <input type="text" id="new-name" value="<%= name %>"></input>
-</div>
-
-<div class="modal-footer">
-    <button type="button" class="btn btn-info btn-mini" data-dismiss="modal">Cancel</button>
-    <button type="button" class="btn btn-danger btn-mini invoke-operation">Invoke</button>
-</div>
+    <div class="hide alert alert-error change-name-error-container" style="margin-top:
9px;">
+        <strong>Error</strong>
+        <span class="change-name-error-message"></span>
+    </div>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/tpl/apps/policy-new.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/policy-new.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/policy-new.html
index 44c877a..49116d2 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/policy-new.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/policy-new.html
@@ -17,16 +17,16 @@ specific language governing permissions and limitations
 under the License.
 -->
 <form style="margin-bottom: 0;">
-    <h4 style="margin-bottom: 9px;">Policy type</h4>
+    <h4 style="margin-bottom: 9px;">Policy Type</h4>
     <input id="policy-add-type" class="input-xlarge" type="text" name="policy-type" placeholder="Type"/>
     <p>Enter the full type of the policy</p>
 
     <h4 style="margin-bottom: 9px; margin-top: 5px">Config Keys</h4>
     <div class="policy-add-config-keys"></div>
     <p>
-        Enter the full type of the policy and its value. Values will be coerced to the
+        Enter the full name of the config key and its value. Values will be coerced to the
         appropriate type automatically. Blank keys and values will cause the property
-        to be ignored. Last-key wins if any key is duplicated.
+        to be ignored. Last key wins if any key is duplicated.
     </p>
 
     <div class="hide alert alert-error policy-add-error-container" style="margin-top:
9px;">

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/jsgui/src/main/webapp/assets/tpl/apps/policy.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/policy.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/policy.html
index 2a66b9e..33748b5 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/policy.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/policy.html
@@ -55,5 +55,3 @@ under the License.
 </div>
 
 <button class="btn add-new-policy pull-right">Attach New Policy</button>
-
-<div id="policy-modal" class="modal hide fade"></div>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java b/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java
index c671269..f18e51c 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/EntityResource.java
@@ -226,7 +226,7 @@ public class EntityResource extends AbstractBrooklynRestResource implements
Enti
                 return Response.status(Status.CREATED).entity(TaskTransformer.taskSummary(task)).build();
             }
         } else {
-            throw new IllegalStateException("Add children only supported for spec instantiator
instances");
+            throw new IllegalStateException("Spec could not be parsed to supply a compatible
instantiator");
         }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e75dc303/usage/rest-server/src/main/java/brooklyn/rest/util/DefaultExceptionMapper.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/util/DefaultExceptionMapper.java
b/usage/rest-server/src/main/java/brooklyn/rest/util/DefaultExceptionMapper.java
index 4fcf6f0..7963e48 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/util/DefaultExceptionMapper.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/util/DefaultExceptionMapper.java
@@ -55,44 +55,46 @@ public class DefaultExceptionMapper implements ExceptionMapper<Throwable>
{
      * mapping is found a {@link Status#INTERNAL_SERVER_ERROR} is assumed.
      */
     @Override
-    public Response toResponse(Throwable throwable) {
+    public Response toResponse(Throwable throwable1) {
 
-        LOG.debug("REST request running as {} threw: {}", Entitlements.getEntitlementContext(),
throwable);
+        LOG.debug("REST request running as {} threw: {}", Entitlements.getEntitlementContext(),

+            Exceptions.collapse(throwable1));
         if (LOG.isTraceEnabled()) {
-            LOG.trace("Full details of "+Entitlements.getEntitlementContext()+" "+throwable,
throwable);
+            LOG.trace("Full details of "+Entitlements.getEntitlementContext()+" "+throwable1,
throwable1);
         }
 
+        Throwable throwable2 = Exceptions.getFirstInteresting(throwable1);
         // Some methods will throw this, which gets converted automatically
-        if (throwable instanceof WebApplicationException) {
-            WebApplicationException wae = (WebApplicationException) throwable;
+        if (throwable2 instanceof WebApplicationException) {
+            WebApplicationException wae = (WebApplicationException) throwable2;
             return wae.getResponse();
         }
 
         // The nicest way for methods to provide errors, wrap as this, and the stack trace
will be suppressed
-        if (throwable instanceof UserFacingException) {
-            return ApiError.of(throwable.getMessage()).asBadRequestResponseJson();
+        if (throwable2 instanceof UserFacingException) {
+            return ApiError.of(throwable2.getMessage()).asBadRequestResponseJson();
         }
 
         // For everything else, a trace is supplied
         
         // Assume ClassCoercionExceptions are caused by TypeCoercions from input parameters
gone wrong
         // And IllegalArgumentException for malformed input parameters.
-        if (throwable instanceof ClassCoercionException || throwable instanceof IllegalArgumentException)
{
-            return ApiError.of(throwable).asBadRequestResponseJson();
+        if (throwable2 instanceof ClassCoercionException || throwable2 instanceof IllegalArgumentException)
{
+            return ApiError.of(throwable2).asBadRequestResponseJson();
         }
 
         // YAML exception 
-        if (throwable instanceof YAMLException) {
-            return ApiError.builder().message(throwable.getMessage()).prefixMessage("Invalid
YAML").build().asBadRequestResponseJson();
+        if (throwable2 instanceof YAMLException) {
+            return ApiError.builder().message(throwable2.getMessage()).prefixMessage("Invalid
YAML").build().asBadRequestResponseJson();
         }
 
-        if (!Exceptions.isPrefixBoring(throwable)) {
-            if ( warnedUnknownExceptions.add( throwable.getClass() )) {
-                LOG.warn("REST call generated exception type "+throwable.getClass()+" unrecognized
in "+getClass()+" (subsequent occurrences will be logged debug only): " + throwable, throwable);
+        if (!Exceptions.isPrefixBoring(throwable2)) {
+            if ( warnedUnknownExceptions.add( throwable2.getClass() )) {
+                LOG.warn("REST call generated exception type "+throwable2.getClass()+" unrecognized
in "+getClass()+" (subsequent occurrences will be logged debug only): " + throwable2, throwable2);
             }
         }
         
-        Builder rb = ApiError.builderFromThrowable(throwable);
+        Builder rb = ApiError.builderFromThrowable(Exceptions.collapse(throwable2));
         if (Strings.isBlank(rb.getMessage()))
             rb.message("Internal error. Contact server administrator to consult logs for
more details.");
         return rb.build().asResponse(Status.INTERNAL_SERVER_ERROR, MediaType.APPLICATION_JSON_TYPE);


Mime
View raw message