org.eclipse.equinox.p2.console_1.0.300.v20120429-0125

hrow new ProvisionException(error.toString());
    }
    IPlanner planner = (IPlanner)agent.getService(IPlanner.SERVICE_NAME);
    if (planner == null) {
      throw new ProvisionException("No planner service found.");
    }
    IEngine engine = (IEngine)agent.getService(IEngine.SERVICE_NAME);
    if (engine == null) {
      throw new ProvisionException("No director service found.");
    }
    ProvisioningContext context = new ProvisioningContext(agent);
    IProfileChangeRequest request = planner.createChangeRequest(profile);
    request.addAll(units.toUnmodifiableSet());
    IProvisioningPlan result = planner.getProvisioningPlan(request, context, progress);
    return PlanExecutionHelper.executePlan(result, engine, context, progress);
  }
  
  static URI[] getArtifactRepositories(IProvisioningAgent agent)
  {
    IArtifactRepositoryManager manager = (IArtifactRepositoryManager)agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
    if (manager == null) {
      throw new IllegalStateException("No metadata repository manager found");
    }
    URI[] repos = manager.getKnownRepositories(0);
    if (repos.length > 0) {
      return repos;
    }
    return null;
  }
  
  static IArtifactRepository getArtifactRepository(IProvisioningAgent agent, URI repoURL)
  {
    IArtifactRepositoryManager manager = (IArtifactRepositoryManager)agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
    try
    {
      if (manager != null) {
        return manager.loadRepository(repoURL, null);
      }
    }
    catch (ProvisionException localProvisionException) {}
    return null;
  }
  
  static long[] getProfileTimestamps(IProvisioningAgent agent, String profileId)
  {
    if (profileId == null) {
      profileId = "_SELF_";
    }
    IProfileRegistry profileRegistry = (IProfileRegistry)agent.getService(IProfileRegistry.SERVICE_NAME);
    if (profileRegistry == null) {
      return null;
    }
    return profileRegistry.listProfileTimestamps(profileId);
  }
  
  static IStatus revertToPreviousState(IProvisioningAgent agent, IProfile profile, long revertToPreviousState)
    throws ProvisionException
  {
    IEngine engine = (IEngine)agent.getService(IEngine.SERVICE_NAME);
    if (engine == null) {
      throw new ProvisionException("No p2 engine found.");
    }
    IPlanner planner = (IPlanner)agent.getService(IPlanner.SERVICE_NAME);
    if (planner == null) {
      throw new ProvisionException("No planner found.");
    }
    IProfileRegistry profileRegistry = (IProfileRegistry)agent.getService(IProfileRegistry.SERVICE_NAME);
    if (profileRegistry == null) {
      throw new ProvisionException("profile registry cannot be null");
    }
    if (profile == null) {
      profile = getProfile(agent, "_SELF_");
    }
    IProfile targetProfile = null;
    if (revertToPreviousState == 0L)
    {
      long[] profiles = profileRegistry.listProfileTimestamps(profile.getProfileId());
      if (profiles.length == 0) {
        return Status.OK_STATUS;
      }
      targetProfile = profileRegistry.getProfile(profile.getProfileId(), profiles[(profiles.length - 1)]);
    }
    else
    {
      targetProfile = profileRegistry.getProfile(profile.getProfileId(), revertToPreviousState);
    }
    if (targetProfile == null) {
      throw new ProvisionException("target profile with timestamp=" + revertToPreviousState + " not found");
    }
    URI[] artifactRepos = getArtifactRepositories(agent);
    URI[] metadataRepos = getMetadataRepositories(agent);
    IProvisioningPlan plan = planner.getDiffPlan(profile, targetProfile, new NullProgressMonitor());
    ProvisioningContext context = new ProvisioningContext(agent);
    context.setMetadataRepositories(metadataRepos);
    context.setArtifactRepositories(artifactRepos);
    return PlanExecutionHelper.executePlan(plan, engine, context, new NullProgressMonitor());
  }
  
  static IStatus uninstall(IProvisioningAgent agent, String unitId, String version, IProfile profile, IProgressMonitor progress)
    throws ProvisionException
  {
    if (profile == null) {
      return null;
    }
    IQueryResult<IInstallableUnit> units = profile.query(QueryUtil.createIUQuery(unitId, Version.create(version)), progress);
    if (units.isEmpty())
    {
      StringBuffer error = new StringBuffer();
      error.append("Installable unit not found: " + unitId + ' ' + version + '\n');
      error.append("Repositories searched:\n");
      URI[] repos = getMetadataRepositories(agent);
      if (repos != null) {
        for (int i = 0; i < repos.length; i++) {
          error.append(repos[i] + "\n");
        }
      }
      throw new ProvisionException(error.toString());
    }
    IPlanner planner = (IPlanner)agent.getService(IPlanner.SERVICE_NAME);
    if (planner == null) {
      throw new ProvisionException("No planner service found.");
    }
    IEngine engine = (IEngine)agent.getService(IEngine.SERVICE_NAME);
    if (engine == null) {
      throw new ProvisionException("No engine service found.");
    }
    ProvisioningContext context = new ProvisioningContext(agent);
    IProfileChangeRequest request = planner.createChangeRequest(profile);
    request.removeAll(units.toUnmodifiableSet());
    IProvisioningPlan result = planner.getProvisioningPlan(request, context, progress);
    return PlanExecutionHelper.executePlan(result, engine, context, progress);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.console.ProvisioningHelper
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
1 2

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd