Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSusan Franklin2010-12-20 17:38:40 -0500
committerSusan Franklin2010-12-20 17:38:40 -0500
commit9e89ef4b80a63ba00bd27fe1f92e4e863a82a977 (patch)
tree6d9b0871de36f9f321f321767553052a48df4849
parent26da76d5c5c87f1d9aadb508ff1534773c228bde (diff)
downloadrt.equinox.p2-9e89ef4b80a63ba00bd27fe1f92e4e863a82a977.tar.gz
rt.equinox.p2-9e89ef4b80a63ba00bd27fe1f92e4e863a82a977.tar.xz
rt.equinox.p2-9e89ef4b80a63ba00bd27fe1f92e4e863a82a977.zip
Bug 311633 - [ui] RepositoryTracker duplicate checking should consult the repo managerv20101221-0005
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoryTracker.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoryTracker.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java15
4 files changed, 31 insertions, 16 deletions
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java
index fd2a99abd..152a3d09e 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/RepositoryTracker.java
@@ -112,15 +112,29 @@ public abstract class RepositoryTracker {
if (!localValidationStatus.isOK())
return localValidationStatus;
- // Syntax was ok, now look for duplicates
+ if (contains(location, session))
+ return new Status(IStatus.ERROR, Activator.ID, IStatusCodes.INVALID_REPOSITORY_LOCATION, Messages.RepositoryTracker_DuplicateLocation, null);
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * Return a boolean indicating whether this tracker already contains the specified
+ * repository location.
+ *
+ * @param location the location in question
+ * @param session the provisioning session providing the repository services
+ * @since 2.1
+ */
+ protected boolean contains(URI location, ProvisioningSession session) {
+ // This is a fallback implementation in the absence of a repository manager
+ // that would know what to do.
URI[] knownRepositories = getKnownRepositories(session);
for (int i = 0; i < knownRepositories.length; i++) {
if (URIUtil.sameURI(knownRepositories[i], location)) {
- localValidationStatus = new Status(IStatus.ERROR, Activator.ID, IStatusCodes.INVALID_REPOSITORY_LOCATION, Messages.RepositoryTracker_DuplicateLocation, null);
- break;
+ return true;
}
}
- return localValidationStatus;
+ return false;
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoryTracker.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoryTracker.java
index ba8ce8de6..25c8f4bd0 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoryTracker.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/ArtifactRepositoryTracker.java
@@ -82,4 +82,9 @@ public class ArtifactRepositoryTracker extends RepositoryTracker {
IArtifactRepositoryManager getArtifactRepositoryManager() {
return ProvUI.getArtifactRepositoryManager(ui.getSession());
}
+
+ @Override
+ protected boolean contains(URI location, ProvisioningSession session) {
+ return ProvUI.getArtifactRepositoryManager(session).contains(location);
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoryTracker.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoryTracker.java
index 107a53152..50798e3e9 100644
--- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoryTracker.java
+++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/MetadataRepositoryTracker.java
@@ -83,4 +83,9 @@ public class MetadataRepositoryTracker extends RepositoryTracker {
IMetadataRepositoryManager getMetadataRepositoryManager() {
return ProvUI.getMetadataRepositoryManager(ui.getSession());
}
+
+ @Override
+ protected boolean contains(URI location, ProvisioningSession session) {
+ return ProvUI.getMetadataRepositoryManager(session).contains(location);
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java
index 81e40fd88..0c21b3a84 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java
@@ -216,17 +216,8 @@ public class ColocatedRepositoryTracker extends RepositoryTracker {
return null;
}
- /*
- * Overridden to do a better job of finding duplicates
- * (non-Javadoc)
- * @see org.eclipse.equinox.p2.operations.RepositoryTracker#validateRepositoryLocation(org.eclipse.equinox.p2.operations.ProvisioningSession, java.net.URI, boolean, org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus validateRepositoryLocation(ProvisioningSession session, URI location, boolean contactRepositories, IProgressMonitor monitor) {
- IStatus status = super.validateRepositoryLocation(session, location, contactRepositories, monitor);
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=268580
- if (status.isOK() && getMetadataRepositoryManager().contains(location))
- return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, STATUS_INVALID_REPOSITORY_LOCATION, ProvUIMessages.RepositoryTracker_DuplicateLocation, null);
- return status;
-
+ @Override
+ protected boolean contains(URI location, ProvisioningSession session) {
+ return ProvUI.getMetadataRepositoryManager(session).contains(location);
}
}

Back to the top