You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2017/10/03 14:24:00 UTC
[23/35] brooklyn-server git commit: clean up config rest utils
following deprecation of config classes
clean up config rest utils following deprecation of config classes
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/83c3d500
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/83c3d500
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/83c3d500
Branch: refs/heads/master
Commit: 83c3d5006e653d4d70ebbf46759bf7ecd29c581a
Parents: 62bcbc5
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Sep 25 13:00:46 2017 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Sep 25 13:04:38 2017 +0100
----------------------------------------------------------------------
.../rest/resources/AdjunctResource.java | 3 +-
.../rest/resources/CatalogResource.java | 21 ++-
.../rest/resources/EntityConfigResource.java | 4 +-
.../rest/transform/AdjunctTransformer.java | 34 +---
.../rest/transform/CatalogTransformer.java | 30 ++--
.../rest/transform/ConfigTransformer.java | 173 +++++++++++++++++++
.../rest/transform/EntityTransformer.java | 114 ++----------
.../rest/transform/SensorTransformer.java | 21 ++-
.../rest/transform/TypeTransformer.java | 6 +-
.../brooklyn/cli/lister/ItemDescriptors.java | 10 +-
10 files changed, 257 insertions(+), 159 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/AdjunctResource.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/AdjunctResource.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/AdjunctResource.java
index 3b5185a..08f3698 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/AdjunctResource.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/AdjunctResource.java
@@ -49,6 +49,7 @@ import org.apache.brooklyn.rest.domain.Status;
import org.apache.brooklyn.rest.domain.SummaryComparators;
import org.apache.brooklyn.rest.filter.HaHotStateRequired;
import org.apache.brooklyn.rest.transform.AdjunctTransformer;
+import org.apache.brooklyn.rest.transform.ConfigTransformer;
import org.apache.brooklyn.rest.transform.EntityTransformer;
import org.apache.brooklyn.rest.util.BrooklynRestResourceUtils;
import org.apache.brooklyn.rest.util.WebResourceUtils;
@@ -215,7 +216,7 @@ public class AdjunctResource extends AbstractBrooklynRestResource implements Adj
List<ConfigSummary> result = Lists.newArrayList();
for (ConfigKey<?> key : adjunct.config().findKeysPresent(Predicates.alwaysTrue())) {
- result.add(AdjunctTransformer.configSummary(brooklyn(), ui.getBaseUriBuilder(), entity, adjunct, key));
+ result.add(ConfigTransformer.of(key).on(entity, adjunct).includeLinks(ui.getBaseUriBuilder(), false, true).transform());
}
return result;
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
----------------------------------------------------------------------
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 65e6956..f95c1ee 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
@@ -84,6 +84,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
private static final Logger log = LoggerFactory.getLogger(CatalogResource.class);
private static final String LATEST = "latest";
+ @Deprecated
private Function<RegisteredType, CatalogItemSummary> toCatalogItemSummary(final UriInfo ui) {
return new Function<RegisteredType, CatalogItemSummary>() {
@Override
@@ -202,11 +203,13 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public void deleteApplication(String symbolicName, String version) throws Exception {
deleteEntity(symbolicName, version);
}
@Override
+ @Deprecated
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.forbidden("User '%s' is not authorized to modify catalog",
@@ -226,6 +229,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public void deletePolicy(String policyId, String version) throws Exception {
if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_CATALOG_ITEM, StringAndArgument.of(policyId+(Strings.isBlank(version) ? "" : ":"+version), "delete"))) {
throw WebResourceUtils.forbidden("User '%s' is not authorized to modify catalog",
@@ -245,6 +249,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public void deleteLocation(String locationId, String version) throws Exception {
if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_CATALOG_ITEM, StringAndArgument.of(locationId+(Strings.isBlank(version) ? "" : ":"+version), "delete"))) {
throw WebResourceUtils.forbidden("User '%s' is not authorized to modify catalog",
@@ -264,6 +269,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public List<CatalogEntitySummary> listEntities(String regex, String fragment, boolean allVersions) {
Predicate<RegisteredType> filter =
Predicates.and(
@@ -274,6 +280,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public List<CatalogItemSummary> listApplications(String regex, String fragment, boolean allVersions) {
@SuppressWarnings("unchecked")
Predicate<RegisteredType> filter =
@@ -285,6 +292,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public CatalogEntitySummary getEntity(String symbolicName, String version) {
if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_CATALOG_ITEM, symbolicName+(Strings.isBlank(version)?"":":"+version))) {
throw WebResourceUtils.forbidden("User '%s' is not authorized to see catalog entry",
@@ -302,11 +310,13 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public CatalogEntitySummary getApplication(String symbolicName, String version) {
return getEntity(symbolicName, version);
}
@Override
+ @Deprecated
public List<CatalogPolicySummary> listPolicies(String regex, String fragment, boolean allVersions) {
Predicate<RegisteredType> filter =
Predicates.and(
@@ -317,6 +327,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public CatalogPolicySummary getPolicy(String policyId, String version) throws Exception {
if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_CATALOG_ITEM, policyId+(Strings.isBlank(version)?"":":"+version))) {
throw WebResourceUtils.forbidden("User '%s' is not authorized to see catalog entry",
@@ -333,6 +344,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public List<CatalogLocationSummary> listLocations(String regex, String fragment, boolean allVersions) {
Predicate<RegisteredType> filter =
Predicates.and(
@@ -343,6 +355,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public CatalogLocationSummary getLocation(String locationId, String version) throws Exception {
if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_CATALOG_ITEM, locationId+(Strings.isBlank(version)?"":":"+version))) {
throw WebResourceUtils.forbidden("User '%s' is not authorized to see catalog entry",
@@ -359,6 +372,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@SuppressWarnings({ "unchecked", "rawtypes" })
+ @Deprecated
private <T,SpecT> List<CatalogItemSummary> getCatalogItemSummariesMatchingRegexFragment(
Predicate<RegisteredType> type, String regex, String fragment, boolean allVersions) {
List<Predicate<RegisteredType>> filters = new ArrayList();
@@ -390,8 +404,8 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
return getCatalogItemIcon(mgmt().getTypeRegistry().get(itemId, version));
}
- @SuppressWarnings("deprecation")
@Override
+ @Deprecated
public void setDeprecated(String itemId, boolean deprecated) {
if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_CATALOG_ITEM, StringAndArgument.of(itemId, "deprecated"))) {
throw WebResourceUtils.forbidden("User '%s' is not authorized to modify catalog",
@@ -400,8 +414,8 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
CatalogUtils.setDeprecated(mgmt(), itemId, deprecated);
}
- @SuppressWarnings("deprecation")
@Override
+ @Deprecated
public void setDisabled(String itemId, boolean disabled) {
if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_CATALOG_ITEM, StringAndArgument.of(itemId, "disabled"))) {
throw WebResourceUtils.forbidden("User '%s' is not authorized to modify catalog",
@@ -411,6 +425,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public List<CatalogEnricherSummary> listEnrichers(@ApiParam(name = "regex", value = "Regular expression to search for") @DefaultValue("") String regex, @ApiParam(name = "fragment", value = "Substring case-insensitive to search for") @DefaultValue("") String fragment, @ApiParam(name = "allVersions", value = "Include all versions (defaults false, only returning the best version)") @DefaultValue("false") boolean includeAllVersions) {
Predicate<RegisteredType> filter =
Predicates.and(
@@ -421,6 +436,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public CatalogEnricherSummary getEnricher(@ApiParam(name = "enricherId", value = "The ID of the enricher to retrieve", required = true) String enricherId, @ApiParam(name = "version", value = "The version identifier of the enricher to retrieve", required = true) String version) throws Exception {
if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_CATALOG_ITEM, enricherId+(Strings.isBlank(version)?"":":"+version))) {
throw WebResourceUtils.forbidden("User '%s' is not authorized to see catalog entry",
@@ -436,6 +452,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
}
@Override
+ @Deprecated
public void deleteEnricher(@ApiParam(name = "enricherId", value = "The ID of the enricher to delete", required = true) String enricherId, @ApiParam(name = "version", value = "The version identifier of the enricher to delete", required = true) String version) throws Exception {
if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_CATALOG_ITEM, StringAndArgument.of(enricherId+(Strings.isBlank(version) ? "" : ":"+version), "delete"))) {
throw WebResourceUtils.forbidden("User '%s' is not authorized to modify catalog",
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java
index dd909e4..3431b99 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java
@@ -34,7 +34,7 @@ import org.apache.brooklyn.core.mgmt.entitlement.Entitlements.EntityAndItem;
import org.apache.brooklyn.rest.api.EntityConfigApi;
import org.apache.brooklyn.rest.domain.ConfigSummary;
import org.apache.brooklyn.rest.filter.HaHotStateRequired;
-import org.apache.brooklyn.rest.transform.EntityTransformer;
+import org.apache.brooklyn.rest.transform.ConfigTransformer;
import org.apache.brooklyn.rest.util.WebResourceUtils;
import org.apache.brooklyn.util.core.flags.TypeCoercions;
import org.apache.brooklyn.util.core.task.Tasks;
@@ -70,7 +70,7 @@ public class EntityConfigResource extends AbstractBrooklynRestResource implement
new Object[] {Entitlements.getEntitlementContext().user(), key.getName(), entity});
continue;
}
- result.add(EntityTransformer.configSummary(brooklyn(), ui.getBaseUriBuilder(), entity, key));
+ result.add(ConfigTransformer.of(key).on(entity).includeLinks(ui.getBaseUriBuilder(), true, true).transform());
}
return result;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/AdjunctTransformer.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/AdjunctTransformer.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/AdjunctTransformer.java
index f841f33..a00cb6e 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/AdjunctTransformer.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/AdjunctTransformer.java
@@ -23,22 +23,17 @@ import static org.apache.brooklyn.rest.util.WebResourceUtils.serviceUriBuilder;
import java.net.URI;
import java.util.Map;
-import javax.annotation.Nullable;
import javax.ws.rs.core.UriBuilder;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.objs.EntityAdjunct;
-import org.apache.brooklyn.api.objs.SpecParameter;
import org.apache.brooklyn.api.policy.Policy;
import org.apache.brooklyn.api.sensor.Feed;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.policy.Policies;
import org.apache.brooklyn.rest.api.AdjunctApi;
-import org.apache.brooklyn.rest.api.ApplicationApi;
-import org.apache.brooklyn.rest.api.EntityApi;
import org.apache.brooklyn.rest.domain.AdjunctDetail;
import org.apache.brooklyn.rest.domain.AdjunctSummary;
-import org.apache.brooklyn.rest.domain.ConfigSummary;
import org.apache.brooklyn.rest.domain.Status;
import org.apache.brooklyn.rest.util.BrooklynRestResourceUtils;
import org.apache.brooklyn.util.collections.MutableMap;
@@ -62,7 +57,7 @@ public class AdjunctTransformer {
public static AdjunctDetail adjunctDetail(BrooklynRestResourceUtils utils, Entity entity, EntityAdjunct adjunct, UriBuilder ub) {
AdjunctDetail result = embellish(new AdjunctDetail(adjunct), entity, adjunct, ub);
for (ConfigKey<?> key: adjunct.config().findKeysDeclared(Predicates.alwaysTrue())) {
- result.parameter(configSummary(utils, ub, entity, adjunct, key));
+ result.parameter(ConfigTransformer.of(key).on(entity, adjunct).includeLinks(ub, false, true).transform());
}
result.config(EntityTransformer.getConfigValues(utils, adjunct));
return result;
@@ -74,8 +69,10 @@ public class AdjunctTransformer {
links.put("self", serviceUriBuilder(ub, AdjunctApi.class, "get").build(entity.getApplicationId(), entity.getId(), adjunct.getId()));
if (detail) {
- links.put("application", serviceUriBuilder(ub, ApplicationApi.class, "get").build(entity.getApplicationId()));
- links.put("entity", serviceUriBuilder(ub, EntityApi.class, "get").build(entity.getApplicationId(), entity.getId()));
+ links.put("application", EntityTransformer.applicationUri(entity.getApplication(), ub) );
+ links.put("entity", EntityTransformer.entityUri(entity, ub) );
+ links.put("adjunct", adjunctUri(entity, adjunct, ub) );
+
links.put("config", serviceUriBuilder(ub, AdjunctApi.class, "listConfig").build(entity.getApplicationId(), entity.getId(), adjunct.getId()));
links.put("status", serviceUriBuilder(ub, AdjunctApi.class, "getStatus").build(entity.getApplicationId(), entity.getId(), adjunct.getId()));
if (adjunct instanceof Policy || adjunct instanceof Feed) {
@@ -92,25 +89,8 @@ public class AdjunctTransformer {
return ApplicationTransformer.statusFromLifecycle( Policies.inferAdjunctStatus(adjunct) );
}
- public static ConfigSummary configSummary(BrooklynRestResourceUtils utils, UriBuilder ub, @Nullable Entity entity, @Nullable EntityAdjunct adjunct, SpecParameter<?> input) {
- Double priority = input.isPinned() ? Double.valueOf(1d) : null;
- return configSummary(utils, ub, entity, adjunct, input.getConfigKey(), input.getLabel(), priority, input.isPinned());
+ public static URI adjunctUri(Entity entity, EntityAdjunct adjunct, UriBuilder ub) {
+ return serviceUriBuilder(ub, AdjunctApi.class, "get").build(entity.getApplicationId(), entity.getId(), adjunct.getId());
}
- public static ConfigSummary configSummary(BrooklynRestResourceUtils utils, UriBuilder ub, Entity entity, EntityAdjunct adjunct, ConfigKey<?> config) {
- // TODO get catalog info from other sources?
- // see EntityTransformer.configSummary
- return configSummary(utils, ub, entity, adjunct, config, null, null, null);
- }
- public static ConfigSummary configSummary(BrooklynRestResourceUtils utils, UriBuilder ub, @Nullable Entity entity, @Nullable EntityAdjunct adjunct, ConfigKey<?> config, String label, Double priority, Boolean pinned) {
- URI configUri = entity==null ? null : serviceUriBuilder(ub, AdjunctApi.class, "getConfig").build(entity.getApplicationId(), entity.getId(), adjunct.getId(), config.getName());
- Map<String, URI> links = MutableMap.<String, URI>builder()
- .putIfNotNull("self", configUri)
- // no point in including app/entity on every summary shown in a list
- // (this is only ever used in a list, as self points at the value)
- .build();
-
- // TODO get actions, see EntityTransformer.configSummary
- return new ConfigSummary(config, label, priority, pinned, links);
- }
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
index aa30dd5..6eeaeb8 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
@@ -71,6 +71,8 @@ import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
+/** @deprecated since 0.13.0 use RegisteredType methods */
+@Deprecated
public class CatalogTransformer {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(CatalogTransformer.class);
@@ -87,9 +89,9 @@ public class CatalogTransformer {
EntityDynamicType typeMap = BrooklynTypes.getDefinedEntityType(spec.getType());
EntityType type = typeMap.getSnapshot();
- AtomicInteger paramPriorityCnt = new AtomicInteger();
+ AtomicInteger priority = new AtomicInteger();
for (SpecParameter<?> input: spec.getParameters())
- config.add(EntityTransformer.entityConfigSummary(input, paramPriorityCnt));
+ config.add(ConfigTransformer.of(input).uiIncrementAndSetPriorityIfPinned(priority).transformLegacyEntityConfig());
for (Sensor<?> x: type.getSensors())
sensors.add(SensorTransformer.sensorSummaryForCatalog(x));
for (Effector<?> x: type.getEffectors())
@@ -149,8 +151,9 @@ public class CatalogTransformer {
PolicySpec<?> spec = null;
try{
spec = b.getTypeRegistry().createSpec(item, null, PolicySpec.class);
- for (final SpecParameter<?> input : spec.getParameters()){
- config.add(EntityTransformer.policyConfigSummary(input));
+ AtomicInteger priority = new AtomicInteger();
+ for (SpecParameter<?> input: spec.getParameters()) {
+ config.add(ConfigTransformer.of(input).uiIncrementAndSetPriorityIfPinned(priority).transformLegacyPolicyConfig());
}
}catch (Exception e) {
Exceptions.propagateIfFatal(e);
@@ -169,8 +172,9 @@ public class CatalogTransformer {
EnricherSpec<?> spec = null;
try{
spec = b.getTypeRegistry().createSpec(item, null, EnricherSpec.class);
- for (final SpecParameter<?> input : spec.getParameters()){
- config.add(EntityTransformer.enricherConfigSummary(input));
+ AtomicInteger priority = new AtomicInteger();
+ for (SpecParameter<?> input: spec.getParameters()) {
+ config.add(ConfigTransformer.of(input).uiIncrementAndSetPriorityIfPinned(priority).transformLegacyEnricherConfig());
}
}catch (Exception e) {
Exceptions.propagateIfFatal(e);
@@ -257,9 +261,9 @@ public class CatalogTransformer {
EntityDynamicType typeMap = BrooklynTypes.getDefinedEntityType(spec.getType());
EntityType type = typeMap.getSnapshot();
- AtomicInteger paramPriorityCnt = new AtomicInteger();
+ AtomicInteger priority = new AtomicInteger();
for (SpecParameter<?> input: spec.getParameters())
- config.add(EntityTransformer.entityConfigSummary(input, paramPriorityCnt));
+ config.add(ConfigTransformer.of(input).uiIncrementAndSetPriorityIfPinned(priority).transformLegacyEntityConfig());
for (Sensor<?> x: type.getSensors())
sensors.add(SensorTransformer.sensorSummaryForCatalog(x));
for (Effector<?> x: type.getEffectors())
@@ -315,8 +319,9 @@ public class CatalogTransformer {
final Set<PolicyConfigSummary> config = Sets.newLinkedHashSet();
try{
final PolicySpec<?> spec = (PolicySpec<?>) b.getCatalog().peekSpec(item);
- for (final SpecParameter<?> input : spec.getParameters()){
- config.add(EntityTransformer.policyConfigSummary(input));
+ AtomicInteger priority = new AtomicInteger();
+ for (SpecParameter<?> input: spec.getParameters()) {
+ config.add(ConfigTransformer.of(input).uiIncrementAndSetPriorityIfPinned(priority).transformLegacyPolicyConfig());
}
}catch (Exception e) {
Exceptions.propagateIfFatal(e);
@@ -333,8 +338,9 @@ public class CatalogTransformer {
final Set<EnricherConfigSummary> config = Sets.newLinkedHashSet();
try{
final EnricherSpec<?> spec = (EnricherSpec<?>) b.getCatalog().peekSpec(item);
- for (final SpecParameter<?> input : spec.getParameters()){
- config.add(EntityTransformer.enricherConfigSummary(input));
+ AtomicInteger priority = new AtomicInteger();
+ for (SpecParameter<?> input: spec.getParameters()) {
+ config.add(ConfigTransformer.of(input).uiIncrementAndSetPriorityIfPinned(priority).transformLegacyEnricherConfig());
}
}catch (Exception e) {
Exceptions.propagateIfFatal(e);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/ConfigTransformer.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/ConfigTransformer.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/ConfigTransformer.java
new file mode 100644
index 0000000..22d4299
--- /dev/null
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/ConfigTransformer.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.rest.transform;
+
+import static org.apache.brooklyn.rest.util.WebResourceUtils.serviceUriBuilder;
+
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.ws.rs.core.UriBuilder;
+
+import org.apache.brooklyn.api.catalog.CatalogConfig;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.objs.BrooklynObject;
+import org.apache.brooklyn.api.objs.EntityAdjunct;
+import org.apache.brooklyn.api.objs.SpecParameter;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.render.RendererHints;
+import org.apache.brooklyn.rest.api.AdjunctApi;
+import org.apache.brooklyn.rest.api.EntityConfigApi;
+import org.apache.brooklyn.rest.domain.ConfigSummary;
+import org.apache.brooklyn.util.collections.MutableMap;
+
+import com.google.common.collect.Iterables;
+
+public class ConfigTransformer {
+
+ private final ConfigKey<?> key;
+
+ UriBuilder ub;
+ boolean includeContextLinks, includeActionLinks;
+ Entity entity;
+ EntityAdjunct adjunct;
+
+ String label;
+ Double priority;
+ Boolean pinned;
+
+ public static ConfigTransformer of(ConfigKey<?> key) {
+ return new ConfigTransformer(key);
+ }
+
+ public static ConfigTransformer of(SpecParameter<?> param) {
+ ConfigTransformer result = of(param.getConfigKey());
+ result.label = param.getLabel();
+ result.pinned = param.isPinned();
+ return result;
+ }
+
+ private ConfigTransformer(ConfigKey<?> key) {
+ this.key = key;
+ }
+
+ public ConfigTransformer on(Entity entity) {
+ this.entity = entity;
+ return this;
+ }
+
+ public ConfigTransformer on(Entity entity, EntityAdjunct adjunct) {
+ this.entity = entity;
+ this.adjunct = adjunct;
+ return this;
+ }
+
+ public ConfigTransformer includeLinks(UriBuilder ub, boolean includeContextLinks, boolean includeActionLinks) {
+ this.ub = ub;
+ this.includeContextLinks = includeContextLinks;
+ this.includeActionLinks = includeActionLinks;
+ return this;
+ }
+
+ public ConfigTransformer uiMetadata(String label, Double priority, Boolean pinned) {
+ this.label = label;
+ this.priority = priority;
+ this.pinned = pinned;
+ return this;
+ }
+
+ public ConfigTransformer uiMetadata(String label, Boolean pinned) {
+ return uiMetadata(label, Boolean.TRUE.equals(pinned) ? 1.0d : 0, pinned);
+ }
+
+ public ConfigTransformer uiIncrementAndSetPriorityIfPinned(AtomicInteger lastPriority) {
+ if (Boolean.TRUE.equals(pinned)) {
+ this.priority = (double) lastPriority.incrementAndGet();
+ }
+ return this;
+ }
+
+ public ConfigTransformer uiMetadata(Field keyField) {
+ if (keyField==null) return this;
+ return uiMetadata(keyField.getDeclaredAnnotation(CatalogConfig.class));
+ }
+
+ public ConfigTransformer uiMetadata(CatalogConfig annotation) {
+ if (annotation==null) return this;
+ return uiMetadata(annotation.label(), annotation.priority(), annotation.pinned());
+ }
+
+ public ConfigSummary transform() {
+ MutableMap.Builder<String, URI> lb = new MutableMap.Builder<String, URI>();
+
+ if (ub!=null && entity!=null) {
+ URI self;
+ if (adjunct!=null) {
+ self = serviceUriBuilder(ub, AdjunctApi.class, "getConfig").build(entity.getApplicationId(), entity.getId(), adjunct.getId(), key.getName());
+ } else {
+ self = serviceUriBuilder(ub, EntityConfigApi.class, "get").build(entity.getApplicationId(), entity.getId(), key.getName());
+ }
+ lb.put("self", self);
+
+ if (includeContextLinks) {
+ // TODO wasteful including these
+ lb.put("application", EntityTransformer.applicationUri(entity.getApplication(), ub) );
+ lb.put("entity", EntityTransformer.entityUri(entity, ub) );
+ if (adjunct!=null) {
+ lb.put("adjunct", AdjunctTransformer.adjunctUri(entity, adjunct, ub) );
+ }
+ }
+ if (includeActionLinks) {
+ // TODO is this json or a display value?
+ lb.put("action:json", self);
+
+ Iterable<RendererHints.NamedAction> hints = Iterables.filter(RendererHints.getHintsFor(key), RendererHints.NamedAction.class);
+ BrooklynObject context = adjunct!=null ? adjunct : entity;
+ for (RendererHints.NamedAction na : hints) {
+ SensorTransformer.addNamedAction(lb, na, context.getConfig(key), key, context);
+ }
+ }
+
+ }
+
+ // TODO if ui metadata not set try to infer or get more info from caller ?
+
+ return new ConfigSummary(key, label, priority, pinned, lb.build());
+ }
+
+ @Deprecated
+ public org.apache.brooklyn.rest.domain.EntityConfigSummary transformLegacyEntityConfig() {
+ ConfigSummary v2 = transform();
+ return new org.apache.brooklyn.rest.domain.EntityConfigSummary(key, v2.getLabel(), v2.getPriority(), v2.isPinned(), v2.getLinks());
+ }
+
+ @Deprecated
+ public org.apache.brooklyn.rest.domain.EnricherConfigSummary transformLegacyEnricherConfig() {
+ ConfigSummary v2 = transform();
+ return new org.apache.brooklyn.rest.domain.EnricherConfigSummary(key, v2.getLabel(), v2.getPriority(), v2.getLinks());
+ }
+
+ @Deprecated
+ public org.apache.brooklyn.rest.domain.PolicyConfigSummary transformLegacyPolicyConfig() {
+ ConfigSummary v2 = transform();
+ return new org.apache.brooklyn.rest.domain.PolicyConfigSummary(key, v2.getLabel(), v2.getPriority(), v2.getLinks());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
index 9359bb5..1537f07 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
@@ -36,25 +36,21 @@ import org.apache.brooklyn.api.objs.BrooklynObject;
import org.apache.brooklyn.api.objs.SpecParameter;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
-import org.apache.brooklyn.core.config.render.RendererHints;
import org.apache.brooklyn.core.objs.BrooklynObjectInternal;
import org.apache.brooklyn.core.typereg.RegisteredTypes;
import org.apache.brooklyn.rest.api.ApplicationApi;
import org.apache.brooklyn.rest.api.CatalogApi;
import org.apache.brooklyn.rest.api.EntityApi;
-import org.apache.brooklyn.rest.api.EntityConfigApi;
import org.apache.brooklyn.rest.domain.ConfigSummary;
import org.apache.brooklyn.rest.domain.EnricherConfigSummary;
import org.apache.brooklyn.rest.domain.EntityConfigSummary;
import org.apache.brooklyn.rest.domain.EntitySummary;
import org.apache.brooklyn.rest.domain.PolicyConfigSummary;
import org.apache.brooklyn.rest.util.BrooklynRestResourceUtils;
-import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.core.config.ConfigBag;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@@ -126,89 +122,39 @@ public class EntityTransformer {
}));
}
- /** @deprecated since 0.13.0 use {@link #configSummary(BrooklynRestResourceUtils, UriBuilder, Entity, ConfigKey, String, Double, Boolean) */
+ public static URI applicationUri(Application entity, UriBuilder ub) {
+ return serviceUriBuilder(ub, ApplicationApi.class, "get").build(entity.getApplicationId());
+ }
+
+ public static URI entityUri(Entity entity, UriBuilder ub) {
+ return serviceUriBuilder(ub, EntityApi.class, "get").build(entity.getApplicationId(), entity.getId());
+ }
+
+ /** @deprecated since 0.13.0 use {@link ConfigTransformer} */
@Deprecated
public static EntityConfigSummary entityConfigSummary(ConfigKey<?> config, String label, Double priority, Boolean pinned, Map<String, URI> links) {
return new EntityConfigSummary(config, label, priority, pinned, links);
}
- /** @deprecated since 0.13.0 use {@link AdjunctTransformer#configSummary(BrooklynRestResourceUtils, UriBuilder, Entity, org.apache.brooklyn.api.objs.EntityAdjunct, ConfigKey, String, Double, Boolean)} */
+ /** @deprecated since 0.13.0 use {@link ConfigTransformer} */
@Deprecated
public static PolicyConfigSummary policyConfigSummary(ConfigKey<?> config, String label, Double priority, Map<String, URI> links) {
return new PolicyConfigSummary(config, label, priority, links);
}
- /** @deprecated since 0.13.0 use {@link AdjunctTransformer#configSummary(BrooklynRestResourceUtils, UriBuilder, Entity, org.apache.brooklyn.api.objs.EntityAdjunct, ConfigKey, String, Double, Boolean)} */
+ /** @deprecated since 0.13.0 use {@link ConfigTransformer} */
@Deprecated
public static EnricherConfigSummary enricherConfigSummary(ConfigKey<?> config, String label, Double priority, Map<String, URI> links) {
return new EnricherConfigSummary(config, label, priority, links);
}
- /** generates a representation for a given config key,
- * with label inferred from annoation in the entity class,
- * and links pointing to the entity and the application
- * @deprecated since 0.13.0 use {@link #configSummary(BrooklynRestResourceUtils, UriBuilder, Entity, ConfigKey)} */
+ /** @deprecated since 0.13.0 use {@link ConfigTransformer} */
@Deprecated
- public static EntityConfigSummary entityConfigSummary(Entity entity, ConfigKey<?> config, UriBuilder ub) {
- return (EntityConfigSummary) configSummary(null, ub, entity, config);
+ public static ConfigSummary entityConfigSummary(Entity entity, ConfigKey<?> config, UriBuilder ub) {
+ return ConfigTransformer.of(config).on(entity).includeLinks(ub, true, true).transform();
}
-
- public static ConfigSummary configSummary(BrooklynRestResourceUtils utils, UriBuilder ub, Entity entity, ConfigKey<?> config) {
- // TODO get catalog/display info
-
- /*
- * following code nearly there to get the @CatalogConfig annotation
- * in the class and use that to populate a label
- */
-
-// EntityDynamicType typeMap =
-// ((AbstractEntity)entity).getMutableEntityType();
-// // above line works if we can cast; line below won't work, but there should some way
-// // to get back the handle to the spec from an entity local, which then *would* work
-// EntityTypes.getDefinedEntityType(entity.getClass());
-// String label = typeMap.getConfigKeyField(config.getName());
- return configSummary(null, ub, entity, config, null);
- }
- public static ConfigSummary configSummary(BrooklynRestResourceUtils utils, UriBuilder ub, Entity entity, ConfigKey<?> config, CatalogConfig annotation) {
- String label = annotation==null ? null : annotation.label();
- Double priority = annotation==null ? null : annotation.priority();
- boolean pinned = annotation!=null && annotation.pinned();
- return configSummary(utils, ub, entity, config, label, priority, pinned);
- }
- public static ConfigSummary configSummary(BrooklynRestResourceUtils utils, UriBuilder ub, Entity entity, ConfigKey<?> config, String label, Double priority, Boolean pinned) {
- // entity can be null if coming from catalog
- URI applicationUri = entity==null ? null : serviceUriBuilder(ub, ApplicationApi.class, "get").build(entity.getApplicationId());
- URI entityUri = entity==null ? null : serviceUriBuilder(ub, EntityApi.class, "get").build(entity.getApplicationId(), entity.getId());
- URI selfUri = entity==null ? null : serviceUriBuilder(ub, EntityConfigApi.class, "get").build(entity.getApplicationId(), entity.getId(), config.getName());
-
- MutableMap.Builder<String, URI> lb = MutableMap.<String, URI>builder()
- .putIfNotNull("self", selfUri)
- // TODO wasteful including these on every item as it is just a list, remove
- .putIfNotNull("application", applicationUri)
- .putIfNotNull("entity", entityUri)
- // TODO is this json or a display value?
- .putIfNotNull("action:json", selfUri);
-
- Iterable<RendererHints.NamedAction> hints = Iterables.filter(RendererHints.getHintsFor(config), RendererHints.NamedAction.class);
- for (RendererHints.NamedAction na : hints) {
- if (entity!=null) {
- SensorTransformer.addNamedAction(lb, na, entity.getConfig(config), config, entity);
- }
- }
-
- return new EntityConfigSummary(config, label, priority, pinned, lb.build());
- }
-
- public static URI applicationUri(Application entity, UriBuilder ub) {
- return serviceUriBuilder(ub, ApplicationApi.class, "get").build(entity.getApplicationId());
- }
-
- public static URI entityUri(Entity entity, UriBuilder ub) {
- return serviceUriBuilder(ub, EntityApi.class, "get").build(entity.getApplicationId(), entity.getId());
- }
-
- /** @deprecated since 0.13.0 use {@link #configSummary(BrooklynRestResourceUtils, UriBuilder, Entity, ConfigKey, CatalogConfig) */
+ /** @deprecated since 0.13.0 use {@link ConfigTransformer} */
@Deprecated
public static EntityConfigSummary entityConfigSummary(ConfigKey<?> config, Field configKeyField) {
CatalogConfig catalogConfig = configKeyField!=null ? configKeyField.getAnnotation(CatalogConfig.class) : null;
@@ -218,7 +164,7 @@ public class EntityTransformer {
return entityConfigSummary(config, label, priority, pinned, null);
}
- /** @deprecated since 0.13.0 use {@link #configSummary(BrooklynRestResourceUtils, UriBuilder, Entity, ConfigKey, AtomicInteger) */
+ /** @deprecated since 0.13.0 use {@link ConfigTransformer} */
@Deprecated
public static EntityConfigSummary entityConfigSummary(SpecParameter<?> input, AtomicInteger paramPriorityCnt) {
// Increment the priority because the config container is a set. Server-side we are using an ordered set
@@ -228,38 +174,14 @@ public class EntityTransformer {
return entityConfigSummary(input.getConfigKey(), input.getLabel(), priority, input.isPinned(), null);
}
- /** @deprecated since 0.13.0 use {@link #configSummary(BrooklynRestResourceUtils, UriBuilder, Entity, SpecParameter) */
- @Deprecated
- public static ConfigSummary configSummary(SpecParameter<?> input) {
- // TODO could increment priority, or take from annotation, or introduce new field
- Double priority = input.isPinned() ? Double.valueOf(1d) : null;
- return new EntityConfigSummary(input.getConfigKey(), input.getLabel(), priority, input.isPinned(), null);
- }
-
-
- public static ConfigSummary configSummary(BrooklynRestResourceUtils utils, UriBuilder ub, Entity entity, SpecParameter<?> input, AtomicInteger paramPriorityCnt) {
- // Increment the priority because the config container is a set. Server-side we are using an ordered set
- // which results in correctly ordered items on the wire (as a list). Clients which use the java bindings
- // though will push the items in an unordered set - so give them means to recover the correct order.
- Double priority = input.isPinned() ? Double.valueOf(paramPriorityCnt.incrementAndGet()) : null;
- return configSummary(utils, ub, entity, input.getConfigKey(), input.getLabel(), priority, input.isPinned());
- }
-
- public static ConfigSummary configSummary(BrooklynRestResourceUtils utils, UriBuilder ub, Entity entity, SpecParameter<?> input) {
- // TODO allow taking priority from a setting somewhere?
- // (this just sets priority 1 if no value specified)
- return configSummary(utils, ub, entity, input, new AtomicInteger(0));
- }
-
-
- /** @deprecated since 0.13.0 use {@link AdjunctTransformer#configSummary(BrooklynRestResourceUtils, UriBuilder, Entity, org.apache.brooklyn.api.objs.EntityAdjunct, SpecParameter)} */
+ /** @deprecated since 0.13.0 use {@link ConfigTransformer} */
@Deprecated
public static PolicyConfigSummary policyConfigSummary(SpecParameter<?> input) {
Double priority = input.isPinned() ? Double.valueOf(1d) : null;
return policyConfigSummary(input.getConfigKey(), input.getLabel(), priority, null);
}
- /** @deprecated since 0.13.0 use {@link AdjunctTransformer#configSummary(BrooklynRestResourceUtils, UriBuilder, Entity, org.apache.brooklyn.api.objs.EntityAdjunct, SpecParameter)} */
+ /** @deprecated since 0.13.0 use {@link ConfigTransformer} */
@Deprecated
public static EnricherConfigSummary enricherConfigSummary(SpecParameter<?> input) {
Double priority = input.isPinned() ? Double.valueOf(1d) : null;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/SensorTransformer.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/SensorTransformer.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/SensorTransformer.java
index 19820d0..e4971ff 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/SensorTransformer.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/SensorTransformer.java
@@ -18,25 +18,28 @@
*/
package org.apache.brooklyn.rest.transform;
+import static org.apache.brooklyn.rest.util.WebResourceUtils.serviceUriBuilder;
+
import java.net.URI;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import javax.ws.rs.core.UriBuilder;
+
import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.objs.BrooklynObject;
import org.apache.brooklyn.api.sensor.AttributeSensor;
import org.apache.brooklyn.api.sensor.Sensor;
import org.apache.brooklyn.core.config.render.RendererHints;
+import org.apache.brooklyn.rest.api.ApplicationApi;
+import org.apache.brooklyn.rest.api.EntityApi;
+import org.apache.brooklyn.rest.api.SensorApi;
import org.apache.brooklyn.rest.domain.SensorSummary;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.exceptions.Exceptions;
import org.apache.brooklyn.util.text.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.collect.Iterables;
-import javax.ws.rs.core.UriBuilder;
-import org.apache.brooklyn.rest.api.ApplicationApi;
-import org.apache.brooklyn.rest.api.EntityApi;
-import org.apache.brooklyn.rest.api.SensorApi;
-import static org.apache.brooklyn.rest.util.WebResourceUtils.serviceUriBuilder;
public class SensorTransformer {
@@ -71,7 +74,7 @@ public class SensorTransformer {
}
@SuppressWarnings("unchecked")
- static <T> void addNamedAction(MutableMap.Builder<String, URI> lb, RendererHints.NamedAction na, T value, Object context, Entity contextEntity) {
+ static <T> void addNamedAction(MutableMap.Builder<String, URI> lb, RendererHints.NamedAction na, T value, Object contextKeyOrSensor, BrooklynObject contextObject) {
if (na instanceof RendererHints.NamedActionWithUrl) {
try {
String v = ((RendererHints.NamedActionWithUrl<T>) na).getUrlFromValue(value);
@@ -81,7 +84,7 @@ public class SensorTransformer {
}
} catch (Exception e) {
Exceptions.propagateIfFatal(e);
- log.warn("Unable to make action "+na+" from "+context+" on "+contextEntity+": "+e, e);
+ log.warn("Unable to make action "+na+" from "+contextKeyOrSensor+" on "+contextObject+": "+e, e);
}
}
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/TypeTransformer.java
----------------------------------------------------------------------
diff --git a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/TypeTransformer.java b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/TypeTransformer.java
index d081efd..736ee83 100644
--- a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/TypeTransformer.java
+++ b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/TypeTransformer.java
@@ -100,7 +100,7 @@ public class TypeTransformer {
AbstractBrooklynObjectSpec<?,?> spec = b.getTypeRegistry().createSpec(item, null, null);
AtomicInteger priority = new AtomicInteger(0);
for (final SpecParameter<?> input : spec.getParameters()){
- config.add(EntityTransformer.configSummary(null, null, null, input, priority));
+ config.add(ConfigTransformer.of(input).uiIncrementAndSetPriorityIfPinned(priority).transform());
}
result.setExtraField("config", config);
@@ -127,9 +127,9 @@ public class TypeTransformer {
EntityDynamicType typeMap = BrooklynTypes.getDefinedEntityType(spec.getType());
EntityType type = typeMap.getSnapshot();
- AtomicInteger paramPriorityCnt = new AtomicInteger();
+ AtomicInteger priority = new AtomicInteger();
for (SpecParameter<?> input: spec.getParameters())
- config.add(EntityTransformer.configSummary(null, null, null, input, paramPriorityCnt));
+ config.add(ConfigTransformer.of(input).uiIncrementAndSetPriorityIfPinned(priority).transform());
for (Sensor<?> x: type.getSensors())
sensors.add(SensorTransformer.sensorSummaryForCatalog(x));
for (Effector<?> x: type.getEffectors())
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/83c3d500/server-cli/src/main/java/org/apache/brooklyn/cli/lister/ItemDescriptors.java
----------------------------------------------------------------------
diff --git a/server-cli/src/main/java/org/apache/brooklyn/cli/lister/ItemDescriptors.java b/server-cli/src/main/java/org/apache/brooklyn/cli/lister/ItemDescriptors.java
index 61a7a2a..1a4ad31 100644
--- a/server-cli/src/main/java/org/apache/brooklyn/cli/lister/ItemDescriptors.java
+++ b/server-cli/src/main/java/org/apache/brooklyn/cli/lister/ItemDescriptors.java
@@ -18,7 +18,6 @@
*/
package org.apache.brooklyn.cli.lister;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -29,7 +28,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.brooklyn.api.catalog.BrooklynCatalog;
import org.apache.brooklyn.api.catalog.Catalog;
-import org.apache.brooklyn.api.catalog.CatalogConfig;
import org.apache.brooklyn.api.catalog.CatalogItem;
import org.apache.brooklyn.api.effector.Effector;
import org.apache.brooklyn.api.entity.EntityType;
@@ -47,8 +45,8 @@ import org.apache.brooklyn.rest.domain.ConfigSummary;
import org.apache.brooklyn.rest.domain.EffectorSummary;
import org.apache.brooklyn.rest.domain.SensorSummary;
import org.apache.brooklyn.rest.domain.SummaryComparators;
+import org.apache.brooklyn.rest.transform.ConfigTransformer;
import org.apache.brooklyn.rest.transform.EffectorTransformer;
-import org.apache.brooklyn.rest.transform.EntityTransformer;
import org.apache.brooklyn.rest.transform.SensorTransformer;
import org.apache.brooklyn.util.collections.MutableMap;
import org.apache.brooklyn.util.exceptions.RuntimeInterruptedException;
@@ -138,9 +136,7 @@ public class ItemDescriptors {
Set<EffectorSummary> effectors = Sets.newTreeSet(SummaryComparators.nameComparator());
for (ConfigKey<?> x: type.getConfigKeys()) {
- Field field = dynamicType.getConfigKeyField(x.getName());
- CatalogConfig annotation = field==null ? null : field.getAnnotation(CatalogConfig.class);
- config.add(EntityTransformer.configSummary(null, null, null, x, annotation));
+ config.add(ConfigTransformer.of(x).uiMetadata(dynamicType.getConfigKeyField(x.getName())).transform());
}
result.put("config", config);
@@ -205,7 +201,7 @@ public class ItemDescriptors {
if (!headingsOnly) {
AtomicInteger priority = new AtomicInteger(0);
for (SpecParameter<?> param: spec.getParameters()) {
- config.add(EntityTransformer.configSummary(null, null, null, param, priority));
+ config.add(ConfigTransformer.of(param).uiIncrementAndSetPriorityIfPinned(priority).transform());
}
itemDescriptor.put("config", config);
}