summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2018-03-24 09:11:03 -0400
committerAlexander Kurtakov2018-06-13 07:38:39 -0400
commit945db477e8c344146a545b54bce694f3db57abfb (patch)
tree3c8404ab15194180fb30837cc3a84f00393ed526
parent69069b9f60e8c0675f2500be6388822b5f967d98 (diff)
downloadrt.equinox.p2-945db477e8c344146a545b54bce694f3db57abfb.zip
rt.equinox.p2-945db477e8c344146a545b54bce694f3db57abfb.tar.gz
rt.equinox.p2-945db477e8c344146a545b54bce694f3db57abfb.tar.xz
Refactor internal MirrorSelector's computeMirrors(String, IProgressMonitor)
Change-Id: I427769a505ef055d3ea5df6481f5bb3546d787de 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.java24
1 files changed, 14 insertions, 10 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 8d6075d..df95017 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
@@ -18,18 +18,18 @@ import static java.lang.Math.min;
import static java.lang.Math.sqrt;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.*;
-import org.eclipse.equinox.internal.p2.repository.DownloadStatus;
-import org.eclipse.equinox.internal.p2.repository.Transport;
+import org.eclipse.equinox.internal.p2.repository.*;
import org.eclipse.equinox.p2.repository.IRepository;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
/**
* Mirror support class for repositories. This class implements
@@ -253,12 +253,7 @@ public class MirrorSelector {
private MirrorInfo[] computeMirrors(String mirrorsURL, IProgressMonitor monitor) {
try {
mirrorsURL = enrichWithClientLocation(mirrorsURL);
- DocumentBuilderFactory domFactory = SecureXMLUtil.newSecureDocumentBuilderFactory();
- DocumentBuilder builder = domFactory.newDocumentBuilder();
- // Use Transport to read the mirrors list (to benefit from proxy support, authentication, etc)
- InputSource input = new InputSource(mirrorsURL);
- input.setByteStream(transport.stream(URIUtil.fromString(mirrorsURL), monitor));
- Document document = builder.parse(input);
+ Document document = getMirrorsDocument(mirrorsURL, monitor);
if (document == null)
return null;
NodeList mirrorNodes = document.getElementsByTagName("mirror"); //$NON-NLS-1$
@@ -284,6 +279,15 @@ public class MirrorSelector {
}
}
+ private Document getMirrorsDocument(String mirrorsURL, IProgressMonitor monitor) throws ParserConfigurationException, FileNotFoundException, CoreException, AuthenticationFailedException, URISyntaxException, SAXException, IOException {
+ DocumentBuilderFactory domFactory = SecureXMLUtil.newSecureDocumentBuilderFactory();
+ DocumentBuilder builder = domFactory.newDocumentBuilder();
+ // Use Transport to read the mirrors list (to benefit from proxy support, authentication, etc)
+ InputSource input = new InputSource(mirrorsURL);
+ input.setByteStream(transport.stream(URIUtil.fromString(mirrorsURL), monitor));
+ return builder.parse(input);
+ }
+
private String enrichWithClientLocation(String baseURL) {
String countryCode = Activator.getContext().getProperty("eclipse.p2.countryCode"); //$NON-NLS-1$
if (countryCode == null || countryCode.trim().length() == 0)