diff options
author | Mykola Nikishov | 2018-03-25 11:52:26 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-06-12 10:32:20 +0000 |
commit | b33a385b7ba003651854d5d055d669a2dba4aade (patch) | |
tree | 3c27f46f942a2c70d6c7adfd1ef9da512bf7498b | |
parent | 0d6405210285b5497b323666f1c6ea833c39885f (diff) | |
download | rt.equinox.p2-b33a385b7ba003651854d5d055d669a2dba4aade.tar.gz rt.equinox.p2-b33a385b7ba003651854d5d055d669a2dba4aade.tar.xz rt.equinox.p2-b33a385b7ba003651854d5d055d669a2dba4aade.zip |
Extract method to get artifact repositories in DownloadManager
Change-Id: I03f3710c7d1debf148a90911557c1353e14cc80d
Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r-- | bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java index 7c5872eb0..ac896b2d7 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/DownloadManager.java @@ -89,15 +89,9 @@ public class DownloadManager { if (provContext == null) provContext = new ProvisioningContext(agent); - IQueryable<IArtifactRepository> repoQueryable = provContext.getArtifactRepositories(subMonitor.newChild(250)); - IQuery<IArtifactRepository> all = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); - IArtifactRepository[] repositories = repoQueryable.query(all, subMonitor.newChild(250)).toArray(IArtifactRepository.class); + IArtifactRepository[] repositories = getArtifactRepositories(subMonitor); if (repositories.length == 0) return new Status(IStatus.ERROR, EngineActivator.ID, Messages.download_no_repository, new Exception(Collect.NO_ARTIFACT_REPOSITORIES_AVAILABLE)); - // Although we get a sorted list back from the ProvisioningContext above, it - // gets unsorted when we convert the queryable into an array so we must re-sort it. - // See https://bugs.eclipse.org/335153. - Arrays.sort(repositories, LOCAL_FIRST_COMPARATOR); fetch(repositories, subMonitor.newChild(500)); return overallStatus(monitor); } finally { @@ -105,6 +99,23 @@ public class DownloadManager { } } + /** + * @return artifact repositories sorted according to LOCAL_FIRST_COMPARATOR + */ + private IArtifactRepository[] getArtifactRepositories(SubMonitor subMonitor) { + IQuery<IArtifactRepository> queryArtifactRepositories = new ExpressionMatchQuery<>(IArtifactRepository.class, ExpressionUtil.TRUE_EXPRESSION); + IQueryable<IArtifactRepository> artifactRepositories = provContext.getArtifactRepositories(subMonitor.newChild(250)); + IQueryResult<IArtifactRepository> queryResult = artifactRepositories.query(queryArtifactRepositories, subMonitor.newChild(250)); + IArtifactRepository[] repositories = queryResult.toArray(IArtifactRepository.class); + + // Although we get a sorted list back from the ProvisioningContext above, it + // gets unsorted when we convert the queryable into an array so we must re-sort it. + // See https://bugs.eclipse.org/335153. + Arrays.sort(repositories, LOCAL_FIRST_COMPARATOR); + + return repositories; + } + private void fetch(IArtifactRepository[] repositories, IProgressMonitor mon) { SubMonitor monitor = SubMonitor.convert(mon, requestsToProcess.size()); for (int i = 0; i < repositories.length && !requestsToProcess.isEmpty() && !monitor.isCanceled(); i++) { |