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

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

commit 3c5ba362f9243291c3de6b8d934746655f6693a7
Author: Alex Heneveld <[email protected]>
AuthorDate: Fri Oct 1 09:48:09 2021 +0100

    REST calls which delete types should scan and delete empty bundles
---
 .../java/org/apache/brooklyn/rest/resources/CatalogResource.java     | 5 +++++
 .../java/org/apache/brooklyn/rest/resources/LocationResource.java    | 3 +++
 2 files changed, 8 insertions(+)

diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
index f4e3019..7fc43d7 100644
--- 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
@@ -34,6 +34,7 @@ import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.brooklyn.api.typereg.RegisteredType;
+import org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog;
 import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
 import 
org.apache.brooklyn.core.mgmt.entitlement.Entitlements.StringAndArgument;
@@ -208,6 +209,7 @@ public class CatalogResource extends 
AbstractBrooklynRestResource implements Cat
             throw WebResourceUtils.preconditionFailed("Item with id '%s:%s' 
not an entity", symbolicName, version);
         } else {
             brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), 
item.getVersion());
+            
((BasicBrooklynCatalog)brooklyn().getCatalog()).uninstallEmptyWrapperBundles();
         }
     }
 
@@ -228,6 +230,7 @@ public class CatalogResource extends 
AbstractBrooklynRestResource implements Cat
             throw WebResourceUtils.preconditionFailed("Item with id '%s:%s' 
not a policy", policyId, version);
         } else {
             brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), 
item.getVersion());
+            
((BasicBrooklynCatalog)brooklyn().getCatalog()).uninstallEmptyWrapperBundles();
         }
     }
 
@@ -248,6 +251,7 @@ public class CatalogResource extends 
AbstractBrooklynRestResource implements Cat
             throw WebResourceUtils.preconditionFailed("Item with id '%s:%s' 
not a location", locationId, version);
         } else {
             brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), 
item.getVersion());
+            
((BasicBrooklynCatalog)brooklyn().getCatalog()).uninstallEmptyWrapperBundles();
         }
     }
 
@@ -449,6 +453,7 @@ public class CatalogResource extends 
AbstractBrooklynRestResource implements Cat
             throw WebResourceUtils.preconditionFailed("Item with id '%s:%s' 
not an enricher", enricherId, version);
         } else {
             brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), 
item.getVersion());
+            
((BasicBrooklynCatalog)brooklyn().getCatalog()).uninstallEmptyWrapperBundles();
         }
     }
 
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/LocationResource.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/LocationResource.java
index 7adc8f8..b06e05e 100644
--- 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/LocationResource.java
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/LocationResource.java
@@ -18,6 +18,7 @@
  */
 package org.apache.brooklyn.rest.resources;
 
+import org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog;
 import static 
org.apache.brooklyn.rest.util.WebResourceUtils.serviceAbsoluteUriBuilder;
 
 import java.net.URI;
@@ -192,6 +193,8 @@ public class LocationResource extends 
AbstractBrooklynRestResource implements Lo
 
         // TODO make all locations be part of the catalog, then flip the JS 
GUI to use catalog api
         if (deleteAllVersions(locationId)>0) return;
+        
((BasicBrooklynCatalog)brooklyn().getCatalog()).uninstallEmptyWrapperBundles();
+
         throw WebResourceUtils.notFound("No catalog item location matching %s; 
only catalog item locations can be deleted", locationId);
     }
     

Reply via email to