org.eclipse.equinox.p2.operations_2.2.0.v20130119-010614

16:44:18.848 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.p2.operations_2.2.0.v20130119-010614.jar
package org.eclipse.equinox.internal.p2.operations;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator
  implements BundleActivator
{
  public static final String ID = "org.eclipse.equinox.p2.operations";
  private static BundleContext context;
  
  public static BundleContext getContext()
  {
    return context;
  }
  
  public void start(BundleContext bundleContext)
    throws Exception
  {
    context = bundleContext;
  }
  
  public void stop(BundleContext bundleContext)
    throws Exception
  {
    context = null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.operations.Activator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.operations;

import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.engine.ProvisioningContext;

public abstract interface IFailedStatusEvaluator
{
  public abstract ProvisioningContext getSecondPassProvisioningContext(IProvisioningPlan paramIProvisioningPlan);
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.operations.IFailedStatusEvaluator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.operations;

public abstract interface IStatusCodes
{
  public static final int NOTHING_TO_UPDATE = 10000;
  public static final int PROFILE_CHANGE_ALTERED = 10001;
  public static final int IU_REQUEST_ALTERED = 10002;
  public static final int ALTERED_IMPLIED_UPDATE = 10003;
  public static final int ALTERED_IGNORED_IMPLIED_DOWNGRADE = 10004;
  public static final int ALTERED_IGNORED_ALREADY_INSTALLED = 10005;
  public static final int ALTERED_PARTIAL_INSTALL = 10006;
  public static final int ALTERED_PARTIAL_UNINSTALL = 10007;
  public static final int ALTERED_SIDE_EFFECT_UPDATE = 10008;
  public static final int ALTERED_SIDE_EFFECT_REMOVE = 10009;
  public static final int ALTERED_SIDE_EFFECT_INSTALL = 10010;
  public static final int ALTERED_IGNORED_INSTALL_REQUEST = 10011;
  public static final int ALTERED_IGNORED_UNINSTALL_REQUEST = 10012;
  public static final int ALTERED_IGNORED_IMPLIED_UPDATE = 10013;
  public static final int UNEXPECTED_NOTHING_TO_DO = 10050;
  public static final int EXPECTED_NOTHING_TO_DO = 10051;
  public static final int OPERATION_ALREADY_IN_PROGRESS = 10052;
  public static final int INVALID_REPOSITORY_LOCATION = 10100;
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.operations.IStatusCodes
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.operations;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.p2.operations.messages";
  public static String InstallOperation_ComputeProfileChangeProgress;
  public static String InstallOperation_InstallJobName;
  public static String InstallOperation_ResolveJobName;
  public static String ProfileChangeOperation_NoProfileChangeRequest;
  public static String ProfileChangeOperation_ResolveTaskName;
  public static String ProvisioningJob_GenericErrorStatusMessage;
  public static String ProvisioningSession_AgentNotFound;
  public static String ProvisioningSession_InstallPlanConfigurationError;
  public static String PlanAnalyzer_IgnoringInstall;
  public static String PlanAnalyzer_LockedImpliedUpdate0;
  public static String PlanAnalyzer_PartialInstall;
  public static String PlanAnalyzer_PartialUninstall;
  public static String PlanAnalyzer_SideEffectInstall;
  public static String PlanAnalyzer_SideEffectUninstall;
  public static String PlannerResolutionJob_NullProvisioningPlan;
  public static String PlanAnalyzer_IgnoringImpliedDowngrade;
  public static String PlanAnalyzer_ImpliedUpdate;
  public static String PlanAnalyzer_Items;
  public static String PlanAnalyzer_NothingToDo;
  public static String PlanAnalyzer_NoUpdates;
  public static String PlanAnalyzer_AlreadyInstalled;
  public static String PlanAnalyzer_AnotherOperationInProgress;
  public static String PlanAnalyzer_RequestAltered;
  public static String PlanAnalyzer_UnexpectedError;
  public static String RepositoryTracker_DuplicateLocation;
  public static String RepositoryTracker_InvalidLocation;
  public static String ResolutionResult_SummaryStatus;
  public static String SizingPhaseSet_PhaseSetName;
  public static String UninstallOperation_ProvisioningJobName;
  public static String UninstallOperation_ResolveJobName;
  public static String UpdateOperation_ProfileChangeRequestProgress;
  public static String UpdateOperation_ResolveJobName;
  public static String UpdateOperation_UpdateJobName;
  public static String RelaxedUpdateOperation_ResolveJobName;
  public static String RelaxedUpdateOperation_UpdateJobName;
  public static String OperationFactory_noAgent;
  public static String OperationFactory_noIUFound;
  
  static
  {
    NLS.initializeMessages("org.eclipse.equinox.internal.p2.operations.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.operations.Messages
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.operations;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.internal.provisional.p2.director.PlannerStatus;
import org.eclipse.equinox.internal.provisional.p2.director.RequestStatus;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;

public class PlanAnalyzer
{
  public static IStatus getStatus(int statusCode, IInstallableUnit affectedIU)
  {
    switch (statusCode)
    {
    case 10000: 
      return new Status(1, "org.eclipse.equinox.p2.operations", statusCode, Messages.PlanAnalyzer_NoUpdates, null);
    case 10001: 
      return new MultiStatus("org.eclipse.equinox.p2.operations", statusCode, Messages.PlanAnalyzer_RequestAltered, null);
    case 10003: 
      return new Status(1, "org.eclipse.equinox.p2.operations", statusCode, NLS.bind(Messages.PlanAnalyzer_ImpliedUpdate, getIUString(affectedIU)), null);
    case 10013: 
      return new Status(2, "org.eclipse.equinox.p2.operations", statusCode, NLS.bind(Messages.PlanAnalyzer_LockedImpliedUpdate0, getIUString(affectedIU)), null);
    case 10004: 
      return new Status(2, "org.eclipse.equinox.p2.operations", statusCode, NLS.bind(Messages.PlanAnalyzer_IgnoringImpliedDowngrade, getIUString(affectedIU)), null);
    case 10005: 
      return new Status(2, "org.eclipse.equinox.p2.operations", statusCode, NLS.bind(Messages.PlanAnalyzer_AlreadyInstalled, getIUString(affectedIU)), null);
    case 10006: 
      return new Status(1, "org.eclipse.equinox.p2.operations", statusCode, NLS.bind(Messages.PlanAnalyzer_PartialInstall, getIUString(affectedIU)), null);
    case 10007: 
      return new Status(1, "org.eclipse.equinox.p2.operations", statusCode, NLS.bind(Messages.PlanAnalyzer_PartialUninstall, getIUString(affectedIU)), null);
    case 10050: 
      return new Status(4, "org.eclipse.equinox.p2.operations", statusCode, NLS.bind(Messages.PlanAnalyzer_NothingToDo, getIUString(affectedIU)), null);
    case 10052: 
      return new Status(4, "org.eclipse.equinox.p2.operations", statusCode, Messages.PlanAnalyzer_AnotherOperationInProgress, null);
    }
    return new Status(4, "org.eclipse.equinox.p2.operations", statusCode, NLS.bind(Messages.PlanAnalyzer_UnexpectedError, new Integer(statusCode), getIUString(affectedIU)), null);
  }
  
  public static MultiStatus getProfileChangeAlteredStatus()
  {
    return (MultiStatus)getStatus(10001, null);
  }
  
  public static ResolutionResult computeResolutionResult(ProfileChangeRequest originalRequest, IProvisioningPlan plan, MultiStatus originalStatus)
  {
    Assert.isNotNull(originalRequest);
    Assert.isNotNull(plan);
    Assert.isNotNull(originalStatus);
    
    ResolutionResult report = new ResolutionResult();
    if (plan.getStatus().getSeverity() == 8)
    {
      report.addSummaryStatus(plan.getStatus());
      return report;
    }
    if (nothingToDo(originalRequest))
    {
      report.addSummaryStatus(getStatus(10050, null));
      IStatus[] details = originalStatus.getChildren();
      for (int i = 0; i < details.length; i++) {
        report.addSummaryStatus(details[i]);
      }
      return report;
    }
    if ((originalStatus != null) && (originalStatus.getChildren().length > 0)) {
      report.addSummaryStatus(originalStatus);
    }
    if (!plan.getStatus().isOK()) {
      report.addSummaryStatus(plan.getStatus());
    }
    PlannerStatus plannerStatus = (plan.getStatus() instanceof PlannerStatus) ? (PlannerStatus)plan.getStatus() : null;
    if (plannerStatus == null) {
      return report;
    }
    Collection<IInstallableUnit> iusRemoved;
    if (plan.getStatus().getSeverity() != 4)
    {
      Collection<IInstallableUnit> iusAdded = originalRequest.getAdditions();
      for (Iterator localIterator = iusAdded.iterator(); localIterator.hasNext();)
      {
        IInstallableUnit added = (IInstallableUnit)localIterator.next();
        rs = (RequestStatus)plannerStatus.getRequestChanges().get(added);
        if (rs.getSeverity() == 4)
        {
          IStatus fail = new Status(4, "org.eclipse.equinox.p2.operations", 10011, NLS.bind(Messages.PlanAnalyzer_IgnoringInstall, getIUString(added)), null);
          report.addStatus(added, fail);
          report.addSummaryStatus(fail);
        }
      }
      iusRemoved = originalRequest.getRemovals();
      for (RequestStatus rs = iusRemoved.iterator(); rs.hasNext();)
      {
        IInstallableUnit removed = (IInstallableUnit)rs.next();
        RequestStatus rs = (RequestStatus)plannerStatus.getRequestChanges().get(removed);
        if (rs.getSeverity() == 4)
        {
          IStatus fail = new Status(1, "org.eclipse.equinox.p2.operations", 10007, NLS.bind(Messages.PlanAnalyzer_PartialUninstall, getIUString(removed)), null);
          report.addStatus(removed, fail);
          report.addSummaryStatus(fail);
        }
      }
    }
    if (plannerStatus.getRequestSideEffects() != null) {
      for (iusRemoved = plannerStatus.getRequestSideEffects().entrySet().iterator(); iusRemoved.hasNext();)
      {
        Map.Entry<IInstallableUnit, RequestStatus> entry = (Map.Entry)iusRemoved.next();
        IInstallableUnit iu = (IInstallableUnit)entry.getKey();
        RequestStatus rs = (RequestStatus)entry.getValue();
        if (rs.getInitialRequestType() == 0) {
          report.addStatus(iu, new Status(rs.getSeverity(), "org.eclipse.equinox.p2.operations", 10010, NLS.bind(Messages.PlanAnalyzer_SideEffectInstall, getIUString(iu)), null));
        } else {
          report.addStatus(iu, new Status(rs.getSeverity(), "org.eclipse.equinox.p2.operations", 10009, NLS.bind(Messages.PlanAnalyzer_SideEffectUninstall, getIUString(iu)), null));
        }
      }
    }
    return report;
  }
  
  private static String getIUString(IInstallableUnit iu)
  {
    if (iu == null) {
      return Messages.PlanAnalyzer_Items;
    }
    String name = iu.getProperty("org.eclipse.equinox.p2.name", null);
    if (name != null) {
      return name;
    }
    return iu.getId();
  }
  
  private static boolean nothingToDo(ProfileChangeRequest request)
  {
    return (request.getAdditions().size() == 0) && (request.getRemovals().size() == 0) && (request.getInstallableUnitProfilePropertiesToAdd().size() == 0) && (request.getInstallableUnitProfilePropertiesToRemove().size() == 0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.operations.PlanAnalyzer
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.operations;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.operations.IProfileChangeJob;
import org.eclipse.equinox.p2.operations.ProvisioningJob;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.planner.IPlanner;

public class PlannerResolutionJob
  extends ProvisioningJob
  implements IProfileChangeJob
{
  ProfileChangeRequest request;
  String profileId;
  IProvisioningPlan plan;
  MultiStatus additionalStatus;
  ResolutionResult report;
  ProvisioningContext firstPass;
  ProvisioningContext successful;
  IFailedStatusEvaluator evaluator;
  
  public static MultiStatus getProfileChangeRequestAlteredStatus()
  {
    return PlanAnalyzer.getProfileChangeAlteredStatus();
  }
  
  public PlannerResolutionJob(String label, ProvisioningSession session, String profileId, ProfileChangeRequest request, ProvisioningContext context, IFailedStatusEvaluator evaluator, MultiStatus additionalStatus)
  {
    super(label, session);
    this.request = request;
    this.profileId = profileId;
    if (context == null) {
      firstPass = new ProvisioningContext(session.getProvisioningAgent());
    } else {
      firstPass = context;
    }
    this.evaluator = evaluator;
    Assert.isNotNull(additionalStatus);
    this.additionalStatus = additionalStatus;
  }
  
  public IProvisioningPlan getProvisioningPlan()
  {
    return plan;
  }
  
  public ProfileChangeRequest getProfileChangeRequest()
  {
    return request;
  }
  
  public ProvisioningContext getActualProvisioningContext()
  {
    return successful;
  }
  
  public void setFirstPassProvisioningContext(ProvisioningContext firstPass)
  {
    this.firstPass = firstPass;
  }
  
  public IStatus runModal(IProgressMonitor monitor)
  {
    SubMonitor sub;
    SubMonitor sub;
    if (evaluator != null) {
      sub = SubMonitor.convert(monitor, 1000);
    } else {
      sub = SubMonitor.convert(monitor, 500);
    }
    plan = ((IPlanner)getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME)).getProvisioningPlan(request, firstPass, sub.newChild(500));
    IStatus status;
    if (plan == null)
    {
      IStatus status = new Status(4, "org.eclipse.equinox.p2.operations", Messages.PlannerResolutionJob_NullProvisioningPlan);
      additionalStatus.add(status);
    }
    else
    {
      status = plan.getStatus();
    }
    if ((status.getSeverity() != 4) || (evaluator == null))
    {
      successful = firstPass;
      return status;
    }
    ProvisioningContext secondPass = evaluator.getSecondPassProvisioningContext(plan);
    if (secondPass == null) {
      return status;
    }
    successful = secondPass;
    plan = ((IPlanner)getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME)).getProvisioningPlan(request, secondPass, sub.newChild(500));
    if (plan == null)
    {
      status = new Status(4, "org.eclipse.equinox.p2.operations", Messages.PlannerResolutionJob_NullProvisioningPlan);
      additionalStatus.add(status);
      return status;
    }
    return plan.getStatus();
  }
  
  public ResolutionResult getResolutionResult()
  {
    if (report == null) {
      if (plan == null)
      {
        if (additionalStatus.getSeverity() != 4) {
          additionalStatus.add(new Status(4, "org.eclipse.equinox.p2.operations", Messages.PlannerResolutionJob_NullProvisioningPlan));
        }
        report = new ResolutionResult();
        report.addSummaryStatus(additionalStatus);
      }
      else
      {
        report = PlanAnalyzer.computeResolutionResult(request, plan, additionalStatus);
      }
    }
    return report;
  }
  
  public String getProfileId()
  {
    return profileId;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.operations.PlannerResolutionJob
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.operations;

import java.util.HashMap;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;

public class ResolutionResult
{
  private static final String NESTING_INDENT = "  ";
  private final HashMap<IInstallableUnit, MultiStatus> iuToStatusMap = new HashMap();
  private MultiStatus summaryStatus;
  
  public IStatus getSummaryStatus()
  {
    if (summaryStatus != null) {
      return summaryStatus;
    }
    return Status.OK_STATUS;
  }
  
  public void addSummaryStatus(IStatus status)
  {
    if (summaryStatus == null) {
      summaryStatus = new MultiStatus("org.eclipse.equinox.p2.operations", 0, Messages.ResolutionResult_SummaryStatus, null);
    }
    summaryStatus.add(status);
  }
  
  public IStatus statusOf(IInstallableUnit iu)
  {
    return (IStatus)iuToStatusMap.get(iu);
  }
  
  public void addStatus(IInstallableUnit iu, IStatus status)
  {
    MultiStatus iuSummaryStatus = (MultiStatus)iuToStatusMap.get(iu);
    if (iuSummaryStatus == null) {
      iuSummaryStatus = new MultiStatus("org.eclipse.equinox.p2.operations", 10002, new IStatus[] { status }, getIUString(iu), null);
    } else {
      iuSummaryStatus.add(status);
    }
  }
  
  private String getIUString(IInstallableUnit iu)
  {
    if (iu == null) {
      return Messages.PlanAnalyzer_Items;
    }
    String name = iu.getProperty("org.eclipse.equinox.p2.name", null);
    if (name != null) {
      return name;
    }
    return iu.getId();
  }
  
  public String getSummaryReport()
  {
    if (summaryStatus != null)
    {
      StringBuffer buffer = new StringBuffer();
      appendDetailText(summaryStatus, buffer, -1, false);
      return buffer.toString();
    }
    return "";
  }
  
  public String getDetailedReport(IInstallableUnit[] ius)
  {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < ius.length; i++)
    {
      MultiStatus iuStatus = (MultiStatus)iuToStatusMap.get(ius[i]);
      if (iuStatus != null) {
        appendDetailText(iuStatus, buffer, 0, true);
      }
    }
    String report = buffer.toString();
    if (report.length() == 0) {
      return null;
    }
    return report;
  }
  
  void appendDetailText(IStatus status, StringBuffer buffer, int indent, boolean includeTopLevelMessage)
  {
    if (includeTopLevelMessage)
    {
      for (int i = 0; i < indent; i++) {
        buffer.append("  ");
      }
      if (status.getMessage() != null) {
        buffer.append(status.getMessage());
      }
    }
    Throwable t = status.getException();
    if (t != null)
    {
      buffer.append('\n');
      for (int i = 0; i <= indent; i++) {
        buffer.append("  ");
      }
      if ((t instanceof CoreException))
      {
        IStatus exceptionStatus = ((CoreException)t).getStatus();
        if ((exceptionStatus != null) && (exceptionStatus.getMessage() != null))
        {
          buffer.append(exceptionStatus.getMessage());
        }
        else
        {
          String details = t.getLocalizedMessage();
          if (details != null) {
            buffer.append(details);
          }
        }
      }
      else
      {
        String details = t.getLocalizedMessage();
        if (details != null) {
          buffer.append(details);
        }
      }
    }
    IStatus[] children = status.getChildren();
    for (int i = 0; i < children.length; i++)
    {
      if (buffer.length() > 0) {
        buffer.append('\n');
      }
      appendDetailText(children[i], buffer, indent + 1, true);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.operations.ResolutionResult
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.operations;

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.operations.UpdateOperation;
import org.eclipse.equinox.p2.repository.IRunnableWithProgress;

public class SearchForUpdatesResolutionJob
  extends PlannerResolutionJob
{
  IRunnableWithProgress searchForUpdatesRunnable;
  ProfileChangeRequest[] requestHolder;
  UpdateOperation operation;
  
  public SearchForUpdatesResolutionJob(String label, ProvisioningSession session, String profileId, ProfileChangeRequest request, ProvisioningContext context, IFailedStatusEvaluator evaluator, MultiStatus additionalStatus, IRunnableWithProgress searchForUpdatesRunnable, ProfileChangeRequest[] requestHolder, UpdateOperation operation)
  {
    super(label, session, profileId, request, context, evaluator, additionalStatus);
    this.searchForUpdatesRunnable = searchForUpdatesRunnable;
    this.requestHolder = requestHolder;
    this.operation = operation;
  }
  
  public IStatus runModal(IProgressMonitor monitor)
  {
    SubMonitor sub = SubMonitor.convert(monitor);
    try
    {
      searchForUpdatesRunnable.run(sub.newChild(500));
      if (requestHolder.length > 0) {
        request = requestHolder[0];
      }
    }
    catch (OperationCanceledException localOperationCanceledException)
    {
      return Status.CANCEL_STATUS;
    }
    catch (InvocationTargetException localInvocationTargetException) {}
    if (request != null) {
      return super.runModal(sub.newChild(500));
    }
    return operation.getResolutionResult();
  }
  
  public ProfileChangeRequest getProfileChangeRequest()
  {
    return request;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.operations.SearchForUpdatesResolutionJob
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.p2.operations;

public abstract interface IProfileChangeJob
{
  public abstract String getProfileId();
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.p2.operations.IProfileChangeJob
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.p2.operations;

import org.eclipse.equinox.internal.p2.operations.IFailedStatusEvaluator;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.engine.ProvisioningContext;

class InstallOperation$1
  implements IFailedStatusEvaluator
{
  final InstallOperation this$0;
  
  InstallOperation$1(InstallOperation paramInstallOperation) {}
  
  public ProvisioningContext getSecondPassProvisioningContext(IProvisioningPlan failedPlan)
  {
    if (this$0.missingRequirement(failedPlan)) {
      this$0.context.setProperty("org.eclipse.equinox.p2.director.followRepositoryReferences", Boolean.toString(true));
    }
    return this$0.context;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.p2.operations.InstallOperation.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.p2.operations;

import java.util.Collection;
import java.util.Iterator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.internal.p2.operations.IFailedStatusEvaluator;
import org.eclipse.equinox.internal.p2.operations.Messages;
import org.eclipse.equinox.internal.p2.operations.PlanAnalyzer;
import org.eclipse.equinox.internal.provisional.p2.director.PlannerStatus;
import org.eclipse.equinox.internal.provisional.p2.director.RequestStatus;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.planner.ProfileInclusionRules;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;

public class InstallOperation
  extends ProfileChangeOperation
{
  protected Collection<IInstallableUnit> toInstall;
  
  public InstallOperation(ProvisioningSession session, Collection<IInstallableUnit> toInstall)
  {
    super(session);
    this.toInstall = toInstall;
  }
  
  protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor)
  {
    request = ProfileChangeRequest.createByProfileId(session.getProvisioningAgent(), profileId);
    IProfile profile = session.getProfileRegistry().getProfile(profileId);
    SubMonitor sub = SubMonitor.convert(monitor, Messages.InstallOperation_ComputeProfileChangeProgress, toInstall.size());
    for (Iterator localIterator = toInstall.iterator(); localIterator.hasNext();)
    {
      IInstallableUnit entryToInstall = (IInstallableUnit)localIterator.next();
      if (QueryUtil.isPatch(entryToInstall)) {
        request.setInstallableUnitInclusionRules(entryToInstall, ProfileInclusionRules.createOptionalInclusionRule(entryToInstall));
      }
      IQueryResult<IInstallableUnit> alreadyInstalled = profile.query(QueryUtil.createIUQuery(entryToInstall.getId()), null);
      if (!alreadyInstalled.isEmpty())
      {
        IInstallableUnit installedIU = (IInstallableUnit)alreadyInstalled.iterator().next();
        int compareTo = entryToInstall.getVersion().compareTo(installedIU.getVersion());
        if (compareTo > 0)
        {
          boolean lockedForUpdate = false;
          String value = profile.getInstallableUnitProperty(installedIU, "org.eclipse.equinox.p2.type.lock");
          if (value != null) {
            lockedForUpdate = (Integer.parseInt(value) & 0x2) == 2;
          }
          if (lockedForUpdate) {
            status.merge(PlanAnalyzer.getStatus(10013, entryToInstall));
          } else {
            dealWithUpdates(status, profile, entryToInstall, installedIU);
          }
        }
        else if (compareTo < 0)
        {
          status.merge(PlanAnalyzer.getStatus(10004, entryToInstall));
        }
        else if (UserVisibleRootQuery.isUserVisible(installedIU, profile))
        {
          status.merge(PlanAnalyzer.getStatus(10005, entryToInstall));
        }
        else
        {
          status.merge(PlanAnalyzer.getStatus(10006, entryToInstall));
          request.setInstallableUnitProfileProperty(entryToInstall, "org.eclipse.equinox.p2.type.root", Boolean.toString(true));
        }
      }
      else
      {
        boolean handled = false;
        Iterator<IInstallableUnit> allIUsIterator = profile.query(QueryUtil.ALL_UNITS, null).iterator();
        while (allIUsIterator.hasNext())
        {
          IInstallableUnit iuAlreadyInstalled = (IInstallableUnit)allIUsIterator.next();
          if ((entryToInstall.getUpdateDescriptor() != null) && (entryToInstall.getUpdateDescriptor().isUpdateOf(iuAlreadyInstalled)))
          {
            dealWithUpdates(status, profile, entryToInstall, iuAlreadyInstalled);
            handled = true;
            break;
          }
        }
        if (!handled) {
          request.add(entryToInstall);
        }
        request.setInstallableUnitProfileProperty(entryToInstall, "org.eclipse.equinox.p2.type.root", Boolean.toString(true));
      }
      sub.worked(1);
    }
    sub.done();
  }
  
  private void dealWithUpdates(MultiStatus status, IProfile profile, IInstallableUnit entryToInstall, IInstallableUnit installedIU)
  {
    request.add(entryToInstall);
    request.remove(installedIU);
    
    status.merge(PlanAnalyzer.getStatus(10003, entryToInstall));
    if (!UserVisibleRootQuery.isUserVisible(installedIU, profile)) {
      request.setInstallableUnitProfileProperty(entryToInstall, "org.eclipse.equinox.p2.type.root", Boolean.toString(true));
    }
  }
  
  protected String getResolveJobName()
  {
    return Messages.InstallOperation_ResolveJobName;
  }
  
  protected String getProvisioningJobName()
  {
    return Messages.InstallOperation_InstallJobName;
  }
  
  ProvisioningContext getFirstPassProvisioningContext()
  {
    context.setProperty("org.eclipse.equinox.p2.director.followRepositoryReferences", null);
    return context;
  }
  
  IFailedStatusEvaluator getSecondPassEvaluator()
  {
    new IFailedStatusEvaluator()
    {
      public ProvisioningContext getSecondPassProvisioningContext(IProvisioningPlan failedPlan)
      {
        if (missingRequirement(failedPlan)) {
          context.setProperty("org.eclipse.equinox.p2.director.followRepositoryReferences", Boolean.toString(true));
        }
        return context;
      }
    };
  }
  
  boolean missingRequirement(IProvisioningPlan failedPlan)
  {
    IStatus status = failedPlan.getStatus();
    RequestStatus requestStatus = null;
    if ((status instanceof PlannerStatus)) {
      requestStatus = ((PlannerStatus)status).getRequestStatus();
    }
    return (requestStatus != null) && (requestStatus.getShortExplanation() == 1);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.p2.operations.InstallOperation
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.p2.operations;

import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.operations.Activator;
import org.eclipse.equinox.internal.p2.operations.Messages;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IVersionedId;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;

public class OperationFactory
{
  private IProvisioningAgent getAgent()
  {
    Collection<ServiceReference<IProvisioningAgent>> ref = null;
    try
    {
      ref = Activator.getContext().getServiceReferences(IProvisioningAgent.class, "(agent.current=" + Boolean.TRUE.toString() + ')');
    }
    catch (InvalidSyntaxException localInvalidSyntaxException) {}
    if ((ref == null) || (ref.size() == 0)) {
      throw new IllegalStateException(Messages.OperationFactory_noAgent);
    }
    IProvisioningAgent agent = (IProvisioningAgent)Activator.getContext().getService((ServiceReference)ref.iterator().next());
    Activator.getContext().ungetService((ServiceReference)ref.iterator().next());
    return agent;
  }
  
  private Collection<IInstallableUnit> gatherIUs(IQueryable<IInstallableUnit> searchContext, Collection<? extends IVersionedId> ius, boolean checkIUs, IProgressMonitor monitor)
    throws ProvisionException
  {
    Collection<IInstallableUnit> gatheredIUs = new ArrayList(ius.size());
    for (Iterator localIterator = ius.iterator(); localIterator.hasNext();)
    {
      IVersionedId versionedId = (IVersionedId)localIterator.next();
      if ((!checkIUs) && ((versionedId instanceof IInstallableUnit)))
      {
        gatheredIUs.add((IInstallableUnit)versionedId);
      }
      else
      {
        IQuery<IInstallableUnit> installableUnits = QueryUtil.createIUQuery(versionedId.getId(), versionedId.getVersion());
        IQueryResult<IInstallableUnit> matches = searchContext.query(installableUnits, monitor);
        if (matches.isEmpty()) {
          throw new ProvisionException(new Status(4, "org.eclipse.equinox.p2.operations", NLS.bind(Messages.OperationFactory_noIUFound, versionedId)));
        }
        Iterator<IInstallableUnit> iuIt = matches.iterator();
        gatheredIUs.add((IInstallableUnit)iuIt.next());
      }
    }
    return gatheredIUs;
  }
  
  private ProvisioningContext createProvisioningContext(Collection<URI> repos, IProvisioningAgent agent)
  {
    ProvisioningContext ctx = new ProvisioningContext(agent);
    if (repos != null)
    {
      ctx.setMetadataRepositories((URI[])repos.toArray(new URI[repos.size()]));
      ctx.setArtifactRepositories((URI[])repos.toArray(new URI[repos.size()]));
    }
    return ctx;
  }
  
  public InstallOperation createInstallOperation(Collection<? extends IVersionedId> toInstall, Collection<URI> repos, IProgressMonitor monitor)
    throws ProvisionException
  {
    Assert.isNotNull(toInstall);
    IProvisioningAgent agent = getAgent();
    
    ProvisioningContext ctx = createProvisioningContext(repos, agent);
    
    InstallOperation resultingOperation = new InstallOperation(new ProvisioningSession(agent), gatherIUs(ctx.getMetadata(monitor), toInstall, false, monitor));
    resultingOperation.setProvisioningContext(ctx);
    resultingOperation.setProfileId("_SELF_");
    
    return resultingOperation;
  }
  
  public UninstallOperation createUninstallOperation(Collection<? extends IVersionedId> toUninstall, Collection<URI> repos, IProgressMonitor monitor)
    throws ProvisionException
  {
    Assert.isNotNull(toUninstall);
    IProvisioningAgent agent = getAgent();
    ProvisioningContext ctx = createProvisioningContext(repos, agent);
    
    UninstallOperation resultingOperation = new UninstallOperation(new ProvisioningSession(agent), gatherIUs(listInstalledElements(false, monitor), toUninstall, true, monitor));
    resultingOperation.setProvisioningContext(ctx);
    resultingOperation.setProfileId("_SELF_");
    
    return resultingOperation;
  }
  
  public IQueryResult<IInstallableUnit> listInstalledElements(boolean rootsOnly, IProgressMonitor monitor)
  {
    IProfileRegistry registry = (IProfileRegistry)getAgent().getService(IProfileRegistry.SERVICE_NAME);
    IProfile profile = registry.getProfile("_SELF_");
    if (rootsOnly) {
      return profile.query(new UserVisibleRootQuery(), monitor);
    }
    return profile.query(QueryUtil.ALL_UNITS, monitor);
  }
  
  public UpdateOperation createUpdateOperation(Collection<? extends IVersionedId> toUpdate, Collection<URI> repos, IProgressMonitor monitor)
    throws ProvisionException
  {
    IProvisioningAgent agent = getAgent();
    ProvisioningContext ctx = createProvisioningContext(repos, agent);
    
    UpdateOperation resultingOperation = new UpdateOperation(new ProvisioningSession(agent), toUpdate == null ? null : gatherIUs(listInstalledElements(false, monitor), toUpdate, false, monitor));
    resultingOperation.setProvisioningContext(ctx);
    resultingOperation.setProfileId("_SELF_");
    
    return resultingOperation;
  }
  
  public SynchronizeOperation createSynchronizeOperation(Collection<? extends IVersionedId> toInstall, Collection<URI> repos, IProgressMonitor monitor)
    throws ProvisionException
  {
    IProvisioningAgent agent = getAgent();
    ProvisioningContext ctx = createProvisioningContext(repos, agent);
    Collection<IInstallableUnit> iusToInstall;
    Collection<IInstallableUnit> iusToInstall;
    if (toInstall == null) {
      iusToInstall = ctx.getMetadata(monitor).query(QueryUtil.createIUGroupQuery(), monitor).toUnmodifiableSet();
    } else {
      iusToInstall = gatherIUs(ctx.getMetadata(monitor), toInstall, false, monitor);
    }
    SynchronizeOperation resultingOperation = new SynchronizeOperation(new ProvisioningSession(agent), iusToInstall);
    resultingOperation.setProvisioningContext(ctx);
    resultingOperation.setProfileId("_SELF_");
    
    return resultingOperation;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.p2.operations.OperationFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.p2.operations;

import org.eclipse.equinox.internal.p2.operations.IFailedStatusEvaluator;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.engine.ProvisioningContext;

class ProfileChangeOperation$1
  implements IFailedStatusEvaluator
{
  final ProfileChangeOperation this$0;
  
  ProfileChangeOperation$1(ProfileChangeOperation paramProfileChangeOperation) {}
  
  public ProvisioningContext getSecondPassProvisioningContext(IProvisioningPlan failedPlan)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.p2.operations.ProfileChangeOperation.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.p2.operations;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.internal.p2.operations.IFailedStatusEvaluator;
import org.eclipse.equinox.internal.p2.operations.Messages;
import org.eclipse.equinox.internal.p2.operations.PlanAnalyzer;
import org.eclipse.equinox.internal.p2.operations.PlannerResolutionJob;
import org.eclipse.equinox.internal.p2.operations.ResolutionResult;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.planner.IProfileChangeRequest;

public abstract class ProfileChangeOperation
  implements IProfileChangeJob
{
  ProvisioningSession session;
  String profileId;
  ProvisioningContext context;
  MultiStatus noChangeRequest;
  PlannerResolutionJob job;
  ProfileChangeRequest request;
  
  protected ProfileChangeOperation(ProvisioningSession session)
  {
    this.session = session;
    profileId = "_SELF_";
    context = new ProvisioningContext(session.getProvisioningAgent());
  }
  
  public final IStatus resolveModal(IProgressMonitor monitor)
  {
    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    prepareToResolve();
    makeResolveJob(monitor);
    if (job != null)
    {
      IStatus status = job.runModal(monitor);
      if (status.getSeverity() == 8) {
        return Status.CANCEL_STATUS;
      }
    }
    return getResolutionResult();
  }
  
  public void setProfileId(String id)
  {
    profileId = id;
  }
  
  public final ProvisioningJob getResolveJob(IProgressMonitor monitor)
  {
    SubMonitor mon = SubMonitor.convert(monitor, Messages.ProfileChangeOperation_ResolveTaskName, 1000);
    prepareToResolve();
    makeResolveJob(mon.newCh
1 2 3

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-2017. Infinite Loop Ltd