summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2018-03-24 09:15:51 -0400
committerAlexander Kurtakov2018-06-13 08:30:58 -0400
commit799da4a57410d3d2a15c3ef49421e052aced6ab4 (patch)
treee684a1b58f59247aeb91f9f440aa95816f2707e0
parent945db477e8c344146a545b54bce694f3db57abfb (diff)
downloadrt.equinox.p2-799da4a57410d3d2a15c3ef49421e052aced6ab4.zip
rt.equinox.p2-799da4a57410d3d2a15c3ef49421e052aced6ab4.tar.gz
rt.equinox.p2-799da4a57410d3d2a15c3ef49421e052aced6ab4.tar.xz
Refactor internal MirrorSelector's computeMirrors(String, IProgressMonitor)
Change-Id: I88ceb0b4f5f076b4ba00cfeccc1a0b2c567c9fdb Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java26
1 files changed, 15 insertions, 11 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java
index df95017..1b55998 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/MirrorSelector.java
@@ -256,17 +256,7 @@ public class MirrorSelector {
Document document = getMirrorsDocument(mirrorsURL, monitor);
if (document == null)
return null;
- NodeList mirrorNodes = document.getElementsByTagName("mirror"); //$NON-NLS-1$
- int mirrorCount = mirrorNodes.getLength();
- MirrorInfo[] infos = new MirrorInfo[mirrorCount + 1];
- for (int i = 0; i < mirrorCount; i++) {
- Element mirrorNode = (Element) mirrorNodes.item(i);
- String infoURL = mirrorNode.getAttribute("url"); //$NON-NLS-1$
- infos[i] = new MirrorInfo(infoURL, i);
- }
- //p2: add the base site as the last resort mirror so we can track download speed and failure rate
- infos[mirrorCount] = new MirrorInfo(baseURI.toString(), mirrorCount);
- return infos;
+ return buildMirrorInfos(document);
} catch (Exception e) {
// log if absolute url
if (mirrorsURL != null && (mirrorsURL.startsWith("http://") //$NON-NLS-1$
@@ -279,6 +269,20 @@ public class MirrorSelector {
}
}
+ private MirrorInfo[] buildMirrorInfos(Document document) {
+ NodeList mirrorNodes = document.getElementsByTagName("mirror"); //$NON-NLS-1$
+ int mirrorCount = mirrorNodes.getLength();
+ MirrorInfo[] infos = new MirrorInfo[mirrorCount + 1];
+ for (int i = 0; i < mirrorCount; i++) {
+ Element mirrorNode = (Element) mirrorNodes.item(i);
+ String infoURL = mirrorNode.getAttribute("url"); //$NON-NLS-1$
+ infos[i] = new MirrorInfo(infoURL, i);
+ }
+ //p2: add the base site as the last resort mirror so we can track download speed and failure rate
+ infos[mirrorCount] = new MirrorInfo(baseURI.toString(), mirrorCount);
+ return infos;
+ }
+
private Document getMirrorsDocument(String mirrorsURL, IProgressMonitor monitor) throws ParserConfigurationException, FileNotFoundException, CoreException, AuthenticationFailedException, URISyntaxException, SAXException, IOException {
DocumentBuilderFactory domFactory = SecureXMLUtil.newSecureDocumentBuilderFactory();
DocumentBuilder builder = domFactory.newDocumentBuilder();