Exemplo n.º 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);
  }
 /** Returns the platform instance location. */
 public Location getInstanceLocation() {
   if (instanceLocationTracker == null) {
     Filter filter;
     try {
       filter = bundleContext.createFilter(Location.INSTANCE_FILTER);
     } catch (InvalidSyntaxException e) {
       LogHelper.log(e);
       return null;
     }
     instanceLocationTracker = new ServiceTracker<Location, Location>(bundleContext, filter, null);
     instanceLocationTracker.open();
   }
   return instanceLocationTracker.getService();
 }
Exemplo n.º 3
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));
   }
 }
Exemplo n.º 4
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;
  }
  public void start(BundleContext context) throws Exception {
    singleton = this;
    bundleContext = context;

    packageAdminTracker =
        new ServiceTracker<PackageAdmin, PackageAdmin>(context, PackageAdmin.class.getName(), null);
    packageAdminTracker.open();

    authServiceTracker = new AuthServiceTracker(context);
    authServiceTracker.open();

    IEclipsePreferences preferences =
        DefaultScope.INSTANCE.getNode(ServerConstants.PREFERENCE_SCOPE);
    Boolean httpsEnabled =
        new Boolean(preferences.get(ConfigurationFormat.HTTPS_ENABLED, "false")); // $NON-NLS-1$

    Dictionary<String, Object> properties = new Hashtable<String, Object>();
    properties.put(
        JettyConstants.CONTEXT_SESSIONINACTIVEINTERVAL, new Integer(4 * 60 * 60)); // 4 hours
    // properties.put(JettyConstants.CONTEXT_PATH, "/cc");
    if (httpsEnabled) {
      LogHelper.log(
          new Status(IStatus.INFO, PI_CONFIGURATOR, "Https is enabled", null)); // $NON-NLS-1$

      properties.put(JettyConstants.HTTPS_ENABLED, true);
      properties.put(
          JettyConstants.HTTPS_PORT,
          new Integer(
              preferences.get(
                  HTTPS_PORT,
                  System.getProperty(
                      "org.eclipse.equinox.http.jetty.https.port",
                      "8443")))); //$NON-NLS-1$//$NON-NLS-2$
      properties.put(
          JettyConstants.SSL_KEYSTORE, preferences.get(SSL_KEYSTORE, "keystore")); // $NON-NLS-1$

      LogHelper.log(
          new Status(
              IStatus.INFO,
              PI_CONFIGURATOR,
              "Keystore absolute path is "
                  + preferences.get(SSL_KEYSTORE, "keystore"))); // $NON-NLS-1$ //$NON-NLS-2$

      properties.put(
          JettyConstants.SSL_PASSWORD, preferences.get(SSL_PASSWORD, "password")); // $NON-NLS-1$
      properties.put(
          JettyConstants.SSL_KEYPASSWORD,
          preferences.get(SSL_KEYPASSWORD, "password")); // $NON-NLS-1$
      properties.put(
          JettyConstants.SSL_PROTOCOL, preferences.get(SSL_PROTOCOL, "SSLv3")); // $NON-NLS-1$

      String httpsHost =
          System.getProperty("org.eclipse.equinox.http.jetty.https.host"); // $NON-NLS-1$
      if (httpsHost != null) {
        properties.put(JettyConstants.HTTPS_HOST, httpsHost);
      }
    }

    String port = null;
    if (!httpsEnabled) {
      properties.put(JettyConstants.HTTP_ENABLED, true);
      port =
          preferences.get(
              HTTP_PORT,
              System.getProperty(
                  "org.eclipse.equinox.http.jetty.http.port", "8080")); // $NON-NLS-1$ //$NON-NLS-2$
      properties.put(JettyConstants.HTTP_PORT, new Integer(port));

      String httpHost =
          System.getProperty("org.eclipse.equinox.http.jetty.http.host"); // $NON-NLS-1$
      if (httpHost != null) {
        properties.put(JettyConstants.HTTP_HOST, httpHost);
      }
    }

    // properties to help us filter orion content
    properties.put("other.info", "org.eclipse.orion"); // $NON-NLS-1$ //$NON-NLS-2$

    try {
      JettyConfigurator.startServer("MasterJetty", properties); // $NON-NLS-1$
    } catch (Exception e) {
      throw new Exception("Error starting Jetty on port: " + port, e);
    }
  }
Exemplo n.º 6
0
 /** User-level log method ( called from a servlet) */
 public void logServlet(String msg, Throwable t) {
   msg = ("path=\"" + path + "\" :" + msg);
   loghelperServlet.log(msg, t);
 }
Exemplo n.º 7
0
 /** Internal log method */
 public void log(String msg, Throwable t, int level) {
   loghelper.log(msg, t, level);
 }
Exemplo n.º 8
0
 /** Internal log method */
 public void log(String msg, Throwable t) {
   loghelper.log(msg, t);
 }
Exemplo n.º 9
0
 /** Internal log method */
 public final void log(String msg) {
   loghelper.log(msg);
 }