jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <notificati...@github.com>
Subject Re: [jclouds] [Softlayer] Implements setting and retrieving the notes property (#756)
Date Tue, 02 Jun 2015 23:59:33 GMT
> +         Map<String, String> meta = templateOptions.getUserMetadata();
> +         if (meta != null && !meta.isEmpty()) {
> +            if (meta.containsKey(USER_META_NOTES)) {
> +               return meta.get(USER_META_NOTES);
> +            } else {
> +               String notes = "User Metadata\n===========\n\n" + Joiner.on("\n").withKeyValueSeparator(":
").join(meta);
> +               if (notes.length() > SoftLayerTemplateOptions.NOTES_MAX_LENGTH) {
> +                  String suffix = "...\n<truncated>";
> +                  notes = notes.substring(0, SoftLayerTemplateOptions.NOTES_MAX_LENGTH
- suffix.length()) + suffix;
> +               }
> +               return notes;
> +            }
> +         }
> +      }
> +      return null;
> +   }

This looks *very* confusing. Are there three different ways to set the notes? There should
be only one understandable way to set them.
Also, what is the purpose of serialising the user metadata as notes? I mean, why the user
metadata and not some other property?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/756/files#r31583472
Mime
View raw message