Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/AggregatedBundleRepository.java57
-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.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java84
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java72
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PublisherUtil.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/SourceManipulator.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java85
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddJVMArgumentAction.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddProgramArgumentAction.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddSourceBundleAction.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CheckTrustAction.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java58
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallFeatureAction.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/LinkAction.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveJVMArgumentAction.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveProgramArgumentAction.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveSourceBundleAction.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java62
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallFeatureAction.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationCache.java70
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java74
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/XMLWriter.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/OSGiBundleQuery.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/package.html18
40 files changed, 696 insertions, 451 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/AggregatedBundleRepository.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/AggregatedBundleRepository.java
index bdcd73ebc..1d90b8326 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/AggregatedBundleRepository.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/AggregatedBundleRepository.java
@@ -15,23 +15,23 @@ import java.io.OutputStream;
import java.util.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.AbstractArtifactRepository;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository;
public class AggregatedBundleRepository extends AbstractArtifactRepository implements IFileArtifactRepository {
private static final String REPOSITORY_TYPE = AggregatedBundleRepository.class.getName();
- private final Collection bundleRepositories;
+ private final Collection<IFileArtifactRepository> bundleRepositories;
- public AggregatedBundleRepository(Collection bundleRepositories) {
+ public AggregatedBundleRepository(Collection<IFileArtifactRepository> bundleRepositories) {
super(REPOSITORY_TYPE, REPOSITORY_TYPE, "1.0", null, null, null, null); //$NON-NLS-1$
this.bundleRepositories = bundleRepositories;
}
public File getArtifactFile(IArtifactKey key) {
- for (Iterator it = bundleRepositories.iterator(); it.hasNext();) {
- IFileArtifactRepository repository = (IFileArtifactRepository) it.next();
+ for (IFileArtifactRepository repository : bundleRepositories) {
File artifactFile = repository.getArtifactFile(key);
if (artifactFile != null)
return artifactFile;
@@ -40,8 +40,7 @@ public class AggregatedBundleRepository extends AbstractArtifactRepository imple
}
public File getArtifactFile(IArtifactDescriptor descriptor) {
- for (Iterator it = bundleRepositories.iterator(); it.hasNext();) {
- IFileArtifactRepository repository = (IFileArtifactRepository) it.next();
+ for (IFileArtifactRepository repository : bundleRepositories) {
File artifactFile = repository.getArtifactFile(descriptor);
if (artifactFile != null)
return artifactFile;
@@ -50,8 +49,7 @@ public class AggregatedBundleRepository extends AbstractArtifactRepository imple
}
public boolean contains(IArtifactDescriptor descriptor) {
- for (Iterator it = bundleRepositories.iterator(); it.hasNext();) {
- IFileArtifactRepository repository = (IFileArtifactRepository) it.next();
+ for (IFileArtifactRepository repository : bundleRepositories) {
if (repository.contains(descriptor))
return true;
}
@@ -59,8 +57,7 @@ public class AggregatedBundleRepository extends AbstractArtifactRepository imple
}
public boolean contains(IArtifactKey key) {
- for (Iterator it = bundleRepositories.iterator(); it.hasNext();) {
- IFileArtifactRepository repository = (IFileArtifactRepository) it.next();
+ for (IFileArtifactRepository repository : bundleRepositories) {
if (repository.contains(key))
return true;
}
@@ -68,25 +65,13 @@ public class AggregatedBundleRepository extends AbstractArtifactRepository imple
}
public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
- Set artifactDescriptors = new HashSet();
- for (Iterator it = bundleRepositories.iterator(); it.hasNext();) {
- IFileArtifactRepository repository = (IFileArtifactRepository) it.next();
+ Set<IArtifactDescriptor> artifactDescriptors = new HashSet<IArtifactDescriptor>();
+ for (IFileArtifactRepository repository : bundleRepositories) {
IArtifactDescriptor[] descriptors = repository.getArtifactDescriptors(key);
if (descriptors != null)
artifactDescriptors.addAll(Arrays.asList(descriptors));
}
- return (IArtifactDescriptor[]) artifactDescriptors.toArray(new IArtifactDescriptor[artifactDescriptors.size()]);
- }
-
- public IArtifactKey[] getArtifactKeys() {
- Set artifactKeys = new HashSet();
- for (Iterator it = bundleRepositories.iterator(); it.hasNext();) {
- IFileArtifactRepository repository = (IFileArtifactRepository) it.next();
- IArtifactKey[] keys = repository.getArtifactKeys();
- if (keys != null)
- artifactKeys.addAll(Arrays.asList(keys));
- }
- return (IArtifactKey[]) artifactKeys.toArray(new IArtifactKey[artifactKeys.size()]);
+ return artifactDescriptors.toArray(new IArtifactDescriptor[artifactDescriptors.size()]);
}
public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
@@ -109,7 +94,21 @@ public class AggregatedBundleRepository extends AbstractArtifactRepository imple
* Exposed for testing and debugging purposes.
* @noreference This method is not intended to be referenced by clients.
*/
- public Collection testGetBundleRepositories() {
+ public Collection<IFileArtifactRepository> testGetBundleRepositories() {
return bundleRepositories;
}
+
+ public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) {
+ // Query all the all the repositories
+ CompoundQueryable<IArtifactKey> queryable = new CompoundQueryable<IArtifactKey>(bundleRepositories);
+ return queryable.query(query, monitor);
+ }
+
+ public IQueryable<IArtifactDescriptor> descriptorQueryable() {
+ List<IQueryable<IArtifactDescriptor>> descQueryables = new ArrayList<IQueryable<IArtifactDescriptor>>(bundleRepositories.size());
+ for (IFileArtifactRepository repository : bundleRepositories)
+ descQueryables.add(repository.descriptorQueryable());
+
+ return new CompoundQueryable<IArtifactDescriptor>(descQueryables);
+ }
}
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 1f280e541..7b0513ceb 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
@@ -15,15 +15,15 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.ProvisioningContext;
public class DirectorUtil {
public static IStatus validateProfile(IProfile profile) {
ProfileChangeRequest pcr = new ProfileChangeRequest(profile);
ProvisioningContext ctx = new ProvisioningContext(new URI[0]);
- IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.class.getName());
+ IPlanner planner = (IPlanner) ServiceHelper.getService(Activator.getContext(), IPlanner.SERVICE_NAME);
return planner.getProvisioningPlan(pcr, ctx, null).getStatus();
}
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java
index b6dafaf98..7ce57715b 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseMarkSetProvider.java
@@ -10,23 +10,22 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-
import java.io.File;
import java.util.*;
+import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.garbagecollector.MarkSet;
import org.eclipse.equinox.internal.p2.garbagecollector.MarkSetProvider;
import org.eclipse.equinox.internal.p2.update.*;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.osgi.framework.ServiceReference;
/**
@@ -36,11 +35,11 @@ public class EclipseMarkSetProvider extends MarkSetProvider {
private static final String ARTIFACT_CLASSIFIER_OSGI_BUNDLE = "osgi.bundle"; //$NON-NLS-1$
private static final String ARTIFACT_CLASSIFIER_FEATURE = "org.eclipse.update.feature"; //$NON-NLS-1$
- private Collection artifactKeyList = null;
+ private Collection<IArtifactKey> artifactKeyList = null;
- public MarkSet[] getMarkSets(IProfile inProfile) {
- artifactKeyList = new HashSet();
- IArtifactRepository repositoryToGC = Util.getBundlePoolRepository(inProfile);
+ public MarkSet[] getMarkSets(IProvisioningAgent agent, IProfile inProfile) {
+ artifactKeyList = new HashSet<IArtifactKey>();
+ IArtifactRepository repositoryToGC = Util.getBundlePoolRepository(agent, inProfile);
if (repositoryToGC == null)
return new MarkSet[0];
addArtifactKeys(inProfile);
@@ -49,15 +48,14 @@ public class EclipseMarkSetProvider extends MarkSetProvider {
addRunningBundles(repositoryToGC);
addRunningFeatures(inProfile, repositoryToGC);
}
- return new MarkSet[] {new MarkSet((IArtifactKey[]) artifactKeyList.toArray(new IArtifactKey[0]), repositoryToGC)};
+ return new MarkSet[] {new MarkSet(artifactKeyList.toArray(new IArtifactKey[artifactKeyList.size()]), repositoryToGC)};
}
private void addRunningFeatures(IProfile profile, IArtifactRepository repositoryToGC) {
try {
- List allFeatures = getAllFeatures(Configuration.load(new File(Util.getConfigurationFolder(profile), "org.eclipse.update/platform.xml"), null)); //$NON-NLS-1$
- for (Iterator iterator = allFeatures.iterator(); iterator.hasNext();) {
- Feature f = (Feature) iterator.next();
- IArtifactKey match = searchArtifact(f.getId(), new Version(f.getVersion()), ARTIFACT_CLASSIFIER_FEATURE, repositoryToGC);
+ List<Feature> allFeatures = getAllFeatures(Configuration.load(new File(Util.getConfigurationFolder(profile), "org.eclipse.update/platform.xml"), null)); //$NON-NLS-1$
+ for (Feature f : allFeatures) {
+ IArtifactKey match = searchArtifact(f.getId(), Version.create(f.getVersion()), ARTIFACT_CLASSIFIER_FEATURE, repositoryToGC);
if (match != null)
artifactKeyList.add(match);
}
@@ -66,13 +64,12 @@ public class EclipseMarkSetProvider extends MarkSetProvider {
}
}
- private List getAllFeatures(Configuration cfg) {
+ private List<Feature> getAllFeatures(Configuration cfg) {
if (cfg == null)
- return Collections.EMPTY_LIST;
- List sites = cfg.getSites();
- ArrayList result = new ArrayList();
- for (Iterator iterator = sites.iterator(); iterator.hasNext();) {
- Site object = (Site) iterator.next();
+ return CollectionUtils.emptyList();
+ List<Site> sites = cfg.getSites();
+ ArrayList<Feature> result = new ArrayList<Feature>();
+ for (Site object : sites) {
Feature[] features = object.getFeatures();
for (int i = 0; i < features.length; i++) {
result.add(features[i]);
@@ -82,7 +79,7 @@ public class EclipseMarkSetProvider extends MarkSetProvider {
}
private IProfile getCurrentProfile() {
- ServiceReference sr = Activator.getContext().getServiceReference(IProfileRegistry.class.getName());
+ ServiceReference sr = Activator.getContext().getServiceReference(IProfileRegistry.SERVICE_NAME);
if (sr == null)
return null;
IProfileRegistry pr = (IProfileRegistry) Activator.getContext().getService(sr);
@@ -93,19 +90,17 @@ public class EclipseMarkSetProvider extends MarkSetProvider {
}
private void addArtifactKeys(IProfile aProfile) {
- Iterator installableUnits = aProfile.query(InstallableUnitQuery.ANY, new Collector(), null).iterator();
+ Iterator<IInstallableUnit> installableUnits = aProfile.query(InstallableUnitQuery.ANY, null).iterator();
while (installableUnits.hasNext()) {
- IArtifactKey[] keys = ((IInstallableUnit) installableUnits.next()).getArtifacts();
+ Collection<IArtifactKey> keys = installableUnits.next().getArtifacts();
if (keys == null)
continue;
- for (int i = 0; i < keys.length; i++) {
- artifactKeyList.add(keys[i]);
- }
+ artifactKeyList.addAll(keys);
}
}
- public IArtifactRepository getRepository(IProfile aProfile) {
- return Util.getBundlePoolRepository(aProfile);
+ public IArtifactRepository getRepository(IProvisioningAgent agent, IProfile aProfile) {
+ return Util.getBundlePoolRepository(agent, aProfile);
}
private void addRunningBundles(IArtifactRepository repo) {
@@ -114,23 +109,20 @@ public class EclipseMarkSetProvider extends MarkSetProvider {
private IArtifactKey searchArtifact(String searchedId, Version searchedVersion, String classifier, IArtifactRepository repo) {
//This is somewhat cheating since normally we should get the artifact key from the IUs that were representing the running system (e.g. we could get that info from the rollback repo)
- IArtifactKey[] keys = repo.getArtifactKeys();
- for (int i = 0; i < keys.length; i++) {
- if (keys[i].getClassifier().equals(classifier)) {
- String id = keys[i].getId();
- Version v = keys[i].getVersion();
- if (id != null && id.equals(searchedId) && v != null && v.equals(searchedVersion))
- return keys[i];
- }
- }
+ VersionRange range = searchedVersion != null ? new VersionRange(searchedVersion, true, searchedVersion, true) : null;
+ ArtifactKeyQuery query = new ArtifactKeyQuery(classifier, searchedId, range);
+ //TODO short-circuit the query when we find one?
+ IQueryResult<IArtifactKey> keys = repo.query(query, null);
+ if (!keys.isEmpty())
+ return keys.iterator().next();
return null;
}
//Find for each bundle info a corresponding artifact in repo
- private ArrayList findCorrespondinArtifacts(BundleInfo[] bis, IArtifactRepository repo) {
- ArrayList toRetain = new ArrayList();
+ private List<IArtifactKey> findCorrespondinArtifacts(BundleInfo[] bis, IArtifactRepository repo) {
+ ArrayList<IArtifactKey> toRetain = new ArrayList<IArtifactKey>();
for (int i = 0; i < bis.length; i++) {
- IArtifactKey match = searchArtifact(bis[i].getSymbolicName(), new Version(bis[i].getVersion()), ARTIFACT_CLASSIFIER_OSGI_BUNDLE, repo);
+ IArtifactKey match = searchArtifact(bis[i].getSymbolicName(), Version.create(bis[i].getVersion()), ARTIFACT_CLASSIFIER_OSGI_BUNDLE, repo);
if (match != null)
toRetain.add(match);
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
index 8cf88ba61..0ded00367 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
@@ -19,10 +19,13 @@ import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdminRuntimeException;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.Operand;
+import org.eclipse.equinox.p2.engine.spi.Touchpoint;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
public class EclipseTouchpoint extends Touchpoint {
@@ -33,36 +36,37 @@ public class EclipseTouchpoint extends Touchpoint {
public static final String PARM_IU = "iu"; //$NON-NLS-1$
public static final String PARM_ARTIFACT = "artifact"; //$NON-NLS-1$
public static final String PARM_ARTIFACT_LOCATION = "artifact.location"; //$NON-NLS-1$
+ private static final Object PARM_AGENT = "agent"; //$NON-NLS-1$
private static final String NATIVE_TOUCHPOINT_ID = "org.eclipse.equinox.p2.touchpoint.natives"; //$NON-NLS-1$
- private static List NATIVE_ACTIONS = Arrays.asList(new String[] {"mkdir", "rmdir"}); //$NON-NLS-1$//$NON-NLS-2$
+ private static List<String> NATIVE_ACTIONS = Arrays.asList(new String[] {"mkdir", "rmdir"}); //$NON-NLS-1$//$NON-NLS-2$
private static final String VALIDATE_PROFILE = "org.eclipse.equinox.internal.p2.touchpoint.eclipse.validateProfile"; //$NON-NLS-1$
- private static Map manipulators = new WeakHashMap();
- private static Map wrappers = new WeakHashMap();
- private static Map sourceManipulators = new WeakHashMap();
- private static Map preparedIUs = new WeakHashMap();
+ private static Map<IProfile, LazyManipulator> manipulators = new WeakHashMap<IProfile, LazyManipulator>();
+ private static Map<IProfile, PlatformConfigurationWrapper> wrappers = new WeakHashMap<IProfile, PlatformConfigurationWrapper>();
+ private static Map<IProfile, SourceManipulator> sourceManipulators = new WeakHashMap<IProfile, SourceManipulator>();
+ private static Map<IProfile, Map<IInstallableUnit, IInstallableUnit>> preparedIUs = new WeakHashMap<IProfile, Map<IInstallableUnit, IInstallableUnit>>();
- private static synchronized LazyManipulator getManipulator(IProfile profile) {
- LazyManipulator manipulator = (LazyManipulator) manipulators.get(profile);
+ private static synchronized LazyManipulator getManipulator(IProvisioningAgent agent, IProfile profile) {
+ LazyManipulator manipulator = manipulators.get(profile);
if (manipulator == null) {
- manipulator = new LazyManipulator(profile);
+ manipulator = new LazyManipulator(agent, profile);
manipulators.put(profile, manipulator);
}
return manipulator;
}
private static synchronized void saveManipulator(IProfile profile) throws FrameworkAdminRuntimeException, IOException {
- LazyManipulator manipulator = (LazyManipulator) manipulators.remove(profile);
+ LazyManipulator manipulator = manipulators.remove(profile);
if (manipulator != null)
manipulator.save(false);
}
- private static synchronized PlatformConfigurationWrapper getPlatformConfigurationWrapper(IProfile profile, LazyManipulator manipulator) {
- PlatformConfigurationWrapper wrapper = (PlatformConfigurationWrapper) wrappers.get(profile);
+ private static synchronized PlatformConfigurationWrapper getPlatformConfigurationWrapper(IProvisioningAgent agent, IProfile profile, LazyManipulator manipulator) {
+ PlatformConfigurationWrapper wrapper = wrappers.get(profile);
if (wrapper == null) {
File configLocation = Util.getConfigurationFolder(profile);
- URI poolURI = Util.getBundlePoolLocation(profile);
+ URI poolURI = Util.getBundlePoolLocation(agent, profile);
wrapper = new PlatformConfigurationWrapper(configLocation, poolURI, manipulator);
wrappers.put(profile, wrapper);
}
@@ -70,13 +74,13 @@ public class EclipseTouchpoint extends Touchpoint {
}
private static synchronized void savePlatformConfigurationWrapper(IProfile profile) throws ProvisionException {
- PlatformConfigurationWrapper wrapper = (PlatformConfigurationWrapper) wrappers.remove(profile);
+ PlatformConfigurationWrapper wrapper = wrappers.remove(profile);
if (wrapper != null)
wrapper.save();
}
private static synchronized SourceManipulator getSourceManipulator(IProfile profile) {
- SourceManipulator sourceManipulator = (SourceManipulator) sourceManipulators.get(profile);
+ SourceManipulator sourceManipulator = sourceManipulators.get(profile);
if (sourceManipulator == null) {
sourceManipulator = new SourceManipulator(profile);
sourceManipulators.put(profile, sourceManipulator);
@@ -85,23 +89,23 @@ public class EclipseTouchpoint extends Touchpoint {
}
private static synchronized void saveSourceManipulator(IProfile profile) throws IOException {
- SourceManipulator sourceManipulator = (SourceManipulator) sourceManipulators.remove(profile);
+ SourceManipulator sourceManipulator = sourceManipulators.remove(profile);
if (sourceManipulator != null)
sourceManipulator.save();
}
private static synchronized IInstallableUnit getPreparedIU(IProfile profile, IInstallableUnit iu) {
- Map preparedProfileIUs = (Map) preparedIUs.get(profile);
+ Map<IInstallableUnit, IInstallableUnit> preparedProfileIUs = preparedIUs.get(profile);
if (preparedProfileIUs == null)
return null;
- return (IInstallableUnit) preparedProfileIUs.get(iu);
+ return preparedProfileIUs.get(iu);
}
private static synchronized void savePreparedIU(IProfile profile, IInstallableUnit iu) {
- Map preparedProfileIUs = (Map) preparedIUs.get(profile);
+ Map<IInstallableUnit, IInstallableUnit> preparedProfileIUs = preparedIUs.get(profile);
if (preparedProfileIUs == null) {
- preparedProfileIUs = new HashMap();
+ preparedProfileIUs = new HashMap<IInstallableUnit, IInstallableUnit>();
preparedIUs.put(profile, preparedProfileIUs);
}
preparedProfileIUs.put(iu, iu);
@@ -165,19 +169,21 @@ public class EclipseTouchpoint extends Touchpoint {
return touchpointQualifier + "." + actionId; //$NON-NLS-1$
}
- public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map touchpointParameters) {
- LazyManipulator manipulator = getManipulator(profile);
+ public IStatus initializePhase(IProgressMonitor monitor, IProfile profile, String phaseId, Map<String, Object> touchpointParameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) touchpointParameters.get(PARM_AGENT);
+ LazyManipulator manipulator = getManipulator(agent, profile);
touchpointParameters.put(PARM_MANIPULATOR, manipulator);
touchpointParameters.put(PARM_SOURCE_BUNDLES, getSourceManipulator(profile));
- touchpointParameters.put(PARM_PLATFORM_CONFIGURATION, getPlatformConfigurationWrapper(profile, manipulator));
+ touchpointParameters.put(PARM_PLATFORM_CONFIGURATION, getPlatformConfigurationWrapper(agent, profile, manipulator));
return null;
}
- public IStatus initializeOperand(IProfile profile, Operand operand, Map parameters) {
+ public IStatus initializeOperand(IProfile profile, Operand operand, Map<String, Object> parameters) {
IInstallableUnit iu = (IInstallableUnit) parameters.get(PARM_IU);
IArtifactKey artifactKey = (IArtifactKey) parameters.get(PARM_ARTIFACT);
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(PARM_AGENT);
if (iu != null && Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue()) {
- IInstallableUnit preparedIU = prepareIU(iu, artifactKey, profile);
+ IInstallableUnit preparedIU = prepareIU(agent, profile, iu, artifactKey);
if (preparedIU == null)
return Util.createError(NLS.bind(Messages.failed_prepareIU, iu));
@@ -185,19 +191,19 @@ public class EclipseTouchpoint extends Touchpoint {
}
if (!parameters.containsKey(PARM_ARTIFACT_LOCATION) && artifactKey != null) {
- File fileLocation = Util.getArtifactFile(artifactKey, profile);
+ File fileLocation = Util.getArtifactFile(agent, artifactKey, profile);
if (fileLocation != null && fileLocation.exists())
parameters.put(PARM_ARTIFACT_LOCATION, fileLocation.getAbsolutePath());
}
return Status.OK_STATUS;
}
- public IInstallableUnit prepareIU(IInstallableUnit iu, IArtifactKey artifactKey, IProfile profile) {
+ public IInstallableUnit prepareIU(IProvisioningAgent agent, IProfile profile, IInstallableUnit iu, IArtifactKey artifactKey) {
IInstallableUnit preparedIU = getPreparedIU(profile, iu);
if (preparedIU != null)
return preparedIU;
- Class c = null;
+ Class<?> c = null;
try {
c = Class.forName("org.eclipse.equinox.p2.publisher.eclipse.BundlesAction"); //$NON-NLS-1$
if (c != null)
@@ -211,7 +217,7 @@ public class EclipseTouchpoint extends Touchpoint {
if (artifactKey == null)
return iu;
- File bundleFile = Util.getArtifactFile(artifactKey, profile);
+ File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
if (bundleFile == null) {
LogHelper.log(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey.toString())));
return null;
@@ -234,7 +240,7 @@ public class EclipseTouchpoint extends Touchpoint {
if (Boolean.FALSE.toString().equals(profile.getProperty(VALIDATE_PROFILE)))
return Status.OK_STATUS;
- Class c = null;
+ Class<?> c = null;
try {
c = Class.forName("org.eclipse.equinox.internal.provisional.p2.director.IPlanner"); //$NON-NLS-1$
} catch (ClassNotFoundException e) {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java
index d432a4e6d..6869eb284 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/LazyManipulator.java
@@ -11,11 +11,10 @@
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
import java.io.IOException;
-import java.net.URISyntaxException;
-import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfile;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
@@ -28,9 +27,11 @@ public class LazyManipulator implements Manipulator {
private Manipulator manipulator;
private final IProfile profile;
+ private final IProvisioningAgent agent;
- public LazyManipulator(IProfile profile) {
+ public LazyManipulator(IProvisioningAgent agent, IProfile profile) {
this.profile = profile;
+ this.agent = agent;
}
private void loadDelegate() {
@@ -61,12 +62,7 @@ public class LazyManipulator implements Manipulator {
}
//TODO These values should be inserted by a configuration unit (bug 204124)
manipulator.getConfigData().setProperty("eclipse.p2.profile", profile.getProfileId()); //$NON-NLS-1$
- try {
- manipulator.getConfigData().setProperty("eclipse.p2.data.area", URIUtil.toURI(Util.getAgentLocation().getURL()).toString()); //$NON-NLS-1$
- } catch (URISyntaxException e) {
- LogHelper.log(Util.createError(Messages.error_loading_manipulator, e));
- throw new IllegalStateException(Messages.error_loading_manipulator);
- }
+ manipulator.getConfigData().setProperty("eclipse.p2.data.area", Util.getAgentLocation(agent).getRootLocation().toString()); //$NON-NLS-1$
}
public static FrameworkAdmin getFrameworkAdmin() {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java
index 5dcf1ab92..e09db8851 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PlatformConfigurationWrapper.java
@@ -12,14 +12,13 @@ package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
import java.io.File;
import java.net.*;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
import org.eclipse.equinox.internal.p2.update.*;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.osgi.util.NLS;
/**
@@ -104,8 +103,7 @@ public class PlatformConfigurationWrapper {
* Otherwise the default is USER-EXCLUDE.
*/
private String getDefaultPolicy() {
- for (Iterator iter = configuration.getSites().iterator(); iter.hasNext();) {
- Site site = (Site) iter.next();
+ for (Site site : configuration.getSites()) {
if (Site.POLICY_MANAGED_ONLY.equals(site.getPolicy()))
return Site.POLICY_MANAGED_ONLY;
}
@@ -133,10 +131,9 @@ public class PlatformConfigurationWrapper {
* the given URL. Return null if there is no match.
*/
private Site getSite(URI url) {
- List sites = configuration.getSites();
+ List<Site> sites = configuration.getSites();
File file = URIUtil.toFile(url);
- for (Iterator iter = sites.iterator(); iter.hasNext();) {
- Site nextSite = (Site) iter.next();
+ for (Site nextSite : sites) {
try {
File nextFile = URLUtil.toFile(new URL(nextSite.getUrl()));
if (nextFile == null)
@@ -155,9 +152,8 @@ public class PlatformConfigurationWrapper {
* with the given identifier and version. Return null if there is none.
*/
private Site getSite(String id, String version) {
- List sites = configuration.getSites();
- for (Iterator iter = sites.iterator(); iter.hasNext();) {
- Site site = (Site) iter.next();
+ List<Site> sites = configuration.getSites();
+ for (Site site : sites) {
Feature[] features = site.getFeatures();
for (int i = 0; i < features.length; i++) {
if (id.equals(features[i].getId()) && version.equals(features[i].getVersion()))
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PublisherUtil.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PublisherUtil.java
index 881a70927..1f6151b6d 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PublisherUtil.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/PublisherUtil.java
@@ -11,12 +11,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-
import java.io.File;
import org.eclipse.core.runtime.Path;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.publisher.eclipse.*;
import org.eclipse.osgi.service.resolver.BundleDescription;
@@ -32,7 +29,7 @@ public class PublisherUtil {
if (bundleDescription == null)
return null;
PublisherInfo info = new PublisherInfo();
- Version version = new Version(bundleDescription.getVersion().toString());
+ Version version = Version.create(bundleDescription.getVersion().toString());
AdviceFileAdvice advice = new AdviceFileAdvice(bundleDescription.getSymbolicName(), version, new Path(bundleFile.getAbsolutePath()), AdviceFileAdvice.BUNDLE_ADVICE_FILE);
if (advice.containsAdvice())
info.addAdvice(advice);
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/SourceManipulator.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/SourceManipulator.java
index 6d6ae8bb2..faab230ac 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/SourceManipulator.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/SourceManipulator.java
@@ -8,19 +8,18 @@
******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.*;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
import org.eclipse.equinox.internal.simpleconfigurator.manipulator.SimpleConfiguratorManipulatorImpl;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.Version;
//This class deals with source bundles and how their addition to the source.info
public class SourceManipulator {
- private List sourceBundles;
+ private List<BundleInfo> sourceBundles;
private IProfile profile;
boolean changed = false;
private SimpleConfiguratorManipulatorImpl manipulator;
@@ -33,7 +32,7 @@ public class SourceManipulator {
public BundleInfo[] getBundles() throws IOException {
if (sourceBundles == null)
load();
- return (BundleInfo[]) sourceBundles.toArray(new BundleInfo[sourceBundles.size()]);
+ return sourceBundles.toArray(new BundleInfo[sourceBundles.size()]);
}
public void addBundle(File bundleFile, String bundleId, Version bundleVersion) throws IOException {
@@ -59,14 +58,14 @@ public class SourceManipulator {
public void save() throws IOException {
if (sourceBundles != null)
- manipulator.saveConfiguration((BundleInfo[]) sourceBundles.toArray(new BundleInfo[sourceBundles.size()]), getFileLocation(), getLauncherLocation());
+ manipulator.saveConfiguration(sourceBundles.toArray(new BundleInfo[sourceBundles.size()]), getFileLocation(), getLauncherLocation());
}
private void load() throws MalformedURLException, IOException {
if (getFileLocation().exists())
- sourceBundles = new ArrayList(Arrays.asList(manipulator.loadConfiguration(getFileLocation().toURL(), getLauncherLocation())));
+ sourceBundles = new ArrayList<BundleInfo>(Arrays.asList(manipulator.loadConfiguration(getFileLocation().toURL(), getLauncherLocation())));
else
- sourceBundles = new ArrayList();
+ sourceBundles = new ArrayList<BundleInfo>();
}
private File getFileLocation() {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
index 68784218c..47f2d0fda 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java
@@ -18,12 +18,11 @@ import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.*;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
+import org.eclipse.equinox.p2.core.*;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.eclipse.osgi.util.ManifestElement;
@@ -53,35 +52,29 @@ public class Util {
*/
public static final int AGGREGATE_CACHE_EXTENSIONS = 0x04;
- public static AgentLocation getAgentLocation() {
- return (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName());
+ public static IAgentLocation getAgentLocation(IProvisioningAgent agent) {
+ return (IAgentLocation) agent.getService(IAgentLocation.class.getName());
}
- public static IArtifactRepositoryManager getArtifactRepositoryManager() {
- return (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
+ public static IArtifactRepositoryManager getArtifactRepositoryManager(IProvisioningAgent agent) {
+ return (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
}
- public static URI getBundlePoolLocation(IProfile profile) {
+ public static URI getBundlePoolLocation(IProvisioningAgent agent, IProfile profile) {
String path = profile.getProperty(IProfile.PROP_CACHE);
if (path != null)
return new File(path).toURI();
- AgentLocation location = getAgentLocation();
+ IAgentLocation location = getAgentLocation(agent);
if (location == null)
return null;
- try {
- return URIUtil.toURI(location.getDataArea(Activator.ID));
- } catch (URISyntaxException e) {
- // unexpected, URLs should be pre-checked
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e));
- throw new RuntimeException(e);
- }
+ return location.getDataArea(Activator.ID);
}
- public static synchronized IFileArtifactRepository getBundlePoolRepository(IProfile profile) {
- URI location = getBundlePoolLocation(profile);
+ public static synchronized IFileArtifactRepository getBundlePoolRepository(IProvisioningAgent agent, IProfile profile) {
+ URI location = getBundlePoolLocation(agent, profile);
if (location == null)
return null;
- IArtifactRepositoryManager manager = getArtifactRepositoryManager();
+ IArtifactRepositoryManager manager = getArtifactRepositoryManager(agent);
try {
return (IFileArtifactRepository) manager.loadRepository(location, null);
} catch (ProvisionException e) {
@@ -89,7 +82,7 @@ public class Util {
}
try {
String repositoryName = Messages.BundlePool;
- Map properties = new HashMap(1);
+ Map<String, String> properties = new HashMap<String, String>(1);
properties.put(IRepository.PROP_SYSTEM, Boolean.TRUE.toString());
return (IFileArtifactRepository) manager.createRepository(location, repositoryName, REPOSITORY_TYPE, properties);
} catch (ProvisionException e) {
@@ -98,15 +91,15 @@ public class Util {
}
}
- public static IFileArtifactRepository getAggregatedBundleRepository(IProfile profile) {
- return getAggregatedBundleRepository(profile, AGGREGATE_CACHE | AGGREGATE_SHARED_CACHE | AGGREGATE_CACHE_EXTENSIONS);
+ public static IFileArtifactRepository getAggregatedBundleRepository(IProvisioningAgent agent, IProfile profile) {
+ return getAggregatedBundleRepository(agent, profile, AGGREGATE_CACHE | AGGREGATE_SHARED_CACHE | AGGREGATE_CACHE_EXTENSIONS);
}
- public static IFileArtifactRepository getAggregatedBundleRepository(IProfile profile, int repoFilter) {
- List bundleRepositories = new ArrayList();
+ public static IFileArtifactRepository getAggregatedBundleRepository(IProvisioningAgent agent, IProfile profile, int repoFilter) {
+ List<IFileArtifactRepository> bundleRepositories = new ArrayList<IFileArtifactRepository>();
// we check for a shared bundle pool first as it should be preferred over the user bundle pool in a shared install
- IArtifactRepositoryManager manager = getArtifactRepositoryManager();
+ IArtifactRepositoryManager manager = getArtifactRepositoryManager(agent);
if ((repoFilter & AGGREGATE_SHARED_CACHE) != 0) {
String sharedCache = profile.getProperty(IProfile.PROP_SHARED_CACHE);
if (sharedCache != null) {
@@ -114,7 +107,7 @@ public class Util {
URI repoLocation = new File(sharedCache).toURI();
IArtifactRepository repository = manager.loadRepository(repoLocation, null);
if (repository != null && repository instanceof IFileArtifactRepository && !bundleRepositories.contains(repository))
- bundleRepositories.add(repository);
+ bundleRepositories.add((IFileArtifactRepository) repository);
} catch (ProvisionException e) {
//skip repository if it could not be read
}
@@ -122,16 +115,15 @@ public class Util {
}
if ((repoFilter & AGGREGATE_CACHE) != 0) {
- IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile);
+ IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(agent, profile);
if (bundlePool != null)
bundleRepositories.add(bundlePool);
}
if ((repoFilter & AGGREGATE_CACHE_EXTENSIONS) != 0) {
- List repos = getListProfileProperty(profile, CACHE_EXTENSIONS);
- for (Iterator iterator = repos.iterator(); iterator.hasNext();) {
+ List<String> repos = getListProfileProperty(profile, CACHE_EXTENSIONS);
+ for (String repo : repos) {
try {
- String repo = (String) iterator.next();
URI repoLocation;
try {
repoLocation = new URI(repo);
@@ -141,7 +133,7 @@ public class Util {
}
IArtifactRepository repository = manager.loadRepository(repoLocation, null);
if (repository != null && repository instanceof IFileArtifactRepository && !bundleRepositories.contains(repository))
- bundleRepositories.add(repository);
+ bundleRepositories.add((IFileArtifactRepository) repository);
} catch (ProvisionException e) {
//skip repositories that could not be read
} catch (URISyntaxException e) {
@@ -153,8 +145,8 @@ public class Util {
return new AggregatedBundleRepository(bundleRepositories);
}
- private static List getListProfileProperty(IProfile profile, String key) {
- List listProperty = new ArrayList();
+ private static List<String> getListProfileProperty(IProfile profile, String key) {
+ List<String> listProperty = new ArrayList<String>();
String dropinRepositories = profile.getProperty(key);
if (dropinRepositories != null) {
StringTokenizer tokenizer = new StringTokenizer(dropinRepositories, PIPE);
@@ -172,20 +164,21 @@ public class Util {
bundleInfo.setManifest(manifest);
try {
- Map headers = ManifestElement.parseBundleManifest(new ByteArrayInputStream(manifest.getBytes("UTF-8")), new HashMap()); //$NON-NLS-1$
- ManifestElement[] element = ManifestElement.parseHeader("bsn", (String) headers.get(Constants.BUNDLE_SYMBOLICNAME)); //$NON-NLS-1$
+ @SuppressWarnings("unchecked")
+ Map<String, String> headers = ManifestElement.parseBundleManifest(new ByteArrayInputStream(manifest.getBytes("UTF-8")), new HashMap<String, String>()); //$NON-NLS-1$
+ ManifestElement[] element = ManifestElement.parseHeader("bsn", headers.get(Constants.BUNDLE_SYMBOLICNAME)); //$NON-NLS-1$
if (element == null || element.length == 0)
return null;
bundleInfo.setSymbolicName(element[0].getValue());
- String version = (String) headers.get(Constants.BUNDLE_VERSION);
+ String version = headers.get(Constants.BUNDLE_VERSION);
if (version == null)
return null;
// convert to a Version object first to ensure we are consistent with our version number w.r.t.
// padding zeros at the end
bundleInfo.setVersion(Version.parseVersion(version).toString());
- String fragmentHost = (String) headers.get(Constants.FRAGMENT_HOST);
+ String fragmentHost = headers.get(Constants.FRAGMENT_HOST);
if (fragmentHost != null)
bundleInfo.setFragmentHost(fragmentHost.trim());
@@ -201,8 +194,8 @@ public class Util {
return bundleInfo;
}
- public static File getArtifactFile(IArtifactKey artifactKey, IProfile profile) {
- IFileArtifactRepository aggregatedView = getAggregatedBundleRepository(profile);
+ public static File getArtifactFile(IProvisioningAgent agent, IArtifactKey artifactKey, IProfile profile) {
+ IFileArtifactRepository aggregatedView = getAggregatedBundleRepository(agent, profile);
File bundleJar = aggregatedView.getArtifactFile(artifactKey);
return bundleJar;
}
@@ -303,9 +296,9 @@ public class Util {
return null;
}
- public static String getManifest(ITouchpointData[] data) {
- for (int i = 0; i < data.length; i++) {
- ITouchpointInstruction manifestInstruction = data[i].getInstruction("manifest"); //$NON-NLS-1$
+ public static String getManifest(List<ITouchpointData> data) {
+ for (int i = 0; i < data.size(); i++) {
+ ITouchpointInstruction manifestInstruction = data.get(i).getInstruction("manifest"); //$NON-NLS-1$
if (manifestInstruction == null)
return null;
String manifest = manifestInstruction.getBody();
@@ -328,7 +321,7 @@ public class Util {
return launcherConfig == null ? null : new File(launcherConfig);
}
- public static String resolveArtifactParam(Map parameters) throws CoreException {
+ public static String resolveArtifactParam(Map<String, Object> parameters) throws CoreException {
String artifactLocation = (String) parameters.get(EclipseTouchpoint.PARM_ARTIFACT_LOCATION);
if (artifactLocation != null)
return artifactLocation;
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java
index 78a56eb6c..1a5c2d1d0 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java
@@ -10,6 +10,7 @@ package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
public class ActionConstants {
+ public static final String PARM_AGENT = "agent"; //$NON-NLS-1$
public static final String PARM_AT_ARTIFACT = "@artifact"; //$NON-NLS-1$
public static final String PARM_ARTIFACT_FILES = "artifactFiles"; //$NON-NLS-1$
public static final String PARM_ARTIFACT_REQUESTS = "artifactRequests"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddJVMArgumentAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddJVMArgumentAction.java
index 816b41879..9268549a8 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddJVMArgumentAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddJVMArgumentAction.java
@@ -15,7 +15,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*;
import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.osgi.util.NLS;
public class AddJVMArgumentAction extends ProvisioningAction {
@@ -27,14 +27,14 @@ public class AddJVMArgumentAction extends ProvisioningAction {
protected static final String XX_MAX_PERM_SIZE = "-XX:MaxPermSize="; //$NON-NLS-1$
protected static final String PREFIX_USER_VALUE = "eclipse.userDefined:"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
String jvmArg = (String) parameters.get(ActionConstants.PARM_JVM_ARG);
if (jvmArg == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_JVM_ARG, ID));
return addArg(jvmArg, parameters);
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
String jvmArg = (String) parameters.get(ActionConstants.PARM_JVM_ARG);
if (jvmArg == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_JVM_ARG, ID));
@@ -45,7 +45,7 @@ public class AddJVMArgumentAction extends ProvisioningAction {
return storedValues.getProperty(PREFIX_USER_VALUE + flag);
}
- protected static IStatus addArg(String arg, Map parameters) {
+ protected static IStatus addArg(String arg, Map<String, Object> parameters) {
LauncherData launcherData = ((Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR)).getLauncherData();
File storageArea = (File) parameters.get(ActionConstants.PARM_PROFILE_DATA_DIRECTORY);
try {
@@ -215,7 +215,7 @@ public class AddJVMArgumentAction extends ProvisioningAction {
if (argString == null || argString.length() == 0)
return new String[0];
- List list = new ArrayList();
+ List<String> list = new ArrayList<String>();
int i = 0;
String arg = ""; //$NON-NLS-1$
@@ -230,10 +230,7 @@ public class AddJVMArgumentAction extends ProvisioningAction {
}
list.add(arg);
- String[] argList = new String[list.size()];
- list.toArray(argList);
-
- return argList;
+ return list.toArray(new String[list.size()]);
}
// Store a single user argument, null removes stored values
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddProgramArgumentAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddProgramArgumentAction.java
index 7672437dc..b44806f9d 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddProgramArgumentAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddProgramArgumentAction.java
@@ -15,13 +15,13 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.osgi.util.NLS;
public class AddProgramArgumentAction extends ProvisioningAction {
public static final String ID = "addProgramArg"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
String programArg = (String) parameters.get(ActionConstants.PARM_PROGRAM_ARG);
if (programArg == null)
@@ -54,7 +54,7 @@ public class AddProgramArgumentAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
String programArg = (String) parameters.get(ActionConstants.PARM_PROGRAM_ARG);
if (programArg == null)
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java
index 71bc26fed..2a05a1c2c 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddRepositoryAction.java
@@ -14,6 +14,9 @@ import java.util.Map;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.engine.Profile;
import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfileRegistry;
/**
* An action that adds a repository to the list of known repositories.
@@ -21,15 +24,18 @@ import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
public class AddRepositoryAction extends RepositoryAction {
public static final String ID = "addRepository"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
try {
+ IProvisioningAgent agent = getAgent(parameters);
+ IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
final RepositoryEvent event = createEvent(parameters);
Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE);
if (profile != null)
- addRepositoryToProfile(profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled());
+ addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled());
//if provisioning into the current profile, broadcast an event to add this repository directly to the current repository managers.
- if (isSelfProfile(profile))
- addToSelf(event);
+ if (isSelfProfile(registry, profile))
+ addToSelf(agentLocation, event);
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
@@ -40,15 +46,18 @@ public class AddRepositoryAction extends RepositoryAction {
return ID;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
try {
+ IProvisioningAgent agent = getAgent(parameters);
+ IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
final RepositoryEvent event = createEvent(parameters);
Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE);
if (profile != null)
- removeRepositoryFromProfile(profile, event.getRepositoryLocation(), event.getRepositoryType());
+ removeRepositoryFromProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryType());
//if provisioning into the current profile, broadcast an event to add this repository directly to the current repository managers.
- if (isSelfProfile(profile))
- removeFromSelf(event);
+ if (isSelfProfile(registry, profile))
+ removeFromSelf(agentLocation, event);
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddSourceBundleAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddSourceBundleAction.java
index 2f90c6aaa..640132ec5 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddSourceBundleAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/AddSourceBundleAction.java
@@ -10,28 +10,31 @@ package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
import java.io.File;
import java.io.IOException;
+import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
public class AddSourceBundleAction extends ProvisioningAction {
public static final String ID = "addSourceBundle"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
return AddSourceBundleAction.addSourceBundle(parameters);
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
return RemoveSourceBundleAction.removeSourceBundle(parameters);
}
- public static IStatus addSourceBundle(Map parameters) {
+ public static IStatus addSourceBundle(Map<String, Object> parameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
SourceManipulator manipulator = (SourceManipulator) parameters.get(EclipseTouchpoint.PARM_SOURCE_BUNDLES);
@@ -39,21 +42,21 @@ public class AddSourceBundleAction extends ProvisioningAction {
if (bundleId == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_BUNDLE, ID));
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.size() == 0)
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
IArtifactKey artifactKey = null;
- for (int i = 0; i < artifacts.length; i++) {
- if (artifacts[i].toString().equals(bundleId)) {
- artifactKey = artifacts[i];
+ for (IArtifactKey candidate : artifacts) {
+ if (candidate.toString().equals(bundleId)) {
+ artifactKey = candidate;
break;
}
}
if (artifactKey == null)
throw new IllegalArgumentException(NLS.bind(Messages.no_matching_artifact, bundleId));
- File bundleFile = Util.getArtifactFile(artifactKey, profile);
+ File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
if (bundleFile == null || !bundleFile.exists())
return Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey));
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CheckTrustAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CheckTrustAction.java
index 027ef3d5f..7eb0d940b 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CheckTrustAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CheckTrustAction.java
@@ -17,12 +17,12 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
/**
* This action collects the set of bundle files on which the signature trust check
@@ -35,20 +35,22 @@ public class CheckTrustAction extends ProvisioningAction {
/* (non-Javadoc)
* @see org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction#execute(java.util.Map)
*/
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
if (iu == null)
return null;
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
//if the IU is already in the profile there is nothing to do
- if (!profile.available(new InstallableUnitQuery(iu), new Collector(), null).isEmpty())
+ if (!profile.available(new InstallableUnitQuery(iu), null).isEmpty())
return null;
- Collection bundleFiles = (Collection) parameters.get(ActionConstants.PARM_ARTIFACT_FILES);
- IArtifactKey[] artifacts = iu.getArtifacts();
+ @SuppressWarnings("unchecked")
+ Collection<File> bundleFiles = (Collection<File>) parameters.get(ActionConstants.PARM_ARTIFACT_FILES);
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
if (artifacts == null)
return null;
- for (int i = 0; i < artifacts.length; i++) {
- File bundleFile = Util.getArtifactFile(artifacts[i], profile);
+ for (IArtifactKey key : artifacts) {
+ File bundleFile = Util.getArtifactFile(agent, key, profile);
if (!bundleFiles.contains(bundleFile))
bundleFiles.add(bundleFile);
}
@@ -58,7 +60,7 @@ public class CheckTrustAction extends ProvisioningAction {
/* (non-Javadoc)
* @see org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction#undo(java.util.Map)
*/
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
return Status.OK_STATUS;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java
index 0aaeb6717..bc1d51d80 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java
@@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.Map;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.osgi.util.NLS;
// This basically a copy of the chmod action in the native touchpoint only it provides @artifact support.
@@ -25,7 +25,7 @@ import org.eclipse.osgi.util.NLS;
public class ChmodAction extends ProvisioningAction {
private static final String ACTION_CHMOD = "chmod"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
String targetDir = (String) parameters.get(ActionConstants.PARM_TARGET_DIR);
if (targetDir == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_TARGET_DIR, ACTION_CHMOD));
@@ -57,7 +57,7 @@ public class ChmodAction extends ProvisioningAction {
String options[] = null;
if (optionsString != null) {
- ArrayList collect = new ArrayList();
+ ArrayList<String> collect = new ArrayList<String>();
String r = optionsString.trim();
while (r.length() > 0) {
int spaceIdx = r.indexOf(' ');
@@ -71,8 +71,7 @@ public class ChmodAction extends ProvisioningAction {
}
}
if (collect.size() > 0) {
- options = new String[collect.size()];
- collect.toArray(options);
+ options = collect.toArray(new String[collect.size()]);
}
}
@@ -80,7 +79,7 @@ public class ChmodAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
//TODO: implement undo ??
return Status.OK_STATUS;
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java
index f1932a576..4ac0e4109 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/CollectAction.java
@@ -12,79 +12,83 @@ import java.util.*;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.InstallableUnitOperand;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.osgi.util.NLS;
public class CollectAction extends ProvisioningAction {
public static final String ID = "collect"; //$NON-NLS-1$
public static final String ARTIFACT_FOLDER = "artifact.folder"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
InstallableUnitOperand operand = (InstallableUnitOperand) parameters.get(ActionConstants.PARM_OPERAND);
IArtifactRequest[] requests;
try {
- requests = CollectAction.collect(operand.second(), profile);
+ requests = CollectAction.collect(agent, profile, operand.second());
} catch (ProvisionException e) {
return e.getStatus();
}
- Collection artifactRequests = (Collection) parameters.get(ActionConstants.PARM_ARTIFACT_REQUESTS);
+ @SuppressWarnings("unchecked")
+ Collection<IArtifactRequest[]> artifactRequests = (Collection<IArtifactRequest[]>) parameters.get(ActionConstants.PARM_ARTIFACT_REQUESTS);
artifactRequests.add(requests);
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
// nothing to do for now
return Status.OK_STATUS;
}
- public static boolean isZipped(ITouchpointData[] data) {
- if (data == null || data.length == 0)
+ public static boolean isZipped(List<ITouchpointData> data) {
+ if (data == null || data.size() == 0)
return false;
- for (int i = 0; i < data.length; i++) {
- if (data[i].getInstruction("zipped") != null) //$NON-NLS-1$
+ for (int i = 0; i < data.size(); i++) {
+ if (data.get(i).getInstruction("zipped") != null) //$NON-NLS-1$
return true;
}
return false;
}
- public static Properties createArtifactDescriptorProperties(IInstallableUnit installableUnit) {
- Properties descriptorProperties = null;
+ public static Map<String, String> createArtifactDescriptorProperties(IInstallableUnit installableUnit) {
+ Map<String, String> descriptorProperties = null;
if (CollectAction.isZipped(installableUnit.getTouchpointData())) {
- descriptorProperties = new Properties();
- descriptorProperties.setProperty(CollectAction.ARTIFACT_FOLDER, Boolean.TRUE.toString());
+ descriptorProperties = new HashMap<String, String>();
+ descriptorProperties.put(CollectAction.ARTIFACT_FOLDER, Boolean.TRUE.toString());
}
return descriptorProperties;
}
// TODO: Here we may want to consult multiple caches
- public static IArtifactRequest[] collect(IInstallableUnit installableUnit, IProfile profile) throws ProvisionException {
- IArtifactKey[] toDownload = installableUnit.getArtifacts();
- if (toDownload == null || toDownload.length == 0)
+ static IArtifactRequest[] collect(IProvisioningAgent agent, IProfile profile, IInstallableUnit installableUnit) throws ProvisionException {
+ Collection<IArtifactKey> toDownload = installableUnit.getArtifacts();
+ if (toDownload == null || toDownload.size() == 0)
return IArtifactRepositoryManager.NO_ARTIFACT_REQUEST;
- IArtifactRepository aggregatedRepositoryView = Util.getAggregatedBundleRepository(profile);
- IArtifactRepository bundlePool = Util.getBundlePoolRepository(profile);
+ IArtifactRepository aggregatedRepositoryView = Util.getAggregatedBundleRepository(agent, profile);
+ IArtifactRepository bundlePool = Util.getBundlePoolRepository(agent, profile);
if (bundlePool == null)
throw new ProvisionException(Util.createError(NLS.bind(Messages.no_bundle_pool, profile.getProfileId())));
- List requests = new ArrayList();
- for (int i = 0; i < toDownload.length; i++) {
- IArtifactKey key = toDownload[i];
+ List<IArtifactRequest> requests = new ArrayList<IArtifactRequest>();
+ for (IArtifactKey key : toDownload) {
if (!aggregatedRepositoryView.contains(key)) {
- Properties repositoryProperties = CollectAction.createArtifactDescriptorProperties(installableUnit);
- requests.add(Util.getArtifactRepositoryManager().createMirrorRequest(key, bundlePool, null, repositoryProperties));
+ Map<String, String> repositoryProperties = CollectAction.createArtifactDescriptorProperties(installableUnit);
+ requests.add(Util.getArtifactRepositoryManager(agent).createMirrorRequest(key, bundlePool, null, repositoryProperties));
}
}
if (requests.isEmpty())
return IArtifactRepositoryManager.NO_ARTIFACT_REQUEST;
- IArtifactRequest[] result = (IArtifactRequest[]) requests.toArray(new IArtifactRequest[requests.size()]);
+ IArtifactRequest[] result = requests.toArray(new IArtifactRequest[requests.size()]);
return result;
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java
index ebfc1240f..c3ef27ec8 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallBundleAction.java
@@ -9,6 +9,7 @@
package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
import java.io.File;
+import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -16,24 +17,27 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.FragmentQuery;
import org.eclipse.osgi.util.NLS;
public class InstallBundleAction extends ProvisioningAction {
public static final String ID = "installBundle"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
return InstallBundleAction.installBundle(parameters);
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
return UninstallBundleAction.uninstallBundle(parameters);
}
- public static IStatus installBundle(Map parameters) {
+ public static IStatus installBundle(Map<String, Object> parameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
@@ -42,26 +46,26 @@ public class InstallBundleAction extends ProvisioningAction {
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_BUNDLE, ID));
//TODO: eventually remove this. What is a fragment doing here??
- if (iu.isFragment()) {
+ if (FragmentQuery.isFragment(iu)) {
System.out.println("What is a fragment doing here!!! -- " + iu); //$NON-NLS-1$
return Status.OK_STATUS;
}
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.isEmpty())
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
IArtifactKey artifactKey = null;
- for (int i = 0; i < artifacts.length; i++) {
- if (artifacts[i].toString().equals(bundleId)) {
- artifactKey = artifacts[i];
+ for (IArtifactKey candidate : artifacts) {
+ if (candidate.toString().equals(bundleId)) {
+ artifactKey = candidate;
break;
}
}
if (artifactKey == null)
throw new IllegalArgumentException(NLS.bind(Messages.no_matching_artifact, bundleId));
- File bundleFile = Util.getArtifactFile(artifactKey, profile);
+ File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
if (bundleFile == null || !bundleFile.exists())
return Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey));
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallFeatureAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallFeatureAction.java
index f0575ebe1..b9d55ba06 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallFeatureAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/InstallFeatureAction.java
@@ -9,14 +9,16 @@
package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
import java.io.File;
+import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*;
import org.eclipse.equinox.internal.p2.update.Site;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
public class InstallFeatureAction extends ProvisioningAction {
@@ -25,29 +27,29 @@ public class InstallFeatureAction extends ProvisioningAction {
private static final String UPDATE_FEATURE_PLUGIN_PROP = "org.eclipse.update.feature.plugin"; //$NON-NLS-1$
private static final String UPDATE_FEATURE_PRIMARY_PROP = "org.eclipse.update.feature.primary"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
return InstallFeatureAction.installFeature(parameters);
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
return UninstallFeatureAction.uninstallFeature(parameters);
}
- public static IStatus installFeature(Map parameters) {
+ public static IStatus installFeature(Map<String, Object> parameters) {
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
PlatformConfigurationWrapper configuration = (PlatformConfigurationWrapper) parameters.get(EclipseTouchpoint.PARM_PLATFORM_CONFIGURATION);
String feature = (String) parameters.get(ActionConstants.PARM_FEATURE);
String featureId = (String) parameters.get(ActionConstants.PARM_FEATURE_ID);
String featureVersion = (String) parameters.get(ActionConstants.PARM_FEATURE_VERSION);
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.isEmpty())
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
IArtifactKey artifactKey = null;
- for (int i = 0; i < artifacts.length; i++) {
- if (artifacts[i].toString().equals(feature)) {
- artifactKey = artifacts[i];
+ for (IArtifactKey candidate : artifacts) {
+ if (candidate.toString().equals(feature)) {
+ artifactKey = candidate;
break;
}
}
@@ -64,8 +66,9 @@ public class InstallFeatureAction extends ProvisioningAction {
featureVersion = artifactKey.getVersion().toString();
}
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
- File file = Util.getArtifactFile(artifactKey, profile);
+ File file = Util.getArtifactFile(agent, artifactKey, profile);
if (file == null || !file.exists()) {
return Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey));
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/LinkAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/LinkAction.java
index 13b860045..708d8bf69 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/LinkAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/LinkAction.java
@@ -14,7 +14,7 @@ import java.io.*;
import java.util.Map;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.osgi.util.NLS;
//This is basically a copy of the ln action in the native touchpoint only it provides @artifact support and does not support the backup store.
@@ -22,7 +22,7 @@ import org.eclipse.osgi.util.NLS;
public class LinkAction extends ProvisioningAction {
public static final String ID = "ln"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
String targetDir = (String) parameters.get(ActionConstants.PARM_TARGET_DIR);
if (targetDir == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_TARGET_DIR, ID));
@@ -53,7 +53,7 @@ public class LinkAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
return null;
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java
index 744b266bb..fb27f1197 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/MarkStartedAction.java
@@ -11,6 +11,7 @@
package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
import java.io.File;
+import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -18,16 +19,18 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
public class MarkStartedAction extends ProvisioningAction {
public static final String ID = "markStarted"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
@@ -35,14 +38,14 @@ public class MarkStartedAction extends ProvisioningAction {
if (started == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_STARTED, ID));
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.isEmpty())
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
- IArtifactKey artifactKey = artifacts[0];
+ IArtifactKey artifactKey = artifacts.iterator().next();
// the bundleFile might be null here, that's OK.
- File bundleFile = Util.getArtifactFile(artifactKey, profile);
+ File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
String manifest = Util.getManifest(iu.getTouchpointData());
if (manifest == null)
@@ -66,7 +69,8 @@ public class MarkStartedAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
Boolean previousStarted = (Boolean) getMemento().get(ActionConstants.PARM_PREVIOUS_STARTED);
if (previousStarted == null)
return Status.OK_STATUS;
@@ -75,13 +79,13 @@ public class MarkStartedAction extends ProvisioningAction {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.isEmpty())
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
- IArtifactKey artifactKey = artifacts[0];
+ IArtifactKey artifactKey = artifacts.iterator().next();
// the bundleFile might be null here, that's OK.
- File bundleFile = Util.getArtifactFile(artifactKey, profile);
+ File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
String manifest = Util.getManifest(iu.getTouchpointData());
if (manifest == null)
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveJVMArgumentAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveJVMArgumentAction.java
index 3560e8acd..10d00d6ad 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveJVMArgumentAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveJVMArgumentAction.java
@@ -17,13 +17,13 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*;
import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.osgi.util.NLS;
public class RemoveJVMArgumentAction extends ProvisioningAction {
public static final String ID = "removeJvmArg"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
String jvmArg = (String) parameters.get(ActionConstants.PARM_JVM_ARG);
if (jvmArg == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_JVM_ARG, ID));
@@ -31,7 +31,7 @@ public class RemoveJVMArgumentAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
String jvmArg = (String) parameters.get(ActionConstants.PARM_JVM_ARG);
if (jvmArg == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_JVM_ARG, ID));
@@ -39,7 +39,7 @@ public class RemoveJVMArgumentAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public static IStatus removeArg(String arg, Map parameters) {
+ public static IStatus removeArg(String arg, Map<String, Object> parameters) {
LauncherData launcherData = ((Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR)).getLauncherData();
File storageArea = (File) parameters.get(ActionConstants.PARM_PROFILE_DATA_DIRECTORY);
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveProgramArgumentAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveProgramArgumentAction.java
index 5cc2277ae..e61c38692 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveProgramArgumentAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveProgramArgumentAction.java
@@ -16,21 +16,21 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.osgi.util.NLS;
public class RemoveProgramArgumentAction extends ProvisioningAction {
public static final String ID = "removeProgramArg"; //$NON-NLS-1$
public static final String EMPTY_ARGUMENT = ""; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
String programArg = (String) parameters.get(ActionConstants.PARM_PROGRAM_ARG);
if (programArg == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PROGRAM_ARG, ID));
if (programArg.startsWith("-")) {//$NON-NLS-1$
- List programArgs = Arrays.asList(manipulator.getLauncherData().getProgramArgs());
+ List<String> programArgs = Arrays.asList(manipulator.getLauncherData().getProgramArgs());
int index = programArgs.indexOf(programArg);
if (index == -1)
@@ -38,7 +38,7 @@ public class RemoveProgramArgumentAction extends ProvisioningAction {
index++; // move index to potential programArgValue
if (programArgs.size() > index) {
- String programArgValue = (String) programArgs.get(index);
+ String programArgValue = programArgs.get(index);
if (!programArgValue.startsWith("-")) //$NON-NLS-1$
getMemento().put(ActionConstants.PARM_PROGRAM_ARG_VALUE, programArgValue);
}
@@ -48,7 +48,7 @@ public class RemoveProgramArgumentAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
String programArg = (String) parameters.get(ActionConstants.PARM_PROGRAM_ARG);
if (programArg == null)
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java
index 4f4fd25ba..b1d388932 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveRepositoryAction.java
@@ -14,6 +14,9 @@ import java.util.Map;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.engine.Profile;
import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfileRegistry;
/**
* An action that adds a repository to the list of known repositories.
@@ -21,30 +24,36 @@ import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
public class RemoveRepositoryAction extends RepositoryAction {
public static final String ID = "removeRepository"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
try {
+ IProvisioningAgent agent = getAgent(parameters);
+ IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
RepositoryEvent event = createEvent(parameters);
Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE);
if (profile != null)
- removeRepositoryFromProfile(profile, event.getRepositoryLocation(), event.getRepositoryType());
+ removeRepositoryFromProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryType());
//if we are provisioning into the self profile, update the current set of repositories in this configuration
- if (isSelfProfile(profile))
- removeFromSelf(event);
+ if (isSelfProfile(registry, profile))
+ removeFromSelf(agentLocation, event);
} catch (CoreException e) {
return e.getStatus();
}
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
try {
+ IProvisioningAgent agent = getAgent(parameters);
+ IProfileRegistry registry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
+ IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
RepositoryEvent event = createEvent(parameters);
Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE);
if (profile != null)
- addRepositoryToProfile(profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled());
+ addRepositoryToProfile(agentLocation, profile, event.getRepositoryLocation(), event.getRepositoryNickname(), event.getRepositoryType(), event.isRepositoryEnabled());
//if we are provisioning into the self profile, update the current set of repositories in this configuration
- if (isSelfProfile(profile))
- addToSelf(event);
+ if (isSelfProfile(registry, profile))
+ addToSelf(agentLocation, event);
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveSourceBundleAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveSourceBundleAction.java
index 21b1a1490..c94490478 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveSourceBundleAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RemoveSourceBundleAction.java
@@ -10,28 +10,31 @@ package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
import java.io.File;
import java.io.IOException;
+import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
public class RemoveSourceBundleAction extends ProvisioningAction {
public static final String ID = "removeSourceBundle"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
return RemoveSourceBundleAction.removeSourceBundle(parameters);
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
return AddSourceBundleAction.addSourceBundle(parameters);
}
- public static IStatus removeSourceBundle(Map parameters) {
+ public static IStatus removeSourceBundle(Map<String, Object> parameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
SourceManipulator manipulator = (SourceManipulator) parameters.get(EclipseTouchpoint.PARM_SOURCE_BUNDLES);
@@ -39,14 +42,14 @@ public class RemoveSourceBundleAction extends ProvisioningAction {
if (bundleId == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_BUNDLE, ID));
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.isEmpty())
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
IArtifactKey artifactKey = null;
- for (int i = 0; i < artifacts.length; i++) {
- if (artifacts[i].toString().equals(bundleId)) {
- artifactKey = artifacts[i];
+ for (IArtifactKey candidate : artifacts) {
+ if (candidate.toString().equals(bundleId)) {
+ artifactKey = candidate;
break;
}
}
@@ -54,7 +57,7 @@ public class RemoveSourceBundleAction extends ProvisioningAction {
throw new IllegalArgumentException(NLS.bind(Messages.no_matching_artifact, bundleId));
// the bundleFile might be null here, that's OK.
- File bundleFile = Util.getArtifactFile(artifactKey, profile);
+ File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
try {
manipulator.removeBundle(bundleFile, artifactKey.getId(), artifactKey.getVersion());
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java
index b3bbf9fe1..38defc24c 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/RepositoryAction.java
@@ -14,15 +14,19 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.engine.Profile;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Activator;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.*;
+import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.util.NLS;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
@@ -49,11 +53,11 @@ abstract class RepositoryAction extends ProvisioningAction {
* Returns the repository manager of the given type, or <code>null</code>
* if not available.
*/
- private static IRepositoryManager getRepositoryManager(int type) {
+ private static IRepositoryManager<?> getRepositoryManager(int type) {
if (type == IRepository.TYPE_METADATA) {
- return (IRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
+ return (IRepositoryManager<?>) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
} else if (type == IRepository.TYPE_ARTIFACT) {
- return (IRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ return (IRepositoryManager<?>) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
}
return null;
}
@@ -62,8 +66,8 @@ abstract class RepositoryAction extends ProvisioningAction {
* Associates the repository described by the given event with the given profile.
* Has no effect if the repository is already associated with this profile.
*/
- protected void addRepositoryToProfile(Profile profile, URI location, String nickname, int type, boolean enabled) {
- Preferences node = getRepositoryPreferenceNode(profile, location, type);
+ protected void addRepositoryToProfile(IAgentLocation agentLocation, Profile profile, URI location, String nickname, int type, boolean enabled) {
+ Preferences node = getRepositoryPreferenceNode(agentLocation, profile, location, type);
int count = 0;
if (repositoryExists(node)) {
@@ -88,10 +92,10 @@ abstract class RepositoryAction extends ProvisioningAction {
/**
* Adds the repository corresponding to the given event to the currently running instance.
*/
- protected void addToSelf(RepositoryEvent event) {
- IRepositoryManager manager = getRepositoryManager(event.getRepositoryType());
+ protected void addToSelf(IAgentLocation agentLocation, RepositoryEvent event) {
+ IRepositoryManager<?> manager = getRepositoryManager(event.getRepositoryType());
final URI location = event.getRepositoryLocation();
- Preferences node = getRepositoryPreferenceNode(null, location, event.getRepositoryType());
+ Preferences node = getRepositoryPreferenceNode(agentLocation, null, location, event.getRepositoryType());
int count = getRepositoryCount(node);
if (manager.contains(location)) {
@@ -113,7 +117,7 @@ abstract class RepositoryAction extends ProvisioningAction {
manager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
}
- protected RepositoryEvent createEvent(Map parameters) throws CoreException {
+ protected RepositoryEvent createEvent(Map<String, Object> parameters) throws CoreException {
String parm = (String) parameters.get(ActionConstants.PARM_REPOSITORY_LOCATION);
if (parm == null)
throw new CoreException(Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_REPOSITORY_LOCATION, getId())));
@@ -148,11 +152,10 @@ abstract class RepositoryAction extends ProvisioningAction {
* Return <code>true</code> if the given profile is the currently running profile,
* and <code>false</code> otherwise.
*/
- protected boolean isSelfProfile(Profile profile) {
+ protected boolean isSelfProfile(IProfileRegistry registry, Profile profile) {
//if we can't determine the current profile, assume we are running on self
if (profile == null)
return true;
- IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(Activator.getContext(), IProfileRegistry.class.getName());
if (registry == null)
return false;
final IProfile selfProfile = registry.getProfile(IProfileRegistry.SELF);
@@ -165,9 +168,9 @@ abstract class RepositoryAction extends ProvisioningAction {
/**
* Removes the repository corresponding to the given event from the currently running instance.
*/
- protected void removeFromSelf(RepositoryEvent event) {
- IRepositoryManager manager = getRepositoryManager(event.getRepositoryType());
- Preferences node = getRepositoryPreferenceNode(null, event.getRepositoryLocation(), event.getRepositoryType());
+ protected void removeFromSelf(IAgentLocation agentLocation, RepositoryEvent event) {
+ IRepositoryManager<?> manager = getRepositoryManager(event.getRepositoryType());
+ Preferences node = getRepositoryPreferenceNode(agentLocation, null, event.getRepositoryLocation(), event.getRepositoryType());
int count = getRepositoryCount(node);
if (--count < 1 && manager != null)
manager.removeRepository(event.getRepositoryLocation());
@@ -179,8 +182,8 @@ abstract class RepositoryAction extends ProvisioningAction {
* and the given profile. Has no effect if the location is not already associated with
* this profile.
*/
- protected void removeRepositoryFromProfile(Profile profile, URI location, int type) {
- Preferences node = getRepositoryPreferenceNode(profile, location, type);
+ protected void removeRepositoryFromProfile(IAgentLocation agentLocation, Profile profile, URI location, int type) {
+ Preferences node = getRepositoryPreferenceNode(agentLocation, profile, location, type);
int count = getRepositoryCount(node);
if (--count < 1) {
@@ -233,13 +236,10 @@ abstract class RepositoryAction extends ProvisioningAction {
/*
* Get the preference node associated with profile & location
*/
- protected Preferences getRepositoryPreferenceNode(Profile profile, URI location, int type) {
+ protected Preferences getRepositoryPreferenceNode(IAgentLocation agentLocation, Profile profile, URI location, int type) {
String key = type == IRepository.TYPE_METADATA ? METADATA_REPOSITORY : ARTIFACT_REPOSITORY;
- IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(Activator.getContext(), IPreferencesService.class.getName());
-
- if (profile != null)
- return prefService.getRootNode().node("/profile/" + profile.getProfileId() + "/" + key + "/" + NODE_REPOSITORIES + "/" + getKey(location)); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
- return prefService.getRootNode().node("/profile/_SELF_/" + key + "/" + NODE_REPOSITORIES + "/" + getKey(location)); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ String profileId = profile == null ? IProfileRegistry.SELF : profile.getProfileId();
+ return new ProfileScope(agentLocation, profileId).getNode(key + '/' + NODE_REPOSITORIES + '/' + getKey(location));
}
/*
@@ -252,4 +252,12 @@ abstract class RepositoryAction extends ProvisioningAction {
key = key.substring(0, key.length() - 1);
return key;
}
+
+ protected IProvisioningAgent getAgent(Map<String, Object> parameters) throws CoreException {
+ //We shouldn't really know about the session parameter
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get("agent"); //$NON-NLS-1$
+ if (agent == null)
+ throw new CoreException(Util.createError(NLS.bind(Messages.parameter_not_set, "agent", getId()))); //$NON-NLS-1$
+ return agent;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java
index 040c44de8..6fadd2397 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetLauncherNameAction.java
@@ -16,12 +16,12 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
public class SetLauncherNameAction extends ProvisioningAction {
public static final String ID = "setLauncherName"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE);
getMemento().put(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME, profile.getProperty(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME));
@@ -30,7 +30,7 @@ public class SetLauncherNameAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
Profile profile = (Profile) parameters.get(ActionConstants.PARM_PROFILE);
String previousLauncherName = (String) getMemento().get(EclipseTouchpoint.PROFILE_PROP_LAUNCHER_NAME);
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java
index 7d31fbc4e..e334402a8 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetProgramPropertyAction.java
@@ -15,13 +15,13 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.osgi.util.NLS;
public class SetProgramPropertyAction extends ProvisioningAction {
public static final String ID = "setProgramProperty"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
String propName = (String) parameters.get(ActionConstants.PARM_PROP_NAME);
if (propName == null)
@@ -40,7 +40,7 @@ public class SetProgramPropertyAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
String propName = (String) parameters.get(ActionConstants.PARM_PROP_NAME);
if (propName == null)
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java
index 55c7314e8..827d8e0d0 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetStartLevelAction.java
@@ -11,6 +11,7 @@
package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
import java.io.File;
+import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -18,16 +19,18 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
public class SetStartLevelAction extends ProvisioningAction {
public static final String ID = "setStartLevel"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
@@ -35,13 +38,13 @@ public class SetStartLevelAction extends ProvisioningAction {
if (startLevel == null)
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_START_LEVEL, ID));
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.isEmpty())
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
- IArtifactKey artifactKey = artifacts[0];
+ IArtifactKey artifactKey = artifacts.iterator().next();
// the bundleFile might be null here, that's OK.
- File bundleFile = Util.getArtifactFile(artifactKey, profile);
+ File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
String manifest = Util.getManifest(iu.getTouchpointData());
if (manifest == null)
@@ -69,7 +72,8 @@ public class SetStartLevelAction extends ProvisioningAction {
return Status.OK_STATUS;
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
Integer previousStartLevel = (Integer) getMemento().get(ActionConstants.PARM_PREVIOUS_START_LEVEL);
if (previousStartLevel == null)
return Status.OK_STATUS;
@@ -78,13 +82,13 @@ public class SetStartLevelAction extends ProvisioningAction {
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.isEmpty())
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
- IArtifactKey artifactKey = artifacts[0];
+ IArtifactKey artifactKey = artifacts.iterator().next();
// the bundleFile might be null here, that's OK.
- File bundleFile = Util.getArtifactFile(artifactKey, profile);
+ File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
String manifest = Util.getManifest(iu.getTouchpointData());
if (manifest == null)
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java
index daf1ec901..7eb4356c1 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallBundleAction.java
@@ -9,6 +9,7 @@
package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
import java.io.File;
+import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -16,24 +17,27 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.FragmentQuery;
import org.eclipse.osgi.util.NLS;
public class UninstallBundleAction extends ProvisioningAction {
public static final String ID = "uninstallBundle"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
return UninstallBundleAction.uninstallBundle(parameters);
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
return InstallBundleAction.installBundle(parameters);
}
- public static IStatus uninstallBundle(Map parameters) {
+ public static IStatus uninstallBundle(Map<String, Object> parameters) {
+ IProvisioningAgent agent = (IProvisioningAgent) parameters.get(ActionConstants.PARM_AGENT);
IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
Manipulator manipulator = (Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR);
@@ -42,19 +46,19 @@ public class UninstallBundleAction extends ProvisioningAction {
return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_BUNDLE, ID));
//TODO: eventually remove this. What is a fragment doing here??
- if (iu.isFragment()) {
+ if (FragmentQuery.isFragment(iu)) {
System.out.println("What is a fragment doing here!!! -- " + iu); //$NON-NLS-1$
return Status.OK_STATUS;
}
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.isEmpty())
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
IArtifactKey artifactKey = null;
- for (int i = 0; i < artifacts.length; i++) {
- if (artifacts[i].toString().equals(bundleId)) {
- artifactKey = artifacts[i];
+ for (IArtifactKey candidate : artifacts) {
+ if (candidate.toString().equals(bundleId)) {
+ artifactKey = candidate;
break;
}
}
@@ -62,7 +66,7 @@ public class UninstallBundleAction extends ProvisioningAction {
throw new IllegalArgumentException(NLS.bind(Messages.no_matching_artifact, bundleId));
// the bundleFile might be null here, that's OK.
- File bundleFile = Util.getArtifactFile(artifactKey, profile);
+ File bundleFile = Util.getArtifactFile(agent, artifactKey, profile);
String manifest = Util.getManifest(iu.getTouchpointData());
if (manifest == null)
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallFeatureAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallFeatureAction.java
index 95ea30f15..33bee8ef9 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallFeatureAction.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/UninstallFeatureAction.java
@@ -8,40 +8,41 @@
******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
+import java.util.Collection;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.osgi.util.NLS;
public class UninstallFeatureAction extends ProvisioningAction {
public static final String ID = "uninstallFeature"; //$NON-NLS-1$
- public IStatus execute(Map parameters) {
+ public IStatus execute(Map<String, Object> parameters) {
return UninstallFeatureAction.uninstallFeature(parameters);
}
- public IStatus undo(Map parameters) {
+ public IStatus undo(Map<String, Object> parameters) {
return InstallFeatureAction.installFeature(parameters);
}
- public static IStatus uninstallFeature(Map parameters) {
+ public static IStatus uninstallFeature(Map<String, Object> parameters) {
IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
PlatformConfigurationWrapper configuration = (PlatformConfigurationWrapper) parameters.get(EclipseTouchpoint.PARM_PLATFORM_CONFIGURATION);
String feature = (String) parameters.get(ActionConstants.PARM_FEATURE);
String featureId = (String) parameters.get(ActionConstants.PARM_FEATURE_ID);
String featureVersion = (String) parameters.get(ActionConstants.PARM_FEATURE_VERSION);
- IArtifactKey[] artifacts = iu.getArtifacts();
- if (artifacts == null || artifacts.length == 0)
+ Collection<IArtifactKey> artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.isEmpty())
return Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu));
IArtifactKey artifactKey = null;
- for (int i = 0; i < artifacts.length; i++) {
- if (artifacts[i].toString().equals(feature)) {
- artifactKey = artifacts[i];
+ for (IArtifactKey candidate : artifacts) {
+ if (candidate.toString().equals(feature)) {
+ artifactKey = candidate;
break;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java
index c3285ce7a..588a5c767 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Configuration.java
@@ -21,21 +21,21 @@ import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Activator;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.core.ProvisionException;
/**
* @since 1.0
*/
public class Configuration {
- private List sites = new ArrayList();
+ private List<Site> sites = new ArrayList<Site>();
String date;
boolean transientProperty;
String version;
String shared_ur;
public static Configuration load(File location, URL osgiInstallArea) throws ProvisionException {
- return ConfigurationParser.parse(location, osgiInstallArea);
+ return ConfigurationIO.read(location, osgiInstallArea);
}
public Configuration() {
@@ -43,7 +43,7 @@ public class Configuration {
}
public void save(File location, URL osgiInstallArea) throws ProvisionException {
- ConfigurationWriter.save(this, location, osgiInstallArea);
+ ConfigurationIO.write(location, this, osgiInstallArea);
}
public String getSharedUR() {
@@ -54,17 +54,17 @@ public class Configuration {
shared_ur = value;
}
- public List getSites() {
+ public List<Site> getSites() {
return internalGetSites(true);
}
- List internalGetSites(boolean includeParent) {
+ List<Site> internalGetSites(boolean includeParent) {
if (!includeParent)
return sites;
String shared = getSharedUR();
if (shared == null)
return sites;
- List result = new ArrayList(sites);
+ List<Site> result = new ArrayList<Site>(sites);
try {
URL url = new URL(shared);
File location = URLUtil.toFile(url);
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationCache.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationCache.java
new file mode 100644
index 000000000..53c5c65f5
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationCache.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.update;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * TODO ensure thread safety
+ *
+ */
+public class ConfigurationCache {
+ private static Map<String, CacheEntry> cache = new HashMap<String, CacheEntry>();
+
+ // class used to represent cache values
+ static class CacheEntry {
+ long timestamp;
+ Configuration config;
+ }
+
+ // helper method to convert the file to a cache key. convert to an absolute
+ // path to ensure equality between relative and absolute comparisons
+ private static String toKey(File file) {
+ try {
+ return file.getCanonicalPath();
+ } catch (IOException e) {
+ // ignore and return the absolute value instead
+ }
+ return file.getAbsolutePath();
+ }
+
+ /*
+ * Return the configuration object in the cache which is represented
+ * by the given file. Do a check on disk to see if the cache is up-to-date.
+ * If not, then treat it as a cache miss.
+ */
+ public static Configuration get(File file) {
+ String key = toKey(file);
+ CacheEntry entry = cache.get(key);
+ if (entry == null)
+ return null;
+ return file.lastModified() == entry.timestamp ? entry.config : null;
+ }
+
+ /*
+ * Store the given configuration in the cache.
+ */
+ public static void put(File file, Configuration config) {
+ String key = toKey(file);
+ if (config == null) {
+ cache.remove(key);
+ return;
+ }
+ CacheEntry entry = new CacheEntry();
+ entry.config = config;
+ entry.timestamp = file.lastModified();
+ cache.put(key, entry);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java
new file mode 100644
index 000000000..44dfae151
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationIO.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.update;
+
+import java.io.File;
+import java.net.URL;
+import org.eclipse.equinox.p2.core.ProvisionException;
+
+/*
+ * Class which controls the reading and writing of Configuration (platform.xml) objects.
+ * We keep a local cached copy to avoid multiple reads. When we install new features we
+ * seem to only write out the platform.xml in the "commit" phase so we don't need to
+ * batch the writes.
+ */
+public class ConfigurationIO {
+ private static CacheEntry cache = null;
+
+ // class used to represent cache values
+ static class CacheEntry {
+ Configuration config;
+ URL osgiInstallArea;
+ File location;
+ long timestamp;
+ }
+
+ /*
+ * Return the configuration object which is represented by the given file.
+ */
+ static Configuration read(File file, URL osgiInstallArea) throws ProvisionException {
+ // check the cached copy first
+ if (cache != null && file.lastModified() == cache.timestamp)
+ return cache.config;
+
+ // cache miss or file is out of date, read from disk
+ Configuration config = ConfigurationParser.parse(file, osgiInstallArea);
+ if (config == null)
+ return null;
+
+ // successful read, store in the cache before we return
+ cache(file, config, osgiInstallArea);
+ return config;
+ }
+
+ /*
+ * Store the given configuration file in the local cache.
+ */
+ private static void cache(File location, Configuration config, URL osgiInstallArea) {
+ CacheEntry entry = new CacheEntry();
+ entry.config = config;
+ entry.osgiInstallArea = osgiInstallArea;
+ entry.location = location;
+ entry.timestamp = location.lastModified();
+ cache = entry;
+ }
+
+ /*
+ * Save the given configuration to the file-system.
+ */
+ static void write(File location, Configuration config, URL osgiInstallArea) throws ProvisionException {
+ // write it to disk
+ ConfigurationWriter.save(config, location, osgiInstallArea);
+ // save a copy in the cache
+ cache(location, config, osgiInstallArea);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java
index c2e5d7de3..4e2cbd18c 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationParser.java
@@ -16,7 +16,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.StringTokenizer;
import javax.xml.parsers.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.osgi.util.NLS;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
@@ -34,7 +34,7 @@ public class ConfigurationParser implements ConfigurationConstants {
* Parse the given file handle which points to a platform.xml file and a configuration object.
* Returns null if the file doesn't exist.
*/
- public static Configuration parse(File file, URL osgiInstallArea) throws ProvisionException {
+ static Configuration parse(File file, URL osgiInstallArea) throws ProvisionException {
return new ConfigurationParser(osgiInstallArea).internalParse(file);
}
@@ -79,7 +79,7 @@ public class ConfigurationParser implements ConfigurationConstants {
String locations = getAttribute(node, ATTRIBUTE_ROOT);
if (locations != null) {
StringTokenizer tokenizer = new StringTokenizer(locations, ","); //$NON-NLS-1$
- ArrayList rootList = new ArrayList();
+ ArrayList<URL> rootList = new ArrayList<URL>();
while (tokenizer.hasMoreTokens()) {
try {
URL rootEntry = new URL(tokenizer.nextToken().trim());
@@ -88,7 +88,7 @@ public class ConfigurationParser implements ConfigurationConstants {
// skip bad entries ...
}
}
- URL[] roots = (URL[]) rootList.toArray(new URL[rootList.size()]);
+ URL[] roots = rootList.toArray(new URL[rootList.size()]);
result.setRoots(roots);
}
@@ -189,12 +189,22 @@ public class ConfigurationParser implements ConfigurationConstants {
* Returns null if the file doesn't exist.
*/
private Configuration internalParse(File file) throws ProvisionException {
- if (!file.exists())
+ if (!file.exists()) {
+ // remove from cache since it doesn't exist anymore on disk
+ ConfigurationCache.put(file, null);
return null;
+ }
+ // have we read this before?
+ Configuration result = ConfigurationCache.get(file);
+ if (result != null)
+ return result;
try {
InputStream input = new BufferedInputStream(new FileInputStream(file));
Document document = load(input);
- return process(document);
+ result = process(document);
+ // save for future use
+ ConfigurationCache.put(file, result);
+ return result;
} catch (IOException e) {
throw new ProvisionException(NLS.bind(Messages.error_reading_config, file), e);
} catch (ParserConfigurationException e) {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java
index 98d0890be..a66cedc6c 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/ConfigurationWriter.java
@@ -13,13 +13,14 @@ package org.eclipse.equinox.internal.p2.update;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Activator;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.osgi.util.NLS;
/**
@@ -30,12 +31,12 @@ public class ConfigurationWriter implements ConfigurationConstants {
/*
* Save the given configuration to the specified location.
*/
- public static void save(Configuration configuration, File location, URL osgiInstallArea) throws ProvisionException {
+ static void save(Configuration configuration, File location, URL osgiInstallArea) throws ProvisionException {
XMLWriter writer = null;
try {
OutputStream output = new BufferedOutputStream(new FileOutputStream(location));
writer = new XMLWriter(output);
- Map args = new HashMap();
+ Map<String, String> args = new HashMap<String, String>();
String value = configuration.getDate();
if (value != null)
@@ -53,8 +54,7 @@ public class ConfigurationWriter implements ConfigurationConstants {
writer.startTag(ELEMENT_CONFIG, args);
- for (Iterator iter = configuration.internalGetSites(false).iterator(); iter.hasNext();) {
- Site site = (Site) iter.next();
+ for (Site site : configuration.internalGetSites(false)) {
write(writer, site, osgiInstallArea);
}
@@ -69,13 +69,15 @@ public class ConfigurationWriter implements ConfigurationConstants {
writer.close();
}
}
+ // put the config in the cache in case someone in the same session wants to read it
+ ConfigurationCache.put(location, configuration);
}
/*
* Write out the given site.
*/
private static void write(XMLWriter writer, Site site, URL osgiInstallArea) {
- Map args = new HashMap();
+ Map<String, String> args = new HashMap<String, String>();
String value = site.getLinkFile();
if (value != null)
@@ -144,7 +146,7 @@ public class ConfigurationWriter implements ConfigurationConstants {
return;
for (int i = 0; i < features.length; i++) {
Feature feature = features[i];
- Map args = new HashMap();
+ Map<String, String> args = new HashMap<String, String>();
String value = feature.getId();
if (value != null)
args.put(ATTRIBUTE_ID, value);
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java
index c4404f16e..ff1f55396 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/Site.java
@@ -27,8 +27,8 @@ public class Site {
private boolean updateable = true;
private String url;
private String linkFile;
- private Collection features = new HashSet();
- private List list = new ArrayList();
+ private Collection<Feature> features = new HashSet<Feature>();
+ private List<String> list = new ArrayList<String>();
public void addFeature(Feature feature) {
this.features.add(feature);
@@ -39,7 +39,7 @@ public class Site {
}
public Feature[] getFeatures() {
- return (Feature[]) features.toArray(new Feature[features.size()]);
+ return features.toArray(new Feature[features.size()]);
}
/*
@@ -50,8 +50,7 @@ public class Site {
public Feature getFeature(String id, String version) {
if (id == null)
return null;
- for (Iterator iter = features.iterator(); iter.hasNext();) {
- Feature feature = (Feature) iter.next();
+ for (Feature feature : features) {
if (id.equals(feature.getId())) {
if (version == null || version.equals(feature.getVersion()))
return feature;
@@ -61,8 +60,7 @@ public class Site {
}
public Feature removeFeature(String featureURL) {
- for (Iterator iter = features.iterator(); iter.hasNext();) {
- Feature feature = (Feature) iter.next();
+ for (Feature feature : features) {
String nextURL = feature.getUrl();
if (nextURL != null && nextURL.equals(featureURL))
return features.remove(feature) ? feature : null;
@@ -75,7 +73,7 @@ public class Site {
}
public String[] getList() {
- return (String[]) list.toArray(new String[list.size()]);
+ return list.toArray(new String[list.size()]);
}
public String getPolicy() {
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/XMLWriter.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/XMLWriter.java
index 9b86646c1..192f1d708 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/XMLWriter.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/update/XMLWriter.java
@@ -11,7 +11,6 @@
package org.eclipse.equinox.internal.p2.update;
import java.io.*;
-import java.util.Iterator;
import java.util.Map;
/**
@@ -49,18 +48,17 @@ public class XMLWriter extends PrintWriter {
super.print('\t');
}
- public void printTag(String name, Map parameters) {
+ public void printTag(String name, Map<String, String> parameters) {
printTag(name, parameters, true, true);
}
- public void printTag(String name, Map parameters, boolean shouldTab, boolean newLine) {
+ public void printTag(String name, Map<String, String> parameters, boolean shouldTab, boolean newLine) {
StringBuffer sb = new StringBuffer();
sb.append("<"); //$NON-NLS-1$
sb.append(name);
if (parameters != null)
- for (Iterator it = parameters.keySet().iterator(); it.hasNext();) {
+ for (String key : parameters.keySet()) {
sb.append(" "); //$NON-NLS-1$
- String key = (String) it.next();
sb.append(key);
sb.append("=\""); //$NON-NLS-1$
sb.append(getEscaped(String.valueOf(parameters.get(key))));
@@ -75,11 +73,11 @@ public class XMLWriter extends PrintWriter {
print(sb.toString());
}
- public void startTag(String name, Map parameters) {
+ public void startTag(String name, Map<String, String> parameters) {
startTag(name, parameters, true);
}
- public void startTag(String name, Map parameters, boolean newLine) {
+ public void startTag(String name, Map<String, String> parameters, boolean newLine) {
printTag(name, parameters, true, newLine);
tab++;
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/OSGiBundleQuery.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/OSGiBundleQuery.java
new file mode 100644
index 000000000..8cdb7c0d1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/OSGiBundleQuery.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.touchpoint.eclipse.query;
+
+import java.util.Collection;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.query.MatchQuery;
+
+/**
+ * A query matching every {@link IInstallableUnit} that describes an OSGi bundle.
+ * @since 2.0
+ */
+public class OSGiBundleQuery extends MatchQuery<IInstallableUnit> {
+
+ public boolean isMatch(IInstallableUnit candidate) {
+ return isOSGiBundle(candidate);
+ }
+
+ /**
+ * Test if the {@link IInstallableUnit} describes an OSGi bundle.
+ * @param iu the element being tested.
+ * @return <tt>true</tt> if the parameter describes an OSGi bundle.
+ */
+ public static boolean isOSGiBundle(IInstallableUnit iu) {
+ Collection<IProvidedCapability> provided = iu.getProvidedCapabilities();
+ for (IProvidedCapability capability : provided) {
+ if (capability.getNamespace().equals("osgi.bundle")) { //$NON-NLS-1$
+ return true;
+ }
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/package.html b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/package.html
new file mode 100644
index 000000000..1af2a8419
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/p2/touchpoint/eclipse/query/package.html
@@ -0,0 +1,18 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Provides query utilities specific to provisioning of OSGi bundles
+<h2>
+Package Specification</h2>
+<p>
+This package specifies API for querying and manipulating provisioning metadata that
+is specific to OSGi bundles or Eclipse-specific constructs such as features.
+<p>
+@since 2.0
+<p>
+</body>
+</html>

Back to the top