Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.director/src')
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IPlanner.java (renamed from bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector2.java)26
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/NewSimpleDirector.java328
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/Oracle.java164
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/ProvisioningPlan.java (renamed from bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/DirectorResult.java)6
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector.java119
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimplePlanner.java (renamed from bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector2.java)145
9 files changed, 189 insertions, 606 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java
index d23b63a31..a622c37de 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Messages.java
@@ -29,6 +29,7 @@ public class Messages extends NLS {
public static String Director_Uninstall_Problems;
public static String Director_Nothing_To_Uninstall;
public static String Director_Cannot_Uninstall;
+ public static String Director_Already_Installed;
public static String Director_Replace_Problems;
public static String Director_Become_Problems;
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties
index 795fa00db..b39b3ac20 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/messages.properties
@@ -13,10 +13,11 @@ Director_Uninstall_Problems=Problems occurred while uninstalling.
Director_Install_Problems=Problems occurred while installing.
Director_Cannot_Uninstall=Can not uninstall {0} because others IUs depend on it.
Director_Nothing_To_Uninstall=Nothing to uninstall.
+Director_Already_Installed={0} is already installed.
Director_Replace_Problems=Problems occurred while replacing.
Director_Become_Problems=Problems occured while running become.
Director_Unexpected_IU=The installable unit {0} can not be used here.
-Director_Task_Installing=Installing {0} to {1}
+Director_Task_Installing=Installing into {1}
Director_Task_Uninstalling=Uninstalling
Director_Task_Updating=Updating
Director_Task_Resolving_Dependencies=Resolving dependencies
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java
index 4ad233379..e75535422 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector.java
@@ -29,11 +29,10 @@ public interface IDirector {
*
* @param toInstall The units to install
* @param profile The profile to install into
- * @param entryPoint The user visible name of the entry point. If <code>null</code> is being passed, no entry point gets created
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting is not desired
*/
- public IStatus install(IInstallableUnit[] toInstall, Profile profile, String entryPoint, IProgressMonitor monitor);
+ public IStatus install(IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor);
/**
* Uninstalls the given units from the given profile.
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector2.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IPlanner.java
index a85fd4ff5..02ac5203d 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IDirector2.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/IPlanner.java
@@ -13,41 +13,37 @@ import org.eclipse.equinox.p2.engine.Profile;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
/**
- * Directors are responsible for determining what should be done to a given
+ * Planners are responsible for determining what should be done to a given
* profile to reshape it as requested. That is, given the current state of a
* profile, a description of the desired end state of that profile and metadata
- * describing the available IUs, a director produces a list of provisioning
- * operations (e.g., install, update or uninstall) to perform on the related IUs.
- * Directors are also able to validate profiles and assist in the diagnosis of
- * configuration errors. Note that directors may range in complexity from
- * very simple (e.g., reading a list of bundles from a static file) to very complex.
+ * describing the available IUs, a planner produces a plan that lists the
+ * provisioning operands that the engine should perform.
*/
-public interface IDirector2 {
+public interface IPlanner {
/**
- * Installs the given units into the given profile.
+ * Provides a plan for installing the given units into the given profile.
*
* @param toInstall The units to install
* @param profile The profile to install into
- * @param entryPoint The user visible name of the entry point. If <code>null</code> is being passed, no entry point gets created
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting is not desired
*/
- public DirectorResult install(IInstallableUnit[] toInstall, Profile profile, String entryPoint, IProgressMonitor monitor);
+ public ProvisioningPlan getInstallPlan(IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor);
/**
- * Uninstalls the given units from the given profile.
+ * Provides a plan for uninstalling the given units from the given profile.
*
* @param toUninstall The units to uninstall
* @param profile The profile from which to uninstall
* @param monitor a progress monitor, or <code>null</code> if progress
* reporting is not desired
*/
- public DirectorResult uninstall(IInstallableUnit[] toUninstall, Profile profile, IProgressMonitor monitor);
+ public ProvisioningPlan getUninstallPlan(IInstallableUnit[] toUninstall, Profile profile, IProgressMonitor monitor);
- public DirectorResult become(IInstallableUnit target, Profile profile, IProgressMonitor monitor);
+ public ProvisioningPlan getBecomePlan(IInstallableUnit target, Profile profile, IProgressMonitor monitor);
- public DirectorResult replace(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor);
+ public ProvisioningPlan getReplacePlan(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor);
- //TODO And many more operations for uninstallation and the rest ! See bug 179819
+ public IInstallableUnit[] updatesFor(IInstallableUnit toUpdate);
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/NewSimpleDirector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/NewSimpleDirector.java
deleted file mode 100644
index 715600543..000000000
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/NewSimpleDirector.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.p2.director;
-
-import java.net.URL;
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.director.*;
-import org.eclipse.equinox.internal.p2.rollback.FormerState;
-import org.eclipse.equinox.p2.core.eventbus.ProvisioningEventBus;
-import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.p2.core.location.AgentLocation;
-import org.eclipse.equinox.p2.core.repository.IRepository;
-import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.p2.resolution.ResolutionHelper;
-import org.eclipse.osgi.service.resolver.VersionRange;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Version;
-
-public class NewSimpleDirector implements IDirector {
- static final int ExpandWork = 10;
- static final int OperationWork = 100;
- private Engine engine;
-
- public static void tagAsImplementation(IMetadataRepository repository) {
- if (repository != null && repository.getProperties().getProperty(IRepository.IMPLEMENTATION_ONLY_KEY) == null) {
- if (repository.isModifiable())
- repository.getModifiableProperties().setProperty(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.valueOf(true).toString());
- }
- }
-
- public NewSimpleDirector() {
- URL rollbackLocation = null;
- AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(DirectorActivator.context, AgentLocation.class.getName());
- rollbackLocation = agentLocation.getTouchpointDataArea("director");
- ProvisioningEventBus eventBus = (ProvisioningEventBus) ServiceHelper.getService(DirectorActivator.context, ProvisioningEventBus.class.getName());
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
- IMetadataRepository rollbackRepo = manager.loadRepository(rollbackLocation, null);
- if (rollbackRepo == null)
- rollbackRepo = manager.createRepository(rollbackLocation, "Agent rollback repo", "org.eclipse.equinox.p2.metadata.repository.simpleRepository"); //$NON-NLS-1$//$NON-NLS-2$
- if (rollbackRepo == null)
- throw new IllegalStateException("Unable to open or create Agent's rollback repository");
- tagAsImplementation(rollbackRepo);
- new FormerState(eventBus, rollbackRepo);
- engine = (Engine) ServiceHelper.getService(DirectorActivator.context, Engine.class.getName());
- }
-
- //TODO This is really gross!!!!! We need to make things uniform
- private IInstallableUnit[] toArray(Iterator it) {
- ArrayList result = new ArrayList();
- while (it.hasNext()) {
- result.add(it.next());
- }
- return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
- }
-
- protected IInstallableUnit[] createEntryPointHelper(String entryPointName, IInstallableUnit[] content) {
- if (entryPointName == null)
- return content;
- return new IInstallableUnit[] {createEntryPoint(entryPointName, content)};
- }
-
- protected InstallableUnit createEntryPoint(String entryPointName, IInstallableUnit[] content) {
- InstallableUnit result = new InstallableUnit();
- result.setId("entry point " + entryPointId(content)); //$NON-NLS-1$
- result.setVersion(new Version(0, 0, 0, Long.toString(System.currentTimeMillis())));
- result.setRequiredCapabilities(IUTransformationHelper.toRequirements(content, false));
- result.setProperty(IInstallableUnitConstants.ENTRYPOINT_IU_KEY, Boolean.TRUE.toString());
- result.setProperty(IInstallableUnitConstants.NAME, entryPointName);
- return result;
- }
-
- private String entryPointId(IInstallableUnit[] ius) {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < ius.length; i++) {
- result.append(ius[i].getId());
- if (i < ius.length - 1)
- result.append(", "); //$NON-NLS-1$
- }
- return result.toString();
- }
-
- public IStatus install(IInstallableUnit[] installRoots, Profile profile, String entryPointName, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, ExpandWork + OperationWork);
- sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
- try {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Install_Problems, null);
- // Get the list of ius installed in the profile we are installing into
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- //Compute the complete closure of things to install to successfully install the installRoots.
- NewDependencyExpander expander = new NewDependencyExpander(createEntryPointHelper(entryPointName, installRoots), alreadyInstalled, gatherAvailableInstallableUnits(installRoots), profile, true);
- // NewDependencyExpander expander = new NewDependencyExpander(installRoots, alreadyInstalled, gatherAvailableInstallableUnits(), profile, true);
- IStatus expanderResult = expander.expand(sub.newChild(ExpandWork));
- if (!expanderResult.isOK()) {
- result.merge(expanderResult);
- return result;
- }
-
- ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection oldState = oldStateHelper.attachCUs(Arrays.asList(alreadyInstalled));
- List oldStateOrder = oldStateHelper.getSorted();
-
- ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), expander.getRecommendations());
- Collection newState = newStateHelper.attachCUs(expander.getAllInstallableUnits());
- List newStateOrder = newStateHelper.getSorted();
-
- //TODO Here we need to sort the operations to ensure that the dependents will be treated first (see ensureDependencyOrder)
- sub.setTaskName(NLS.bind(Messages.Director_Task_Installing, entryPointName, profile.getValue(Profile.PROP_INSTALL_FOLDER)));
- IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), generateOperations(oldState, newState, oldStateOrder, newStateOrder), sub.newChild(OperationWork));
- if (!engineResult.isOK())
- result.merge(engineResult);
-
- return result.isOK() ? Status.OK_STATUS : result;
- } finally {
- sub.done();
- }
- }
-
- private Operand[] generateOperations(Collection fromState, Collection toState, List fromStateOrder, List newStateOrder) {
- return sortOperations(new OperationGenerator().generateOperation(fromState, toState), newStateOrder, fromStateOrder);
- }
-
- private Operand[] sortOperations(Operand[] toSort, List installOrder, List uninstallOrder) {
- List updateOp = new ArrayList();
- for (int i = 0; i < toSort.length; i++) {
- Operand op = toSort[i];
- if (op.first() == null && op.second() != null) {
- installOrder.set(installOrder.indexOf(op.second()), op);
- continue;
- }
- if (op.first() != null && op.second() == null) {
- uninstallOrder.set(uninstallOrder.indexOf(op.first()), op);
- continue;
- }
- if (op.first() != null && op.second() != null) {
- updateOp.add(op);
- continue;
- }
- }
- int i = 0;
- for (Iterator iterator = installOrder.iterator(); iterator.hasNext();) {
- Object elt = iterator.next();
- if (elt instanceof Operand) {
- toSort[i++] = (Operand) elt;
- }
- }
- for (Iterator iterator = uninstallOrder.iterator(); iterator.hasNext();) {
- Object elt = iterator.next();
- if (elt instanceof Operand) {
- toSort[i++] = (Operand) elt;
- }
- }
- for (Iterator iterator = updateOp.iterator(); iterator.hasNext();) {
- Object elt = iterator.next();
- if (elt instanceof Operand) {
- toSort[i++] = (Operand) elt;
- }
- }
- return toSort;
- }
-
- public IStatus become(IInstallableUnit target, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
- sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
- try {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Become_Problems, null);
-
- if (!Boolean.valueOf(target.getProperty(IInstallableUnitConstants.PROFILE_IU_KEY)).booleanValue()) {
- result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Unexpected_IU, target.getId())));
- return result;
- }
-
- //TODO Here we need to deal with the change of properties between the two profiles
- //Also if the profile changes (locations are being modified, etc), should not we do a full uninstall then an install?
- //Maybe it depends on the kind of changes in a profile
- //We need to get all the ius that were part of the profile and give that to be what to become
- NewDependencyExpander toExpander = new NewDependencyExpander(new IInstallableUnit[] {target}, null, gatherAvailableInstallableUnits(new IInstallableUnit[] {target}), profile, true);
- toExpander.expand(sub.newChild(ExpandWork));
- ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), toExpander.getRecommendations());
- Collection newState = newStateHelper.attachCUs(toExpander.getAllInstallableUnits());
- newState.remove(target);
-
- Iterator it = profile.getInstallableUnits();
- Collection oldIUs = new HashSet();
- for (; it.hasNext();) {
- oldIUs.add(it.next());
- }
-
- ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection oldState = oldStateHelper.attachCUs(oldIUs);
- sub.setTaskName(Messages.Director_Task_Updating);
- IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()), sub.newChild(OperationWork));
- if (!engineResult.isOK())
- result.merge(engineResult);
-
- return result;
- } finally {
- sub.done();
- }
- }
-
- private IInstallableUnit[] inProfile(IInstallableUnit[] toFind, Profile profile, boolean found, IProgressMonitor monitor) {
- ArrayList result = new ArrayList(toFind.length);
- for (int i = 0; i < toFind.length; i++) {
- if (profile.query(toFind[i].getId(), new VersionRange(toFind[i].getVersion(), true, toFind[i].getVersion(), true), null, false, monitor).length > 0) {
- if (found)
- result.add(toFind[i]);
- } else {
- if (!found)
- result.add(toFind[i]);
- }
- }
- return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
- }
-
- public IStatus uninstall(IInstallableUnit[] uninstallRoots, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
- sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
- try {
- IInstallableUnit[] toReallyUninstall = inProfile(uninstallRoots, profile, true, sub.newChild(0));
- if (toReallyUninstall.length == 0) {
- return new Status(IStatus.OK, DirectorActivator.PI_DIRECTOR, Messages.Director_Nothing_To_Uninstall);
- } else if (toReallyUninstall.length != uninstallRoots.length) {
- uninstallRoots = toReallyUninstall;
- }
-
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Uninstall_Problems, null);
-
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection oldState = oldStateHelper.attachCUs(Arrays.asList(alreadyInstalled));
-
- NewDependencyExpander expander = new NewDependencyExpander(uninstallRoots, new IInstallableUnit[0], alreadyInstalled, profile, true);
- expander.expand(sub.newChild(ExpandWork / 2));
- Collection toUninstallClosure = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(expander.getAllInstallableUnits());
-
- Collection remainingIUs = new HashSet(oldState);
- remainingIUs.removeAll(toUninstallClosure);
- NewDependencyExpander finalExpander = new NewDependencyExpander(null, (IInstallableUnit[]) remainingIUs.toArray(new IInstallableUnit[remainingIUs.size()]), gatherAvailableInstallableUnits(uninstallRoots), profile, true);
- finalExpander.expand(sub.newChild(ExpandWork / 2));
- ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection newState = newStateHelper.attachCUs(finalExpander.getAllInstallableUnits());
-
- for (int i = 0; i < uninstallRoots.length; i++) {
- if (newState.contains(uninstallRoots[i]))
- result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Cannot_Uninstall, uninstallRoots[i])));
- }
- if (!result.isOK())
- return result;
-
- sub.setTaskName(Messages.Director_Task_Uninstalling);
- IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()), sub.newChild(OperationWork));
- if (!engineResult.isOK())
- result.merge(engineResult);
-
- return result.isOK() ? Status.OK_STATUS : result;
- } finally {
- sub.done();
- }
- }
-
- protected IInstallableUnit[] gatherAvailableInstallableUnits(IInstallableUnit[] additionalSource) {
- IMetadataRepositoryManager repoMgr = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
- IMetadataRepository[] repos = repoMgr.getKnownRepositories();
- List results = new ArrayList();
- if (additionalSource != null) {
- for (int i = 0; i < additionalSource.length; i++) {
- results.add(additionalSource[i]);
- }
- }
-
- for (int i = 0; i < repos.length; i++) {
- results.addAll(Arrays.asList(repos[i].getInstallableUnits(null)));
- }
- return (IInstallableUnit[]) results.toArray(new IInstallableUnit[results.size()]);
- }
-
- public IStatus replace(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
- sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
- try {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Replace_Problems, null);
-
- //TODO Need to worry about the entry points
-
- //find the things being updated in the profile
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- IInstallableUnit[] uninstallRoots = toUninstall;
-
- //compute the transitive closure and remove them.
- ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection oldState = oldStateHelper.attachCUs(Arrays.asList(alreadyInstalled));
-
- NewDependencyExpander expander = new NewDependencyExpander(uninstallRoots, new IInstallableUnit[0], alreadyInstalled, profile, true);
- expander.expand(sub.newChild(ExpandWork / 2));
- Collection toUninstallClosure = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(expander.getAllInstallableUnits());
-
- //add the new set.
- Collection remainingIUs = new HashSet(oldState);
- remainingIUs.removeAll(toUninstallClosure);
- // for (int i = 0; i < updateRoots.length; i++) {
- // remainingIUs.add(updateRoots[i]);
- // }
- NewDependencyExpander finalExpander = new NewDependencyExpander(toInstall, (IInstallableUnit[]) remainingIUs.toArray(new IInstallableUnit[remainingIUs.size()]), gatherAvailableInstallableUnits(null), profile, true);
- finalExpander.expand(sub.newChild(ExpandWork / 2));
- ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
- Collection newState = newStateHelper.attachCUs(finalExpander.getAllInstallableUnits());
-
- sub.setTaskName(Messages.Director_Task_Updating);
- IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()), sub.newChild(OperationWork));
- if (!engineResult.isOK())
- result.merge(engineResult);
-
- return result.isOK() ? Status.OK_STATUS : result;
- } finally {
- sub.done();
- }
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/Oracle.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/Oracle.java
deleted file mode 100644
index 2954c855e..000000000
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/Oracle.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.p2.director;
-
-import java.util.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.director.DirectorActivator;
-import org.eclipse.equinox.internal.p2.director.Messages;
-import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.resolution.ResolutionHelper;
-import org.eclipse.osgi.service.resolver.VersionRange;
-
-//TODO The "extends" relationship with the director is a hack to get stuffs working
-public class Oracle extends NewSimpleDirector {
- public Object canInstall(IInstallableUnit[] toAdd, Profile profile, IProgressMonitor monitor) {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, "oracle", null);
- SubMonitor sub = SubMonitor.convert(monitor, ExpandWork + OperationWork);
- try {
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- if (alreadyIn(alreadyInstalled, toAdd[0])) {
- return Boolean.FALSE;
- }
- //Compute the complete closure of things to install to successfully install the installRoots.
- NewDependencyExpander expander = new NewDependencyExpander(toAdd, alreadyInstalled, gatherAvailableInstallableUnits(toAdd), profile, true);
- IStatus expanderResult = expander.expand(sub);
- sub.worked(ExpandWork);
- if (expanderResult.isOK()) {
- return Boolean.TRUE;
- }
- Collection resolved = expander.getAllInstallableUnits();
- Collection entryPoints = new HashSet();
- for (Iterator iterator = resolved.iterator(); iterator.hasNext();) {
- IInstallableUnit iu = (IInstallableUnit) iterator.next();
- // if ("true".equals(iu.getProperty("entryPoint"))) {
- entryPoints.add(iu);
- // }
- }
- Collection initialEntryPoints = new HashSet();
- for (int i = 0; i < alreadyInstalled.length; i++) {
- // if ("true".equals(alreadyInstalled[i].getProperty("entryPoint"))) {
- initialEntryPoints.add(alreadyInstalled[i]);
- // }
- }
- initialEntryPoints.removeAll(entryPoints);
- if (initialEntryPoints.size() != 0) {
- return initialEntryPoints;
- }
- return Boolean.FALSE;
- } finally {
- sub.done();
- }
- }
-
- public boolean canInstall(IInstallableUnit[] toAdd, IInstallableUnit[] toUpdate, Profile profile, IProgressMonitor monitor) {
- IInstallableUnit[] replacements = new IInstallableUnit[toUpdate.length + toAdd.length];
- for (int i = 0; i < toUpdate.length; i++) {
- replacements[i] = containsUpdate(toUpdate[i]);
- //TODO We need to be able to deal with multiple updates and even where is none
- if (replacements[i] == null)
- return false;
- }
- System.arraycopy(toAdd, 0, replacements, toUpdate.length, toAdd.length);
-
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Uninstall_Problems, null);
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
-
- IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
- Collection oldState = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(Arrays.asList(alreadyInstalled));
-
- NewDependencyExpander expander = new NewDependencyExpander(toUpdate, new IInstallableUnit[0], alreadyInstalled, profile, true);
- expander.expand(sub);
- Collection toUninstallClosure = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(expander.getAllInstallableUnits());
-
- Collection remainingIUs = new HashSet(oldState);
- remainingIUs.removeAll(toUninstallClosure);
- NewDependencyExpander finalExpander = new NewDependencyExpander(replacements, (IInstallableUnit[]) remainingIUs.toArray(new IInstallableUnit[remainingIUs.size()]), gatherAvailableInstallableUnits(toAdd), profile, true);
- finalExpander.expand(sub);
- Collection newState = new ResolutionHelper(profile.getSelectionContext(), null).attachCUs(finalExpander.getAllInstallableUnits());
-
- return true;
- }
-
- private IInstallableUnit containsUpdate(IInstallableUnit iu) {
- IInstallableUnit[] candidates = gatherAvailableInstallableUnits(null);
- for (int i = 0; i < candidates.length; i++) {
- if (iu.getId().equals(candidates[i].getProperty(IInstallableUnitConstants.UPDATE_FROM))) {
- if (iu.equals(candidates[i]))
- continue;
- VersionRange range = new VersionRange(candidates[i].getProperty(IInstallableUnitConstants.UPDATE_RANGE));
- if (range.isIncluded(iu.getVersion()) && candidates[i].getVersion().compareTo(iu.getVersion()) > 0)
- return candidates[i];
- }
- }
- return null;
- }
-
- private boolean alreadyIn(IInstallableUnit[] ius, IInstallableUnit id) {
- for (int i = 0; i < ius.length; i++) {
- if (ius[i].equals(id))
- return true;
- }
- return false;
- }
-
- private IInstallableUnit[] toArray(Iterator it) {
- ArrayList result = new ArrayList();
- while (it.hasNext()) {
- result.add(it.next());
- }
- return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
- }
-
- public Collection hasUpdate(IInstallableUnit toUpdate) {
- if (toUpdate.getProperty(IInstallableUnitConstants.ENTRYPOINT_IU_KEY) != null)
- return entryPointProcessing(toUpdate);
- IInstallableUnit[] allius = gatherAvailableInstallableUnits(null);
- Set updates = new HashSet();
- for (int i = 0; i < allius.length; i++) {
- if (toUpdate.getId().equals(allius[i].getProperty(IInstallableUnitConstants.UPDATE_FROM))) {
- if (toUpdate.getVersion().compareTo(allius[i].getVersion()) < 0 && new VersionRange(allius[i].getProperty(IInstallableUnitConstants.UPDATE_RANGE)).isIncluded(toUpdate.getVersion()))
- updates.add(allius[i]);
- }
- }
- return updates;
- }
-
- private Collection entryPointProcessing(IInstallableUnit entryPoint) {
- ArrayList updates = new ArrayList();
- RequiredCapability[] entries = entryPoint.getRequiredCapabilities();
- for (int i = 0; i < entries.length; i++) {
- if (!IInstallableUnit.IU_NAMESPACE.equals(entries[i].getNamespace()))
- continue;
- IInstallableUnit[] allius = gatherAvailableInstallableUnits(null);
- IInstallableUnit match = null;
- for (int j = 0; j < allius.length; j++) {
- if (entries[i].getName().equals(allius[j].getProperty(IInstallableUnitConstants.UPDATE_FROM))) {
- if (new VersionRange(allius[j].getProperty(IInstallableUnitConstants.UPDATE_RANGE)).isIncluded(entries[i].getRange().getMinimum()) && allius[j].getVersion().compareTo(entries[i].getRange().getMinimum()) > 0) {
- if (match == null || allius[j].getVersion().compareTo(match.getVersion()) > 0)
- match = allius[j];
- }
- }
- }
- if (match != null)
- updates.add(match);
- }
- if (updates.size() == 0)
- return updates;
- String entryPointName = entryPoint.getProperty(IInstallableUnitConstants.NAME);
- if (entryPointName == null)
- entryPointName = entryPoint.getId();
- InstallableUnit newEntryPoint = createEntryPoint(entryPointName, (IInstallableUnit[]) updates.toArray(new IInstallableUnit[updates.size()]));
- newEntryPoint.setProperty(IInstallableUnitConstants.UPDATE_FROM, entryPoint.getId());
- ArrayList result = new ArrayList();
- result.add(newEntryPoint);
- return result;
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/DirectorResult.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/ProvisioningPlan.java
index 3d37220c8..ef70bf67d 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/DirectorResult.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/ProvisioningPlan.java
@@ -11,15 +11,15 @@ package org.eclipse.equinox.p2.director;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.engine.Operand;
-public class DirectorResult {
+public class ProvisioningPlan {
private IStatus status;
private Operand[] operands;
- public DirectorResult(IStatus status) {
+ public ProvisioningPlan(IStatus status) {
this(status, null);
}
- public DirectorResult(IStatus status, Operand[] operands) {
+ public ProvisioningPlan(IStatus status, Operand[] operands) {
this.status = status;
this.operands = operands;
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector.java
new file mode 100644
index 000000000..6217e2dbe
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.p2.director;
+
+import java.net.URL;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.director.DirectorActivator;
+import org.eclipse.equinox.internal.p2.director.Messages;
+import org.eclipse.equinox.internal.p2.rollback.FormerState;
+import org.eclipse.equinox.p2.core.eventbus.ProvisioningEventBus;
+import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.p2.core.location.AgentLocation;
+import org.eclipse.equinox.p2.core.repository.IRepository;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
+import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.osgi.util.NLS;
+
+public class SimpleDirector implements IDirector {
+ static final int OperationWork = 100;
+ private Engine engine;
+ private IPlanner planner;
+
+ public static void tagAsImplementation(IMetadataRepository repository) {
+ if (repository != null && repository.getProperties().getProperty(IRepository.IMPLEMENTATION_ONLY_KEY) == null) {
+ if (repository.isModifiable())
+ repository.getModifiableProperties().setProperty(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.valueOf(true).toString());
+ }
+ }
+
+ public SimpleDirector() {
+ URL rollbackLocation = null;
+ AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(DirectorActivator.context, AgentLocation.class.getName());
+ rollbackLocation = agentLocation.getTouchpointDataArea("director");
+ ProvisioningEventBus eventBus = (ProvisioningEventBus) ServiceHelper.getService(DirectorActivator.context, ProvisioningEventBus.class.getName());
+ IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
+ IMetadataRepository rollbackRepo = manager.loadRepository(rollbackLocation, null);
+ if (rollbackRepo == null)
+ rollbackRepo = manager.createRepository(rollbackLocation, "Agent rollback repo", "org.eclipse.equinox.p2.metadata.repository.simpleRepository"); //$NON-NLS-1$//$NON-NLS-2$
+ if (rollbackRepo == null)
+ throw new IllegalStateException("Unable to open or create Agent's rollback repository");
+ tagAsImplementation(rollbackRepo);
+ new FormerState(eventBus, rollbackRepo);
+ engine = (Engine) ServiceHelper.getService(DirectorActivator.context, Engine.class.getName());
+ if (engine == null)
+ throw new IllegalStateException("Provisioning engine is not registered");
+ planner = (IPlanner) ServiceHelper.getService(DirectorActivator.context, IPlanner.class.getName());
+ if (planner == null)
+ throw new IllegalStateException("Unable to find provisioning planner");
+ }
+
+ public IStatus install(IInstallableUnit[] installRoots, Profile profile, IProgressMonitor monitor) {
+ ProvisioningPlan plan = planner.getInstallPlan(installRoots, profile, monitor);
+ if (!plan.getStatus().isOK())
+ return plan.getStatus();
+ SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
+ sub.setTaskName(NLS.bind(Messages.Director_Task_Installing, profile.getValue(Profile.PROP_INSTALL_FOLDER)));
+ try {
+ IStatus engineResult = engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), sub.newChild(OperationWork));
+ if (!engineResult.isOK())
+ return engineResult;
+ // mark the roots as such
+ for (int i = 0; i < installRoots.length; i++)
+ profile.setInstallableUnitProfileProperty(installRoots[i], IInstallableUnitConstants.PROFILE_ROOT_IU, Boolean.toString(true));
+
+ return engineResult;
+ } finally {
+ sub.done();
+ }
+ }
+
+ public IStatus become(IInstallableUnit target, Profile profile, IProgressMonitor monitor) {
+ ProvisioningPlan plan = planner.getBecomePlan(target, profile, monitor);
+ if (!plan.getStatus().isOK())
+ return plan.getStatus();
+ SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
+ sub.setTaskName(Messages.Director_Task_Updating);
+ try {
+ return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), sub.newChild(OperationWork));
+ } finally {
+ sub.done();
+ }
+ }
+
+ public IStatus uninstall(IInstallableUnit[] uninstallRoots, Profile profile, IProgressMonitor monitor) {
+ ProvisioningPlan plan = planner.getUninstallPlan(uninstallRoots, profile, monitor);
+ if (!plan.getStatus().isOK())
+ return plan.getStatus();
+ SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
+ sub.setTaskName(Messages.Director_Task_Uninstalling);
+ try {
+ return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), sub.newChild(OperationWork));
+ } finally {
+ sub.done();
+ }
+ }
+
+ public IStatus replace(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor) {
+ ProvisioningPlan plan = planner.getReplacePlan(toUninstall, toInstall, profile, monitor);
+ if (!plan.getStatus().isOK())
+ return plan.getStatus();
+ SubMonitor sub = SubMonitor.convert(monitor, OperationWork);
+ sub.setTaskName(Messages.Director_Task_Updating);
+ try {
+ return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), sub.newChild(OperationWork));
+ } finally {
+ sub.done();
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector2.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimplePlanner.java
index c76b1419b..56990566c 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimpleDirector2.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/p2/director/SimplePlanner.java
@@ -8,100 +8,48 @@
******************************************************************************/
package org.eclipse.equinox.p2.director;
-import java.net.URL;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.director.*;
-import org.eclipse.equinox.internal.p2.rollback.FormerState;
-import org.eclipse.equinox.p2.core.eventbus.ProvisioningEventBus;
import org.eclipse.equinox.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.p2.core.location.AgentLocation;
-import org.eclipse.equinox.p2.core.repository.IRepository;
import org.eclipse.equinox.p2.engine.Operand;
import org.eclipse.equinox.p2.engine.Profile;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitConstants;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepository;
import org.eclipse.equinox.p2.metadata.repository.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.resolution.ResolutionHelper;
import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Version;
-public class SimpleDirector2 implements IDirector2 {
+public class SimplePlanner implements IPlanner {
static final int ExpandWork = 10;
- static final int OperationWork = 100;
- public static void tagAsImplementation(IMetadataRepository repository) {
- if (repository != null && repository.getProperties().getProperty(IRepository.IMPLEMENTATION_ONLY_KEY) == null) {
- if (repository.isModifiable())
- repository.getModifiableProperties().setProperty(IRepository.IMPLEMENTATION_ONLY_KEY, Boolean.valueOf(true).toString());
- }
- }
-
- public SimpleDirector2() {
- URL rollbackLocation = null;
- AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(DirectorActivator.context, AgentLocation.class.getName());
- rollbackLocation = agentLocation.getTouchpointDataArea("director");
- ProvisioningEventBus eventBus = (ProvisioningEventBus) ServiceHelper.getService(DirectorActivator.context, ProvisioningEventBus.class.getName());
- IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(DirectorActivator.context, IMetadataRepositoryManager.class.getName());
- IMetadataRepository rollbackRepo = manager.loadRepository(rollbackLocation, null);
- if (rollbackRepo == null)
- rollbackRepo = manager.createRepository(rollbackLocation, "Agent rollback repo", "org.eclipse.equinox.p2.metadata.repository.simpleRepository"); //$NON-NLS-1$//$NON-NLS-2$
- if (rollbackRepo == null)
- throw new IllegalStateException("Unable to open or create Agent's rollback repository");
- tagAsImplementation(rollbackRepo);
- new FormerState(eventBus, rollbackRepo);
- }
-
- //TODO This is really gross!!!!! We need to make things uniform
- private IInstallableUnit[] toArray(Iterator it) {
- ArrayList result = new ArrayList();
- while (it.hasNext()) {
- result.add(it.next());
- }
- return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
- }
-
- protected IInstallableUnit[] createEntryPointHelper(String entryPointName, IInstallableUnit[] content) {
- if (entryPointName == null)
- return content;
- return new IInstallableUnit[] {createEntryPoint(entryPointName, content)};
- }
-
- protected InstallableUnit createEntryPoint(String entryPointName, IInstallableUnit[] content) {
- InstallableUnit result = new InstallableUnit();
- result.setId("entry point " + entryPointId(content)); //$NON-NLS-1$
- result.setVersion(new Version(0, 0, 0, Long.toString(System.currentTimeMillis())));
- result.setRequiredCapabilities(IUTransformationHelper.toRequirements(content, false));
- result.setProperty(IInstallableUnitConstants.ENTRYPOINT_IU_KEY, Boolean.TRUE.toString());
- result.setProperty(IInstallableUnitConstants.NAME, entryPointName);
- return result;
- }
-
- private String entryPointId(IInstallableUnit[] ius) {
- StringBuffer result = new StringBuffer();
- for (int i = 0; i < ius.length; i++) {
- result.append(ius[i].getId());
- if (i < ius.length - 1)
- result.append(", "); //$NON-NLS-1$
- }
- return result.toString();
- }
-
- public DirectorResult install(IInstallableUnit[] installRoots, Profile profile, String entryPointName, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, ExpandWork + OperationWork);
+ public ProvisioningPlan getInstallPlan(IInstallableUnit[] installRoots, Profile profile, IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, ExpandWork);
sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
try {
MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Install_Problems, null);
// Get the list of ius installed in the profile we are installing into
IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
+
+ // If any of these are already installed, return a warning status
+ // specifying that they are already installed.
+ for (int i = 0; i < installRoots.length; i++)
+ for (int j = 0; j < alreadyInstalled.length; j++)
+ if (installRoots[i].equals(alreadyInstalled[j]))
+ result.merge(new Status(IStatus.WARNING, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Already_Installed, installRoots[i].getId())));
+
+ if (!result.isOK()) {
+ return new ProvisioningPlan(result);
+ }
//Compute the complete closure of things to install to successfully install the installRoots.
- NewDependencyExpander expander = new NewDependencyExpander(createEntryPointHelper(entryPointName, installRoots), alreadyInstalled, gatherAvailableInstallableUnits(installRoots), profile, true);
+ NewDependencyExpander expander = new NewDependencyExpander(installRoots, alreadyInstalled, gatherAvailableInstallableUnits(installRoots), profile, true);
// NewDependencyExpander expander = new NewDependencyExpander(installRoots, alreadyInstalled, gatherAvailableInstallableUnits(), profile, true);
IStatus expanderResult = expander.expand(sub.newChild(ExpandWork));
if (!expanderResult.isOK()) {
result.merge(expanderResult);
- return new DirectorResult(result);
+ return new ProvisioningPlan(result);
}
ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
@@ -111,10 +59,7 @@ public class SimpleDirector2 implements IDirector2 {
ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), expander.getRecommendations());
Collection newState = newStateHelper.attachCUs(expander.getAllInstallableUnits());
List newStateOrder = newStateHelper.getSorted();
-
- //TODO Here we need to sort the operations to ensure that the dependents will be treated first (see ensureDependencyOrder)
- sub.setTaskName(NLS.bind(Messages.Director_Task_Installing, entryPointName, profile.getValue(Profile.PROP_INSTALL_FOLDER)));
- return new DirectorResult(Status.OK_STATUS, generateOperations(oldState, newState, oldStateOrder, newStateOrder));
+ return new ProvisioningPlan(Status.OK_STATUS, generateOperations(oldState, newState, oldStateOrder, newStateOrder));
} finally {
sub.done();
}
@@ -163,15 +108,15 @@ public class SimpleDirector2 implements IDirector2 {
return toSort;
}
- public DirectorResult become(IInstallableUnit target, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
+ public ProvisioningPlan getBecomePlan(IInstallableUnit target, Profile profile, IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, ExpandWork);
sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
try {
MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Become_Problems, null);
if (!Boolean.valueOf(target.getProperty(IInstallableUnitConstants.PROFILE_IU_KEY)).booleanValue()) {
result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Unexpected_IU, target.getId())));
- return new DirectorResult(result);
+ return new ProvisioningPlan(result);
}
//TODO Here we need to deal with the change of properties between the two profiles
@@ -192,8 +137,7 @@ public class SimpleDirector2 implements IDirector2 {
ResolutionHelper oldStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
Collection oldState = oldStateHelper.attachCUs(oldIUs);
- sub.setTaskName(Messages.Director_Task_Updating);
- return new DirectorResult(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
+ return new ProvisioningPlan(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
} finally {
sub.done();
}
@@ -213,13 +157,13 @@ public class SimpleDirector2 implements IDirector2 {
return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
}
- public DirectorResult uninstall(IInstallableUnit[] uninstallRoots, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
+ public ProvisioningPlan getUninstallPlan(IInstallableUnit[] uninstallRoots, Profile profile, IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, ExpandWork);
sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
try {
IInstallableUnit[] toReallyUninstall = inProfile(uninstallRoots, profile, true, sub.newChild(0));
if (toReallyUninstall.length == 0) {
- return new DirectorResult(new Status(IStatus.OK, DirectorActivator.PI_DIRECTOR, Messages.Director_Nothing_To_Uninstall));
+ return new ProvisioningPlan(new Status(IStatus.OK, DirectorActivator.PI_DIRECTOR, Messages.Director_Nothing_To_Uninstall));
} else if (toReallyUninstall.length != uninstallRoots.length) {
uninstallRoots = toReallyUninstall;
}
@@ -246,10 +190,9 @@ public class SimpleDirector2 implements IDirector2 {
result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Director_Cannot_Uninstall, uninstallRoots[i])));
}
if (!result.isOK())
- return new DirectorResult(result);
+ return new ProvisioningPlan(result);
- sub.setTaskName(Messages.Director_Task_Uninstalling);
- return new DirectorResult(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
+ return new ProvisioningPlan(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
} finally {
sub.done();
}
@@ -271,14 +214,10 @@ public class SimpleDirector2 implements IDirector2 {
return (IInstallableUnit[]) results.toArray(new IInstallableUnit[results.size()]);
}
- public DirectorResult replace(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor) {
- SubMonitor sub = SubMonitor.convert(monitor, OperationWork + ExpandWork);
+ public ProvisioningPlan getReplacePlan(IInstallableUnit[] toUninstall, IInstallableUnit[] toInstall, Profile profile, IProgressMonitor monitor) {
+ SubMonitor sub = SubMonitor.convert(monitor, ExpandWork);
sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
try {
- MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Director_Replace_Problems, null);
-
- //TODO Need to worry about the entry points
-
//find the things being updated in the profile
IInstallableUnit[] alreadyInstalled = toArray(profile.getInstallableUnits());
IInstallableUnit[] uninstallRoots = toUninstall;
@@ -302,10 +241,30 @@ public class SimpleDirector2 implements IDirector2 {
ResolutionHelper newStateHelper = new ResolutionHelper(profile.getSelectionContext(), null);
Collection newState = newStateHelper.attachCUs(finalExpander.getAllInstallableUnits());
- sub.setTaskName(Messages.Director_Task_Updating);
- return new DirectorResult(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
+ return new ProvisioningPlan(Status.OK_STATUS, generateOperations(oldState, newState, oldStateHelper.getSorted(), newStateHelper.getSorted()));
} finally {
sub.done();
}
}
+
+ public IInstallableUnit[] updatesFor(IInstallableUnit toUpdate) {
+ IInstallableUnit[] allius = gatherAvailableInstallableUnits(null);
+ Set updates = new HashSet();
+ for (int i = 0; i < allius.length; i++) {
+ if (toUpdate.getId().equals(allius[i].getProperty(IInstallableUnitConstants.UPDATE_FROM))) {
+ if (toUpdate.getVersion().compareTo(allius[i].getVersion()) < 0 && new VersionRange(allius[i].getProperty(IInstallableUnitConstants.UPDATE_RANGE)).isIncluded(toUpdate.getVersion()))
+ updates.add(allius[i]);
+ }
+ }
+ return (IInstallableUnit[]) updates.toArray(new IInstallableUnit[updates.size()]);
+ }
+
+ //TODO This is really gross!!!!! We need to make things uniform
+ private IInstallableUnit[] toArray(Iterator it) {
+ ArrayList result = new ArrayList();
+ while (it.hasNext()) {
+ result.add(it.next());
+ }
+ return (IInstallableUnit[]) result.toArray(new IInstallableUnit[result.size()]);
+ }
}

Back to the top