Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-02-21 20:10:11 -0500
committerThomas Hallgren2010-02-21 20:10:11 -0500
commit8aa5a700fd1df2f75541c1329747668a0eb1716e (patch)
tree85a71b311400712ede104e6ebc524662633f745f /bundles/org.eclipse.equinox.p2.directorywatcher
parent9dc753efb1afeb1c6778b8338f01c80919e8b143 (diff)
downloadrt.equinox.p2-8aa5a700fd1df2f75541c1329747668a0eb1716e.tar.gz
rt.equinox.p2-8aa5a700fd1df2f75541c1329747668a0eb1716e.tar.xz
rt.equinox.p2-8aa5a700fd1df2f75541c1329747668a0eb1716e.zip
302201 : Unify the two query approaches used in p2, step 3.
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.directorywatcher')
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java22
1 files changed, 8 insertions, 14 deletions
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
index dcf0dd358..3d7c91ba8 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
@@ -20,11 +20,13 @@ import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.update.Site;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction;
import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction;
-import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.query.IMatchQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
@@ -212,19 +214,11 @@ public class RepositoryListener extends DirectoryChangeListener {
if (!removedFiles.isEmpty() || !changes.isEmpty()) {
metadataRepository.removeInstallableUnits(changes.toArray(new IInstallableUnit[changes.size()]), null);
- // create a query that will identify all ius related to removed files
- IMatchQuery<IInstallableUnit> removeQuery = new MatchQuery<IInstallableUnit>() {
- public boolean isMatch(IInstallableUnit iu) {
- String filename = iu.getProperty(FILE_NAME);
- if (filename == null) {
- String message = NLS.bind(Messages.filename_missing, "installable unit", iu.getId()); //$NON-NLS-1$
- LogHelper.log(new Status(IStatus.ERROR, Activator.ID, message, null));
- return false;
- }
- File iuFile = new File(filename);
- return removedFiles.contains(iuFile);
- }
- };
+ // create a query that will identify all ius related to removed files.
+ // It's safe to compare a String with a File since the auto coercion will
+ // first convert the String into a File.
+ IMatchQuery<IInstallableUnit> removeQuery = new ExpressionQuery<IInstallableUnit>(IInstallableUnit.class, //
+ "$1.exists(x | properties[$0] == x)", FILE_NAME, removedFiles); //$NON-NLS-1$
IQueryResult<IInstallableUnit> toRemove = metadataRepository.query(removeQuery, null);
metadataRepository.removeInstallableUnits(toRemove.toArray(IInstallableUnit.class), null);
}

Back to the top