brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreaturli <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: add entitlements to EffectorResou...
Date Tue, 15 Jul 2014 11:30:46 GMT
Github user andreaturli commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/67#discussion_r14928989
  
    --- Diff: usage/rest-server/src/main/java/brooklyn/rest/resources/EffectorResource.java
---
    @@ -43,57 +48,61 @@
     import brooklyn.util.guava.Maybe;
     import brooklyn.util.time.Time;
     
    -import com.google.common.base.Function;
    -import com.google.common.collect.FluentIterable;
    -
     public class EffectorResource extends AbstractBrooklynRestResource implements EffectorApi
{
     
         private static final Logger log = LoggerFactory.getLogger(EffectorResource.class);
     
    -   @Override
    -  public List<EffectorSummary> list(final String application, final String entityToken)
{
    -       final EntityLocal entity = brooklyn().getEntity(application, entityToken);
    -       return FluentIterable.from(entity.getEntityType().getEffectors())
    -            .transform(new Function<Effector<?>, EffectorSummary>() {
    -                @Override
    -                public EffectorSummary apply(Effector<?> effector) {
    -                    return EffectorTransformer.effectorSummary(entity, effector);
    -                }
    -            })
    -           .toSortedList(SummaryComparators.nameComparator());
    -   }
    +    @Override
    +    public List<EffectorSummary> list(final String application, final String entityToken)
{
    +        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
    +        return FluentIterable
    +                .from(entity.getEntityType().getEffectors())
    +                .filter(new Predicate<Effector<?>>() {
    +                    @Override
    +                    public boolean apply(@Nullable Effector<?> input) {
    +                        return Entitlements.isEntitled(mgmt().getEntitlementManager(),
Entitlements.INVOKE_EFFECTOR,
    +                                Entitlements.EntityAndItem.of(entity, input.getName()));
    +                    }
    +                })
    +                .transform(new Function<Effector<?>, EffectorSummary>() {
    +                    @Override
    +                    public EffectorSummary apply(Effector<?> effector) {
    +                        return EffectorTransformer.effectorSummary(entity, effector);
    +                    }
    +                })
    +                .toSortedList(SummaryComparators.nameComparator());
    +    }
     
         @Override
    -  public Response invoke(String application, String entityToken, String effectorName,
    -      String timeout, Map<String, String> parameters
    -  ) {
    -      final EntityLocal entity = brooklyn().getEntity(application, entityToken);
    +    public Response invoke(String application, String entityToken, String effectorName,
    +                           String timeout, Map<String, String> parameters) {
    +        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
    --- End diff --
    
    @aledsage `BrooklynRestResourceUtils.getEntity` already uses internally `Entitlements.isEntitled`
so no need to add it also to that method, correct?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message