brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geom...@apache.org
Subject [02/12] brooklyn-server git commit: Require bundle and version fields when uploading an archive through the REST API
Date Mon, 27 Mar 2017 10:35:21 GMT
Require bundle and version fields when uploading an archive through the REST API


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/2ed75431
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/2ed75431
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/2ed75431

Branch: refs/heads/master
Commit: 2ed7543170c41790ee1fb404bfc3f2853303d102
Parents: 48beb5c
Author: Thomas Bouron <thomas.bouron@cloudsoftcorp.com>
Authored: Thu Mar 23 16:04:43 2017 +0000
Committer: Thomas Bouron <thomas.bouron@cloudsoftcorp.com>
Committed: Thu Mar 23 17:21:02 2017 +0000

----------------------------------------------------------------------
 .../catalog/internal/BasicBrooklynCatalog.java  | 39 +++-----------------
 1 file changed, 6 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2ed75431/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
index 6e2a802..2634ecf 100644
--- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
+++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
@@ -425,45 +425,18 @@ public class BasicBrooklynCatalog implements BrooklynCatalog {
     }
     
     public static VersionedName getVersionedName(Map<?,?> catalogMetadata) {
-        String id = getFirstAs(catalogMetadata, String.class, "id").orNull();
         String version = getFirstAs(catalogMetadata, String.class, "version").orNull();
-        String symbolicName = getFirstAs(catalogMetadata, String.class, "symbolicName").orNull();
-        symbolicName = findAssertingConsistentIfSet("symbolicName", symbolicName, getFirstAs(catalogMetadata,
String.class, "symbolic-name").orNull());
-        // prefer symbolic name and version, if supplied
-        // else use id as symbolic name : version or just symbolic name
-        // (must match if both supplied)
-        if (Strings.isNonBlank(id)) {
-            if (CatalogUtils.looksLikeVersionedId(id)) {
-                symbolicName = findAssertingConsistentIfSet("symbolicName", symbolicName,
CatalogUtils.getSymbolicNameFromVersionedId(id));
-                version = findAssertingConsistentIfSet("version", version, CatalogUtils.getVersionFromVersionedId(id));
-            } else {
-                symbolicName = findAssertingConsistentIfSet("symbolicName", symbolicName,
id);
-            }
-        }
-        if (Strings.isBlank(symbolicName) && Strings.isBlank(version)) {
-            throw new IllegalStateException("Catalog BOM must define symbolicName and version");
+        String bundle = getFirstAs(catalogMetadata, String.class, "bundle").orNull();
+        if (Strings.isBlank(bundle) && Strings.isBlank(version)) {
+            throw new IllegalStateException("Catalog BOM must define bundle and version");
         }
-        if (Strings.isBlank(symbolicName)) {
-            throw new IllegalStateException("Catalog BOM must define symbolicName");
+        if (Strings.isBlank(bundle)) {
+            throw new IllegalStateException("Catalog BOM must define bundle");
         }
         if (Strings.isBlank(version)) {
             throw new IllegalStateException("Catalog BOM must define version");
         }
-        return new VersionedName(symbolicName, Version.valueOf(version));
-    }
-    
-    private static String findAssertingConsistentIfSet(String context, String ...values)
{
-        String v = null;
-        for (String vi: values) {
-            if (Strings.isNonBlank(vi)) {
-                if (Strings.isNonBlank(v)) {
-                    if (!v.equals(vi)) throw new IllegalStateException("Mismatch in "+context+":
'"+v+"' or '"+vi+"' supplied");
-                } else {
-                    v = vi;
-                }
-            }
-        }
-        return v;
+        return new VersionedName(bundle, Version.valueOf(version));
     }
 
     private void collectCatalogItems(String yaml, List<CatalogItemDtoAbstract<?, ?>>
result, Map<?, ?> parentMeta) {


Mime
View raw message