Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 19DEE200C45 for ; Tue, 28 Mar 2017 11:18:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 18699160B89; Tue, 28 Mar 2017 09:18:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5F336160B7E for ; Tue, 28 Mar 2017 11:18:32 +0200 (CEST) Received: (qmail 67422 invoked by uid 500); 28 Mar 2017 09:18:31 -0000 Mailing-List: contact dev-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list dev@brooklyn.apache.org Received: (qmail 67401 invoked by uid 99); 28 Mar 2017 09:18:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Mar 2017 09:18:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3A290DFBCA; Tue, 28 Mar 2017 09:18:31 +0000 (UTC) From: tbouron To: dev@brooklyn.apache.org Reply-To: dev@brooklyn.apache.org References: In-Reply-To: Subject: [GitHub] brooklyn-server pull request #612: Brooklyn Camp syntax for adding tags to a... Content-Type: text/plain Message-Id: <20170328091831.3A290DFBCA@git1-us-west.apache.org> Date: Tue, 28 Mar 2017 09:18:31 +0000 (UTC) archived-at: Tue, 28 Mar 2017 09:18:33 -0000 Github user tbouron commented on a diff in the pull request: https://github.com/apache/brooklyn-server/pull/612#discussion_r108371784 --- Diff: camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java --- @@ -230,4 +234,45 @@ protected void addDecorationFromJsonMap(Map decorationJson, List> { + protected TagsResolver(BrooklynYamlTypeInstantiator.Factory instantiator) { + super(instantiator); + } + + @Override + public void decorate(EntitySpec entitySpec, ConfigBag attrs, Set encounteredRegisteredTypeIds) { + if (getDecorationAttributeJsonValue(attrs) != null) { + entitySpec.tagsAdd((Iterable)getDecorationAttributeJsonValue(attrs)); + } + } + + @Override + protected String getDecorationKind() { + return "Brooklyn Tags"; + } + + @Override + protected Object getDecorationAttributeJsonValue(ConfigBag attrs) { + Object brooklynTags = attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_TAGS); + if (brooklynTags == null) { + return null; + } else if (brooklynTags != null && !(brooklynTags instanceof List)) { + throw new IllegalArgumentException("brooklyn.tags should be a List of strings " + attrs); + } else { + return Iterables.transform((List)brooklynTags, new Function() { + @Nullable + @Override + public BrooklynTags.NamedStringTag apply(@Nullable String input) { + return BrooklynTags.newNotesTag(input); + } + }); + } + } + + @Override + protected void addDecorationFromJsonMap(Map decorationJson, List> decorations) { + throw new IllegalStateException("Not called"); --- End diff -- Is it right to not implement this? Or at least, shouldn't we have a better exception message? --- 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. ---