Search in sources :

Example 1 with BundleField

use of org.codice.ddf.admin.query.dev.system.fields.BundleField in project admin-console-beta by connexta.

the class BundleUtils method populateServices.

private void populateServices(Bundle bundle, BundleField toPopulate) {
    Optional<BlueprintContainer> blueprintContainer = getBlueprintContainer(bundle);
    if (blueprintContainer.isPresent()) {
        List<ComponentMetadata> cmpMetas = blueprintContainer.get().getComponentIds().stream().map(id -> blueprintContainer.get().getComponentMetadata(id)).collect(Collectors.toList());
        for (ComponentMetadata meta : cmpMetas) {
            if (meta instanceof ReferenceListMetadata) {
                populateServiceRefLists((ReferenceListMetadata) meta, bundle, toPopulate);
            } else if (meta instanceof ReferenceMetadata) {
                populateServiceRef((ReferenceMetadata) meta, bundle, toPopulate);
            } else if (meta instanceof BeanMetadata || meta instanceof ServiceMetadata || meta instanceof PassThroughMetadata) {
                continue;
            } else {
                LOGGER.warn("Unable to handle blueprint metadata of type {} for bundle {}.", meta.getClass(), bundle.getSymbolicName());
            }
        }
        getRegisteredServices(bundle).forEach(ref -> toPopulate.addService(createServiceField(ref)));
    }
}
Also used : BlueprintContainer(org.osgi.service.blueprint.container.BlueprintContainer) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) ServiceReferenceField(org.codice.ddf.admin.query.dev.system.fields.ServiceReferenceField) ServiceReferenceListField(org.codice.ddf.admin.query.dev.system.fields.ServiceReferenceListField) BundleService(org.apache.karaf.bundle.core.BundleService) LoggerFactory(org.slf4j.LoggerFactory) PackageField(org.codice.ddf.admin.query.dev.system.fields.PackageField) ServiceMetadata(org.osgi.service.blueprint.reflect.ServiceMetadata) ArrayList(java.util.ArrayList) PassThroughMetadata(org.apache.aries.blueprint.PassThroughMetadata) Parser(org.apache.felix.utils.manifest.Parser) ServiceField(org.codice.ddf.admin.query.dev.system.fields.ServiceField) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) Clause(org.apache.felix.utils.manifest.Clause) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) GetBundles(org.codice.ddf.admin.query.dev.system.discover.GetBundles) Bundle(org.osgi.framework.Bundle) BundleField(org.codice.ddf.admin.query.dev.system.fields.BundleField) ServiceReference(org.osgi.framework.ServiceReference) Logger(org.slf4j.Logger) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) ReferenceMetadata(org.osgi.service.blueprint.reflect.ReferenceMetadata) Collectors(java.util.stream.Collectors) BundleContext(org.osgi.framework.BundleContext) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) List(java.util.List) ReferenceListMetadata(org.osgi.service.blueprint.reflect.ReferenceListMetadata) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) FrameworkUtil(org.osgi.framework.FrameworkUtil) BlueprintContainer(org.osgi.service.blueprint.container.BlueprintContainer) ReferenceListMetadata(org.osgi.service.blueprint.reflect.ReferenceListMetadata) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) PassThroughMetadata(org.apache.aries.blueprint.PassThroughMetadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) ReferenceMetadata(org.osgi.service.blueprint.reflect.ReferenceMetadata) ServiceMetadata(org.osgi.service.blueprint.reflect.ServiceMetadata)

Example 2 with BundleField

use of org.codice.ddf.admin.query.dev.system.fields.BundleField in project admin-console-beta by connexta.

the class FeatureUtils method featureToField.

private FeatureField featureToField(Feature feat, Map<String, BundleField> bundlesByLocation) {
    List<String> featDeps = feat.getDependencies().stream().map(Dependency::getName).collect(Collectors.toList());
    List<BundleField> bundleDepLocations = feat.getBundles().stream().map(BundleInfo::getLocation).map(loc -> createBundleFromLocation(loc, bundlesByLocation)).collect(Collectors.toList());
    return new FeatureField().name(feat.getName()).featDescription(feat.getDescription()).state(feat.getInstall()).id(feat.getId()).repoUrl(feat.getRepositoryUrl()).addFeatureDeps(featDeps).addBundleDeps(bundleDepLocations);
}
Also used : Dependency(org.apache.karaf.features.Dependency) Arrays(java.util.Arrays) BundleInfo(org.apache.karaf.features.BundleInfo) Logger(org.slf4j.Logger) Feature(org.apache.karaf.features.Feature) LoggerFactory(org.slf4j.LoggerFactory) Collectors(java.util.stream.Collectors) FeaturesService(org.apache.karaf.features.FeaturesService) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField) List(java.util.List) Map(java.util.Map) Collections(java.util.Collections) BundleField(org.codice.ddf.admin.query.dev.system.fields.BundleField) BundleField(org.codice.ddf.admin.query.dev.system.fields.BundleField) BundleInfo(org.apache.karaf.features.BundleInfo) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField)

Example 3 with BundleField

use of org.codice.ddf.admin.query.dev.system.fields.BundleField in project admin-console-beta by connexta.

the class BundleUtils method getBundles.

public List<BundleField> getBundles(List<Integer> bundleIds) {
    List<BundleField> bundlesFields = new ArrayList<>();
    List<Bundle> bundles = getAllBundles();
    if (CollectionUtils.isNotEmpty(bundleIds)) {
        bundles = bundles.stream().filter(bundle -> bundleIds.contains(((Long) bundle.getBundleId()).intValue())).collect(Collectors.toList());
    }
    for (Bundle bundle : bundles) {
        BundleField newBundleField = new BundleField().bundleName(bundle.getSymbolicName()).id(Math.toIntExact(bundle.getBundleId())).location(bundle.getLocation()).state(bundle.getState());
        populatePackages(bundle, newBundleField);
        populateServices(bundle, newBundleField);
        bundlesFields.add(newBundleField);
    }
    return bundlesFields;
}
Also used : BundleField(org.codice.ddf.admin.query.dev.system.fields.BundleField) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList)

Example 4 with BundleField

use of org.codice.ddf.admin.query.dev.system.fields.BundleField in project admin-console-beta by connexta.

the class CreatePackageDependencyGraph method createPkgDependencyGraph.

private DirectedGraph<BundleField, DependencyEdge<PackageField>> createPkgDependencyGraph() {
    DirectedGraph graph = new DirectedPseudograph<>(ServiceReferenceField.class);
    List<BundleField> allBundles = bundleUtils.getAllBundleFields();
    allBundles.forEach(graph::addVertex);
    allBundles.forEach(bundle -> createEdgesFromPkgs(bundle, graph, allBundles));
    return graph;
}
Also used : BundleField(org.codice.ddf.admin.query.dev.system.fields.BundleField) DirectedGraph(org.jgrapht.DirectedGraph) DirectedPseudograph(org.jgrapht.graph.DirectedPseudograph) DirectedPseudograph(org.jgrapht.graph.DirectedPseudograph)

Aggregations

BundleField (org.codice.ddf.admin.query.dev.system.fields.BundleField)4 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Bundle (org.osgi.framework.Bundle)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Optional (java.util.Optional)1 PassThroughMetadata (org.apache.aries.blueprint.PassThroughMetadata)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 StringUtils (org.apache.commons.lang.StringUtils)1 Clause (org.apache.felix.utils.manifest.Clause)1 Parser (org.apache.felix.utils.manifest.Parser)1 BundleService (org.apache.karaf.bundle.core.BundleService)1 BundleInfo (org.apache.karaf.features.BundleInfo)1 Dependency (org.apache.karaf.features.Dependency)1