Example #1
0
  /** {@inheritDoc}. */
  @SuppressWarnings("unchecked")
  @Override
  public List<Map<String, Object>> getServices(String applicationID) {
    List<Map<String, Object>> services =
        configAdminExt.listServices(getDefaultFactoryLdapFilter(), getDefaultLdapFilter());
    List<Map<String, Object>> returnValues = new ArrayList<Map<String, Object>>();
    BundleContext context = getContext();

    if (!services.isEmpty()) {
      Application app = appService.getApplication(applicationID);
      MetaTypeService metatypeService = getMetaTypeService();

      if (app != null) {
        try {
          Set<BundleInfo> bundles = app.getBundles();

          Set<String> bundleLocations = new HashSet<String>();
          Set<MetaTypeInformation> metatypeInformation = new HashSet<MetaTypeInformation>();
          for (BundleInfo info : bundles) {
            bundleLocations.add(info.getLocation());
          }

          for (Bundle bundle : context.getBundles()) {
            for (BundleInfo info : bundles) {
              if (info.getLocation().equals(bundle.getLocation())) {
                metatypeInformation.add(metatypeService.getMetaTypeInformation(bundle));
              }
            }
          }

          for (Map<String, Object> service : services) {
            if (service.containsKey("configurations")) {
              List<Map<String, Object>> configurations =
                  (List<Map<String, Object>>) service.get("configurations");
              for (Map<String, Object> item : configurations) {
                if (item.containsKey("bundle_location")) {
                  String bundleLocation = (String) item.get("bundle_location");
                  if (bundleLocations.contains(bundleLocation)) {
                    returnValues.add(service);
                    break;
                  }
                }
              }
            } else {
              if (checkForMetaTypesForService(metatypeInformation, service)) {
                returnValues.add(service);
              }
            }
          }

        } catch (ApplicationServiceException e) {
          LOGGER.warn("There was an error while trying to access the application", e);
          return new ArrayList<Map<String, Object>>();
        }
      }
    }

    return returnValues;
  }
 /*
  * Get a list of bundle locations in a feature
  */
 private List<String> getBundleLocations(Feature feature) {
   List<String> result = new LinkedList<String>();
   if (feature != null && feature.getBundles() != null) {
     for (BundleInfo bundle : feature.getBundles()) {
       result.add(bundle.getLocation());
     }
   }
   return result;
 }
 private Set<String> getFeatureLocations() throws Exception {
   Set<String> bundleLocations = new LinkedHashSet<String>();
   for (Feature feature : featuresService.listFeatures()) {
     try {
       for (BundleInfo info : feature.getBundles()) {
         bundleLocations.add(info.getLocation());
       }
     } catch (Exception e) {
       // Ignore
     }
   }
   return bundleLocations;
 }
Example #4
0
 /**
  * Get the list of features where the bundle is belonging.
  *
  * @param bundleLocation the bundle location.
  * @return the list of feature where the bundle is present.
  * @throws Exception in case of retrieval failure.
  */
 protected List<Feature> retrieveFeature(String bundleLocation) throws Exception {
   Feature[] features = featuresService.listFeatures();
   List<Feature> matchingFeatures = new ArrayList<Feature>();
   for (Feature feature : features) {
     List<BundleInfo> bundles = feature.getBundles();
     for (BundleInfo bundleInfo : bundles) {
       String location = bundleInfo.getLocation();
       if (location.equalsIgnoreCase(bundleLocation)) {
         matchingFeatures.add(feature);
         LOGGER.debug(
             "CELLAR BUNDLE: found a feature {} containing bundle {}",
             feature.getName(),
             bundleLocation);
       }
     }
   }
   return matchingFeatures;
 }
Example #5
0
 @Override
 public int compare(BundleInfo bundle1, BundleInfo bundle2) {
   return bundle1.getLocation().compareTo(bundle2.getLocation());
 }