Search in sources :

Example 1 with LocationPattern

use of org.apache.karaf.features.LocationPattern in project karaf by apache.

the class Blacklist method compileClauses.

/**
 * Extracts blacklisting clauses related to bundles, features and repositories and changes them to more
 * usable form.
 */
private void compileClauses() {
    for (Clause c : clauses) {
        String type = c.getAttribute(BLACKLIST_TYPE);
        if (type == null) {
            String url = c.getAttribute(BLACKLIST_URL);
            if (url != null || c.getName().startsWith("mvn:")) {
                // some special rules from etc/blacklisted.properties
                type = TYPE_BUNDLE;
            } else {
                type = TYPE_FEATURE;
            }
        }
        String location;
        switch(type) {
            case TYPE_REPOSITORY:
                location = c.getName();
                if (c.getAttribute(BLACKLIST_URL) != null) {
                    location = c.getAttribute(BLACKLIST_URL);
                }
                if (location == null) {
                    // should not happen?
                    LOG.warn("Repository blacklist URI is empty. Ignoring.");
                } else {
                    try {
                        repositoryBlacklist.add(new LocationPattern(location));
                    } catch (IllegalArgumentException e) {
                        LOG.warn("Problem parsing repository blacklist URI \"" + location + "\": " + e.getMessage() + ". Ignoring.");
                    }
                }
                break;
            case TYPE_FEATURE:
                try {
                    featureBlacklist.add(new FeaturePattern(c.toString()));
                } catch (IllegalArgumentException e) {
                    LOG.warn("Problem parsing blacklisted feature identifier \"" + c.toString() + "\": " + e.getMessage() + ". Ignoring.");
                }
                break;
            case TYPE_BUNDLE:
                location = c.getName();
                if (c.getAttribute(BLACKLIST_URL) != null) {
                    location = c.getAttribute(BLACKLIST_URL);
                }
                if (location == null) {
                    // should not happen?
                    LOG.warn("Bundle blacklist URI is empty. Ignoring.");
                } else {
                    try {
                        bundleBlacklist.add(new LocationPattern(location));
                    } catch (IllegalArgumentException e) {
                        LOG.warn("Problem parsing bundle blacklist URI \"" + location + "\": " + e.getMessage() + ". Ignoring.");
                    }
                }
                break;
        }
    }
}
Also used : LocationPattern(org.apache.karaf.features.LocationPattern) FeaturePattern(org.apache.karaf.features.FeaturePattern) Clause(org.apache.felix.utils.manifest.Clause)

Example 2 with LocationPattern

use of org.apache.karaf.features.LocationPattern in project karaf by apache.

the class FeaturesProcessing method postUnmarshall.

/**
 * <p>Perform <em>compilation</em> of rules declared in feature processing XML file.</p>
 * <p>Additional blacklist and overrides definitions will be added to this model</p>
 *
 * @param blacklist additional {@link Blacklist} definition with lower priority
 * @param overrides additional overrides definition with lower priority
 */
public void postUnmarshall(Blacklist blacklist, Set<String> overrides) {
    // configure Blacklist tool
    List<String> blacklisted = new LinkedList<>();
    // compile blacklisted repository URIs (from XML and additional blacklist)
    blacklist.getRepositoryBlacklist().stream().map(LocationPattern::getOriginalUri).forEach(uri -> getBlacklistedRepositories().add(uri));
    for (String repositoryURI : getBlacklistedRepositories()) {
        try {
            blacklistedRepositoryLocationPatterns.add(new LocationPattern(repositoryURI));
            blacklisted.add(repositoryURI + ";" + Blacklist.BLACKLIST_TYPE + "=" + Blacklist.TYPE_REPOSITORY);
        } catch (IllegalArgumentException e) {
            LOG.warn("Can't parse blacklisted repository location pattern: " + repositoryURI + ". Ignoring.");
        }
    }
    // add external blacklisted features to this model
    blacklist.getFeatureBlacklist().forEach(fb -> getBlacklistedFeatures().add(new BlacklistedFeature(fb.getName(), fb.getVersion())));
    blacklisted.addAll(getBlacklistedFeatures().stream().map(bf -> bf.getName() + ";" + Blacklist.BLACKLIST_TYPE + "=" + Blacklist.TYPE_FEATURE + (bf.getVersion() == null ? "" : ";" + FeaturePattern.RANGE + "=\"" + bf.getVersion() + "\"")).collect(Collectors.toList()));
    // add external blacklisted bundle URIs to this model
    blacklist.getBundleBlacklist().stream().map(LocationPattern::getOriginalUri).forEach(uri -> getBlacklistedBundles().add(uri));
    blacklisted.addAll(getBlacklistedBundles().stream().map(bl -> bl + ";" + Blacklist.BLACKLIST_TYPE + "=" + Blacklist.TYPE_BUNDLE).collect(Collectors.toList()));
    this.blacklist = new Blacklist(blacklisted);
    // verify bundle override definitions (from XML and additional overrides)
    bundleReplacements.getOverrideBundles().addAll(parseOverridesClauses(overrides));
    for (Iterator<BundleReplacements.OverrideBundle> iterator = bundleReplacements.getOverrideBundles().iterator(); iterator.hasNext(); ) {
        BundleReplacements.OverrideBundle overrideBundle = iterator.next();
        if (overrideBundle.getOriginalUri() == null) {
            // we have to derive it from replacement - as with etc/overrides.properties entry
            if (overrideBundle.getMode() == BundleReplacements.BundleOverrideMode.MAVEN) {
                LOG.warn("Can't override bundle in maven mode without explicit original URL. Switching to osgi mode.");
                overrideBundle.setMode(BundleReplacements.BundleOverrideMode.OSGI);
            }
            String originalUri = calculateOverridenURI(overrideBundle.getReplacement(), null);
            if (originalUri != null) {
                overrideBundle.setOriginalUri(originalUri);
            } else {
                iterator.remove();
                continue;
            }
        }
        try {
            overrideBundle.compile();
        } catch (MalformedURLException e) {
            LOG.warn("Can't parse override URL location pattern: " + overrideBundle.getOriginalUri() + ". Ignoring.");
            iterator.remove();
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) LocationPattern(org.apache.karaf.features.LocationPattern) Blacklist(org.apache.karaf.features.internal.service.Blacklist) LinkedList(java.util.LinkedList)

Example 3 with LocationPattern

use of org.apache.karaf.features.LocationPattern in project fuse-karaf by jboss-fuse.

the class GitPatchManagementServiceImpl method updateOverrides.

/**
 * <p>Updates existing <code>etc/org.apache.karaf.features.xml</code> after installing single {@link PatchKind#NON_ROLLUP}
 * patch. Both bundle and feature replacements are taken into account.</p>
 * @param workTree
 * @param patches
 */
private void updateOverrides(File workTree, List<PatchData> patches) throws IOException {
    File overrides = new File(workTree, "etc/" + featureProcessing);
    File versions = new File(workTree, "etc/" + featureProcessingVersions);
    // we need two different versions to detect whether the version is externalized in etc/versions.properties
    FeaturesProcessing fp1;
    FeaturesProcessing fp2;
    if (overrides.isFile()) {
        fp1 = InternalUtils.loadFeatureProcessing(overrides, versions);
        fp2 = InternalUtils.loadFeatureProcessing(overrides, null);
    } else {
        fp1 = fp2 = new FeaturesProcessing();
    }
    List<BundleReplacements.OverrideBundle> br1 = fp1.getBundleReplacements().getOverrideBundles();
    List<BundleReplacements.OverrideBundle> br2 = fp2.getBundleReplacements().getOverrideBundles();
    org.apache.felix.utils.properties.Properties props = null;
    boolean propertyChanged = false;
    if (versions.isFile()) {
        props = new org.apache.felix.utils.properties.Properties(versions);
    }
    for (PatchData patchData : patches) {
        for (String bundle : patchData.getBundles()) {
            Artifact artifact = mvnurlToArtifact(bundle, true);
            if (artifact == null) {
                continue;
            }
            // Compute patch bundle version and range
            Version oVer = Utils.getOsgiVersion(artifact.getVersion());
            String vr = patchData.getVersionRange(bundle);
            if (vr != null && !vr.isEmpty()) {
                artifact.setVersion(vr);
            } else {
                Version v1 = new Version(oVer.getMajor(), oVer.getMinor(), 0);
                Version v2 = new Version(oVer.getMajor(), oVer.getMinor() + 1, 0);
                artifact.setVersion(new VersionRange(VersionRange.LEFT_CLOSED, v1, v2, VersionRange.RIGHT_OPEN).toString());
            }
            // features processing file may contain e.g.,:
            // <bundle originalUri="mvn:org.jboss.fuse/fuse-zen/[1,2)/war"
            // replacement="mvn:org.jboss.fuse/fuse-zen/${version.test2}/war" mode="maven" />
            // patch descriptor contains e.g.,:
            // bundle.0 = mvn:org.jboss.fuse/fuse-zen/1.2.0/war
            // bundle.0.range = [1.1,1.2)
            // 
            // we will always match by replacement attribute, ignoring originalUri - the patch descriptor must be
            // prepared correctly
            int idx = 0;
            BundleReplacements.OverrideBundle existing = null;
            // we'll examine model with resolved property placeholders, but modify the other one
            for (BundleReplacements.OverrideBundle override : br1) {
                LocationPattern lp = new LocationPattern(artifact.getCanonicalUri());
                if (lp.matches(override.getReplacement())) {
                    // we've found existing override in current etc/org.apache.karaf.features.xml
                    existing = br2.get(idx);
                    break;
                }
                idx++;
            }
            if (existing == null) {
                existing = new BundleReplacements.OverrideBundle();
                br2.add(existing);
            }
            // either update existing override or configure a new one
            existing.setMode(BundleReplacements.BundleOverrideMode.MAVEN);
            existing.setOriginalUri(artifact.getCanonicalUri());
            String replacement = existing.getReplacement();
            if (replacement != null && replacement.contains("${")) {
                // assume that we have existing replacement="mvn:org.jboss.fuse/fuse-zen/${version.test2}/war"
                // so we can't change the replacement and instead we have to update properties
                String property = null;
                String value = null;
                if (replacement.startsWith("mvn:")) {
                    LocationPattern existingReplacement = new LocationPattern(replacement);
                    property = existingReplacement.getVersionString().substring(existingReplacement.getVersionString().indexOf("${") + 2);
                    if (property.contains("}")) {
                        // it should...
                        property = property.substring(0, property.indexOf("}"));
                    }
                    LocationPattern newReplacement = new LocationPattern(bundle);
                    value = newReplacement.getVersionString();
                } else {
                // non-mvn? then we can't determine the version from non-mvn: URI...
                }
                // we are not changing replacement - we'll have to update properties
                if (props != null && property != null) {
                    props.setProperty(property, value);
                    propertyChanged = true;
                }
            } else {
                existing.setReplacement(bundle);
            }
        }
        // feature overrides
        File featureOverridesLocation = new File(patchData.getPatchDirectory(), "org.apache.karaf.features.xml");
        if (featureOverridesLocation.isFile()) {
            FeaturesProcessing featureOverrides = InternalUtils.loadFeatureProcessing(featureOverridesLocation, null);
            Map<String, FeatureReplacements.OverrideFeature> patchedFeatures = new LinkedHashMap<>();
            List<FeatureReplacements.OverrideFeature> mergedOverrides = new LinkedList<>();
            featureOverrides.getFeatureReplacements().getReplacements().forEach(of -> patchedFeatures.put(of.getFeature().getId(), of));
            fp2.getFeatureReplacements().getReplacements().forEach(of -> {
                FeatureReplacements.OverrideFeature override = patchedFeatures.remove(of.getFeature().getId());
                mergedOverrides.add(override == null ? of : override);
            });
            // add remaining
            mergedOverrides.addAll(patchedFeatures.values());
            fp2.getFeatureReplacements().getReplacements().clear();
            fp2.getFeatureReplacements().getReplacements().addAll(mergedOverrides);
        }
    }
    if (propertyChanged) {
        props.save();
    }
    InternalUtils.saveFeatureProcessing(fp2, overrides, versions);
}
Also used : BundleReplacements(org.apache.karaf.features.internal.model.processing.BundleReplacements) VersionRange(org.osgi.framework.VersionRange) FeatureReplacements(org.apache.karaf.features.internal.model.processing.FeatureReplacements) FeaturesProcessing(org.apache.karaf.features.internal.model.processing.FeaturesProcessing) LinkedHashMap(java.util.LinkedHashMap) Version(org.osgi.framework.Version) PatchData(org.jboss.fuse.patch.management.PatchData) Artifact(org.jboss.fuse.patch.management.Artifact) LinkedList(java.util.LinkedList) LocationPattern(org.apache.karaf.features.LocationPattern) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File)

Example 4 with LocationPattern

use of org.apache.karaf.features.LocationPattern in project karaf by apache.

the class Builder method generateConsistencyReport.

/**
 * Produces human readable XML with <em>feature consistency report</em>.
 * @param repositories
 * @param result
 */
public void generateConsistencyReport(Map<String, Features> repositories, File result, boolean full) {
    Map<String, String> featureId2repository = new HashMap<>();
    // list of feature IDs containing given bundle URIs
    Map<String, Set<String>> bundle2featureId = new TreeMap<>(new URIAwareComparator());
    // map of groupId/artifactId to full URI list to detect "duplicates"
    Map<String, List<String>> ga2uri = new TreeMap<>();
    Set<String> haveDuplicates = new HashSet<>();
    // collect closure of bundles and features
    repositories.forEach((name, features) -> {
        if (full || !features.isBlacklisted()) {
            features.getFeature().forEach(feature -> {
                if (full || !feature.isBlacklisted()) {
                    featureId2repository.put(feature.getId(), name);
                    feature.getBundle().forEach(bundle -> {
                        // normal bundles of feature
                        bundle2featureId.computeIfAbsent(bundle.getLocation().trim(), k -> new TreeSet<>()).add(feature.getId());
                    });
                    feature.getConditional().forEach(cond -> {
                        cond.asFeature().getBundles().forEach(bundle -> {
                            // conditional bundles of feature
                            bundle2featureId.computeIfAbsent(bundle.getLocation().trim(), k -> new TreeSet<>()).add(feature.getId());
                        });
                    });
                }
            });
        }
    });
    // collect bundle URIs - for now, only wrap:mvn: and mvn: are interesting
    bundle2featureId.keySet().forEach(uri -> {
        String originalUri = uri;
        if (uri.startsWith("wrap:mvn:")) {
            uri = uri.substring(5);
            if (uri.indexOf(";") > 0) {
                uri = uri.substring(0, uri.indexOf(";"));
            }
            if (uri.indexOf("$") > 0) {
                uri = uri.substring(0, uri.indexOf("$"));
            }
        }
        if (uri.startsWith("mvn:")) {
            try {
                LocationPattern pattern = new LocationPattern(uri);
                String ga = String.format("%s/%s", pattern.getGroupId(), pattern.getArtifactId());
                ga2uri.computeIfAbsent(ga, k -> new LinkedList<>()).add(originalUri);
            } catch (IllegalArgumentException ignored) {
            /*
                        <!-- hibernate-validator-osgi-karaf-features-5.3.4.Final-features.xml -->
                        <feature name="hibernate-validator-paranamer" version="5.3.4.Final">
                            <feature>hibernate-validator</feature>
                            <bundle>wrap:mvn:com.thoughtworks.paranamer:paranamer:2.8</bundle>
                        </feature>
                     */
            }
        }
    });
    ga2uri.values().forEach(l -> {
        if (l.size() > 1) {
            haveDuplicates.addAll(l);
        }
    });
    if (result == null) {
        return;
    }
    try (BufferedWriter writer = new BufferedWriter(new FileWriter(result))) {
        writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        writer.write("<?xml-stylesheet type=\"text/xsl\" href=\"bundle-report.xslt\"?>\n");
        writer.write("<consistency-report xmlns=\"urn:apache:karaf:consistency:1.0\">\n");
        writer.write("    <duplicates>\n");
        ga2uri.forEach((key, uris) -> {
            if (uris.size() > 1) {
                try {
                    writer.write(String.format("        <duplicate ga=\"%s\">\n", key));
                    for (String uri : uris) {
                        writer.write(String.format("            <bundle uri=\"%s\">\n", sanitize(uri)));
                        for (String fid : bundle2featureId.get(uri)) {
                            writer.write(String.format("                <feature repository=\"%s\">%s</feature>\n", featureId2repository.get(fid), fid));
                        }
                        writer.write("            </bundle>\n");
                    }
                    writer.write("        </duplicate>\n");
                } catch (IOException e) {
                }
            }
        });
        writer.write("    </duplicates>\n");
        writer.write("    <bundles>\n");
        for (String uri : bundle2featureId.keySet()) {
            writer.write(String.format("        <bundle uri=\"%s\" duplicate=\"%b\">\n", sanitize(uri), haveDuplicates.contains(uri)));
            for (String fid : bundle2featureId.get(uri)) {
                writer.write(String.format("            <feature>%s</feature>\n", fid));
            }
            writer.write("        </bundle>\n");
        }
        writer.write("    </bundles>\n");
        writer.write("</consistency-report>\n");
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : Manifest(java.util.jar.Manifest) Dependency(org.apache.karaf.features.internal.model.Dependency) Profile(org.apache.karaf.profile.Profile) Arrays(java.util.Arrays) MultiException(org.apache.karaf.features.internal.util.MultiException) FeaturesProcessorImpl(org.apache.karaf.features.internal.service.FeaturesProcessorImpl) Constants(org.osgi.framework.Constants) FeaturePattern(org.apache.karaf.features.FeaturePattern) KarafPropertiesEditor(org.apache.karaf.tools.utils.KarafPropertiesEditor) LoggerFactory(org.slf4j.LoggerFactory) ConfigFile(org.apache.karaf.features.internal.model.ConfigFile) FeaturesService(org.apache.karaf.features.FeaturesService) Collections.singletonList(java.util.Collections.singletonList) Clause(org.apache.felix.utils.manifest.Clause) ByteArrayInputStream(java.io.ByteArrayInputStream) JaxbUtil(org.apache.karaf.features.internal.model.JaxbUtil) Map(java.util.Map) FeaturesProcessing(org.apache.karaf.features.internal.model.processing.FeaturesProcessing) URI(java.net.URI) Repository(org.osgi.service.repository.Repository) Path(java.nio.file.Path) ZipEntry(java.util.zip.ZipEntry) BundleRevision(org.osgi.framework.wiring.BundleRevision) MavenResolver(org.ops4j.pax.url.mvn.MavenResolver) BundleInfo(org.apache.karaf.features.BundleInfo) Blacklist(org.apache.karaf.features.internal.service.Blacklist) Deployer(org.apache.karaf.features.internal.service.Deployer) MapUtils(org.apache.karaf.features.internal.util.MapUtils) Collection(java.util.Collection) Set(java.util.Set) MANIFEST_NAME(java.util.jar.JarFile.MANIFEST_NAME) UUID(java.util.UUID) Library(org.apache.karaf.features.Library) FileSystem(java.nio.file.FileSystem) Attributes(java.util.jar.Attributes) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) ThreadUtils(org.apache.karaf.util.ThreadUtils) List(java.util.List) PropertiesLoader(org.apache.karaf.util.config.PropertiesLoader) Properties(org.apache.felix.utils.properties.Properties) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) DownloadManager(org.apache.karaf.features.internal.download.DownloadManager) Features(org.apache.karaf.features.internal.model.Features) Dictionary(java.util.Dictionary) ZipInputStream(java.util.zip.ZipInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DownloadCallback(org.apache.karaf.features.internal.download.DownloadCallback) HashMap(java.util.HashMap) ResourceBuilder(org.apache.karaf.features.internal.resolver.ResourceBuilder) Kar(org.apache.karaf.kar.internal.Kar) Function(java.util.function.Function) TreeSet(java.util.TreeSet) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) StreamProvider(org.apache.karaf.features.internal.download.StreamProvider) ProfileBuilder(org.apache.karaf.profile.ProfileBuilder) Parser(org.apache.karaf.util.maven.Parser) BaseRepository(org.apache.karaf.features.internal.repository.BaseRepository) FeaturesProcessor(org.apache.karaf.features.internal.service.FeaturesProcessor) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Bundle(org.apache.karaf.features.internal.model.Bundle) MavenResolvers(org.ops4j.pax.url.mvn.MavenResolvers) Downloader(org.apache.karaf.features.internal.download.Downloader) LinkedList(java.util.LinkedList) Hashtable(java.util.Hashtable) LinkedHashSet(java.util.LinkedHashSet) LocationPattern(org.apache.karaf.features.LocationPattern) Logger(org.slf4j.Logger) Profiles(org.apache.karaf.profile.impl.Profiles) MalformedURLException(java.net.MalformedURLException) FileSystemNotFoundException(java.nio.file.FileSystemNotFoundException) Files(java.nio.file.Files) Conditional(org.apache.karaf.features.internal.model.Conditional) BufferedWriter(java.io.BufferedWriter) Resource(org.osgi.resource.Resource) Version(org.apache.karaf.util.Version) FileWriter(java.io.FileWriter) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) ResolverImpl(org.apache.felix.resolver.ResolverImpl) Resolver(org.osgi.service.resolver.Resolver) KarafPropertyEdits(org.apache.karaf.tools.utils.model.KarafPropertyEdits) File(java.io.File) Overrides(org.apache.karaf.features.internal.service.Overrides) TreeMap(java.util.TreeMap) Paths(java.nio.file.Paths) Feature(org.apache.karaf.features.internal.model.Feature) URLUtils(org.ops4j.net.URLUtils) Startup(org.apache.karaf.profile.assembly.Builder.Stage.Startup) Collections(java.util.Collections) FileSystems(java.nio.file.FileSystems) InputStream(java.io.InputStream) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FileWriter(java.io.FileWriter) IOException(java.io.IOException) TreeMap(java.util.TreeMap) LinkedList(java.util.LinkedList) BufferedWriter(java.io.BufferedWriter) LocationPattern(org.apache.karaf.features.LocationPattern) TreeSet(java.util.TreeSet) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 5 with LocationPattern

use of org.apache.karaf.features.LocationPattern in project karaf by apache.

the class Builder method processBlacklist.

/**
 * Checks existing and configured blacklisting definitions
 * @param initialProfile
 * @return
 * @throws IOException
 */
private Blacklist processBlacklist(Profile initialProfile) throws IOException {
    Blacklist existingBlacklist = null;
    Blacklist blacklist = new Blacklist();
    Path existingBLacklistedLocation = etcDirectory.resolve("blacklisted.properties");
    if (existingBLacklistedLocation.toFile().isFile()) {
        LOGGER.warn("Found {} which is deprecated, please use new feature processor configuration.", homeDirectory.relativize(existingBLacklistedLocation));
        existingBlacklist = new Blacklist(Files.readAllLines(existingBLacklistedLocation));
    }
    for (String br : blacklistedRepositoryURIs) {
        // from Maven/Builder configuration
        try {
            blacklist.blacklistRepository(new LocationPattern(br));
        } catch (IllegalArgumentException e) {
            LOGGER.warn("Blacklisted features XML repository URI is invalid: {}, ignoring", br);
        }
    }
    for (LocationPattern br : initialProfile.getBlacklistedRepositories()) {
        // from profile configuration
        blacklist.blacklistRepository(br);
    }
    for (String bf : blacklistedFeatureIdentifiers) {
        // from Maven/Builder configuration
        blacklist.blacklistFeature(new FeaturePattern(bf));
    }
    for (FeaturePattern bf : initialProfile.getBlacklistedFeatures()) {
        // from profile configuration
        blacklist.blacklistFeature(bf);
    }
    for (String bb : blacklistedBundleURIs) {
        // from Maven/Builder configuration
        try {
            blacklist.blacklistBundle(new LocationPattern(bb));
        } catch (IllegalArgumentException e) {
            LOGGER.warn("Blacklisted bundle URI is invalid: {}, ignoring", bb);
        }
    }
    for (LocationPattern bb : initialProfile.getBlacklistedBundles()) {
        // from profile configuration
        blacklist.blacklistBundle(bb);
    }
    if (existingBlacklist != null) {
        blacklist.merge(existingBlacklist);
    }
    return blacklist;
}
Also used : Path(java.nio.file.Path) LocationPattern(org.apache.karaf.features.LocationPattern) FeaturePattern(org.apache.karaf.features.FeaturePattern) Blacklist(org.apache.karaf.features.internal.service.Blacklist)

Aggregations

LocationPattern (org.apache.karaf.features.LocationPattern)5 LinkedList (java.util.LinkedList)3 FeaturePattern (org.apache.karaf.features.FeaturePattern)3 Blacklist (org.apache.karaf.features.internal.service.Blacklist)3 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2 Path (java.nio.file.Path)2 LinkedHashMap (java.util.LinkedHashMap)2 BufferedWriter (java.io.BufferedWriter)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 FileSystem (java.nio.file.FileSystem)1 FileSystemNotFoundException (java.nio.file.FileSystemNotFoundException)1 FileSystems (java.nio.file.FileSystems)1 Files (java.nio.file.Files)1