You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by m4rkmckenna <gi...@git.apache.org> on 2016/06/04 18:12:59 UTC

[GitHub] brooklyn-server pull request #182: Change to Catalog API so that policy conf...

GitHub user m4rkmckenna opened a pull request:

    https://github.com/apache/brooklyn-server/pull/182

    Change to Catalog API so that policy config is correctly returned

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/m4rkmckenna/brooklyn-server bugfix/catalog-api-policy-config

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/182.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #182
    
----
commit ade2dc04b6727af14b7063657aa11879eee7fddd
Author: Mark McKenna <m4...@gmail.com>
Date:   2016-06-04T18:01:33Z

    Catalog Policy REST API now returns config array

----


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

[GitHub] brooklyn-server issue #182: Change to Catalog API so that policy config is c...

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on the issue:

    https://github.com/apache/brooklyn-server/pull/182
  
    LGTM, merging.


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

[GitHub] brooklyn-server pull request #182: Change to Catalog API so that policy conf...

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/182#discussion_r65898229
  
    --- Diff: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java ---
    @@ -131,7 +132,11 @@ public static CatalogItemSummary catalogItemSummary(BrooklynRestResourceUtils b,
         }
     
         public static CatalogPolicySummary catalogPolicySummary(BrooklynRestResourceUtils b, CatalogItem<? extends Policy,PolicySpec<?>> item, UriBuilder ub) {
    -        Set<PolicyConfigSummary> config = ImmutableSet.of();
    +        final Set<PolicyConfigSummary> config = new HashSet<>();
    +        final PolicySpec<?> spec = (PolicySpec<?>) b.getCatalog().createSpec((CatalogItem) item);
    +        for (final SpecParameter<?> input : spec.getParameters()){
    --- End diff --
    
    Parameters are already ordered and you lose the ordering with the `HashSet`. Suggest to use `LinkedHashSet`. (for the case of = priority).
    The API doesn't actually guarantee ordering (it's a `Set`), but Javascript will keep it anyway. Decided to keep it like this (for the entity case) and not introduce backward compatibility issues until needed.



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

[GitHub] brooklyn-server issue #182: Change to Catalog API so that policy config is c...

Posted by m4rkmckenna <gi...@git.apache.org>.
Github user m4rkmckenna commented on the issue:

    https://github.com/apache/brooklyn-server/pull/182
  
    @neykov comments addressed 


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

[GitHub] brooklyn-server pull request #182: Change to Catalog API so that policy conf...

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/182#discussion_r65896126
  
    --- Diff: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java ---
    @@ -122,6 +123,12 @@ public static EntityConfigSummary entityConfigSummary(ConfigKey<?> config, Strin
             Map<String, URI> mapOfLinks =  links==null ? null : ImmutableMap.copyOf(links);
             return new EntityConfigSummary(config, label, priority, mapOfLinks);
         }
    +
    +    public static PolicyConfigSummary policyConfigSummary(ConfigKey<?> config, String label, Double priority, Map<String, URI> links) {
    +        Map<String, URI> mapOfLinks =  links==null ? null : ImmutableMap.copyOf(links);
    --- End diff --
    
    Isn't this already handled in the constructor below?


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

[GitHub] brooklyn-server pull request #182: Change to Catalog API so that policy conf...

Posted by neykov <gi...@git.apache.org>.
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/182#discussion_r65895846
  
    --- Diff: rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java ---
    @@ -131,7 +132,11 @@ public static CatalogItemSummary catalogItemSummary(BrooklynRestResourceUtils b,
         }
     
         public static CatalogPolicySummary catalogPolicySummary(BrooklynRestResourceUtils b, CatalogItem<? extends Policy,PolicySpec<?>> item, UriBuilder ub) {
    -        Set<PolicyConfigSummary> config = ImmutableSet.of();
    +        final Set<PolicyConfigSummary> config = new HashSet<>();
    +        final PolicySpec<?> spec = (PolicySpec<?>) b.getCatalog().createSpec((CatalogItem) item);
    --- End diff --
    
    wrap in a `try-catch`, could throw on invalid catalog item (for example some dependency no longer exists)


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

[GitHub] brooklyn-server pull request #182: Change to Catalog API so that policy conf...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/182


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