This is an automated email from the ASF dual-hosted git repository.

iuliana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git


The following commit(s) were added to refs/heads/master by this push:
     new deb58f384a allow lookup of an icon url with respect to an entity
     new 6b58a4062b Merge pull request #1311 from ahgittin/show-other-icon-url
deb58f384a is described below

commit deb58f384ad73f28e2f04b6bd28f9313907e4c07
Author: Alex Heneveld <[email protected]>
AuthorDate: Wed May 4 11:50:53 2022 +0100

    allow lookup of an icon url with respect to an entity
    
    adds an optional iconUrl query parameter, if an alternate icon is specified 
in the context of an entity
    useful in the composer to show custom icons on entities
---
 .gitignore                                              |  1 +
 .../main/java/org/apache/brooklyn/rest/api/TypeApi.java | 17 ++++++++++-------
 .../apache/brooklyn/rest/resources/TypeResource.java    | 14 +++++++++++---
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore
index 540ceae56f..ad2ad87c82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@ brooklyn*.log.*
 *brooklyn-persisted-state/
 
 ignored
+.java-version
diff --git 
a/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/TypeApi.java 
b/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/TypeApi.java
index 914dce2c6f..f17a003b7c 100644
--- a/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/TypeApi.java
+++ b/rest/rest-api/src/main/java/org/apache/brooklyn/rest/api/TypeApi.java
@@ -84,17 +84,20 @@ public interface TypeApi {
         @ApiParam(name = "version", value = "Version to query", required = 
true)
         @PathParam("version")
         String version);
-    
+
     @Path("/{symbolicName}/{version}/icon")
     @GET
     @ApiOperation(value = "Returns the icon image registered for this item")
     @Produces("application/image")
     public Response icon(
-        @ApiParam(name = "symbolicName", value = "Type name to query", 
required = true)
-        @PathParam("symbolicName")
-        String symbolicName,
-        @ApiParam(name = "version", value = "Version to query", required = 
true)
-        @PathParam("version")
-        String version);
+            @ApiParam(name = "symbolicName", value = "Type name to query", 
required = true)
+            @PathParam("symbolicName")
+                    String symbolicName,
+            @ApiParam(name = "version", value = "Version to query (or 
'latest')", required = true)
+            @PathParam("version")
+                    String version,
+            @ApiParam(name = "iconUrl", value = "URL or path to icon to load 
with respect to this entity", required = false)
+            @QueryParam("iconUrl")
+            String iconUrl);
     
 }
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/TypeResource.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/TypeResource.java
index 264714c657..a7990d18a2 100644
--- 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/TypeResource.java
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/TypeResource.java
@@ -160,14 +160,22 @@ public class TypeResource extends 
AbstractBrooklynRestResource implements TypeAp
         return item;
     }
 
-    @Override
+    @Deprecated /** @deprecated since 1.1, include iconUrl */
     public Response icon(String symbolicName, String version) {
+        return icon(symbolicName, version, null);
+    }
+
+    @Override
+    public Response icon(String symbolicName, String version, String iconUrl) {
         RegisteredType item = lookup(symbolicName, version);
-        return produceIcon(mgmt(), brooklyn(), item);
+        return produceIcon(mgmt(), brooklyn(), item, iconUrl);
     }
 
     static Response produceIcon(ManagementContext mgmt, 
BrooklynRestResourceUtils brooklyn, RegisteredType result) {
-        String url = result.getIconUrl();
+        return produceIcon(mgmt, brooklyn, result, null);
+    }
+    static Response produceIcon(ManagementContext mgmt, 
BrooklynRestResourceUtils brooklyn, RegisteredType result, String url) {
+        if (Strings.isBlank(url)) url = result.getIconUrl();
         if (url==null) {
             log.debug("No icon available for "+result+"; returning 
"+Status.NO_CONTENT);
             return Response.status(Status.NO_CONTENT).build();

Reply via email to