Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PlannerComponent.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java104
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProvisioningPlan.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java237
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/internal/p2/operations/PlannerResolutionJob.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/ArtifactDescriptorQuery.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104.java357
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.java3
58 files changed, 615 insertions, 460 deletions
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
index 9c806e5e2..ab4626bb3 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
@@ -198,7 +198,7 @@ public class ProvisioningHelper {
IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
if (engine == null)
throw new ProvisionException("No director service found.");
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(agent);
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addAll(units.toUnmodifiableSet());
IProvisioningPlan result = planner.getProvisioningPlan(request, context, progress);
@@ -266,7 +266,8 @@ public class ProvisioningHelper {
URI[] artifactRepos = getArtifactRepositories(agent);
URI[] metadataRepos = getMetadataRepositories(agent);
IProvisioningPlan plan = planner.getDiffPlan(profile, targetProfile, new NullProgressMonitor());
- ProvisioningContext context = new ProvisioningContext(metadataRepos);
+ ProvisioningContext context = new ProvisioningContext(agent);
+ context.setMetadataRepositories(metadataRepos);
context.setArtifactRepositories(artifactRepos);
return PlanExecutionHelper.executePlan(plan, engine, context, new NullProgressMonitor());
}
@@ -297,7 +298,7 @@ public class ProvisioningHelper {
IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
if (engine == null)
throw new ProvisionException("No engine service found.");
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(agent);
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.removeAll(units.toUnmodifiableSet());
IProvisioningPlan result = planner.getProvisioningPlan(request, context, progress);
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java
index 26d87faa1..0fa76f6dc 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java
@@ -405,7 +405,8 @@ public class Application implements IApplication {
logFailure(multi);
return EXIT_ERROR;
}
- ProvisioningContext context = new ProvisioningContext(metadataRepositoryLocations);
+ ProvisioningContext context = new ProvisioningContext(agent);
+ context.setMetadataRepositories(metadataRepositoryLocations);
context.setArtifactRepositories(artifactRepositoryLocations);
ProfileChangeRequest request = buildProvisioningRequest(profile, roots, command == COMMAND_INSTALL);
printRequest(request);
@@ -534,7 +535,8 @@ public class Application implements IApplication {
// will set it back later (see bug 269468)
request.setProfileProperty(IProfile.PROP_ROAMING, "false"); //$NON-NLS-1$
- ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ ProvisioningContext context = new ProvisioningContext(agent);
+ context.setMetadataRepositories(new URI[0]);
context.setArtifactRepositories(new URI[0]);
IProvisioningPlan result = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
return PlanExecutionHelper.executePlan(result, engine, context, new NullProgressMonitor());
@@ -546,7 +548,8 @@ public class Application implements IApplication {
private IStatus setRoaming(IProfile profile) {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.setProfileProperty(IProfile.PROP_ROAMING, "true"); //$NON-NLS-1$
- ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ ProvisioningContext context = new ProvisioningContext(agent);
+ context.setMetadataRepositories(new URI[0]);
context.setArtifactRepositories(new URI[0]);
IProvisioningPlan result = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
return PlanExecutionHelper.executePlan(result, engine, context, new NullProgressMonitor());
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
index b9551dab9..047098eca 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
@@ -531,7 +531,8 @@ public class DirectorApplication implements IApplication {
boolean wasRoaming = Boolean.valueOf(profile.getProperty(IProfile.PROP_ROAMING)).booleanValue();
try {
updateRoamingProperties(profile);
- ProvisioningContext context = new ProvisioningContext(metadataRepositoryLocations.toArray(new URI[metadataRepositoryLocations.size()]));
+ ProvisioningContext context = new ProvisioningContext(agent);
+ context.setMetadataRepositories(metadataRepositoryLocations.toArray(new URI[metadataRepositoryLocations.size()]));
context.setArtifactRepositories(artifactRepositoryLocations.toArray(new URI[artifactRepositoryLocations.size()]));
ProfileChangeRequest request = buildProvisioningRequest(profile, installs, uninstalls);
printRequest(request);
@@ -806,7 +807,8 @@ public class DirectorApplication implements IApplication {
throw new CoreException(new Status(IStatus.ERROR, Activator.ID, Messages.Missing_profile));
IProvisioningPlan plan = planner.getDiffPlan(profile, targetProfile, new NullProgressMonitor());
- ProvisioningContext context = new ProvisioningContext(metadataRepositoryLocations.toArray(new URI[metadataRepositoryLocations.size()]));
+ ProvisioningContext context = new ProvisioningContext(agent);
+ context.setMetadataRepositories(metadataRepositoryLocations.toArray(new URI[metadataRepositoryLocations.size()]));
context.setArtifactRepositories(artifactRepositoryLocations.toArray(new URI[artifactRepositoryLocations.size()]));
executePlan(context, plan);
}
@@ -900,7 +902,8 @@ public class DirectorApplication implements IApplication {
private IStatus setRoaming(IProfile profile) {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.setProfileProperty(IProfile.PROP_ROAMING, "true"); //$NON-NLS-1$
- ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ ProvisioningContext context = new ProvisioningContext(agent);
+ context.setMetadataRepositories(new URI[0]);
context.setArtifactRepositories(new URI[0]);
IProvisioningPlan result = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
return PlanExecutionHelper.executePlan(result, engine, context, new NullProgressMonitor());
@@ -951,7 +954,8 @@ public class DirectorApplication implements IApplication {
// will set it back later (see bug 269468)
request.setProfileProperty(IProfile.PROP_ROAMING, "false"); //$NON-NLS-1$
- ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ ProvisioningContext context = new ProvisioningContext(agent);
+ context.setMetadataRepositories(new URI[0]);
context.setArtifactRepositories(new URI[0]);
IProvisioningPlan result = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
IStatus status = PlanExecutionHelper.executePlan(result, engine, context, new NullProgressMonitor());
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PlannerComponent.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PlannerComponent.java
index 0a3079c4b..515e795fa 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PlannerComponent.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/PlannerComponent.java
@@ -12,9 +12,6 @@ package org.eclipse.equinox.internal.p2.director;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
-import org.eclipse.equinox.p2.engine.IEngine;
-import org.eclipse.equinox.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
/**
* A service factory that provides planner implementations
@@ -22,9 +19,6 @@ import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
public class PlannerComponent implements IAgentServiceFactory {
public Object createService(IProvisioningAgent agent) {
- IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
- IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
- IMetadataRepositoryManager repoManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
- return new SimplePlanner(engine, profileRegistry, repoManager);
+ return new SimplePlanner(agent);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
index bffea53c7..ccf27db7b 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
@@ -11,11 +11,6 @@
******************************************************************************/
package org.eclipse.equinox.internal.p2.director;
-import org.eclipse.equinox.p2.planner.ProfileInclusionRules;
-
-import org.eclipse.equinox.p2.metadata.MetadataFactory;
-import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
-
import java.lang.reflect.Method;
import java.net.URI;
import java.util.*;
@@ -26,16 +21,12 @@ import org.eclipse.equinox.internal.p2.metadata.query.UpdateQuery;
import org.eclipse.equinox.internal.p2.rollback.FormerState;
import org.eclipse.equinox.internal.provisional.p2.director.*;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery;
import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.planner.IPlanner;
-import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
+import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.planner.*;
import org.eclipse.equinox.p2.query.*;
-import org.eclipse.equinox.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.util.NLS;
public class SimplePlanner implements IPlanner {
@@ -47,8 +38,7 @@ public class SimplePlanner implements IPlanner {
private static final String ID_IU_FOR_ACTIONS = "org.eclipse.equinox.p2.engine.actions.root"; //$NON-NLS-1$
private static final String EXPLANATION = "org.eclipse.equinox.p2.director.explain"; //$NON-NLS-1$
private static final String CONSIDER_METAREQUIREMENTS = "org.eclipse.equinox.p2.planner.resolveMetaRequirements"; //$NON-NLS-1$
-
- private final IMetadataRepositoryManager repoManager;
+ private final IProvisioningAgent agent;
private final IProfileRegistry profileRegistry;
private final IEngine engine;
@@ -194,7 +184,7 @@ public class SimplePlanner implements IPlanner {
sub.setTaskName(Messages.Director_Task_Resolving_Dependencies);
try {
IProfileChangeRequest profileChangeRequest = FormerState.generateProfileDeltaChangeRequest(currentProfile, targetProfile);
- ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ ProvisioningContext context = new ProvisioningContext(agent);
if (context.getProperty(INCLUDE_PROFILE_IUS) == null)
context.setProperty(INCLUDE_PROFILE_IUS, Boolean.FALSE.toString());
context.setExtraInstallableUnits(Arrays.asList(targetProfile.available(QueryUtil.createIUAnyQuery(), null).toArray(IInstallableUnit.class)));
@@ -224,7 +214,7 @@ public class SimplePlanner implements IPlanner {
return result;
}
- private IInstallableUnit[] gatherAvailableInstallableUnits(IInstallableUnit[] additionalSource, URI[] repositories, ProvisioningContext context, IProgressMonitor monitor) {
+ private IInstallableUnit[] gatherAvailableInstallableUnits(IInstallableUnit[] additionalSource, ProvisioningContext context, IProgressMonitor monitor) {
Map<String, IInstallableUnit> resultsMap = new HashMap<String, IInstallableUnit>();
if (additionalSource != null) {
for (int i = 0; i < additionalSource.length; i++) {
@@ -232,34 +222,23 @@ public class SimplePlanner implements IPlanner {
resultsMap.put(key, additionalSource[i]);
}
}
- if (context != null) {
+ if (context == null) {
+ context = new ProvisioningContext(agent);
+ } else {
for (IInstallableUnit iu : context.getExtraInstallableUnits()) {
String key = iu.getId() + '_' + iu.getVersion().toString();
resultsMap.put(key, iu);
}
}
-
- if (repositories == null)
- repositories = repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
-
- SubMonitor sub = SubMonitor.convert(monitor, repositories.length * 200);
- for (int i = 0; i < repositories.length; i++) {
- try {
- if (sub.isCanceled())
- throw new OperationCanceledException();
-
- IMetadataRepository repository = repoManager.loadRepository(repositories[i], sub.newChild(100));
- IQueryResult<IInstallableUnit> matches = repository.query(QueryUtil.createIUQuery(null, VersionRange.emptyRange), sub.newChild(100));
- for (Iterator<IInstallableUnit> it = matches.iterator(); it.hasNext();) {
- IInstallableUnit iu = it.next();
- String key = iu.getId() + "_" + iu.getVersion().toString(); //$NON-NLS-1$
- IInstallableUnit currentIU = resultsMap.get(key);
- if (currentIU == null || hasHigherFidelity(iu, currentIU))
- resultsMap.put(key, iu);
- }
- } catch (ProvisionException e) {
- //skip unreadable repositories
- }
+ SubMonitor sub = SubMonitor.convert(monitor, 1000);
+ IQueryable<IInstallableUnit> queryable = context.getMetadata(sub.newChild(500));
+ IQueryResult<IInstallableUnit> matches = queryable.query(QueryUtil.createIUQuery(null, VersionRange.emptyRange), sub.newChild(500));
+ for (Iterator<IInstallableUnit> it = matches.iterator(); it.hasNext();) {
+ IInstallableUnit iu = it.next();
+ String key = iu.getId() + "_" + iu.getVersion().toString(); //$NON-NLS-1$
+ IInstallableUnit currentIU = resultsMap.get(key);
+ if (currentIU == null || hasHigherFidelity(iu, currentIU))
+ resultsMap.put(key, iu);
}
sub.done();
Collection<IInstallableUnit> results = resultsMap.values();
@@ -272,13 +251,13 @@ public class SimplePlanner implements IPlanner {
return false;
}
- public SimplePlanner(IEngine engine, IProfileRegistry profileRegistry, IMetadataRepositoryManager repoManager) {
+ public SimplePlanner(IProvisioningAgent agent) {
+ Assert.isNotNull(agent);
+ this.agent = agent;
+ this.engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
+ this.profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
Assert.isNotNull(engine);
Assert.isNotNull(profileRegistry);
- Assert.isNotNull(repoManager);
- this.engine = engine;
- this.profileRegistry = profileRegistry;
- this.repoManager = repoManager;
}
private boolean satisfyMetaRequirements(Map<String, String> props) {
@@ -302,7 +281,6 @@ public class SimplePlanner implements IPlanner {
Object[] updatedPlan = updatePlannerInfo(profileChangeRequest, context);
- URI[] metadataRepositories = (context != null) ? context.getMetadataRepositories() : null;
Dictionary<String, String> newSelectionContext = createSelectionContext(profileChangeRequest.getProfileProperties());
List<IInstallableUnit> extraIUs = new ArrayList<IInstallableUnit>(profileChangeRequest.getAdditions());
@@ -313,7 +291,7 @@ public class SimplePlanner implements IPlanner {
extraIUs.add(itor.next());
}
- IInstallableUnit[] availableIUs = gatherAvailableInstallableUnits(extraIUs.toArray(new IInstallableUnit[extraIUs.size()]), metadataRepositories, context, sub.newChild(ExpandWork / 4));
+ IInstallableUnit[] availableIUs = gatherAvailableInstallableUnits(extraIUs.toArray(new IInstallableUnit[extraIUs.size()]), context, sub.newChild(ExpandWork / 4));
Slicer slicer = new Slicer(new QueryableArray(availableIUs), newSelectionContext, satisfyMetaRequirements(profileChangeRequest.getProfileProperties()));
IQueryable<IInstallableUnit> slice = slicer.slice(new IInstallableUnit[] {(IInstallableUnit) updatedPlan[0]}, sub.newChild(ExpandWork / 4));
@@ -545,7 +523,8 @@ public class SimplePlanner implements IPlanner {
agentRequest.remove(previousMetaRequirementIU);
agentRequest.add(metaRequirementIU);
- ProvisioningContext agentCtx = new ProvisioningContext(new URI[0]);
+ ProvisioningContext agentCtx = new ProvisioningContext(agent);
+ agentCtx.setMetadataRepositories(new URI[0]);
ArrayList<IInstallableUnit> extraIUs = new ArrayList<IInstallableUnit>(unattachedState);
agentCtx.setExtraInstallableUnits(extraIUs);
Object agentSolution = getSolutionFor(agentRequest, agentCtx, monitor.newChild(3));
@@ -604,7 +583,8 @@ public class SimplePlanner implements IPlanner {
}
private ProvisioningContext createNoRepoContext(ProfileChangeRequest request) {
- ProvisioningContext noRepoContext = new ProvisioningContext(new URI[0]);
+ ProvisioningContext noRepoContext = new ProvisioningContext(agent);
+ noRepoContext.setMetadataRepositories(new URI[0]);
noRepoContext.setArtifactRepositories(new URI[0]);
noRepoContext.setProperty(INCLUDE_PROFILE_IUS, Boolean.FALSE.toString());
noRepoContext.setExtraInstallableUnits(new ArrayList<IInstallableUnit>(request.getProfile().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor()).toUnmodifiableSet()));
@@ -735,27 +715,15 @@ public class SimplePlanner implements IPlanner {
public IQueryResult<IInstallableUnit> updatesFor(IInstallableUnit toUpdate, ProvisioningContext context, IProgressMonitor monitor) {
Map<String, IInstallableUnit> resultsMap = new HashMap<String, IInstallableUnit>();
- URI[] repositories = context.getMetadataRepositories();
- if (repositories == null)
- repositories = repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
-
- SubMonitor sub = SubMonitor.convert(monitor, repositories.length * 200);
- for (int i = 0; i < repositories.length; i++) {
- try {
- if (sub.isCanceled())
- throw new OperationCanceledException();
- IMetadataRepository repository = repoManager.loadRepository(repositories[i], sub.newChild(100));
- IQueryResult<IInstallableUnit> matches = repository.query(new UpdateQuery(toUpdate), sub.newChild(100));
- for (Iterator<IInstallableUnit> it = matches.iterator(); it.hasNext();) {
- IInstallableUnit iu = it.next();
- String key = iu.getId() + "_" + iu.getVersion().toString(); //$NON-NLS-1$
- IInstallableUnit currentIU = resultsMap.get(key);
- if (currentIU == null || hasHigherFidelity(iu, currentIU))
- resultsMap.put(key, iu);
- }
- } catch (ProvisionException e) {
- //skip unreadable repositories
- }
+ SubMonitor sub = SubMonitor.convert(monitor, 1000);
+ IQueryable<IInstallableUnit> queryable = context.getMetadata(sub.newChild(500));
+ IQueryResult<IInstallableUnit> matches = queryable.query(new UpdateQuery(toUpdate), sub.newChild(500));
+ for (Iterator<IInstallableUnit> it = matches.iterator(); it.hasNext();) {
+ IInstallableUnit iu = it.next();
+ String key = iu.getId() + "_" + iu.getVersion().toString(); //$NON-NLS-1$
+ IInstallableUnit currentIU = resultsMap.get(key);
+ if (currentIU == null || hasHigherFidelity(iu, currentIU))
+ resultsMap.put(key, iu);
}
sub.done();
return new CollectionResult<IInstallableUnit>(resultsMap.values());
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java
index 29671627e..437b20013 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DebugHelper.java
@@ -124,11 +124,7 @@ public class DebugHelper {
}
public static String formatContext(ProvisioningContext context) {
- StringBuffer buffer = new StringBuffer();
- buffer.append("{artifactRepos=" + DebugHelper.formatArray(Arrays.asList(context.getArtifactRepositories()), true, false)); //$NON-NLS-1$
- buffer.append(", metadataRepos=" + DebugHelper.formatArray(Arrays.asList(context.getMetadataRepositories()), true, false)); //$NON-NLS-1$
- buffer.append(", properties=" + context.getProperties() + "}"); //$NON-NLS-1$ //$NON-NLS-2$
- return buffer.toString();
+ return context.toString();
}
public static String formatAction(ProvisioningAction action, Map<String, Object> parameters) {
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
index 3d40efa56..b1bd5aaa1 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java
@@ -12,41 +12,23 @@
package org.eclipse.equinox.internal.p2.engine;
import java.net.URI;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.engine.phases.Collect;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.*;
public class DownloadManager {
private ProvisioningContext provContext = null;
ArrayList<IArtifactRequest> requestsToProcess = new ArrayList<IArtifactRequest>();
+ private IProvisioningAgent agent = null;
- private static final String FILE_PROTOCOL = "file"; //$NON-NLS-1$
-
- /**
- * This Comparator sorts the repositories such that �local� repositories are first
- */
- private static final Comparator<URI> LOCAL_FIRST_COMPARATOR = new Comparator<URI>() {
-
- public int compare(URI arg0, URI arg1) {
- String protocol0 = arg0.getScheme();
- String protocol1 = arg1.getScheme();
-
- if (FILE_PROTOCOL.equals(protocol0) && !FILE_PROTOCOL.equals(protocol1))
- return -1;
- if (!FILE_PROTOCOL.equals(protocol0) && FILE_PROTOCOL.equals(protocol1))
- return 1;
- return 0;
- }
- };
- private final IArtifactRepositoryManager repositoryManager;
-
- public DownloadManager(ProvisioningContext context, IArtifactRepositoryManager repositoryManager) {
+ public DownloadManager(ProvisioningContext context, IProvisioningAgent agent) {
provContext = context;
- this.repositoryManager = repositoryManager;
+ this.agent = agent;
}
/*
@@ -78,20 +60,23 @@ public class DownloadManager {
* Start the downloads. Return a status message indicating success or failure of the overall operation
*/
public IStatus start(IProgressMonitor monitor) {
- SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.download_artifact, requestsToProcess.size());
+ SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.download_artifact, 1000);
try {
if (requestsToProcess.isEmpty())
return Status.OK_STATUS;
- URI[] repositories = null;
- if (provContext == null || provContext.getArtifactRepositories() == null)
- repositories = repositoryManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
- else
- repositories = provContext.getArtifactRepositories();
+ if (provContext == null)
+ provContext = new ProvisioningContext(agent);
+
+ if (requestsToProcess.isEmpty())
+ return Status.OK_STATUS;
+
+ // Should be using queryable here
+ URI[] repositories = provContext.getArtifactRepositories();
+ subMonitor.worked(500);
if (repositories.length == 0)
return new Status(IStatus.ERROR, EngineActivator.ID, Messages.download_no_repository, new Exception(Collect.NO_ARTIFACT_REPOSITORIES_AVAILABLE));
- Arrays.sort(repositories, LOCAL_FIRST_COMPARATOR);
- fetch(repositories, subMonitor);
+ fetch(repositories, subMonitor.newChild(500));
return overallStatus(monitor);
} finally {
subMonitor.done();
@@ -99,6 +84,7 @@ public class DownloadManager {
}
private void fetch(URI[] repositories, SubMonitor monitor) {
+ IArtifactRepositoryManager repositoryManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
for (int i = 0; i < repositories.length && !requestsToProcess.isEmpty() && !monitor.isCanceled(); i++) {
try {
IArtifactRepository current = repositoryManager.loadRepository(repositories[i], monitor.newChild(0));
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java
index e0e393e37..ae5be5835 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.engine;
-import org.eclipse.equinox.p2.engine.PhaseSetFactory;
-
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
@@ -57,7 +55,7 @@ public class Engine implements IEngine {
IProvisioningEventBus eventBus = (IProvisioningEventBus) agent.getService(IProvisioningEventBus.SERVICE_NAME);
if (context == null)
- context = new ProvisioningContext();
+ context = new ProvisioningContext(agent);
if (monitor == null)
monitor = new NullProgressMonitor();
@@ -108,7 +106,7 @@ public class Engine implements IEngine {
checkArguments(iprofile, phaseSet, operands, context, monitor);
if (context == null)
- context = new ProvisioningContext();
+ context = new ProvisioningContext(agent);
if (monitor == null)
monitor = new NullProgressMonitor();
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProvisioningPlan.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProvisioningPlan.java
index 379ef2664..72f1ade0b 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProvisioningPlan.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProvisioningPlan.java
@@ -36,11 +36,12 @@ public class ProvisioningPlan implements IProvisioningPlan {
}
public ProvisioningPlan(IStatus status, IProfile profile, Operand[] operands, ProvisioningContext context, IProvisioningPlan installerPlan) {
+ Assert.isNotNull(profile);
this.status = status;
this.profile = profile;
if (operands != null)
this.operands.addAll(Arrays.asList(operands));
- this.context = (context == null) ? new ProvisioningContext() : context;
+ this.context = (context == null) ? new ProvisioningContext(profile.getProvisioningAgent()) : context;
this.installerPlan = installerPlan;
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java
index 6a32e8770..af6060481 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/phases/Collect.java
@@ -20,7 +20,6 @@ import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.ITouchpointType;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
/**
@@ -69,9 +68,8 @@ public class Collect extends InstallableUnitPhase {
List<IArtifactRequest[]> artifactRequests = (List<IArtifactRequest[]>) parameters.get(PARM_ARTIFACT_REQUESTS);
ProvisioningContext context = (ProvisioningContext) parameters.get(PARM_CONTEXT);
IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
- IArtifactRepositoryManager repositoryManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
- DownloadManager dm = new DownloadManager(context, repositoryManager);
+ DownloadManager dm = new DownloadManager(context, agent);
for (IArtifactRequest[] requests : artifactRequests) {
dm.add(requests);
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java
index 44e95b86f..68dde447b 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningContext.java
@@ -13,8 +13,18 @@ package org.eclipse.equinox.p2.engine;
import java.net.URI;
import java.util.*;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.IRequirement;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.engine.DebugHelper;
+import org.eclipse.equinox.internal.p2.engine.EngineActivator;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
/**
* A provisioning context defines the scope in which a provisioning operation
@@ -23,30 +33,71 @@ import org.eclipse.equinox.p2.metadata.IRequirement;
* @since 2.0
*/
public class ProvisioningContext {
+ private IProvisioningAgent agent;
private Collection<IRequirement> additionalRequirements;
private URI[] artifactRepositories; //artifact repositories to consult
private final List<IInstallableUnit> extraIUs = Collections.synchronizedList(new ArrayList<IInstallableUnit>());
private URI[] metadataRepositories; //metadata repositories to consult
private final Map<String, String> properties = new HashMap<String, String>();
+ private static final String FILE_PROTOCOL = "file"; //$NON-NLS-1$
+
/**
- * Creates a new provisioning context that includes all available metadata and
- * artifact repositories.
+ * This Comparator sorts the repositories such that local repositories are first
+ */
+ private static final Comparator<URI> LOCAL_FIRST_COMPARATOR = new Comparator<URI>() {
+
+ public int compare(URI arg0, URI arg1) {
+ String protocol0 = arg0.getScheme();
+ String protocol1 = arg1.getScheme();
+
+ if (FILE_PROTOCOL.equals(protocol0) && !FILE_PROTOCOL.equals(protocol1))
+ return -1;
+ if (!FILE_PROTOCOL.equals(protocol0) && FILE_PROTOCOL.equals(protocol1))
+ return 1;
+ return 0;
+ }
+ };
+
+ /**
+ * Instructs the provisioning context to follow repository references when providing
+ * queryables for obtaining metadata and artifacts.
+ *
+ * @see #getMetadata(IProgressMonitor)
+ * @see #getArtifacts(IProgressMonitor)
+ */
+ public static final String FOLLOW_REPOSITORY_REFERENCES = "org.eclipse.equinox.p2.director.followRepositoryReferences"; //$NON-NLS-1$
+
+ /**
+ * @deprecated
+ * @see #ProvisioningContext(IProvisioningAgent)
+ * @see #setMetadataRepositories(URI[])
*/
public ProvisioningContext() {
- // null repos means look at them all
- metadataRepositories = null;
- artifactRepositories = null;
+ this((IProvisioningAgent) ServiceHelper.getService(EngineActivator.getContext(), IProvisioningAgent.SERVICE_NAME));
}
/**
- * Creates a new provisioning context that includes only the specified metadata
- * repositories, and all available artifact repositories.
- *
- * @param metadataRepositories the metadata repositories to include
+ * @deprecated
+ * @see #ProvisioningContext(IProvisioningAgent)
+ * @see #setMetadataRepositories(URI[])
*/
public ProvisioningContext(URI[] metadataRepositories) {
- this.metadataRepositories = metadataRepositories;
+ this();
+ setMetadataRepositories(metadataRepositories);
+ }
+
+ /**
+ * Creates a new provisioning context that includes all available metadata and
+ * artifact repositories available to the specified provisioning agent.
+ *
+ * @param agent the provisioning agent from which to obtain any necessary services.
+ */
+ public ProvisioningContext(IProvisioningAgent agent) {
+ this.agent = agent;
+ // null repos means look at them all
+ metadataRepositories = null;
+ artifactRepositories = null;
}
/**
@@ -61,14 +112,117 @@ public class ProvisioningContext {
}
/**
- * Returns the locations of the artifact repositories that are included in this
- * provisioning context, or <code>null</code> to indicate that all available
- * artifact repositories are included
+ * Returns a queryable that can be used to obtain any artifact keys that
+ * are needed for the provisioning operation.
*
- * @return The artifact repositories to use, or <code>null</code>
+ * @param monitor a progress monitor to be used when creating the queryable
+ * @return a queryable that can be used to query available artifact keys.
+ *
+ * @see #setArtifactRepositories(URI[])
+ * @see #FOLLOW_REPOSITORY_REFERENCES
*/
- public URI[] getArtifactRepositories() {
- return artifactRepositories;
+ public IQueryable<IArtifactKey> getArtifactKeys(IProgressMonitor monitor) {
+ IArtifactRepositoryManager repoManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ URI[] repositories = getArtifactRepositories();
+ List<IArtifactRepository> repos = new ArrayList<IArtifactRepository>();
+ SubMonitor sub = SubMonitor.convert(monitor, repositories.length * 100);
+ try {
+ for (int i = 0; i < repositories.length; i++) {
+ if (sub.isCanceled())
+ throw new OperationCanceledException();
+ repos.add(repoManager.loadRepository(repositories[i], sub.newChild(100)));
+ }
+ } catch (ProvisionException e) {
+ //skip unreadable repositories
+ }
+ return QueryUtil.compoundQueryable(repos);
+ }
+
+ /**
+ * Returns a queryable that can be used to obtain any artifact descriptors that
+ * are needed for the provisioning operation.
+ *
+ * @param monitor a progress monitor to be used when creating the queryable
+ * @return a queryable that can be used to query available artifact descriptors.
+ *
+ * @see #setArtifactRepositories(URI[])
+ * @see #FOLLOW_REPOSITORY_REFERENCES
+ */
+ public IQueryable<IArtifactDescriptor> getArtifactDescriptors(IProgressMonitor monitor) {
+ IArtifactRepositoryManager repoManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ URI[] repositories = getArtifactRepositories();
+ List<IQueryable<IArtifactDescriptor>> descriptorQueryables = new ArrayList<IQueryable<IArtifactDescriptor>>();
+ SubMonitor sub = SubMonitor.convert(monitor, repositories.length * 100);
+ try {
+ for (int i = 0; i < repositories.length; i++) {
+ if (sub.isCanceled())
+ throw new OperationCanceledException();
+ IArtifactRepository repo = repoManager.loadRepository(repositories[i], sub.newChild(100));
+ descriptorQueryables.add(repo.descriptorQueryable());
+ }
+ } catch (ProvisionException e) {
+ //skip unreadable repositories
+ }
+ return QueryUtil.compoundQueryable(descriptorQueryables);
+ }
+
+ /**
+ * Returns a queryable that can be used to obtain any artifact repositories that
+ * are needed for the provisioning operation.
+ *
+ * @param monitor a progress monitor to be used when creating the queryable
+ * @return a queryable that can be used to query available artifact repositories.
+ *
+ * @see #setArtifactRepositories(URI[])
+ * @see #FOLLOW_REPOSITORY_REFERENCES
+ */
+ public IQueryable<IArtifactRepository> getArtifactRepositories(IProgressMonitor monitor) {
+ IArtifactRepositoryManager repoManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ URI[] repositories = getArtifactRepositories();
+ final List<IArtifactRepository> repos = new ArrayList<IArtifactRepository>();
+ SubMonitor sub = SubMonitor.convert(monitor, repositories.length * 100);
+ try {
+ for (int i = 0; i < repositories.length; i++) {
+ if (sub.isCanceled())
+ throw new OperationCanceledException();
+ repos.add(repoManager.loadRepository(repositories[i], sub.newChild(100)));
+ }
+ } catch (ProvisionException e) {
+ //skip unreadable repositories
+ }
+ return new IQueryable<IArtifactRepository>() {
+ public IQueryResult<IArtifactRepository> query(IQuery<IArtifactRepository> query, IProgressMonitor mon) {
+ return query.perform(repos.iterator());
+ }
+
+ };
+ }
+
+ /**
+ * Returns a queryable that can be used to obtain any metadata (installable units)
+ * that are needed for the provisioning operation.
+ *
+ * @param monitor a progress monitor to be used when creating the queryable
+ * @return a queryable that can be used to query available metadata.
+ *
+ * @see #setMetadataRepositories(URI[])
+ * @see #FOLLOW_REPOSITORY_REFERENCES
+ */
+ public IQueryable<IInstallableUnit> getMetadata(IProgressMonitor monitor) {
+ IMetadataRepositoryManager repoManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ URI[] repositories = metadataRepositories == null ? repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL) : metadataRepositories;
+ List<IMetadataRepository> repos = new ArrayList<IMetadataRepository>();
+ SubMonitor sub = SubMonitor.convert(monitor, repositories.length * 100);
+ try {
+ for (int i = 0; i < repositories.length; i++) {
+ if (sub.isCanceled())
+ throw new OperationCanceledException();
+ repos.add(repoManager.loadRepository(repositories[i], sub.newChild(100)));
+ }
+ } catch (ProvisionException e) {
+ //skip unreadable repositories
+ }
+ return QueryUtil.compoundQueryable(repos);
}
/**
@@ -84,17 +238,6 @@ public class ProvisioningContext {
}
/**
- * Returns the locations of the metadata repositories that are included in this
- * provisioning context, or <code>null</code> to indicate that all available
- * metadata repositories are included
- *
- * @return The metadata repositories to use, or <code>null</code>
- */
- public URI[] getMetadataRepositories() {
- return metadataRepositories;
- }
-
- /**
* Returns the properties that are defined in this context. Context properties can
* be used to influence the behavior of either the planner or engine.
*
@@ -133,6 +276,14 @@ public class ProvisioningContext {
}
/**
+ * Sets the metadata repositories to consult when performing an operation.
+ * @param metadataRepositories the metadata repository locations
+ */
+ public void setMetadataRepositories(URI[] metadataRepositories) {
+ this.metadataRepositories = metadataRepositories;
+ }
+
+ /**
* Sets the list of additional installable units that should be considered as
* available for installation by the planner. This method has no effect on the
* execution of the engine.
@@ -154,4 +305,32 @@ public class ProvisioningContext {
public void setProperty(String key, String value) {
properties.put(key, value);
}
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("{artifactRepos=" + DebugHelper.formatArray(Arrays.asList(artifactRepositories), true, false)); //$NON-NLS-1$
+ buffer.append(", metadataRepos=" + DebugHelper.formatArray(Arrays.asList(metadataRepositories), true, false)); //$NON-NLS-1$
+ buffer.append(", properties=" + getProperties() + "}"); //$NON-NLS-1$ //$NON-NLS-2$
+ return buffer.toString();
+ }
+
+ /**
+ * Return the array of repository locations for artifact repositories.
+ * @return an array of repository locations. This is never <code>null</code>.
+ *
+ * @deprecated
+ * @see #getArtifactRepositories()
+ * @see #getArtifactDescriptors(IProgressMonitor)
+ * @see #getArtifactKeys(IProgressMonitor)
+ */
+ public URI[] getArtifactRepositories() {
+ IArtifactRepositoryManager repoManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ URI[] repositories = artifactRepositories == null ? repoManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL) : artifactRepositories;
+ Arrays.sort(repositories, LOCAL_FIRST_COMPARATOR);
+ return repositories;
+ }
}
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
index 23c46986d..c8cd61cc6 100644
--- 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
@@ -40,7 +40,7 @@ public class PlannerResolutionJob extends ProvisioningJob implements IProfileCha
this.request = request;
this.profileId = profileId;
if (provisioningContext == null)
- this.provisioningContext = new ProvisioningContext();
+ this.provisioningContext = new ProvisioningContext(session.getProvisioningAgent());
else
this.provisioningContext = provisioningContext;
Assert.isNotNull(additionalStatus);
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java
index b01fd26c1..ae6519cfc 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java
@@ -96,7 +96,7 @@ public abstract class ProfileChangeOperation implements IProfileChangeJob {
protected ProfileChangeOperation(ProvisioningSession session) {
this.session = session;
this.profileId = IProfileRegistry.SELF;
- this.context = new ProvisioningContext();
+ this.context = new ProvisioningContext(session.getProvisioningAgent());
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
index f7806aaa3..29dc5efe5 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
@@ -217,7 +217,8 @@ public class ProfileSynchronizer {
//ignore
}
}
- ProvisioningContext result = new ProvisioningContext(repoURLs.toArray(new URI[repoURLs.size()]));
+ ProvisioningContext result = new ProvisioningContext(agent);
+ result.setMetadataRepositories(repoURLs.toArray(new URI[repoURLs.size()]));
result.setArtifactRepositories(new URI[0]);
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
index 346998652..328d0a757 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.equinox.p2.internal.repository.tools;
-import org.eclipse.equinox.p2.query.QueryUtil;
-
import java.net.URISyntaxException;
import java.util.*;
import org.eclipse.core.runtime.*;
@@ -29,6 +27,7 @@ import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.planner.IPlanner;
import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
@@ -95,8 +94,7 @@ public class Repo2Runnable extends AbstractApplication implements IApplication {
List<IArtifactRequest> artifactRequests = (List<IArtifactRequest>) parameters.get(NATIVE_ARTIFACTS);
ProvisioningContext context = (ProvisioningContext) parameters.get(PARM_CONTEXT);
IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
- IArtifactRepositoryManager repositoryManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
- DownloadManager dm = new DownloadManager(context, repositoryManager);
+ DownloadManager dm = new DownloadManager(context, agent);
for (IArtifactRequest request : artifactRequests) {
dm.add(request);
}
@@ -128,7 +126,7 @@ public class Repo2Runnable extends AbstractApplication implements IApplication {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.setAbsoluteMode(true);
request.addAll(processedIUs);
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(agent);
IEngine engine = (IEngine) agent.getService(IEngine.SERVICE_NAME);
if (engine == null)
throw new ProvisionException(Messages.exception_noEngineService);
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/ArtifactDescriptorQuery.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/ArtifactDescriptorQuery.java
index 56337f1be..26e096645 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/ArtifactDescriptorQuery.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/p2/repository/artifact/ArtifactDescriptorQuery.java
@@ -12,12 +12,12 @@
package org.eclipse.equinox.p2.repository.artifact;
-import org.eclipse.equinox.p2.query.ExpressionMatchQuery;
-
import java.util.*;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.metadata.expression.*;
+import org.eclipse.equinox.p2.query.ExpressionMatchQuery;
/**
* A general purpose query for matching {@link IArtifactDescriptor} instances
@@ -74,6 +74,15 @@ public class ArtifactDescriptorQuery extends ExpressionMatchQuery<IArtifactDescr
}
/**
+ * The query will match descriptors whose <code>id</code> and <code>versionRange</code>
+ * match the supplied key
+ * @param key the artifact key to match. Cannot be <code>null</code>.
+ */
+ public ArtifactDescriptorQuery(IArtifactKey key) {
+ super(IArtifactDescriptor.class, createExpression(key.getId(), new VersionRange(key.getVersion(), true, key.getVersion(), true), null, null));
+ }
+
+ /**
* The query will match descriptors with the given <code>id</code>, <code>versionRange</code>,
* <code>format</code>, and <code>properties</code>.
* @param id the descriptor id to match. Can not be <code>null</code>
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java
index 0a8cdf778..168702de8 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java
@@ -139,10 +139,12 @@ public abstract class AbstractProvisioningUITest extends AbstractProvisioningTes
req.setInstallableUnitProfileProperty(iu, IProfile.PROP_PROFILE_LOCKED_IU, new Integer(IProfile.LOCK_UNINSTALL | IProfile.LOCK_UPDATE).toString());
}
// Use an empty provisioning context to prevent repo access
- IProvisioningPlan plan = getPlanner(getSession().getProvisioningAgent()).getProvisioningPlan(req, new ProvisioningContext(new URI[] {}), getMonitor());
+ ProvisioningContext context = new ProvisioningContext(getAgent());
+ context.setMetadataRepositories(new URI[] {});
+ IProvisioningPlan plan = getPlanner(getSession().getProvisioningAgent()).getProvisioningPlan(req, context, getMonitor());
if (plan.getStatus().getSeverity() == IStatus.ERROR || plan.getStatus().getSeverity() == IStatus.CANCEL)
return plan.getStatus();
- return getSession().performProvisioningPlan(plan, PhaseSetFactory.createDefaultPhaseSet(), new ProvisioningContext(), getMonitor());
+ return getSession().performProvisioningPlan(plan, PhaseSetFactory.createDefaultPhaseSet(), new ProvisioningContext(getAgent()), getMonitor());
}
protected IInstallableUnit createNamedIU(String id, String name, Version version, boolean isCategory) {
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java
index efefd7c00..6394a9903 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/operations/SizingTest.java
@@ -25,9 +25,9 @@ public class SizingTest extends AbstractProvisioningUITest {
IProfile testProfile = createProfile(profileId);
ProfileChangeRequest request = new ProfileChangeRequest(testProfile);
IProvisioningPlan plan = null;
- plan = getPlanner(getSession().getProvisioningAgent()).getProvisioningPlan(request, new ProvisioningContext(), getMonitor());
+ plan = getPlanner(getSession().getProvisioningAgent()).getProvisioningPlan(request, new ProvisioningContext(getAgent()), getMonitor());
long size = ProvUI.SIZE_NOTAPPLICABLE;
- size = ProvUI.getSize(getEngine(), plan, new ProvisioningContext(), getMonitor());
+ size = ProvUI.getSize(getEngine(), plan, new ProvisioningContext(getAgent()), getMonitor());
assertEquals("1.0", 0, size);
}
@@ -41,9 +41,9 @@ public class SizingTest extends AbstractProvisioningUITest {
ProfileChangeRequest request = new ProfileChangeRequest(testProfile);
request.add(f1);
IProvisioningPlan plan = null;
- plan = getPlanner(getSession().getProvisioningAgent()).getProvisioningPlan(request, new ProvisioningContext(), getMonitor());
+ plan = getPlanner(getSession().getProvisioningAgent()).getProvisioningPlan(request, new ProvisioningContext(getAgent()), getMonitor());
long size = ProvUI.SIZE_NOTAPPLICABLE;
- size = ProvUI.getSize(getEngine(), plan, new ProvisioningContext(), getMonitor());
+ size = ProvUI.getSize(getEngine(), plan, new ProvisioningContext(getAgent()), getMonitor());
assertEquals("1.0", 0, size);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java
index 52fb22815..d70c3044d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java
@@ -54,7 +54,8 @@ public class Bug265577 extends AbstractProvisioningTest {
private void initializeMetadataRepo(URI location) throws ProvisionException {
IMetadataRepositoryManager mgr = getMetadataRepositoryManager();
metadataRepo = mgr.loadRepository(location, new NullProgressMonitor());
- context = new ProvisioningContext(mgr.getKnownRepositories(0));
+ context = new ProvisioningContext(getAgent());
+ context.setMetadataRepositories(mgr.getKnownRepositories(0));
}
// Tests the response to a feature folder inside a jar
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java
index cc5c9d171..f026990b9 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java
@@ -43,9 +43,9 @@ public class CorruptedJar extends AbstractProvisioningTest {
}
public void testDownloadCorruptedJar() {
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ctx.setArtifactRepositories(new URI[] {getTestData("CorruptedJar repo", testDataLocation).toURI()});
- DownloadManager mgr = new DownloadManager(ctx, getArtifactRepositoryManager());
+ DownloadManager mgr = new DownloadManager(ctx, getAgent());
IArtifactKey key = (IArtifactKey) source.query(ArtifactKeyQuery.ALL_KEYS, null).iterator().next();
mgr.add(new MirrorRequest(key, target, null, null));
IStatus s = mgr.start(new NullProgressMonitor());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java
index 6141b65be..e30943ae7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java
@@ -72,7 +72,7 @@ public class ReplacePlanTest extends AbstractProvisioningTest {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.removeInstallableUnits(oldUnits);
request.addInstallableUnits(newUnits);
- IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null);
+ IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(getAgent()), null);
assertTrue("1.0", plan.getStatus().isOK());
assertProfileContainsAll("1.1", profile, oldUnits);
IStatus result = createEngine().perform(plan, null);
@@ -85,7 +85,7 @@ public class ReplacePlanTest extends AbstractProvisioningTest {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.removeInstallableUnits(new IInstallableUnit[] {frag1});
request.addInstallableUnits(new IInstallableUnit[] {frag1_4});
- IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null);
+ IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(getAgent()), null);
assertTrue("1.0", plan.getStatus().isOK());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java
index 2449086a1..071371741 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java
@@ -93,7 +93,7 @@ public class RollbackTest extends AbstractProvisioningTest {
assertEquals(3, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
IProfile revertProfile = profileRegistry.getProfile(profile.getProfileId(), profileRegistry.listProfileTimestamps(profile.getProfileId())[1]);
- status = director.revert(profile, revertProfile, new ProvisioningContext(), new NullProgressMonitor());
+ status = director.revert(profile, revertProfile, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertEquals("10.0", IStatus.OK, status.getCode());
assertEquals("11.0", "test", profile.getProperty("test1"));
assertEquals("12.0", "test", profile.getProperty("test2"));
@@ -130,7 +130,7 @@ public class RollbackTest extends AbstractProvisioningTest {
assertEquals(3, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
IProfile revertProfile = profileRegistry.getProfile(profile.getProfileId(), profileRegistry.listProfileTimestamps(profile.getProfileId())[1]);
- status = director.revert(profile, revertProfile, new ProvisioningContext(), new NullProgressMonitor());
+ status = director.revert(profile, revertProfile, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertEquals("10.0", IStatus.OK, status.getCode());
profileIUs = profile.query(QueryUtil.createIUAnyQuery(), null);
@@ -167,7 +167,7 @@ public class RollbackTest extends AbstractProvisioningTest {
assertEquals(3, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
IProfile revertProfile = profileRegistry.getProfile(profile.getProfileId(), profileRegistry.listProfileTimestamps(profile.getProfileId())[1]);
- status = director.revert(profile, revertProfile, new ProvisioningContext(), new NullProgressMonitor());
+ status = director.revert(profile, revertProfile, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertEquals("10.0", IStatus.OK, status.getCode());
assertEquals("11.0", "test", profile.getInstallableUnitProperty(a1, "test1"));
assertEquals("12.0", "test", profile.getInstallableUnitProperty(a1, "test2"));
@@ -203,7 +203,7 @@ public class RollbackTest extends AbstractProvisioningTest {
assertEquals(3, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
IProfile revertProfile = profileRegistry.getProfile(profile.getProfileId(), profileRegistry.listProfileTimestamps(profile.getProfileId())[1]);
- status = director.revert(profile, revertProfile, new ProvisioningContext(), new NullProgressMonitor());
+ status = director.revert(profile, revertProfile, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertEquals("10.0", IStatus.OK, status.getCode());
assertEquals("11.0", "test", profile.getInstallableUnitProperty(d1, "test1"));
assertEquals("12.0", "test", profile.getInstallableUnitProperty(a1, "test2"));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
index bc582cb4c..a487c19e3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
@@ -57,7 +57,7 @@ public class UpdateTest extends AbstractProvisioningTest {
public void testInstall() {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {f1_1});
- IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), new NullProgressMonitor());
+ IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertOK("1.0", plan.getStatus());
assertOK("1.1", director.provision(request, null, null));
request = new ProfileChangeRequest(profile);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java
index a36606e66..081090a22 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java
@@ -43,7 +43,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
* Tests invocation of DownloadManager when there is nothing to download.
*/
public void testEmptyWithContext() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
DownloadManager manager = createDownloadManager(context);
IStatus result = manager.start(null);
assertTrue("1.0", result.isOK());
@@ -53,7 +53,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
* Tests invocation of DownloadManager when there is nothing to download.
*/
public void testAddNullArtifactRequest() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
DownloadManager manager = createDownloadManager(context);
try {
manager.add((IArtifactRequest) null);
@@ -64,7 +64,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testAddNullArtifactRequestArray() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
DownloadManager manager = createDownloadManager(context);
try {
manager.add((IArtifactRequest[]) null);
@@ -75,7 +75,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testAddEmptyArtifactRequestArray() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
DownloadManager manager = createDownloadManager(context);
manager.add(new IArtifactRequest[0]);
IStatus result = manager.start(null);
@@ -83,7 +83,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testAddArtifactRequestArrayContainingNull() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
DownloadManager manager = createDownloadManager(context);
try {
IArtifactRequest[] requests = new IArtifactRequest[] {null};
@@ -95,7 +95,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testAddArtifactRequest() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
DownloadManager manager = createDownloadManager(context);
IArtifactRequest request = createArtifactRequest();
@@ -106,7 +106,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testContext() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
context.setArtifactRepositories(new URI[0]);
DownloadManager manager = createDownloadManager(context);
@@ -118,7 +118,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testAddArtifactRequestArray() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
DownloadManager manager = createDownloadManager(context);
IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()};
@@ -146,7 +146,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testEmptyArtifactRepositoryListContext() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
context.setArtifactRepositories(new URI[0]);
DownloadManager manager = createDownloadManager(context);
@@ -157,7 +157,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testFileFirstArtifactRepositoryListContext() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
URI[] artifactRepos = new URI[2];
try {
artifactRepos[0] = new URI("file:/test");
@@ -176,7 +176,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testFileLastArtifactRepositoryListContext() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
URI[] artifactRepos = new URI[2];
try {
artifactRepos[0] = new URI("jar:file:/test!/");
@@ -195,7 +195,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
public void testNoFileArtifactRepositoryListContext() {
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
URI[] artifactRepos = new URI[2];
try {
artifactRepos[0] = new URI("jar:file:/test1!/");
@@ -214,6 +214,6 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
private DownloadManager createDownloadManager(ProvisioningContext context) {
- return new DownloadManager(context, getArtifactRepositoryManager());
+ return new DownloadManager(context, getAgent());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java
index 06aec32e3..84b93b833 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java
@@ -165,7 +165,7 @@ public class EngineTest extends AbstractProvisioningTest {
IProfile profile = null;
try {
engine.perform(engine.createPlan(profile, null), new NullProgressMonitor());
- } catch (IllegalArgumentException expected) {
+ } catch (AssertionFailedException expected) {
return;
}
fail();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java
index 1e5ef50be..c5b7b2a95 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java
@@ -53,7 +53,7 @@ public class PhaseSetTest extends AbstractProvisioningTest {
InstallableUnitOperand op = new InstallableUnitOperand(createResolvedIU(createIU("iu")), null);
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {op};
- ProvisioningContext context = new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getAgent());
IStatus result = phaseSet.perform(new EngineSession(null, profile, context), operands, new NullProgressMonitor());
assertTrue(result.isOK());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
index aa204de64..8a8b16855 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
@@ -134,7 +134,7 @@ public class End2EndTest extends AbstractProvisioningTest {
IProfile revertProfile = profileRegistry.getProfile(profile2.getProfileId(), timestamps[1]);
- IStatus s = director.revert(profile2, revertProfile, new ProvisioningContext(), new NullProgressMonitor());
+ IStatus s = director.revert(profile2, revertProfile, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertTrue(s.isOK());
validateInstallContentFor35(installFolder);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java
index 68a54ce1c..e0647756a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java
@@ -58,7 +58,8 @@ public class RepoValidator extends AbstractProvisioningTest {
// q = InstallableUnitQuery.ANY;
IQueryResult iusToTest = validatedRepo.query(q, null);
- ProvisioningContext pc = new ProvisioningContext(new URI[] {repoLoc});
+ ProvisioningContext pc = new ProvisioningContext(getAgent());
+ pc.setMetadataRepositories(new URI[] {repoLoc});
for (Iterator iterator = iusToTest.iterator(); iterator.hasNext();) {
try {
IInstallableUnit isInstallable = (IInstallableUnit) iterator.next();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java
index a28b3a341..3cf915bdb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java
@@ -25,14 +25,14 @@ public class AbsolutePlanTest extends AbstractProvisioningTest {
IInstallableUnit iuA = createEclipseIU("A");
pcr.addInstallableUnits(new IInstallableUnit[] {iuA, createEclipseIU("B"), createEclipseIU("C")});
IPlanner planner = createPlanner();
- IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(), null);
+ IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(getAgent()), null);
assertEquals(3, countPlanElements(plan));
createEngine().perform(plan, null);
ProfileChangeRequest removeRequest = new ProfileChangeRequest(profile);
removeRequest.setAbsoluteMode(true);
removeRequest.removeInstallableUnits(new IInstallableUnit[] {iuA});
- assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(), null)));
+ assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(getAgent()), null)));
}
public void testAddAndRemoveProperty() {
@@ -45,7 +45,7 @@ public class AbsolutePlanTest extends AbstractProvisioningTest {
pcr.setInstallableUnitProfileProperty(iuA, "key", "value");
IPlanner planner = createPlanner();
- ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, new ProvisioningContext(), null);
+ ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, new ProvisioningContext(getAgent()), null);
assertEquals(1, countPlanElements(plan));
createEngine().perform(plan, null);
@@ -62,7 +62,7 @@ public class AbsolutePlanTest extends AbstractProvisioningTest {
removeRequest.removeInstallableUnits(new IInstallableUnit[] {iuA});
removeRequest.removeInstallableUnitProfileProperty(iuA, "key");
- assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(), null)));
+ assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(getAgent()), null)));
}
public void testAddProperty() {
@@ -73,7 +73,7 @@ public class AbsolutePlanTest extends AbstractProvisioningTest {
pcr.setProfileProperty("foo", "bar");
IPlanner planner = createPlanner();
- IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(), null);
+ IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(getAgent()), null);
createEngine().perform(plan, null);
assertEquals("bar", getProfileRegistry().getProfile(getName()).getProperty("foo"));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java
index fcc20cfb9..f92422c98 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java
@@ -50,7 +50,7 @@ public class AdditionalConstraints extends AbstractProvisioningTest {
public void testInstallA1() {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.addInstallableUnits(new IInstallableUnit[] {a1});
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ctx.setAdditionalRequirements(Arrays.<IRequirement> asList(createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.0.0]"))[0]));
IProvisioningPlan plan = planner.getProvisioningPlan(req, ctx, null);
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java
index a099fa991..1e3a1e8b4 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java
@@ -65,7 +65,8 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
- ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ ProvisioningContext context = new ProvisioningContext(getAgent());
+ context.setMetadataRepositories(new URI[0]);
IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
assertNotOK(plan.getStatus());
@@ -81,7 +82,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProfile profile = getProfile("installation");
IPlanner planner = createPlanner();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -103,7 +104,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProfile profile = getProfile("installation");
IPlanner planner = createPlanner();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -123,7 +124,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation"));
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -157,7 +158,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProfile profile = getProfile("installation");
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -185,7 +186,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
//install A which will install Action1
ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation"));
@@ -236,7 +237,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
//install A which will install Action1
ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation"));
@@ -325,7 +326,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
IProfile profile = getProfile("installation");
IPlanner planner = createPlanner();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a, d});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java
index 8a07b7704..17a0032f2 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java
@@ -65,7 +65,8 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
- ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ ProvisioningContext context = new ProvisioningContext(getAgent());
+ context.setMetadataRepositories(new URI[0]);
IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
assertNotOK(plan.getStatus());
@@ -81,7 +82,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProfile profile = getProfile("installation");
IPlanner planner = createPlanner();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -103,7 +104,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProfile profile = getProfile("installation");
IPlanner planner = createPlanner();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -123,7 +124,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation"));
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -157,7 +158,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProfile profile = getProfile("installation");
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -185,7 +186,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
//install A which will install Action1
ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation"));
@@ -236,7 +237,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
//install A which will install Action1
ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation"));
@@ -325,7 +326,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
IProfile profile = getProfile("installation");
IPlanner planner = createPlanner();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a, d});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java
index cd70edd86..361139c9f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java
@@ -40,7 +40,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProfile profileAfterTestRun = getProfile(IProfileRegistry.SELF);
IProvisioningPlan rollbackPlan = createPlanner().getDiffPlan(profileAfterTestRun, initialProfile, new NullProgressMonitor());
assertOK("rollback plan", rollbackPlan.getStatus());
- assertOK("rollback execution", PlanExecutionHelper.executePlan(rollbackPlan, createEngine(), new ProvisioningContext(), new NullProgressMonitor()));
+ assertOK("rollback execution", PlanExecutionHelper.executePlan(rollbackPlan, createEngine(), new ProvisioningContext(getAgent()), new NullProgressMonitor()));
}
super.tearDown();
}
@@ -54,7 +54,8 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
- ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ ProvisioningContext context = new ProvisioningContext(getAgent());
+ context.setMetadataRepositories(new URI[0]);
IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
assertNotOK(plan.getStatus());
@@ -70,7 +71,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProfile profile = getProfile(IProfileRegistry.SELF);
IPlanner planner = createPlanner();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -92,7 +93,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProfile profile = getProfile(IProfileRegistry.SELF);
IPlanner planner = createPlanner();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -112,7 +113,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF));
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -145,7 +146,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProfile profile = getProfile(IProfileRegistry.SELF);
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a});
@@ -174,7 +175,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
//install A which will install Action1
ProfileChangeRequest request = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF));
@@ -219,7 +220,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IPlanner planner = createPlanner();
IEngine engine = createEngine();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
//install A which will install Action1
ProfileChangeRequest request = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF));
@@ -288,7 +289,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
IProfile profile = getProfile(IProfileRegistry.SELF);
IPlanner planner = createPlanner();
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a, d});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java
index c072dab78..4616ae7b0 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java
@@ -47,7 +47,7 @@ public class Bug252682 extends AbstractProvisioningTest {
System.out.println(p2Feature);
IQueryResult c = profile.query(QueryUtil.createIUQuery("org.eclipse.equinox.p2.core.patch"), new NullProgressMonitor());
assertEquals(1, queryResultSize(c));
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ctx.setExtraInstallableUnits(newIUs);
IInstallableUnit patch = (IInstallableUnit) c.iterator().next();
ProfileChangeRequest request = new ProfileChangeRequest(profile);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java
index 49b30e101..2572b5e94 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java
@@ -91,7 +91,7 @@ public class Bug271067 extends AbstractProvisioningTest {
installFeature1.setInstallableUnitInclusionRules(helloPatch, ProfileInclusionRules.createOptionalInclusionRule(helloPatch));
installFeature1.setInstallableUnitInclusionRules(patchJar, ProfileInclusionRules.createOptionalInclusionRule(patchJar));
- IProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(), null);
+ IProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(getAgent()), null);
assertOK("installation of feature1 and patch", createEngine().perform(feature1Plan, new NullProgressMonitor()));
assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor())));
@@ -105,7 +105,7 @@ public class Bug271067 extends AbstractProvisioningTest {
installFeature2.setInstallableUnitInclusionRules(helloIU2, ProfileInclusionRules.createOptionalInclusionRule(helloIU2));
installFeature2.setInstallableUnitInclusionRules(featureJar2, ProfileInclusionRules.createOptionalInclusionRule(featureJar2));
- IProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(), null);
+ IProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(getAgent()), null);
assertOK("installation of feature2", createEngine().perform(feature2Plan, new NullProgressMonitor()));
assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor())));
}
@@ -121,7 +121,7 @@ public class Bug271067 extends AbstractProvisioningTest {
installFeature2.setInstallableUnitInclusionRules(helloIU2, ProfileInclusionRules.createOptionalInclusionRule(helloIU2));
installFeature2.setInstallableUnitInclusionRules(featureJar2, ProfileInclusionRules.createOptionalInclusionRule(featureJar2));
- IProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(), null);
+ IProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(getAgent()), null);
assertOK("installation of feature2", createEngine().perform(feature2Plan, new NullProgressMonitor()));
assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.2")), new NullProgressMonitor())));
@@ -142,7 +142,7 @@ public class Bug271067 extends AbstractProvisioningTest {
installFeature1.setInstallableUnitInclusionRules(helloPatch, ProfileInclusionRules.createOptionalInclusionRule(helloPatch));
installFeature1.setInstallableUnitInclusionRules(patchJar, ProfileInclusionRules.createOptionalInclusionRule(patchJar));
- IProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(), null);
+ IProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(getAgent()), null);
assertOK("installation of feature1 and patch", createEngine().perform(feature1Plan, new NullProgressMonitor()));
assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor())));
}
@@ -172,7 +172,7 @@ public class Bug271067 extends AbstractProvisioningTest {
installEverything.setInstallableUnitInclusionRules(helloPatch, ProfileInclusionRules.createOptionalInclusionRule(helloPatch));
installEverything.setInstallableUnitInclusionRules(patchJar, ProfileInclusionRules.createOptionalInclusionRule(patchJar));
- IProvisioningPlan plan = createPlanner().getProvisioningPlan(installEverything, new ProvisioningContext(), null);
+ IProvisioningPlan plan = createPlanner().getProvisioningPlan(installEverything, new ProvisioningContext(getAgent()), null);
assertOK("installation of feature1 and patch", createEngine().perform(plan, new NullProgressMonitor()));
assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor())));
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java
index 03ec197d6..9331deb71 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java
@@ -79,7 +79,8 @@ public class Bug271954 extends AbstractProvisioningTest {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.removeInstallableUnits((IInstallableUnit[]) c.toArray(IInstallableUnit.class));
- ProvisioningContext ctx = new ProvisioningContext(new URI[0]);
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
+ ctx.setMetadataRepositories(new URI[0]);
ctx.setArtifactRepositories(new URI[0]);
IProvisioningPlan plan = createPlanner().getProvisioningPlan(req, ctx, new NullProgressMonitor());
assertOK("Uninstall plan for myBundle", plan.getStatus());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104.java
index 599755ef6..d10a67600 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug300104.java
@@ -1,179 +1,178 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.tests.planner;
-
-
-import java.io.File;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.p2.core.*;
-import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.planner.IPlanner;
-import org.eclipse.equinox.p2.planner.ProfileInclusionRules;
-import org.eclipse.equinox.p2.query.IQueryResult;
-import org.eclipse.equinox.p2.query.QueryUtil;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
-import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-
-public class Bug300104 extends AbstractProvisioningTest {
- String profileLoadedId = "SDKProfile";
- IMetadataRepository repo = null;
- IProvisioningAgent agent = null;
- private IProfileRegistry profileRegistry;
-
- protected void setUp() throws Exception {
- super.setUp();
- File reporegistry1 = getTestData("test data bug 300104", "testData/bug300104/p2");
- File tempFolder = new File(getTempFolder(), "p2");
- copy("0.2", reporegistry1, tempFolder);
-
- IProvisioningAgentProvider provider = getAgentProvider();
- agent = provider.createAgent(tempFolder.toURI());
- profileRegistry = ((IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME));
- assertNotNull(profileRegistry.getProfile(profileLoadedId));
- }
-
- IInstallableUnit getIU(IMetadataRepository source, String id, String version) {
- IQueryResult c = repo.query(QueryUtil.createIUQuery(id, Version.create(version)), new NullProgressMonitor());
- assertEquals(1, queryResultSize(c));
- return (IInstallableUnit) c.iterator().next();
- }
-
- public void testInstallPatchesInOrder() throws ProvisionException {
-
- // generated metadata was massaged to remove artifact aspects which would require tests to also
- // provide artifacts.
-
- boolean optional = true;
- installHello(optional);
-
- applyHelloPatch1();
-
- applyHelloPatch2();
-
- }
-
- public void testInstallPatchesInOrderStricy() throws ProvisionException {
-
- // generated metadata was massaged to remove artifact aspects which would require tests to also
- // provide artifacts.
-
- boolean optional = false;
- installHello(optional);
-
- applyHelloPatch1();
-
- applyHelloPatch2();
-
- }
-
- public void testInstallOnlyLaterPatch() throws ProvisionException {
- boolean optional = true;
- installHello(optional);
-
- applyHelloPatch2();
- }
-
- private void installHello(boolean optional) throws ProvisionException {
- // install hello 1.0 and related feature.
- repo = loadMetadataRepository(getTestData("Repository for 300104", "testData/bug300104/hello1.0").toURI());
- ProfileChangeRequest installFeature1 = new ProfileChangeRequest(profileRegistry.getProfile(profileLoadedId));
- IInstallableUnit featureGroup = getIU(repo, "hellofeature.feature.group", "1.0.0.200911201237");
- IInstallableUnit featureJar = getIU(repo, "hellofeature.feature.jar", "1.0.0.200911201237");
- IInstallableUnit helloIU = getIU(repo, "hello", "1.0.0.200911201237");
-
- installFeature1.addInstallableUnits(new IInstallableUnit[] {featureGroup, featureJar, helloIU});
-
- installFeature1.setInstallableUnitInclusionRules(featureGroup, createInclusionRule(featureGroup, optional));
- installFeature1.setInstallableUnitInclusionRules(featureJar, ProfileInclusionRules.createOptionalInclusionRule(featureJar));
- installFeature1.setInstallableUnitInclusionRules(helloIU, ProfileInclusionRules.createOptionalInclusionRule(helloIU));
-
- IProvisioningPlan feature1Plan = getPlannerService().getProvisioningPlan(installFeature1, new ProvisioningContext(), null);
- assertOK("installation of feature1", getEngineService().perform(feature1Plan, new NullProgressMonitor()));
- assertEquals(1, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.200911201237")), new NullProgressMonitor())));
- }
-
- private IEngine getEngineService() {
- return ((IEngine) agent.getService(IEngine.SERVICE_NAME));
- }
-
- private IPlanner getPlannerService() {
- return ((IPlanner) agent.getService(IPlanner.SERVICE_NAME));
- }
-
- private String createInclusionRule(IInstallableUnit unit, boolean optional) {
- return optional ? ProfileInclusionRules.createOptionalInclusionRule(unit) : ProfileInclusionRules.createStrictInclusionRule(unit);
- }
-
- private void applyHelloPatch1() throws ProvisionException {
- // install first feature patch which updates hello to version 1.0.1
- /*
- <unit id='hellopatch.feature.group' version='1.0.0' singleton='false'>
- <unit id='hellopatch.feature.jar' version='1.0.0'>
- <unit id='hello' version='1.0.1.200911201237'>
- */
-
- repo = loadMetadataRepository(getTestData("Repository for 300104", "testData/bug300104/hellopatch1").toURI());
-
- ProfileChangeRequest installFeature1 = new ProfileChangeRequest(profileRegistry.getProfile(profileLoadedId));
- IInstallableUnit featureGroup = getIU(repo, "hellopatch.feature.group", "1.0.0");
- IInstallableUnit featureJar = getIU(repo, "hellopatch.feature.jar", "1.0.0");
- IInstallableUnit helloIU = getIU(repo, "hello", "1.0.1.200911201237");
-
- installFeature1.addInstallableUnits(new IInstallableUnit[] {featureGroup, featureJar, helloIU});
-
- installFeature1.setInstallableUnitInclusionRules(featureGroup, ProfileInclusionRules.createOptionalInclusionRule(featureGroup));
- installFeature1.setInstallableUnitInclusionRules(featureJar, ProfileInclusionRules.createOptionalInclusionRule(featureJar));
- installFeature1.setInstallableUnitInclusionRules(helloIU, ProfileInclusionRules.createOptionalInclusionRule(helloIU));
-
- IProvisioningPlan feature1Plan = getPlannerService().getProvisioningPlan(installFeature1, new ProvisioningContext(), null);
- assertOK("installation of feature1", getEngineService().perform(feature1Plan, new NullProgressMonitor()));
- assertEquals(0, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.200911201237")), new NullProgressMonitor())));
- assertEquals(1, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.1.200911201237")), new NullProgressMonitor())));
- }
-
- private void applyHelloPatch2() throws ProvisionException {
- // install newer version of feature patch which updates
- // hello to version 1.0.1 with later qualifier and
- // adds unit hello2 1.0.0
- /*
- <unit id='hellopatch.feature.group' version='1.0.1.200911201358' singleton='false'>
- <unit id='hellopatch.feature.jar' version='1.0.1.200911201358'>
- <unit id='hello' version='1.0.1.200911201358'>
- <unit id='hello2' version='1.0.0.200911201358'>
- */
-
- repo = loadMetadataRepository(getTestData("Repository for 300104", "testData/bug300104/hellopatch2").toURI());
-
- ProfileChangeRequest installFeature1 = new ProfileChangeRequest(profileRegistry.getProfile(profileLoadedId));
- IInstallableUnit featureGroup = getIU(repo, "hellopatch.feature.group", "1.0.1.200911201358");
- IInstallableUnit featureJar = getIU(repo, "hellopatch.feature.jar", "1.0.1.200911201358");
- IInstallableUnit helloIU = getIU(repo, "hello", "1.0.1.200911201358");
- IInstallableUnit hello2IU = getIU(repo, "hello2", "1.0.0.200911201358");
-
- installFeature1.addInstallableUnits(new IInstallableUnit[] {featureGroup, featureJar, helloIU, hello2IU});
-
- installFeature1.setInstallableUnitInclusionRules(featureGroup, ProfileInclusionRules.createOptionalInclusionRule(featureGroup));
- installFeature1.setInstallableUnitInclusionRules(featureJar, ProfileInclusionRules.createOptionalInclusionRule(featureJar));
- installFeature1.setInstallableUnitInclusionRules(helloIU, ProfileInclusionRules.createOptionalInclusionRule(helloIU));
- installFeature1.setInstallableUnitInclusionRules(hello2IU, ProfileInclusionRules.createOptionalInclusionRule(hello2IU));
-
- IProvisioningPlan feature1Plan = getPlannerService().getProvisioningPlan(installFeature1, new ProvisioningContext(), null);
- assertOK("installation of feature1", getEngineService().perform(feature1Plan, new NullProgressMonitor()));
- assertEquals(1, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello2", Version.create("1.0.0.200911201358")), new NullProgressMonitor())));
-
- assertEquals(0, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.200911201237")), new NullProgressMonitor())));
- assertEquals(0, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.1.200911201237")), new NullProgressMonitor())));
- assertEquals(1, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.1.200911201358")), new NullProgressMonitor())));
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2010 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.tests.planner;
+
+import java.io.File;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
+import org.eclipse.equinox.p2.core.*;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.planner.IPlanner;
+import org.eclipse.equinox.p2.planner.ProfileInclusionRules;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.QueryUtil;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+
+public class Bug300104 extends AbstractProvisioningTest {
+ String profileLoadedId = "SDKProfile";
+ IMetadataRepository repo = null;
+ IProvisioningAgent agent = null;
+ private IProfileRegistry profileRegistry;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ File reporegistry1 = getTestData("test data bug 300104", "testData/bug300104/p2");
+ File tempFolder = new File(getTempFolder(), "p2");
+ copy("0.2", reporegistry1, tempFolder);
+
+ IProvisioningAgentProvider provider = getAgentProvider();
+ agent = provider.createAgent(tempFolder.toURI());
+ profileRegistry = ((IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME));
+ assertNotNull(profileRegistry.getProfile(profileLoadedId));
+ }
+
+ IInstallableUnit getIU(IMetadataRepository source, String id, String version) {
+ IQueryResult c = repo.query(QueryUtil.createIUQuery(id, Version.create(version)), new NullProgressMonitor());
+ assertEquals(1, queryResultSize(c));
+ return (IInstallableUnit) c.iterator().next();
+ }
+
+ public void testInstallPatchesInOrder() throws ProvisionException {
+
+ // generated metadata was massaged to remove artifact aspects which would require tests to also
+ // provide artifacts.
+
+ boolean optional = true;
+ installHello(optional);
+
+ applyHelloPatch1();
+
+ applyHelloPatch2();
+
+ }
+
+ public void testInstallPatchesInOrderStricy() throws ProvisionException {
+
+ // generated metadata was massaged to remove artifact aspects which would require tests to also
+ // provide artifacts.
+
+ boolean optional = false;
+ installHello(optional);
+
+ applyHelloPatch1();
+
+ applyHelloPatch2();
+
+ }
+
+ public void testInstallOnlyLaterPatch() throws ProvisionException {
+ boolean optional = true;
+ installHello(optional);
+
+ applyHelloPatch2();
+ }
+
+ private void installHello(boolean optional) throws ProvisionException {
+ // install hello 1.0 and related feature.
+ repo = loadMetadataRepository(getTestData("Repository for 300104", "testData/bug300104/hello1.0").toURI());
+ ProfileChangeRequest installFeature1 = new ProfileChangeRequest(profileRegistry.getProfile(profileLoadedId));
+ IInstallableUnit featureGroup = getIU(repo, "hellofeature.feature.group", "1.0.0.200911201237");
+ IInstallableUnit featureJar = getIU(repo, "hellofeature.feature.jar", "1.0.0.200911201237");
+ IInstallableUnit helloIU = getIU(repo, "hello", "1.0.0.200911201237");
+
+ installFeature1.addInstallableUnits(new IInstallableUnit[] {featureGroup, featureJar, helloIU});
+
+ installFeature1.setInstallableUnitInclusionRules(featureGroup, createInclusionRule(featureGroup, optional));
+ installFeature1.setInstallableUnitInclusionRules(featureJar, ProfileInclusionRules.createOptionalInclusionRule(featureJar));
+ installFeature1.setInstallableUnitInclusionRules(helloIU, ProfileInclusionRules.createOptionalInclusionRule(helloIU));
+
+ IProvisioningPlan feature1Plan = getPlannerService().getProvisioningPlan(installFeature1, new ProvisioningContext(getAgent()), null);
+ assertOK("installation of feature1", getEngineService().perform(feature1Plan, new NullProgressMonitor()));
+ assertEquals(1, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.200911201237")), new NullProgressMonitor())));
+ }
+
+ private IEngine getEngineService() {
+ return ((IEngine) agent.getService(IEngine.SERVICE_NAME));
+ }
+
+ private IPlanner getPlannerService() {
+ return ((IPlanner) agent.getService(IPlanner.SERVICE_NAME));
+ }
+
+ private String createInclusionRule(IInstallableUnit unit, boolean optional) {
+ return optional ? ProfileInclusionRules.createOptionalInclusionRule(unit) : ProfileInclusionRules.createStrictInclusionRule(unit);
+ }
+
+ private void applyHelloPatch1() throws ProvisionException {
+ // install first feature patch which updates hello to version 1.0.1
+ /*
+ <unit id='hellopatch.feature.group' version='1.0.0' singleton='false'>
+ <unit id='hellopatch.feature.jar' version='1.0.0'>
+ <unit id='hello' version='1.0.1.200911201237'>
+ */
+
+ repo = loadMetadataRepository(getTestData("Repository for 300104", "testData/bug300104/hellopatch1").toURI());
+
+ ProfileChangeRequest installFeature1 = new ProfileChangeRequest(profileRegistry.getProfile(profileLoadedId));
+ IInstallableUnit featureGroup = getIU(repo, "hellopatch.feature.group", "1.0.0");
+ IInstallableUnit featureJar = getIU(repo, "hellopatch.feature.jar", "1.0.0");
+ IInstallableUnit helloIU = getIU(repo, "hello", "1.0.1.200911201237");
+
+ installFeature1.addInstallableUnits(new IInstallableUnit[] {featureGroup, featureJar, helloIU});
+
+ installFeature1.setInstallableUnitInclusionRules(featureGroup, ProfileInclusionRules.createOptionalInclusionRule(featureGroup));
+ installFeature1.setInstallableUnitInclusionRules(featureJar, ProfileInclusionRules.createOptionalInclusionRule(featureJar));
+ installFeature1.setInstallableUnitInclusionRules(helloIU, ProfileInclusionRules.createOptionalInclusionRule(helloIU));
+
+ IProvisioningPlan feature1Plan = getPlannerService().getProvisioningPlan(installFeature1, new ProvisioningContext(getAgent()), null);
+ assertOK("installation of feature1", getEngineService().perform(feature1Plan, new NullProgressMonitor()));
+ assertEquals(0, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.200911201237")), new NullProgressMonitor())));
+ assertEquals(1, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.1.200911201237")), new NullProgressMonitor())));
+ }
+
+ private void applyHelloPatch2() throws ProvisionException {
+ // install newer version of feature patch which updates
+ // hello to version 1.0.1 with later qualifier and
+ // adds unit hello2 1.0.0
+ /*
+ <unit id='hellopatch.feature.group' version='1.0.1.200911201358' singleton='false'>
+ <unit id='hellopatch.feature.jar' version='1.0.1.200911201358'>
+ <unit id='hello' version='1.0.1.200911201358'>
+ <unit id='hello2' version='1.0.0.200911201358'>
+ */
+
+ repo = loadMetadataRepository(getTestData("Repository for 300104", "testData/bug300104/hellopatch2").toURI());
+
+ ProfileChangeRequest installFeature1 = new ProfileChangeRequest(profileRegistry.getProfile(profileLoadedId));
+ IInstallableUnit featureGroup = getIU(repo, "hellopatch.feature.group", "1.0.1.200911201358");
+ IInstallableUnit featureJar = getIU(repo, "hellopatch.feature.jar", "1.0.1.200911201358");
+ IInstallableUnit helloIU = getIU(repo, "hello", "1.0.1.200911201358");
+ IInstallableUnit hello2IU = getIU(repo, "hello2", "1.0.0.200911201358");
+
+ installFeature1.addInstallableUnits(new IInstallableUnit[] {featureGroup, featureJar, helloIU, hello2IU});
+
+ installFeature1.setInstallableUnitInclusionRules(featureGroup, ProfileInclusionRules.createOptionalInclusionRule(featureGroup));
+ installFeature1.setInstallableUnitInclusionRules(featureJar, ProfileInclusionRules.createOptionalInclusionRule(featureJar));
+ installFeature1.setInstallableUnitInclusionRules(helloIU, ProfileInclusionRules.createOptionalInclusionRule(helloIU));
+ installFeature1.setInstallableUnitInclusionRules(hello2IU, ProfileInclusionRules.createOptionalInclusionRule(hello2IU));
+
+ IProvisioningPlan feature1Plan = getPlannerService().getProvisioningPlan(installFeature1, new ProvisioningContext(getAgent()), null);
+ assertOK("installation of feature1", getEngineService().perform(feature1Plan, new NullProgressMonitor()));
+ assertEquals(1, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello2", Version.create("1.0.0.200911201358")), new NullProgressMonitor())));
+
+ assertEquals(0, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.0.200911201237")), new NullProgressMonitor())));
+ assertEquals(0, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.1.200911201237")), new NullProgressMonitor())));
+ assertEquals(1, queryResultSize(profileRegistry.getProfile(profileLoadedId).query(QueryUtil.createIUQuery("hello", Version.create("1.0.1.200911201358")), new NullProgressMonitor())));
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java
index b0517982a..205c851e1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java
@@ -45,7 +45,7 @@ public class DisabledExplanation extends AbstractProvisioningTest {
public void testExplanation() {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.addInstallableUnits(new IInstallableUnit[] {a1, b1});
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ctx.setProperty("org.eclipse.equinox.p2.director.explain", "false");
ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, ctx, null);
assertEquals(IStatus.ERROR, plan.getStatus().getSeverity());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java
index c7ba283ac..dc65a0cbe 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java
@@ -56,14 +56,14 @@ public class FindingPatchesThroughUpdates extends AbstractProvisioningTest {
}
public void testInstall() {
- IQueryResult<IInstallableUnit> updates = planner.updatesFor(a1, new ProvisioningContext(), new NullProgressMonitor());
+ IQueryResult<IInstallableUnit> updates = planner.updatesFor(a1, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertEquals(2, updates.toUnmodifiableSet().size());
assertTrue(updates.toUnmodifiableSet().contains(a120));
assertTrue(updates.toUnmodifiableSet().contains(patchA1));
}
public void testFindUpdatesOfPatches() {
- IQueryResult<IInstallableUnit> updates = planner.updatesFor(anotherPatch2, new ProvisioningContext(), new NullProgressMonitor());
+ IQueryResult<IInstallableUnit> updates = planner.updatesFor(anotherPatch2, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertEquals(1, updates.toUnmodifiableSet().size());
assertTrue(updates.toUnmodifiableSet().contains(anotherPatch3));
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java
index fc02d1fcf..68c032ef8 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java
@@ -57,7 +57,8 @@ public class NonMinimalState extends AbstractProvisioningTest {
public void testValidateProfileWithoutRepo() {
IPlanner planner = createPlanner();
ProfileChangeRequest request = new ProfileChangeRequest(profile);
- ProvisioningContext ctx = new ProvisioningContext(new URI[0]);
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
+ ctx.setMetadataRepositories(new URI[0]);
IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor());
assertOK("Plan OK", plan.getStatus());
assertTrue(plan.getAdditions().query(QueryUtil.createIUQuery("org.eclipse.tptp.platform.agentcontroller"), null).isEmpty());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java
index 07c971522..83f536f1f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java
@@ -76,7 +76,8 @@ public class PatchTestUpdate3 extends AbstractProvisioningTest {
public void testUpdate() {
ProfileChangeRequest req2 = new ProfileChangeRequest(getProfile("TestProfile." + getName()));
- ProvisioningContext ctx = new ProvisioningContext(new URI[0]);
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
+ ctx.setMetadataRepositories(new URI[0]);
assertOK("Validating the profile", planner.getProvisioningPlan(req2, ctx, null).getStatus());
//The update of the feature will cause the patch pp2 to be uninstalled because its lifecycle is no longer matched. pp1 stays because its lifecycle is still applicable
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java
index f14552cad..18c28d1a4 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java
@@ -18,29 +18,32 @@ import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class ProvisioningPlanQueryTest extends AbstractProvisioningTest {
+
+ private static final String TESTPROFILE = "test";
+
public void testNull() {
- IQueryResult c = new ProvisioningPlan(Status.OK_STATUS, null, null, null).getAdditions().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
+ IQueryResult c = new ProvisioningPlan(Status.OK_STATUS, getProfile(TESTPROFILE), null, null).getAdditions().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
assertTrue(c.isEmpty());
}
public void testAddition() {
Operand[] ops = new Operand[] {new InstallableUnitOperand(null, createIU("A"))};
- IQueryResult c = new ProvisioningPlan(null, ops, null).getAdditions().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
+ IQueryResult c = new ProvisioningPlan(getProfile(TESTPROFILE), ops, null).getAdditions().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
assertEquals(1, queryResultSize(c));
- assertTrue(new ProvisioningPlan(null, ops, null).getRemovals().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor()).isEmpty());
+ assertTrue(new ProvisioningPlan(getProfile(TESTPROFILE), ops, null).getRemovals().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor()).isEmpty());
}
public void testRemoval() {
Operand[] ops = new Operand[] {new InstallableUnitOperand(createIU("A"), null)};
- IQueryResult c = new ProvisioningPlan(null, ops, null).getRemovals().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
+ IQueryResult c = new ProvisioningPlan(getProfile(TESTPROFILE), ops, null).getRemovals().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
assertEquals(1, queryResultSize(c));
- assertTrue(new ProvisioningPlan(null, ops, null).getAdditions().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor()).isEmpty());
+ assertTrue(new ProvisioningPlan(getProfile(TESTPROFILE), ops, null).getAdditions().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor()).isEmpty());
}
public void testUpdate() {
Operand[] ops = new Operand[] {new InstallableUnitOperand(createIU("A"), createIU("B"))};
- IQueryResult c = new ProvisioningPlan(null, ops, null).getRemovals().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
+ IQueryResult c = new ProvisioningPlan(getProfile(TESTPROFILE), ops, null).getRemovals().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor());
assertEquals(1, queryResultSize(c));
- assertEquals(1, queryResultSize(new ProvisioningPlan(null, ops, null).getAdditions().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor())));
+ assertEquals(1, queryResultSize(new ProvisioningPlan(getProfile(TESTPROFILE), ops, null).getAdditions().query(QueryUtil.createIUAnyQuery(), new NullProgressMonitor())));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java
index c0d4acc94..8f85e0da2 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java
@@ -50,7 +50,7 @@ public class SDKPatchingTest1 extends AbstractProvisioningTest {
}
public void testInstallFeaturePatch() {
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ctx.setExtraInstallableUnits(newIUs);
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {patchInstallingCommon});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java
index fc9f19d8f..ed6dfdbf4 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java
@@ -65,7 +65,7 @@ public class SDKPatchingTest2 extends AbstractProvisioningTest {
}
public void testInstallFeaturePatch() {
- ProvisioningContext ctx = new ProvisioningContext();
+ ProvisioningContext ctx = new ProvisioningContext(getAgent());
ctx.setExtraInstallableUnits(newIUs);
ProfileChangeRequest validationRequest = new ProfileChangeRequest(profile);
IProvisioningPlan validationPlan = createPlanner().getProvisioningPlan(validationRequest, null, null);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
index 7d717a321..1c44269b7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
@@ -50,7 +50,8 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest {
request.setAbsoluteMode(true);
request.addInstallableUnits(new IInstallableUnit[] {a1});
request.setInstallableUnitInclusionRules(a1, ProfileInclusionRules.createStrictInclusionRule(a1));
- final ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ final ProvisioningContext context = new ProvisioningContext(getAgent());
+ context.setMetadataRepositories(new URI[0]);
IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
assertEquals(IStatus.OK, engine.perform(plan, new NullProgressMonitor()).getSeverity());
assertContains(profile.query(QueryUtil.createIUAnyQuery(), null), a1);
@@ -69,7 +70,8 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest {
request.setAbsoluteMode(true);
request.addInstallableUnits(new IInstallableUnit[] {c1});
request.setInstallableUnitInclusionRules(c1, ProfileInclusionRules.createStrictInclusionRule(c1));
- final ProvisioningContext context = new ProvisioningContext(new URI[0]);
+ final ProvisioningContext context = new ProvisioningContext(getAgent());
+ context.setMetadataRepositories(new URI[0]);
IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor());
assertEquals(IStatus.OK, engine.perform(plan, new NullProgressMonitor()).getSeverity());
assertContains(profile.query(QueryUtil.createIUAnyQuery(), null), c1);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java
index a353c367f..5b2e3fb84 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java
@@ -177,7 +177,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest {
assertTrue("0.1", !getArtifactRepositoryManager().contains(locationURI));
- IStatus result = createDirector().provision(request, new ProvisioningContext(), getMonitor());
+ IStatus result = createDirector().provision(request, new ProvisioningContext(getAgent()), getMonitor());
assertTrue("1.0", result.isOK());
//check that profile property is set
@@ -205,7 +205,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
final IInstallableUnit[] oldIUs = new IInstallableUnit[] {oldIU};
request.addInstallableUnits(oldIUs);
- IStatus result = createDirector().provision(request, new ProvisioningContext(), getMonitor());
+ IStatus result = createDirector().provision(request, new ProvisioningContext(getAgent()), getMonitor());
assertTrue("1.0", result.isOK());
assertTrue("1.1", !getArtifactRepositoryManager().contains(locationURI));
@@ -224,7 +224,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest {
final IInstallableUnit[] newIUs = new IInstallableUnit[] {newIU, bundle};
request.addInstallableUnits(newIUs);
request.removeInstallableUnits(oldIUs);
- result = createDirector().provision(request, new ProvisioningContext(), getMonitor());
+ result = createDirector().provision(request, new ProvisioningContext(getAgent()), getMonitor());
if (!result.isOK())
LogHelper.log(result);
assertTrue("2.0", result.isOK());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java
index bcf3ed333..9bc07f1b7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java
@@ -226,7 +226,7 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest {
request.addInstallableUnits(newIUs);
IPlanner planner = createPlanner();
- IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), new NullProgressMonitor());
+ IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(getAgent()), new NullProgressMonitor());
assertTrue("1.0", plan.getStatus().isOK());
IStatus result = createEngine().perform(plan, getMonitor());
assertFalse("2.0", result.isOK());
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java
index 52519d457..42c022ed9 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/DirectorUtil.java
@@ -11,19 +11,19 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
-import org.eclipse.equinox.p2.planner.IPlanner;
-
import java.net.URI;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.planner.IPlanner;
public class DirectorUtil {
public static IStatus validateProfile(IProfile profile) {
ProfileChangeRequest pcr = new ProfileChangeRequest(profile);
- ProvisioningContext ctx = new ProvisioningContext(new URI[0]);
+ ProvisioningContext ctx = new ProvisioningContext(profile.getProvisioningAgent());
+ ctx.setMetadataRepositories(new URI[0]);
IPlanner planner = (IPlanner) profile.getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
return planner.getProvisioningPlan(pcr, ctx, null).getStatus();
}
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java
index b21a230de..d6adf2684 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdater.java
@@ -117,7 +117,7 @@ public class AutomaticUpdater implements IUpdateListener {
// preference dictates.
if (download) {
- ProfileModificationJob job = new ProfileModificationJob(AutomaticUpdateMessages.AutomaticUpdater_AutomaticDownloadOperationName, getSession(), event.getProfileId(), operation.getProvisioningPlan(), new ProvisioningContext());
+ ProfileModificationJob job = new ProfileModificationJob(AutomaticUpdateMessages.AutomaticUpdater_AutomaticDownloadOperationName, getSession(), event.getProfileId(), operation.getProvisioningPlan(), new ProvisioningContext(getSession().getProvisioningAgent()));
job.setPhaseSet(PhaseSetFactory.createPhaseSetIncluding(new String[] {PhaseSetFactory.PHASE_COLLECT}));
job.setUser(false);
job.setSystem(true);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
index da1174836..852c587d7 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java
@@ -561,12 +561,12 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta
public ProvisioningContext getProvisioningContext() {
// If the user can't manipulate repos, always resolve against everything
if (!getPolicy().getRepositoriesVisible() || repoSelector == null) {
- return new ProvisioningContext();
+ return new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent());
}
// Consult the checkbox to see if we should resolve against everything,
// or use the combo to determine what to do.
if (resolveAllCheckbox.getSelection())
- return new ProvisioningContext();
+ return new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent());
// Use the contents of the combo to determine the context
return repoSelector.getProvisioningContext();
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java
index a661b27c3..1119c06fb 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java
@@ -12,7 +12,6 @@
package org.eclipse.equinox.internal.p2.ui.dialogs;
import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
import java.util.HashSet;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.*;
@@ -162,7 +161,7 @@ public abstract class ProvisioningOperationWizard extends Wizard {
if (currentProvisioningContext == null && provisioningContext == null)
return false;
if (currentProvisioningContext != null && provisioningContext != null)
- return !Arrays.equals(provisioningContext.getMetadataRepositories(), currentProvisioningContext.getMetadataRepositories());
+ return currentProvisioningContext.equals(provisioningContext);
// One is null and the other is not
return true;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
index 0f5871db3..6c3f039e1 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
@@ -560,7 +560,7 @@ public class RepositorySelectionGroup {
public ProvisioningContext getProvisioningContext() {
int siteSel = getComboIndex(repoCombo.getText().trim());
if (siteSel < 0 || siteSel == INDEX_SITE_ALL || siteSel == INDEX_SITE_NONE)
- return new ProvisioningContext();
+ return new ProvisioningContext(ui.getSession().getProvisioningAgent());
URI[] locals = getLocalSites();
// If there are local sites, the last item in the combo is "Local Sites Only"
// Use all local sites in this case
@@ -568,12 +568,14 @@ public class RepositorySelectionGroup {
// provisioning context because the artifact repositories are used for
// sizing.
if (locals.length > 0 && siteSel == repoCombo.getItemCount() - 1) {
- ProvisioningContext context = new ProvisioningContext(locals);
+ ProvisioningContext context = new ProvisioningContext(ui.getSession().getProvisioningAgent());
+ context.setMetadataRepositories(locals);
context.setArtifactRepositories(locals);
return context;
}
// A single site is selected.
- ProvisioningContext context = new ProvisioningContext(new URI[] {comboRepos[siteSel]});
+ ProvisioningContext context = new ProvisioningContext(ui.getSession().getProvisioningAgent());
+ context.setMetadataRepositories(new URI[] {comboRepos[siteSel]});
context.setArtifactRepositories(new URI[] {comboRepos[siteSel]});
return context;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java
index 564430a3c..097d40ec8 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableIUElement.java
@@ -185,8 +185,10 @@ public class AvailableIUElement extends QueriedElement implements IIUElement {
}
private ProvisioningContext getProvisioningContext() {
- if (hasQueryable() && getQueryable() instanceof IRepository<?>)
- return new ProvisioningContext(new URI[] {((IRepository<?>) getQueryable()).getLocation()});
- return new ProvisioningContext();
+ ProvisioningContext context = new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent());
+ if (hasQueryable() && getQueryable() instanceof IRepository<?>) {
+ context.setMetadataRepositories(new URI[] {((IRepository<?>) getQueryable()).getLocation()});
+ }
+ return context;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java
index 7aa65a0a2..cf3db66fc 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java
@@ -44,7 +44,7 @@ public class AvailableUpdateElement extends AvailableIUElement {
if (iuToBeUpdated.getId().equals(getIU().getId()))
request.remove(iuToBeUpdated);
request.add(getIU());
- return getPlanner().getProvisioningPlan(request, new ProvisioningContext(), monitor);
+ return getPlanner().getProvisioningPlan(request, new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent()), monitor);
}
public boolean equals(Object obj) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
index 6da88b9da..82c8d4f08 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
@@ -46,7 +46,7 @@ public class QueryableUpdates implements IQueryable<IInstallableUnit> {
for (int i = 0; i < iusToUpdate.length; i++) {
if (monitor.isCanceled())
return Collector.emptyCollector();
- IQueryResult<IInstallableUnit> updates = planner.updatesFor(iusToUpdate[i], new ProvisioningContext(), new SubProgressMonitor(monitor, totalWork / 2 / iusToUpdate.length));
+ IQueryResult<IInstallableUnit> updates = planner.updatesFor(iusToUpdate[i], new ProvisioningContext(ui.getSession().getProvisioningAgent()), new SubProgressMonitor(monitor, totalWork / 2 / iusToUpdate.length));
allUpdates.addAll(updates.toUnmodifiableSet());
}
return query.perform(allUpdates.iterator());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
index 3076096ba..5975e7d87 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
@@ -175,12 +175,13 @@ public class ProvisioningUI {
private ProvisioningContext makeProvisioningContext(URI[] repos) {
if (repos != null) {
- ProvisioningContext context = new ProvisioningContext(repos);
+ ProvisioningContext context = new ProvisioningContext(getSession().getProvisioningAgent());
+ context.setMetadataRepositories(repos);
context.setArtifactRepositories(repos);
return context;
}
// look everywhere
- return new ProvisioningContext();
+ return new ProvisioningContext(getSession().getProvisioningAgent());
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
index feefb0284..422b730ab 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
@@ -376,7 +376,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
if (plan[0].getStatus().isOK()) {
// We use a default provisioning context (all repos) because we have no other
// way currently to figure out which sites the user wants to contact
- ProfileModificationJob op = new ProfileModificationJob(ProvUIMessages.RevertDialog_RevertOperationLabel, getSession(), profileId, plan[0], new ProvisioningContext());
+ ProfileModificationJob op = new ProfileModificationJob(ProvUIMessages.RevertDialog_RevertOperationLabel, getSession(), profileId, plan[0], new ProvisioningContext(getSession().getProvisioningAgent()));
// we want to force a restart (not allow apply changes)
op.setRestartPolicy(ProvisioningJob.RESTART_ONLY);
ui.schedule(op, StatusManager.SHOW | StatusManager.LOG);
@@ -437,7 +437,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
public ProvElementNode(Object input) {
pe = (ProvElement) input;
- iu = (IInstallableUnit) ProvUI.getAdapter(pe, IInstallableUnit.class);
+ iu = ProvUI.getAdapter(pe, IInstallableUnit.class);
if (iu != null) {
id = iu.getId();
}
diff --git a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.java b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.java
index eb483f559..f3b4b2a65 100644
--- a/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.java
+++ b/bundles/org.eclipse.equinox.p2.updatechecker/src/org/eclipse/equinox/internal/p2/updatechecker/UpdateChecker.java
@@ -124,7 +124,8 @@ public class UpdateChecker implements IUpdateChecker {
ArrayList<IInstallableUnit> iusWithUpdates = new ArrayList<IInstallableUnit>();
if (profile == null)
return CollectionUtils.emptyList();
- ProvisioningContext context = new ProvisioningContext(getAvailableRepositories());
+ ProvisioningContext context = new ProvisioningContext(agent);
+ context.setMetadataRepositories(getAvailableRepositories());
if (query == null)
query = QueryUtil.createIUAnyQuery();
Iterator<IInstallableUnit> iter = profile.query(query, null).iterator();

Back to the top