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

    https://github.com/apache/incubator-brooklyn/pull/156#discussion_r17307183
  
    --- Diff: 
usage/rest-server/src/main/java/brooklyn/rest/resources/EntityConfigResource.java
 ---
    @@ -77,10 +83,33 @@ public String getPlain(String application, String 
entityToken, String configKeyN
       
       public Object get(boolean preferJson, String application, String 
entityToken, String configKeyName) {
         EntityLocal entity = brooklyn().getEntity(application, entityToken);
    -    ConfigKey<?> ck = entity.getEntityType().getConfigKey(configKeyName);
    -    if (ck==null) ck = new BasicConfigKey<Object>(Object.class, 
configKeyName);
    +    ConfigKey<?> ck = findConfig(entity, configKeyName);
         
         return getValueForDisplay(entity.getConfigRaw(ck, true).orNull(), 
preferJson, true);
       }
     
    +  private ConfigKey<?> findConfig(EntityLocal entity, String 
configKeyName) {
    +      ConfigKey<?> ck = entity.getEntityType().getConfigKey(configKeyName);
    +      if (ck==null) ck = new BasicConfigKey<Object>(Object.class, 
configKeyName);
    +      return ck;
    +  }
    +
    +  @SuppressWarnings({ "rawtypes", "unchecked" })
    +  @Override
    +  public void set(String application, String entityToken, String 
configName, Boolean recurse, Object newValue) {
    +      final EntityLocal entity = brooklyn().getEntity(application, 
entityToken);
    +      if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), 
Entitlements.MODIFY_ENTITY, entity)) {
    +          throw WebResourceUtils.unauthorized("User '%s' is not authorized 
to modify entity '%s'",
    +              Entitlements.getEntitlementContext().user(), entity);
    +      }
    +
    +      ConfigKey ck = findConfig(entity, configName);
    +      ((EntityInternal)entity).setConfig(ck, 
TypeCoercions.coerce(newValue, ck.getType()));
    --- End diff --
    
    To check my understanding: there is no point in setting config on running 
entities. This is of use for unstarted entities, for example those added with 
the AddChildren effector.


---
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