Search in sources :

Example 6 with BundleInfo

use of io.fabric8.agent.model.BundleInfo in project fabric8 by jboss-fuse.

the class AgentUtils method getProfileArtifacts.

/**
 * Returns the location and parser map (i.e. the location and the parsed maven coordinates and artifact locations) of each bundle and feature
 */
public static Map<String, Parser> getProfileArtifacts(FabricService fabricService, Profile profile, Iterable<String> bundles, Iterable<Feature> features, Callback<String> nonMavenLocationCallback) {
    Set<String> locations = new HashSet<>();
    for (Feature feature : features) {
        List<BundleInfo> bundleList = feature.getBundles();
        if (bundleList == null) {
            LOGGER.warn("No bundles for feature " + feature);
        } else {
            for (BundleInfo bundle : bundleList) {
                locations.add(bundle.getLocation());
            }
        }
    }
    for (String bundle : bundles) {
        locations.add(bundle);
    }
    Map<String, Parser> artifacts = new HashMap<>();
    for (String location : locations) {
        try {
            if (location.contains("$")) {
                ProfileService profileService = fabricService.adapt(ProfileService.class);
                Profile overlay = profileService.getOverlayProfile(profile);
                location = VersionPropertyPointerResolver.replaceVersions(fabricService, overlay.getConfigurations(), location);
            }
            if (location.startsWith("mvn:") || location.contains(":mvn:")) {
                Parser parser = Parser.parsePathWithSchemePrefix(location);
                artifacts.put(location, parser);
            } else {
                if (nonMavenLocationCallback != null) {
                    nonMavenLocationCallback.call(location);
                }
            }
        } catch (MalformedURLException e) {
            LOGGER.error("Failed to parse bundle URL: " + location + ". " + e, e);
        }
    }
    return artifacts;
}
Also used : MalformedURLException(java.net.MalformedURLException) BundleInfo(io.fabric8.agent.model.BundleInfo) ProfileService(io.fabric8.api.ProfileService) HashMap(java.util.HashMap) Feature(io.fabric8.agent.model.Feature) Profile(io.fabric8.api.Profile) HashSet(java.util.HashSet) Parser(io.fabric8.maven.util.Parser)

Aggregations

BundleInfo (io.fabric8.agent.model.BundleInfo)5 HashMap (java.util.HashMap)4 Feature (io.fabric8.agent.model.Feature)3 Resource (org.osgi.resource.Resource)3 Downloader (io.fabric8.agent.download.Downloader)2 ConfigFile (io.fabric8.agent.model.ConfigFile)2 FeatureResource (io.fabric8.agent.resolver.FeatureResource)2 MultiException (io.fabric8.common.util.MultiException)2 Parser (io.fabric8.maven.util.Parser)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 HashSet (java.util.HashSet)2 VersionRange (org.apache.felix.utils.version.VersionRange)2 Bundle (org.osgi.framework.Bundle)2 BundleStartLevel (org.osgi.framework.startlevel.BundleStartLevel)2 DeploymentAgent.getPrefixedProperties (io.fabric8.agent.DeploymentAgent.getPrefixedProperties)1 DownloadManager (io.fabric8.agent.download.DownloadManager)1 StreamProvider (io.fabric8.agent.download.StreamProvider)1 MapUtils.addToMapSet (io.fabric8.agent.internal.MapUtils.addToMapSet)1 MapUtils.removeFromMapSet (io.fabric8.agent.internal.MapUtils.removeFromMapSet)1