Example #1
0
  public static IFileArtifactRepository getAggregatedBundleRepository(
      IProvisioningAgent agent, IProfile profile, int repoFilter) {
    List<IFileArtifactRepository> bundleRepositories = new ArrayList<IFileArtifactRepository>();

    // we check for a shared bundle pool first as it should be preferred over the user bundle pool
    // in a shared install
    IArtifactRepositoryManager manager = getArtifactRepositoryManager(agent);
    if ((repoFilter & AGGREGATE_SHARED_CACHE) != 0) {
      String sharedCache = profile.getProperty(IProfile.PROP_SHARED_CACHE);
      if (sharedCache != null) {
        try {
          URI repoLocation = new File(sharedCache).toURI();
          IArtifactRepository repository = manager.loadRepository(repoLocation, null);
          if (repository != null
              && repository instanceof IFileArtifactRepository
              && !bundleRepositories.contains(repository))
            bundleRepositories.add((IFileArtifactRepository) repository);
        } catch (ProvisionException e) {
          // skip repository if it could not be read
        }
      }
    }

    if ((repoFilter & AGGREGATE_CACHE) != 0) {
      IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(agent, profile);
      if (bundlePool != null) bundleRepositories.add(bundlePool);
    }

    if ((repoFilter & AGGREGATE_CACHE_EXTENSIONS) != 0) {
      List<String> repos = getListProfileProperty(profile, CACHE_EXTENSIONS);
      for (String repo : repos) {
        try {
          URI repoLocation;
          try {
            repoLocation = new URI(repo);
          } catch (URISyntaxException e) {
            // in 1.0 we wrote unencoded URL strings, so try as an unencoded string
            repoLocation = URIUtil.fromString(repo);
          }
          IArtifactRepository repository = manager.loadRepository(repoLocation, null);
          if (repository != null
              && repository instanceof IFileArtifactRepository
              && !bundleRepositories.contains(repository))
            bundleRepositories.add((IFileArtifactRepository) repository);
        } catch (ProvisionException e) {
          // skip repositories that could not be read
        } catch (URISyntaxException e) {
          // unexpected, URLs should be pre-checked
          LogHelper.log(new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e));
        }
      }
    }
    return new AggregatedBundleRepository(agent, bundleRepositories);
  }
Example #2
0
 public static synchronized IFileArtifactRepository getBundlePoolRepository(
     IProvisioningAgent agent, IProfile profile) {
   URI location = getBundlePoolLocation(agent, profile);
   if (location == null) return null;
   IArtifactRepositoryManager manager = getArtifactRepositoryManager(agent);
   try {
     return (IFileArtifactRepository) manager.loadRepository(location, null);
   } catch (ProvisionException e) {
     // the repository doesn't exist, so fall through and create a new one
   }
   try {
     String repositoryName = Messages.BundlePool;
     Map<String, String> properties = new HashMap<String, String>(1);
     properties.put(IRepository.PROP_SYSTEM, Boolean.TRUE.toString());
     return (IFileArtifactRepository)
         manager.createRepository(location, repositoryName, REPOSITORY_TYPE, properties);
   } catch (ProvisionException e) {
     LogHelper.log(e);
     throw new IllegalArgumentException(NLS.bind(Messages.bundle_pool_not_writeable, location));
   }
 }
Example #3
0
  public static BundleInfo createBundleInfo(File bundleFile, IInstallableUnit unit) {
    BundleInfo bundleInfo = new BundleInfo();
    if (bundleFile != null) bundleInfo.setLocation(bundleFile.toURI());

    Collection<IProvidedCapability> capabilities = unit.getProvidedCapabilities();
    for (IProvidedCapability capability : capabilities) {
      String nameSpace = capability.getNamespace();
      if (nameSpace.equals("osgi.bundle")) { // $NON-NLS-1$
        bundleInfo.setSymbolicName(capability.getName());
        bundleInfo.setVersion(capability.getVersion().toString());
      } else if (nameSpace.equals("osgi.fragment")) { // $NON-NLS-1$
        String fragmentName = capability.getName();
        String fragmentHost = getFragmentHost(unit, fragmentName);
        // shouldn't happen as long as the metadata is well-formed
        if (fragmentHost == null)
          LogHelper.log(createError("Unable to find fragment host for IU: " + unit)); // $NON-NLS-1$
        else bundleInfo.setFragmentHost(fragmentHost);
        bundleInfo.setVersion(capability.getVersion().toString());
      }
    }
    return bundleInfo;
  }
Example #4
0
 /** User-level log method ( called from a servlet) */
 public void logServlet(String msg, Throwable t) {
   msg = ("path=\"" + path + "\" :" + msg);
   loghelperServlet.log(msg, t);
 }
Example #5
0
 /** Internal log method */
 public void log(String msg, Throwable t, int level) {
   loghelper.log(msg, t, level);
 }
Example #6
0
 /** Internal log method */
 public void log(String msg, Throwable t) {
   loghelper.log(msg, t);
 }
Example #7
0
 /** Internal log method */
 public final void log(String msg) {
   loghelper.log(msg);
 }