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

    https://github.com/apache/incubator-brooklyn/pull/307#discussion_r20035772
  
    --- 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<String[]> 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 --
    
    I'd include the string in the error 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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to