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

    https://github.com/apache/incubator-brooklyn/pull/920#discussion_r40301213
  
    --- Diff: 
usage/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
 ---
    @@ -444,9 +447,13 @@ public void run() {
             if 
(mgmt.getEntitlementManager().isEntitled(Entitlements.getEntitlementContext(),
                     Entitlements.INVOKE_EFFECTOR, 
Entitlements.EntityAndItem.of(entity, 
                         StringAndArgument.of("expunge", 
MutableMap.of("release", release))))) {
    +            Map<String, Object> flags = MutableMap.<String, 
Object>of("displayName", "expunging " + entity, "description", "REST call to 
expunge entity "
    +                    + entity.getDisplayName() + " (" + entity + ")");
    +            if (Entitlements.getEntitlementContext() != null) {
    +                flags.put("tags", 
MutableSet.of(BrooklynTaskTags.tagForEntitlement(Entitlements.getEntitlementContext())));
    --- End diff --
    
    It feels like we shouldn't have to treat `expunge` differently from the 
other REST api operations. 
    
    It looks like the reason we aren't getting the entitlementContext set 
automatically is that it's using `getExecutionManager().submit(...)`. For 
normal effectors, it goes through the `BasicExecutionContext.submitInternal` 
which adds the `EntitlementContext` tag.
    
    I see next to this method `destroy(Application)` which would have the same 
problem (it is called by the rest `ApplicationApi.delete` operation).
    
    Therefore it feels like a more holistic fix would be good.


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