Github user sjcorbett commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1039#discussion_r45323195
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
 ---
    @@ -558,15 +561,34 @@ private void collectCatalogItems(String sourceYaml, 
Map<?,?> itemMetadata, List<
                 throw new IllegalStateException("Could not resolve plan once 
id and itemType are known (recursive reference?): "+sourceYaml);
             }
             String sourcePlanYaml = planInterpreter.getPlanYaml();
    -        
    -        CatalogItemDtoAbstract<?, ?> dto = createItemBuilder(itemType, 
symbolicName, version)
    +
    +        CatalogItemBuilder itemBuilder = createItemBuilder(itemType, 
symbolicName, version)
                 .libraries(libraryBundles)
                 .displayName(displayName)
                 .description(description)
                 .deprecated(catalogDeprecated)
                 .iconUrl(catalogIconUrl)
    -            .plan(sourcePlanYaml)
    -            .build();
    +            .plan(sourcePlanYaml);
    +        if (itemType.equals(CatalogItemType.ENTITY) || 
itemType.equals(CatalogItemType.TEMPLATE)) {
    +            String stringServiceType = getFirstAs(itemAsMap, String.class, 
"type").orNull();
    +            // This is not a single item but a services based YAML
    +            if (stringServiceType == null) {
    +                final List<Map<?, ?>> services = getFirstAs(itemAsMap, 
List.class, "services").orNull();
    +                if (services.isEmpty()) {
    +                    throw new IllegalStateException("Services are empty: " 
+ sourceYaml);
    +                }
    +                stringServiceType = services.get(0).get("type").toString();
    +            }
    +            Class<?> serviceType = 
JavaBrooklynClassLoadingContext.create(mgmt).tryLoadClass(stringServiceType).orNull();
    +            if (serviceType == null) {
    +                final CatalogItem<?, ?> relatedCatalogItem = 
getCatalogItem(stringServiceType, "");
    +                if (relatedCatalogItem != null) {
    +                    serviceType = 
JavaBrooklynClassLoadingContext.create(mgmt).tryLoadClass(relatedCatalogItem.getJavaType()).orNull();
    --- End diff --
    
    Sounds like a good test case. Your best shot would be to set the tags when 
all items have been collected - e.g. at the end of `addItems(String, boolean)`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to