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

    https://github.com/apache/incubator-brooklyn/pull/312#discussion_r20128585
  
    --- Diff: 
core/src/main/java/brooklyn/catalog/internal/BasicBrooklynCatalog.java ---
    @@ -387,38 +436,60 @@ public void load() {
             Maybe<Object> possibleLibraries = catalog.getMaybe("libraries");
             if (possibleLibraries.isAbsent()) possibleLibraries = 
catalog.getMaybe("brooklyn.libraries");
             if (possibleLibraries.isPresentAndNonNull()) {
    -            if (!(possibleLibraries.get() instanceof List))
    +            if (!(possibleLibraries.get() instanceof Collection))
                     throw new IllegalArgumentException("Libraries should be a 
list, not "+possibleLibraries.get());
    -            libraries = CatalogLibrariesDto.from((List<?>) 
possibleLibraries.get());
    +            libraries = 
CatalogItemDtoAbstract.parseLibraries((Collection<?>) possibleLibraries.get());
             }
     
    -        // TODO clear up the abundance of id, name, registered type, java 
type
    -        String registeredTypeName = (String) 
catalog.getMaybe("id").orNull();
    -        if (Strings.isBlank(registeredTypeName))
    -            registeredTypeName = (String) 
catalog.getMaybe("name").orNull();
    +        String symbolicName;
    +        String version = null;
    +
    +        symbolicName = (String) catalog.getMaybe("symbolicName").orNull();
    +        if (Strings.isBlank(symbolicName)) {
    +            symbolicName = (String) catalog.getMaybe("id").orNull();
    +            if (Strings.isNonBlank(symbolicName) && 
CatalogUtils.looksLikeVersionedId(symbolicName)) {
    +                symbolicName = 
CatalogUtils.getIdFromVersionedId(symbolicName);
    +                version = 
CatalogUtils.getVersionFromVersionedId(symbolicName);
    +            }
    +        }
    +        if (Strings.isBlank(symbolicName))
    +            symbolicName = (String) catalog.getMaybe("name").orNull();
             // take name from plan if not specified in brooklyn.catalog 
section not supplied
    -        if (Strings.isBlank(registeredTypeName)) {
    -            registeredTypeName = plan.getName();
    -            if (Strings.isBlank(registeredTypeName)) {
    +        if (Strings.isBlank(symbolicName)) {
    +            symbolicName = plan.getName();
    +            if (Strings.isBlank(symbolicName)) {
                     if (plan.getServices().size()==1) {
                         Service svc = 
Iterables.getOnlyElement(plan.getServices());
    -                    registeredTypeName = svc.getServiceType();
    +                    symbolicName = svc.getServiceType();
                     }
                 }
             }
     
    +        Maybe<Object> possibleVersion = catalog.getMaybe("version");
    +        if (possibleVersion.isAbsent() && Strings.isBlank(version)) {
    +            throw new IllegalArgumentException("'version' attribute 
missing in 'brooklyn.catalog' section.");
    +        } else if (possibleVersion.isPresent()) {
    +            if (Strings.isNonBlank(version)) {
    +                throw new IllegalArgumentException("Can't use both 
attribute 'version' and versioned id");
    --- End diff --
    
    i'd be in favour of allowing if they match; someone might for some reason 
want `id` and `symbolicName` and `version` in their json (eg if you get full 
details from a server and just send that back)


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