[BROOKLYN-153] Rename REST API "type" attribute to "symbolicName" to avoid 
confusion. Also match the internal representation for a better understanding


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

Branch: refs/heads/master
Commit: f2f8470d59232d42787280157ab1ebab1f9cd46c
Parents: 08790a7
Author: Thomas Bouron <[email protected]>
Authored: Thu Jul 2 13:35:16 2015 +0100
Committer: Thomas Bouron <[email protected]>
Committed: Thu Jul 2 13:35:16 2015 +0100

----------------------------------------------------------------------
 .../main/java/brooklyn/rest/api/CatalogApi.java | 24 ++++++++--------
 .../rest/resources/CatalogResource.java         | 30 ++++++++++----------
 2 files changed, 27 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2f8470d/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java
----------------------------------------------------------------------
diff --git a/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java 
b/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java
index fe6de3a..09e60a9 100644
--- a/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java
+++ b/usage/rest-api/src/main/java/brooklyn/rest/api/CatalogApi.java
@@ -94,27 +94,27 @@ public interface CatalogApi {
         @PathParam("entityId") String entityId) throws Exception;
 
     @DELETE
-    @Path("/applications/{type}/{version}")
+    @Path("/applications/{symbolicName}/{version}")
     @ApiOperation(value = "Deletes a specific version of an application's 
definition from the catalog")
     @ApiErrors(value = {
         @ApiError(code = 404, reason = "Entity not found")
     })
     public void deleteApplication(
-        @ApiParam(name = "type", value = "The type identifier of the 
application or template to delete", required = true)
-        @PathParam("type") String type,
+        @ApiParam(name = "symbolicName", value = "The symbolic name of the 
application or template to delete", required = true)
+        @PathParam("symbolicName") String symbolicName,
 
         @ApiParam(name = "version", value = "The version identifier of the 
application or template to delete", required = true)
         @PathParam("version") String version) throws Exception;
 
     @DELETE
-    @Path("/entities/{type}/{version}")
+    @Path("/entities/{symbolicName}/{version}")
     @ApiOperation(value = "Deletes a specific version of an entity's 
definition from the catalog")
     @ApiErrors(value = {
         @ApiError(code = 404, reason = "Entity not found")
     })
     public void deleteEntity(
-        @ApiParam(name = "type", value = "The type identifier of the entity or 
template to delete", required = true)
-        @PathParam("type") String type,
+        @ApiParam(name = "symbolicName", value = "The symbolic name of the 
entity or template to delete", required = true)
+        @PathParam("symbolicName") String symbolicName,
 
         @ApiParam(name = "version", value = "The version identifier of the 
entity or template to delete", required = true)
         @PathParam("version") String version) throws Exception;
@@ -180,14 +180,14 @@ public interface CatalogApi {
         @PathParam("entityId") String entityId) throws Exception;
 
     @GET
-    @Path("/entities/{type}/{version}")
+    @Path("/entities/{symbolicName}/{version}")
     @ApiOperation(value = "Fetch a specific version of an entity's definition 
from the catalog", responseClass = "CatalogEntitySummary", multiValueResponse = 
true)
     @ApiErrors(value = {
         @ApiError(code = 404, reason = "Entity not found")
     })
     public CatalogEntitySummary getEntity(
-        @ApiParam(name = "type", value = "The type identifier of the entity or 
template to retrieve", required = true)
-        @PathParam("type") String type,
+        @ApiParam(name = "symbolicName", value = "The symbolic name of the 
entity or template to retrieve", required = true)
+        @PathParam("symbolicName") String symbolicName,
 
         @ApiParam(name = "version", value = "The version identifier of the 
entity or template to retrieve", required = true)
         @PathParam("version") String version) throws Exception;
@@ -205,14 +205,14 @@ public interface CatalogApi {
         @PathParam("applicationId") String applicationId) throws Exception;
 
     @GET
-    @Path("/applications/{type}/{version}")
+    @Path("/applications/{symbolicName}/{version}")
     @ApiOperation(value = "Fetch a specific version of an application's 
definition from the catalog", responseClass = "CatalogEntitySummary", 
multiValueResponse = true)
     @ApiErrors(value = {
         @ApiError(code = 404, reason = "Entity not found")
     })
     public CatalogEntitySummary getApplication(
-        @ApiParam(name = "type", value = "The type identifier of the 
application to retrieve", required = true)
-        @PathParam("type") String type,
+        @ApiParam(name = "symbolicName", value = "The symbolic name of the 
application to retrieve", required = true)
+        @PathParam("symbolicName") String symbolicName,
 
         @ApiParam(name = "version", value = "The version identifier of the 
application to retrieve", required = true)
         @PathParam("version") String version) throws Exception;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2f8470d/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
----------------------------------------------------------------------
diff --git 
a/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java 
b/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
index 344e939..3bb14e7 100644
--- 
a/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
+++ 
b/usage/rest-server/src/main/java/brooklyn/rest/resources/CatalogResource.java
@@ -160,22 +160,22 @@ public class CatalogResource extends 
AbstractBrooklynRestResource implements Cat
     }
 
     @Override
-    public void deleteApplication(String applicationId, String version) throws 
Exception {
-        deleteEntity(applicationId, version);
+    public void deleteApplication(String symbolicName, String version) throws 
Exception {
+        deleteEntity(symbolicName, version);
     }
 
     @Override
-    public void deleteEntity(String entityId, String version) throws Exception 
{
-        if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), 
Entitlements.MODIFY_CATALOG_ITEM, 
StringAndArgument.of(entityId+(Strings.isBlank(version) ? "" : ":"+version), 
"delete"))) {
+    public void deleteEntity(String symbolicName, String version) throws 
Exception {
+        if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), 
Entitlements.MODIFY_CATALOG_ITEM, 
StringAndArgument.of(symbolicName+(Strings.isBlank(version) ? "" : 
":"+version), "delete"))) {
             throw WebResourceUtils.unauthorized("User '%s' is not authorized 
to modify catalog",
                 Entitlements.getEntitlementContext().user());
         }
         
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(entityId, 
version);
+        CatalogItem<?, ?> item = 
mgmt().getCatalog().getCatalogItem(symbolicName, version);
         if (item == null) {
-            throw WebResourceUtils.notFound("Entity with id '%s:%s' not 
found", entityId, version);
+            throw WebResourceUtils.notFound("Entity with id '%s:%s' not 
found", symbolicName, version);
         } else if (item.getCatalogItemType() != CatalogItemType.ENTITY && 
item.getCatalogItemType() != CatalogItemType.TEMPLATE) {
-            throw WebResourceUtils.preconditionFailed("Item with id '%s:%s' 
not an entity", entityId, version);
+            throw WebResourceUtils.preconditionFailed("Item with id '%s:%s' 
not an entity", symbolicName, version);
         } else {
             brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), 
item.getVersion());
         }
@@ -248,8 +248,8 @@ public class CatalogResource extends 
AbstractBrooklynRestResource implements Cat
     }
     
     @Override
-    public CatalogEntitySummary getEntity(String entityId, String version) {
-        if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), 
Entitlements.SEE_CATALOG_ITEM, 
entityId+(Strings.isBlank(version)?"":":"+version))) {
+    public CatalogEntitySummary getEntity(String symbolicName, String version) 
{
+        if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), 
Entitlements.SEE_CATALOG_ITEM, 
symbolicName+(Strings.isBlank(version)?"":":"+version))) {
             throw WebResourceUtils.unauthorized("User '%s' is not authorized 
to see catalog entry",
                 Entitlements.getEntitlementContext().user());
         }
@@ -258,10 +258,10 @@ public class CatalogResource extends 
AbstractBrooklynRestResource implements Cat
         //Or we could provide asEntity/asPolicy cast methods on the CataloItem 
doing a safety check internally
         @SuppressWarnings("unchecked")
         CatalogItem<? extends Entity, EntitySpec<?>> result =
-              (CatalogItem<? extends Entity, EntitySpec<?>>) 
brooklyn().getCatalog().getCatalogItem(entityId, version);
+              (CatalogItem<? extends Entity, EntitySpec<?>>) 
brooklyn().getCatalog().getCatalogItem(symbolicName, version);
 
         if (result==null) {
-            throw WebResourceUtils.notFound("Entity with id '%s:%s' not 
found", entityId, version);
+            throw WebResourceUtils.notFound("Entity with id '%s:%s' not 
found", symbolicName, version);
         }
 
         return CatalogTransformer.catalogEntitySummary(brooklyn(), result);
@@ -269,13 +269,13 @@ public class CatalogResource extends 
AbstractBrooklynRestResource implements Cat
 
     @Override
     @Deprecated
-    public CatalogEntitySummary getApplication(String entityId) throws 
Exception {
-        return getEntity(entityId);
+    public CatalogEntitySummary getApplication(String applicationId) throws 
Exception {
+        return getEntity(applicationId);
     }
 
     @Override
-    public CatalogEntitySummary getApplication(String applicationId, String 
version) {
-        return getEntity(applicationId, version);
+    public CatalogEntitySummary getApplication(String symbolicName, String 
version) {
+        return getEntity(symbolicName, version);
     }
 
     @Override

Reply via email to