Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal')
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Activator.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/DownloadPhaseSet.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/IStatusCodes.java51
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Messages.java76
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java154
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlannerResolutionJob.java84
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java125
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/SizingPhaseSet.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/messages.properties44
9 files changed, 625 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Activator.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Activator.java
new file mode 100644
index 000000000..9580bc9f7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Activator.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.operations;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Activator class that registers the update checker service.
+ */
+public class Activator implements BundleActivator {
+ public static final String ID = "org.eclipse.equinox.p2.operations"; //$NON-NLS-1$
+ private static BundleContext context;
+
+ public static BundleContext getContext() {
+ return context;
+ }
+
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/DownloadPhaseSet.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/DownloadPhaseSet.java
new file mode 100644
index 000000000..bd0f4a5d1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/DownloadPhaseSet.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/**
+ *
+ */
+package org.eclipse.equinox.internal.p2.operations;
+
+import org.eclipse.equinox.internal.p2.engine.Phase;
+import org.eclipse.equinox.internal.p2.engine.PhaseSet;
+import org.eclipse.equinox.internal.p2.engine.phases.Collect;
+
+
+public class DownloadPhaseSet extends PhaseSet {
+ public DownloadPhaseSet() {
+ super(new Phase[] {new Collect(10)});
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/IStatusCodes.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/IStatusCodes.java
new file mode 100644
index 000000000..34f92df10
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/IStatusCodes.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.operations;
+
+/**
+ * IStatusCodes defines codes for common status conditions when
+ * performing provisioning operations.
+ *
+ * This interface is not intended to be implemented
+ *
+ * @since 2.0
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IStatusCodes {
+
+ //Operation status codes [10000-10999] - note these cannot conflict with the core codes
+ //in ProvisionException or we'll see strange results.
+
+ public static final int NOTHING_TO_UPDATE = 10000;
+
+ // Status codes associated with profile change request or plans being altered from the original intent
+ 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;
+
+ // Status codes associated with inability to perform an operation
+ 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;
+
+ // Status codes associated with repositories
+ public static final int INVALID_REPOSITORY_LOCATION = 10100;
+}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Messages.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Messages.java
new file mode 100644
index 000000000..55e98c177
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/Messages.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.equinox.internal.p2.operations;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @since 2.0
+ *
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.p2.operations.messages"; //$NON-NLS-1$
+
+ 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;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java
new file mode 100644
index 000000000..6a0a709f2
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlanAnalyzer.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.equinox.internal.p2.operations;
+
+import java.util.Map.Entry;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
+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;
+
+/**
+ * This class analyzes a profile change request and the resultant provisioning plan,
+ * and reports problems in a way that can be communicated to a user.
+ *
+ * @since 3.5
+ */
+public class PlanAnalyzer {
+
+ public static IStatus getStatus(int statusCode, IInstallableUnit affectedIU) {
+ switch (statusCode) {
+ case IStatusCodes.NOTHING_TO_UPDATE :
+ return new Status(IStatus.INFO, Activator.ID, statusCode, Messages.PlanAnalyzer_NoUpdates, null);
+ case IStatusCodes.PROFILE_CHANGE_ALTERED :
+ return new MultiStatus(Activator.ID, statusCode, Messages.PlanAnalyzer_RequestAltered, null);
+ case IStatusCodes.ALTERED_IMPLIED_UPDATE :
+ return new Status(IStatus.INFO, Activator.ID, statusCode, NLS.bind(Messages.PlanAnalyzer_ImpliedUpdate, getIUString(affectedIU)), null);
+ case IStatusCodes.ALTERED_IGNORED_IMPLIED_UPDATE :
+ return new Status(IStatus.WARNING, Activator.ID, statusCode, NLS.bind(Messages.PlanAnalyzer_LockedImpliedUpdate0, getIUString(affectedIU)), null);
+ case IStatusCodes.ALTERED_IGNORED_IMPLIED_DOWNGRADE :
+ return new Status(IStatus.WARNING, Activator.ID, statusCode, NLS.bind(Messages.PlanAnalyzer_IgnoringImpliedDowngrade, getIUString(affectedIU)), null);
+ case IStatusCodes.ALTERED_IGNORED_ALREADY_INSTALLED :
+ return new Status(IStatus.WARNING, Activator.ID, statusCode, NLS.bind(Messages.PlanAnalyzer_AlreadyInstalled, getIUString(affectedIU)), null);
+ case IStatusCodes.ALTERED_PARTIAL_INSTALL :
+ return new Status(IStatus.INFO, Activator.ID, statusCode, NLS.bind(Messages.PlanAnalyzer_PartialInstall, getIUString(affectedIU)), null);
+ case IStatusCodes.ALTERED_PARTIAL_UNINSTALL :
+ return new Status(IStatus.INFO, Activator.ID, statusCode, NLS.bind(Messages.PlanAnalyzer_PartialUninstall, getIUString(affectedIU)), null);
+ case IStatusCodes.UNEXPECTED_NOTHING_TO_DO :
+ return new Status(IStatus.ERROR, Activator.ID, statusCode, NLS.bind(Messages.PlanAnalyzer_NothingToDo, getIUString(affectedIU)), null);
+ case IStatusCodes.OPERATION_ALREADY_IN_PROGRESS :
+ return new Status(IStatus.ERROR, Activator.ID, statusCode, Messages.PlanAnalyzer_AnotherOperationInProgress, null);
+ default :
+ return new Status(IStatus.ERROR, Activator.ID, statusCode, NLS.bind(Messages.PlanAnalyzer_UnexpectedError, new Integer(statusCode), getIUString(affectedIU)), null);
+ }
+ }
+
+ public static MultiStatus getProfileChangeAlteredStatus() {
+ return (MultiStatus) getStatus(IStatusCodes.PROFILE_CHANGE_ALTERED, 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 the plan was canceled, no further analysis is needed
+ if (plan.getStatus().getSeverity() == IStatus.CANCEL) {
+ report.addSummaryStatus(plan.getStatus());
+ return report;
+ }
+
+ if (nothingToDo(originalRequest)) {
+ report.addSummaryStatus(getStatus(IStatusCodes.UNEXPECTED_NOTHING_TO_DO, null));
+ IStatus[] details = originalStatus.getChildren();
+ for (int i = 0; i < details.length; i++)
+ report.addSummaryStatus(details[i]);
+ return report;
+ }
+
+ // If there was already some status supplied before resolution, this should get included
+ // with the report. For example, this might contain information about the profile request
+ // being altered before resolution began.
+ if (originalStatus != null && originalStatus.getChildren().length > 0) {
+ report.addSummaryStatus(originalStatus);
+ }
+
+ // If the overall plan had a non-OK status, capture that in the report.
+ if (!plan.getStatus().isOK())
+ report.addSummaryStatus(plan.getStatus());
+
+ // Now we compare what was requested with what is going to happen.
+ // In the long run, when a RequestStatus can provide actual explanation/status
+ // about failures, we might want to add this information to the overall status.
+ // As it stands now, if the provisioning plan is in error, that info is more detailed
+ // than the request status. So we will only add request status info to the overall
+ // status when the overall status is not in error.
+ if (plan.getStatus().getSeverity() != IStatus.ERROR) {
+ IInstallableUnit[] iusAdded = originalRequest.getAddedInstallableUnits();
+ for (int i = 0; i < iusAdded.length; i++) {
+ RequestStatus rs = (RequestStatus) plan.getRequestStatus(iusAdded[i]);
+ if (rs.getSeverity() == IStatus.ERROR) {
+ // This is a serious error so it must also appear in the overall status
+ IStatus fail = new Status(IStatus.ERROR, Activator.ID, IStatusCodes.ALTERED_IGNORED_INSTALL_REQUEST, NLS.bind(Messages.PlanAnalyzer_IgnoringInstall, getIUString(iusAdded[i])), null);
+ report.addStatus(iusAdded[i], fail);
+ report.addSummaryStatus(fail);
+ }
+ }
+ IInstallableUnit[] iusRemoved = originalRequest.getRemovedInstallableUnits();
+ for (int i = 0; i < iusRemoved.length; i++) {
+ RequestStatus rs = (RequestStatus) plan.getRequestStatus(iusRemoved[i]);
+ if (rs.getSeverity() == IStatus.ERROR) {
+ // TODO see https://bugs.eclipse.org/bugs/show_bug.cgi?id=255984
+ // We are making assumptions here about why the planner chose to ignore an uninstall.
+ // Assume it could not be uninstalled because of some other dependency, yet the planner did not view
+ // this as an error. So we inform the user that we can only uninstall parts of it. The root property will be
+ // removed per the original change request.
+ IStatus fail = new Status(IStatus.INFO, Activator.ID, IStatusCodes.ALTERED_PARTIAL_UNINSTALL, NLS.bind(Messages.PlanAnalyzer_PartialUninstall, getIUString(iusRemoved[i])), null);
+ report.addStatus(iusRemoved[i], fail);
+ report.addSummaryStatus(fail);
+ }
+ }
+ }
+
+ // Now process the side effects
+ for (Entry<IInstallableUnit, IStatus> entry : plan.getSideEffectChanges().entrySet()) {
+ IInstallableUnit iu = entry.getKey();
+ RequestStatus rs = (RequestStatus) entry.getValue();
+ if (rs.getInitialRequestType() == RequestStatus.ADDED) {
+ report.addStatus(iu, new Status(rs.getSeverity(), Activator.ID, IStatusCodes.ALTERED_SIDE_EFFECT_INSTALL, NLS.bind(Messages.PlanAnalyzer_SideEffectInstall, getIUString(iu)), null));
+ } else {
+ report.addStatus(iu, new Status(rs.getSeverity(), Activator.ID, IStatusCodes.ALTERED_SIDE_EFFECT_REMOVE, NLS.bind(Messages.PlanAnalyzer_SideEffectUninstall, getIUString(iu)), null));
+ }
+ }
+
+ return report;
+
+ }
+
+ private static String getIUString(IInstallableUnit iu) {
+ if (iu == null)
+ return Messages.PlanAnalyzer_Items;
+ // Get the iu name in the default locale
+ String name = iu.getProperty(IInstallableUnit.PROP_NAME, null);
+ if (name != null)
+ return name;
+ return iu.getId();
+ }
+
+ private static boolean nothingToDo(ProfileChangeRequest request) {
+ return request.getAddedInstallableUnits().length == 0 && request.getRemovedInstallableUnits().length == 0 && request.getInstallableUnitProfilePropertiesToAdd().size() == 0 && request.getInstallableUnitProfilePropertiesToRemove().size() == 0;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlannerResolutionJob.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlannerResolutionJob.java
new file mode 100644
index 000000000..14ed2c330
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlannerResolutionJob.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.operations;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
+import org.eclipse.equinox.p2.engine.IProvisioningPlan;
+import org.eclipse.equinox.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.operations.*;
+
+/**
+ * Class representing a provisioning profile plan
+ *
+ * @since 2.0
+ */
+public class PlannerResolutionJob extends ProvisioningJob implements IProfileChangeJob {
+
+ ProfileChangeRequest request;
+ String profileId;
+ IProvisioningPlan plan;
+ MultiStatus additionalStatus;
+ ResolutionResult report;
+ ProvisioningContext provisioningContext;
+
+ public static MultiStatus getProfileChangeRequestAlteredStatus() {
+ return PlanAnalyzer.getProfileChangeAlteredStatus();
+ }
+
+ public PlannerResolutionJob(String label, ProvisioningSession session, String profileId, ProfileChangeRequest request, ProvisioningContext provisioningContext, MultiStatus additionalStatus) {
+ super(label, session);
+ this.request = request;
+ this.profileId = profileId;
+ if (provisioningContext == null)
+ this.provisioningContext = new ProvisioningContext();
+ else
+ this.provisioningContext = provisioningContext;
+ Assert.isNotNull(additionalStatus);
+ this.additionalStatus = additionalStatus;
+ }
+
+ public IProvisioningPlan getProvisioningPlan() {
+ return plan;
+ }
+
+ public ProfileChangeRequest getProfileChangeRequest() {
+ return request;
+ }
+
+ public ProvisioningContext getProvisioningContext() {
+ return provisioningContext;
+ }
+
+ public void setProvisioningContext(ProvisioningContext context) {
+ this.provisioningContext = context;
+ }
+
+ public IStatus runModal(IProgressMonitor monitor) {
+ plan = getSession().getPlanner().getProvisioningPlan(request, provisioningContext, monitor);
+ if (plan == null) {
+ return new Status(IStatus.ERROR, Activator.ID, Messages.PlannerResolutionJob_NullProvisioningPlan);
+ }
+ return plan.getStatus();
+
+ }
+
+ public ResolutionResult getResolutionResult() {
+ if (report == null) {
+ report = PlanAnalyzer.computeResolutionResult(request, plan, additionalStatus);
+ }
+ return report;
+ }
+
+ public String getProfileId() {
+ return profileId;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java
new file mode 100644
index 000000000..0d0d90bab
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/ResolutionResult.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.equinox.internal.p2.operations;
+
+import java.util.HashMap;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+
+/**
+ * ResolutionResult describes problems in a provisioning plan in a structured
+ * way that can be presented to a user.
+ *
+ * @since 2.0
+ */
+public class ResolutionResult {
+ private static final String NESTING_INDENT = " "; //$NON-NLS-1$
+
+ private final HashMap<IInstallableUnit, MultiStatus> iuToStatusMap = new HashMap<IInstallableUnit, MultiStatus>();
+ 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(Activator.ID, 0, Messages.ResolutionResult_SummaryStatus, null);
+ }
+ summaryStatus.add(status);
+ }
+
+ public IStatus statusOf(IInstallableUnit iu) {
+ return iuToStatusMap.get(iu);
+ }
+
+ public void addStatus(IInstallableUnit iu, IStatus status) {
+ MultiStatus iuSummaryStatus = iuToStatusMap.get(iu);
+ if (iuSummaryStatus == null) {
+ iuSummaryStatus = new MultiStatus(Activator.ID, IStatusCodes.IU_REQUEST_ALTERED, new IStatus[] {status}, getIUString(iu), null);
+ } else
+ iuSummaryStatus.add(status);
+ }
+
+ private String getIUString(IInstallableUnit iu) {
+ if (iu == null)
+ return Messages.PlanAnalyzer_Items;
+ // Get the iu name in the default locale
+ String name = iu.getProperty(IInstallableUnit.PROP_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 ""; //$NON-NLS-1$
+ }
+
+ // Answers null if there is nothing to say about the ius
+ public String getDetailedReport(IInstallableUnit[] ius) {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < ius.length; i++) {
+ MultiStatus iuStatus = 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(NESTING_INDENT);
+ if (status.getMessage() != null)
+ buffer.append(status.getMessage());
+ }
+ Throwable t = status.getException();
+ if (t != null) {
+ // A provision (or core) exception occurred. Get its status message or if none, its top level message.
+ // Indent by one more level (note the <=)
+ buffer.append('\n');
+ for (int i = 0; i <= indent; i++)
+ buffer.append(NESTING_INDENT);
+ 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);
+ }
+ }
+ // Now print the children status info (if there are children)
+ 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);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/SizingPhaseSet.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/SizingPhaseSet.java
new file mode 100644
index 000000000..1b433695b
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/SizingPhaseSet.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/**
+ *
+ */
+package org.eclipse.equinox.internal.p2.operations;
+
+import org.eclipse.equinox.internal.p2.engine.Phase;
+import org.eclipse.equinox.internal.p2.engine.PhaseSet;
+import org.eclipse.equinox.internal.p2.engine.phases.Sizing;
+
+
+public class SizingPhaseSet extends PhaseSet {
+
+ private static Sizing sizing;
+
+ public SizingPhaseSet() {
+ super(new Phase[] {sizing = new Sizing(100, Messages.SizingPhaseSet_PhaseSetName)});
+ }
+
+ public Sizing getSizing() {
+ return sizing;
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/messages.properties b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/messages.properties
new file mode 100644
index 000000000..24c99f571
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/messages.properties
@@ -0,0 +1,44 @@
+###############################################################################
+# Copyright (c) 2009 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+InstallOperation_ComputeProfileChangeProgress=Checking the install request
+InstallOperation_InstallJobName=Installing Software
+InstallOperation_ResolveJobName=Computing install requirements
+ProfileChangeOperation_NoProfileChangeRequest=Could not interpret the installation request.
+ProfileChangeOperation_ResolveTaskName=Analyzing the install operation
+ProvisioningJob_GenericErrorStatusMessage=Error encountered while running {0}
+ProvisioningSession_AgentNotFound=No provisioning agent could be found
+ProvisioningSession_InstallPlanConfigurationError=A problem was encountered while preparing the system for the installation
+PlanAnalyzer_IgnoringInstall="{0}" is not applicable to the current configuration and will not be installed.
+PlanAnalyzer_LockedImpliedUpdate0={0} will be ignored because it is already installed, and updates are not permitted.
+PlanAnalyzer_PartialInstall="{0}" is already present because other installed software requires it. It will be added to the installed software list.
+PlanAnalyzer_PartialUninstall= "{0}" cannot be fully uninstalled because other installed software requires it. The parts that are not required will be uninstalled.
+PlanAnalyzer_SideEffectInstall="{0}" will also be installed in order to complete this operation.
+PlanAnalyzer_SideEffectUninstall="{0}" must be uninstalled in order to complete this operation.
+PlannerResolutionJob_NullProvisioningPlan=Could not obtain provisioning plan. No details were available.
+PlanAnalyzer_IgnoringImpliedDowngrade="{0}" will be ignored because a newer version is already installed.
+PlanAnalyzer_ImpliedUpdate="{0}" is already installed, so an update will be performed instead.
+PlanAnalyzer_Items=Items
+PlanAnalyzer_NothingToDo=Cannot complete the request. See the error log for details.
+PlanAnalyzer_NoUpdates=No updates were found.
+PlanAnalyzer_AlreadyInstalled="{0}" will be ignored because it is already installed.
+PlanAnalyzer_AnotherOperationInProgress=Cannot continue the operation. There is another install operation in progress.
+PlanAnalyzer_RequestAltered=Your original request has been modified.
+PlanAnalyzer_UnexpectedError=Unexpected error code {0} encountered for {1}.
+RepositoryTracker_DuplicateLocation=Duplicate location
+RepositoryTracker_InvalidLocation=The location "{0}" is not a valid software site location.
+ResolutionResult_SummaryStatus=Operation details
+SizingPhaseSet_PhaseSetName=Compute sizes
+
+UninstallOperation_ProvisioningJobName=Uninstalling Software
+UninstallOperation_ResolveJobName=Calculating Uninstall Validity
+UpdateOperation_ProfileChangeRequestProgress=Computing update request
+UpdateOperation_ResolveJobName=Computing Update Requirements
+UpdateOperation_UpdateJobName=Updating Software

Back to the top