Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0936D173BC for ; Tue, 11 Nov 2014 01:50:14 +0000 (UTC) Received: (qmail 78973 invoked by uid 500); 11 Nov 2014 01:50:13 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 78933 invoked by uid 500); 11 Nov 2014 01:50:13 -0000 Mailing-List: contact dev-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list dev@brooklyn.incubator.apache.org Received: (qmail 78920 invoked by uid 99); 11 Nov 2014 01:50:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Nov 2014 01:50:13 +0000 X-ASF-Spam-Status: No, hits=-2000.6 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 11 Nov 2014 01:50:12 +0000 Received: (qmail 78766 invoked by uid 99); 11 Nov 2014 01:49:52 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Nov 2014 01:49:52 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id BCD5E9A67F2; Tue, 11 Nov 2014 01:49:51 +0000 (UTC) From: ahgittin To: dev@brooklyn.incubator.apache.org Reply-To: dev@brooklyn.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-brooklyn pull request: support multiple instances of the... Content-Type: text/plain Message-Id: <20141111014951.BCD5E9A67F2@tyr.zones.apache.org> Date: Tue, 11 Nov 2014 01:49:51 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Github user ahgittin commented on a diff in the pull request: https://github.com/apache/incubator-brooklyn/pull/307#discussion_r20127703 --- Diff: core/src/main/java/brooklyn/util/osgi/Osgis.java --- @@ -395,6 +564,25 @@ public static boolean isExtensionBundle(Bundle bundle) { EXTENSION_PROTOCOL.equals(Urls.getProtocol(location)); } + /** Takes a string which might be of the form "symbolic-name" or "symbolic-name:version" (or something else entirely) + * and returns an array of 1 or 2 string items being the symbolic name or symbolic name and version if possible + * (or returning {@link Maybe#absent()} if not, with a suitable error message). */ + public static Maybe parseOsgiIdentifier(String symbolicNameOptionalWithVersion) { + if (Strings.isBlank(symbolicNameOptionalWithVersion)) + return Maybe.absent("OSGi identifier is blank"); + + String[] parts = symbolicNameOptionalWithVersion.split(":"); + if (parts.length>2) + return Maybe.absent("OSGi identifier has too many parts; max one ':' symbol"); + + try { + Version.parseVersion(parts[1]); + } catch (IllegalArgumentException e) { + return Maybe.absent("OSGi identifier has invalid version string"); --- End diff -- the caller includes plenty of context message; given how it is used i think it would be overkill here --- 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. ---