Github user neykov commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/705#discussion_r33142638
--- Diff:
usage/rest-server/src/main/java/brooklyn/rest/transform/CatalogTransformer.java
---
@@ -59,21 +59,28 @@
private static final org.slf4j.Logger log =
LoggerFactory.getLogger(CatalogTransformer.class);
public static CatalogEntitySummary
catalogEntitySummary(BrooklynRestResourceUtils b, CatalogItem<? extends
Entity,EntitySpec<?>> item) {
- EntitySpec<?> spec = b.getCatalog().createSpec(item);
- EntityDynamicType typeMap =
BrooklynTypes.getDefinedEntityType(spec.getType());
- EntityType type = typeMap.getSnapshot();
-
Set<EntityConfigSummary> config =
Sets.newTreeSet(SummaryComparators.nameComparator());
Set<SensorSummary> sensors =
Sets.newTreeSet(SummaryComparators.nameComparator());
Set<EffectorSummary> effectors =
Sets.newTreeSet(SummaryComparators.nameComparator());
- for (ConfigKey<?> x: type.getConfigKeys())
- config.add(EntityTransformer.entityConfigSummary(x,
typeMap.getConfigKeyField(x.getName())));
- for (Sensor<?> x: type.getSensors())
- sensors.add(SensorTransformer.sensorSummaryForCatalog(x));
- for (Effector<?> x: type.getEffectors())
-
effectors.add(EffectorTransformer.effectorSummaryForCatalog(x));
+ try {
+ EntitySpec<?> spec = b.getCatalog().createSpec(item);
+ EntityDynamicType typeMap =
BrooklynTypes.getDefinedEntityType(spec.getType());
+ EntityType type = typeMap.getSnapshot();
+ for (ConfigKey<?> x: type.getConfigKeys())
+ config.add(EntityTransformer.entityConfigSummary(x,
typeMap.getConfigKeyField(x.getName())));
+ for (Sensor<?> x: type.getSensors())
+ sensors.add(SensorTransformer.sensorSummaryForCatalog(x));
+ for (Effector<?> x: type.getEffectors())
+
effectors.add(EffectorTransformer.effectorSummaryForCatalog(x));
+
+ } catch (Exception e) {
+ // templates with multiple entities can't have spec created in
the manner above; just ignore
--- End diff --
Rethrow if type==Entity (or at least log an error), also propagateIfFatal.
---
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.
---