brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drigod...@apache.org
Subject [1/2] brooklyn-server git commit: Fix BasicBrooklynCatalog create Spec
Date Thu, 28 Sep 2017 13:06:45 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 1dcd797ab -> 15f822d8a


Fix BasicBrooklynCatalog create Spec


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

Branch: refs/heads/master
Commit: 357b82e1abeccf5b7d225b5361e89f8157a476c0
Parents: a0e5edc
Author: graeme.miller <graeme.miller@cloudsoftcorp.com>
Authored: Mon Sep 25 10:34:52 2017 +0100
Committer: graeme.miller <graeme.miller@cloudsoftcorp.com>
Committed: Mon Sep 25 10:34:52 2017 +0100

----------------------------------------------------------------------
 .../core/catalog/internal/BasicBrooklynCatalog.java | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/357b82e1/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
index d170970..f2c91fa 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
@@ -433,7 +433,21 @@ public class BasicBrooklynCatalog implements BrooklynCatalog {
     public <T, SpecT extends AbstractBrooklynObjectSpec<? extends T, SpecT>>
SpecT createSpec(CatalogItem<T, SpecT> item) {
         if (item == null) return null;
         CatalogItemDo<T,SpecT> loadedItem = (CatalogItemDo<T, SpecT>) getCatalogItemDo(item.getSymbolicName(),
item.getVersion());
-        if (loadedItem == null) throw new RuntimeException(item+" not in catalog; cannot
create spec");
+
+        if (loadedItem == null) {
+            RegisteredType registeredType = mgmt.getTypeRegistry().get(item.getSymbolicName(),
item.getVersion());
+            if(registeredType == null) {
+                throw new RuntimeException(item + " not in catalog; cannot create spec");
+            }
+
+            AbstractBrooklynObjectSpec<?, ?> spec = mgmt.getTypeRegistry().createSpec(registeredType,
null, null);
+            if(spec == null) {
+                throw new RuntimeException("Problem loading spec for type "+registeredType);
+            }
+
+            return (SpecT)spec;
+        }
+
         if (loadedItem.getSpecType()==null) return null;
         
         SpecT spec = internalCreateSpecLegacy(mgmt, loadedItem, MutableSet.<String>of(),
true);


Mime
View raw message