Examples of ResolverException


Examples of org.apache.aries.application.management.ResolverException

    try {     
      ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
      RepositoryGeneratorImpl.generateRepository(repositoryAdmin, appName + "_" + appVersion, byValueBundles, bytesOut);
      appRepo = helper.readRepository(new InputStreamReader(new ByteArrayInputStream(bytesOut.toByteArray())));
    } catch (Exception e) {
      throw new ResolverException(e);
    }
       
    List<Repository> resolveRepos = new ArrayList<Repository>();
    // add system repository
    resolveRepos.add(repositoryAdmin.getSystemRepository());
View Full Code Here

Examples of org.apache.aries.application.management.ResolverException

      for (String reason : unsatisfiedRequirements.keySet()) {
        reqList.append('\n');
        reqList.append(reason);
      }

      ResolverException re = new ResolverException(MessageUtil.getMessage("RESOLVER_UNABLE_TO_RESOLVE",
          new Object[] { app.getApplicationMetadata().getApplicationName(), reqList }));
      re.setUnsatisfiedRequirementsAndReasons(unsatisfiedRequirements);
      log.debug(LOG_EXIT, "resolve", re);
     
      throw re;
    }
  }
View Full Code Here

Examples of org.apache.aries.application.management.ResolverException

     List<ImportedBundle> result = new ArrayList<ImportedBundle>();
     for (Content c : content) {
       try {
       result.add(modellingManager.getImportedBundle(c.getContentName(), c.getVersion().toString()));
       } catch (InvalidAttributeException iae) {
         throw new ResolverException(iae);
       }
     }
     log.debug(LOG_EXIT, "toImportedBundle", result);
     return result;
   }
View Full Code Here

Examples of org.apache.aries.application.management.ResolverException

     if ((bundleInfos != null) && (!!!bundleInfos.isEmpty())) {
       for (BundleInfo bi : bundleInfos) {
         try {
         result.add(modellingManager.getModelledResource(null, bi, null, null));
         } catch (InvalidAttributeException iae) {
           throw new ResolverException(iae);
         }
       }
     }
     return result;
   }
View Full Code Here

Examples of org.apache.aries.application.management.ResolverException

    Document doc;
    try {
      doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();

    } catch (ParserConfigurationException pce) {
      throw new ResolverException(pce);
    }
    Element root = doc.createElement("repository");

    root.setAttribute("name", repositoryName);
    doc.appendChild(root);
    for (ModelledResource mr : byValueBundles) {
      BundleResource bundleResource = new BundleResource(mr, repositoryAdmin);
      if (bundleResourceTransformers.size() > 0) {
        for (BundleResourceTransformer brt : bundleResourceTransformers) {
          bundleResource = brt.transform (bundleResource);
        }
      }
      writeResource (bundleResource, mr.getLocation(), doc, root);
    }

    try {
      Transformer trans = TransformerFactory.newInstance().newTransformer();
      trans.setOutputProperty(OutputKeys.INDENT, "yes");
      trans.transform(new DOMSource(doc), new StreamResult(os));
    } catch (TransformerException te) {
      logger.debug(LOG_EXIT, "generateRepository", te);
      throw new ResolverException(te);
    }
    logger.debug(LOG_EXIT, "generateRepository");
  }
View Full Code Here

Examples of org.apache.aries.application.management.ResolverException

            appRepository = repositoryAdmin.getHelper().repository(f.toURI().toURL());

            f.delete();
        } catch (Exception e) {
            throw new ResolverException(e);
        }

        List<Repository> appRepositories = new ArrayList<Repository>();
       
        // add system & local repositories
        appRepositories.add(repositoryAdmin.getSystemRepository());
        appRepositories.add(repositoryAdmin.getLocalRepository());
       
        // add application repository
        appRepositories.add(appRepository);
       
        // add user repositories
        Repository[] userRepositories = repositoryAdmin.listRepositories();
        for (Repository userRepository : userRepositories) {
            appRepositories.add(userRepository);
        }
       
        Resolver obrResolver = repositoryAdmin.resolver(appRepositories.toArray(new Repository[appRepositories.size()]));

        // add a resource describing the requirements of the application metadata.
        try {
            obrResolver.add(new ApplicationResourceImpl(repositoryAdmin, appName, appVersion, appContent));
        } catch (InvalidSyntaxException e) {
            throw new ResolverException(e);
        }

        if (obrResolver.resolve()) {
            Set<BundleInfo> result = new HashSet<BundleInfo>();
            for (Resource resource : obrResolver.getRequiredResources()) {
                BundleInfo bundleInfo = toBundleInfo(resource, false);
                result.add(bundleInfo);
            }
            if (includeOptional) {
                for (Resource resource : obrResolver.getOptionalResources()) {
                    BundleInfo bundleInfo = toBundleInfo(resource, true);
                    result.add(bundleInfo);
                }
            }
            return result;
        } else {
            throw new ResolverException("Could not resolve requirements: "
                                        + getUnsatisfiedRequirements(obrResolver));
        }

    }
View Full Code Here

Examples of org.apache.aries.application.management.ResolverException

      if (range == null) {
        _provisionSharedContent.add(dp);
      } else if (range.matches(info.getVersion())) {
        _deploymentContent.add(dp);
      } else {
        throw new ResolverException("Bundle " + info.getSymbolicName() + " at version " + info.getVersion() + " is not in the range " + range);
      }
    }
  }
View Full Code Here

Examples of org.apache.aries.application.management.ResolverException

    try {
      // find out blueprint information
      byValueBundles = getByValueBundles(app);
      // find out by value bundles and then by reference bundles
    } catch (Exception e) {
      throw new ResolverException (e);
    }

    Collection<Content> bundlesToResolve = new ArrayList<Content>();
    bundlesToResolve.addAll(appMetadata.getApplicationContents());   
    bundlesToResolve.addAll(app.getApplicationMetadata().getUseBundles());
View Full Code Here

Examples of org.apache.aries.application.management.ResolverException

    Collection<ModelledResource> byValueBundles = new ArrayList<ModelledResource>(provideByValueBundles);
    ModelledResource fakeBundleResource;
    try {
      fakeBundleResource = createFakeBundle(appMetadata.getApplicationImportServices());
    } catch (InvalidAttributeException iax) {
      ResolverException rx = new ResolverException (iax);
      _logger.debug(LOG_EXIT, "generateDeploymentManifest", new Object[] {rx});

      throw rx;
    }
    byValueBundles.add(fakeBundleResource);
   
    Collection<ModelledResource> fakeResources = new ArrayList<ModelledResource>();
    for (PreResolveHook hook : preResolveHooks) {
      hook.collectFakeResources(fakeResources);
    }
   
    byValueBundles.addAll(fakeResources);
   
    String appSymbolicName = appMetadata.getApplicationSymbolicName();
    String appVersion = appMetadata.getApplicationVersion().toString();
    String uniqueName = appSymbolicName + "_" + appVersion;
   
    DeployedBundles deployedBundles = modellingHelper.createDeployedBundles(appSymbolicName, appContentIB, useBundleIB, Arrays.asList(fakeBundleResource));
    Collection<ModelledResource> bundlesToBeProvisioned = resolver.resolve(
        appSymbolicName, appVersion, byValueBundles, bundlesToResolve);
    pruneFakeBundlesFromResults (bundlesToBeProvisioned, fakeResources);

    if (bundlesToBeProvisioned.isEmpty()) {
      throw new ResolverException(MessageUtil.getMessage("EMPTY_DEPLOYMENT_CONTENT",uniqueName));
    }
    for (ModelledResource rbm : bundlesToBeProvisioned)
    {
      deployedBundles.addBundle(rbm);
    }
    Collection<ModelledResource> requiredUseBundle = deployedBundles.getRequiredUseBundle();
    if (requiredUseBundle.size() < useBundleSet.size())
    {
      // Some of the use-bundle entries were redundant so resolve again with just the good ones.
      deployedBundles = modellingHelper.createDeployedBundles(appSymbolicName, appContentIB, useBundleIB, Arrays.asList(fakeBundleResource));
      bundlesToResolve.clear();
      bundlesToResolve.addAll(appContent);
      Collection<ImportedBundle> slimmedDownUseBundle = narrowUseBundles(useBundleIB, requiredUseBundle);
      bundlesToResolve.addAll(toContent(slimmedDownUseBundle));
      bundlesToBeProvisioned = resolver.resolve(appSymbolicName, appVersion,
          byValueBundles, bundlesToResolve);
       pruneFakeBundlesFromResults (bundlesToBeProvisioned, fakeResources);
      for (ModelledResource rbm : bundlesToBeProvisioned)
      {
        deployedBundles.addBundle(rbm);
      }
    }

    // Check for circular dependencies. No shared bundle can depend on any
    // isolated bundle.
    Collection<ModelledResource> sharedBundles = new HashSet<ModelledResource>();
    sharedBundles.addAll (deployedBundles.getDeployedProvisionBundle());
    sharedBundles.addAll (deployedBundles.getRequiredUseBundle());

    Collection<ModelledResource> appContentBundles = deployedBundles.getDeployedContent();
    Collection<Content> requiredSharedBundles = new ArrayList<Content>();
    for (ModelledResource mr : sharedBundles) {
      String version = mr.getExportedBundle().getVersion();
      String exactVersion = "[" + version + "," + version + "]";

      Content ib = ContentFactory.parseContent(mr.getExportedBundle().getSymbolicName(),
          exactVersion);
      requiredSharedBundles.add(ib);

    }
    // This will throw a ResolverException if the shared content does not resolve
    Collection<ModelledResource> resolvedSharedBundles = resolver.resolve(appSymbolicName, appVersion
        , byValueBundles, requiredSharedBundles);

    // we need to find out whether any shared bundles depend on the isolated bundles
    List<String> suspects = findSuspects (resolvedSharedBundles, sharedBundles, appContentBundles);
    // If we have differences, it means that we have shared bundles trying to import packages
    // from isolated bundles. We need to build up the error message and throw a ResolverException
    if (!suspects.isEmpty()) {
     
     
      StringBuilder msgs = new StringBuilder();
      List<String> unsatisfiedRequirements = new ArrayList<String>();

      Map<String, List<String>> isolatedBundles = new HashMap<String, List<String>>();
      // Find the isolated bundles and store all the packages that they export in a map.
      for (ModelledResource mr : resolvedSharedBundles) {
        String mrName = mr.getSymbolicName() + "_" + mr.getExportedBundle().getVersion();
        if (suspects.contains(mrName)) {
          List<String> exportedPackages = new ArrayList<String>();
          isolatedBundles.put(mrName, exportedPackages);
          for (ExportedPackage ep : mr.getExportedPackages()) {
            exportedPackages.add(ep.getPackageName());
          }
        }
      }
      // Now loop through the shared bundles, reading the imported packages, and find which ones
      // are exported from the isolated bundles.
      for (ModelledResource mr : resolvedSharedBundles) {
        String mrName = mr.getSymbolicName() + "_" + mr.getExportedBundle().getVersion();
        // if current resource isn't an isolated bundle check it's requirements
        if (!!! suspects.contains(mrName)) {
          // Iterate through the imported packages of the current shared bundle.
          for (ImportedPackage ip : mr.getImportedPackages()) {
            String packageName = ip.getPackageName();
            List<String> bundlesExportingPackage = new ArrayList<String>();
            // Loop through each exported package of each isolated bundle, and if we
            // get a match store the info away.
            for (Map.Entry<String, List<String>> currBundle : isolatedBundles.entrySet()) {

              List<String> exportedPackages = currBundle.getValue();
              if (exportedPackages != null && exportedPackages.contains(packageName)) {
                bundlesExportingPackage.add(currBundle.getKey());
              }
            }
            // If we have found at least one matching entry, we construct the sub message for the
            // exception.
            if (!!! bundlesExportingPackage.isEmpty()) {
              String newMsg;
              if (bundlesExportingPackage.size() > 1) {
                newMsg = MessageUtil.getMessage("SHARED_BUNDLE_IMPORTING_FROM_ISOLATED_BUNDLES",
                    new Object[] {mrName, packageName, bundlesExportingPackage});
              } else {
                newMsg = MessageUtil.getMessage("SHARED_BUNDLE_IMPORTING_FROM_ISOLATED_BUNDLE",
                    new Object[] {mrName, packageName, bundlesExportingPackage});
              }
              msgs.append("\n");
              msgs.append(newMsg);
              unsatisfiedRequirements.add(newMsg);
            }
          }
        }
      }
      // Once we have iterated over all bundles and have got our translated submessages,
      // throw the exception.
      // Well! if the msgs is empty, no need to throw an exception
      if (msgs.length() !=0) {
        String message = MessageUtil.getMessage(
            "SUSPECTED_CIRCULAR_DEPENDENCIES", new Object[] {appSymbolicName, msgs});
        ResolverException rx = new ResolverException (message);
        rx.setUnsatisfiedRequirements(unsatisfiedRequirements);
        _logger.debug(LOG_EXIT, "generateDeploymentManifest", new Object[] {rx});
        throw (rx);
      }
    }
   
View Full Code Here

Examples of org.apache.aries.application.management.ResolverException

    Map<String,String> result = new HashMap<String, String>();
    String content = deployedBundles.getContent();
    if (!content.isEmpty()) {
      result.put(AppConstants.DEPLOYMENT_CONTENT, content);
    } else {
      throw new ResolverException(MessageUtil.getMessage("EMPTY_DEPLOYMENT_CONTENT", appSymbolicName));
    }

    String useBundle = deployedBundles.getUseBundle();
    if (!useBundle.isEmpty()) {
      result.put(AppConstants.DEPLOYMENT_USE_BUNDLE, useBundle);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.