Bug 247380 Three copies of mirror parsing code but one is used
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/features/DefaultSiteParser.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/features/DefaultSiteParser.java
index 14dbbb1..8a7d137 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/features/DefaultSiteParser.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/features/DefaultSiteParser.java
@@ -39,7 +39,6 @@
 	private static final String DESCRIPTION = "description"; //$NON-NLS-1$
 	private static final String FEATURE = "feature"; //$NON-NLS-1$
 	private static final String FEATURES = "features/"; //$NON-NLS-1$
-	private static final String MIRROR = "mirror"; //$NON-NLS-1$
 	private final static SAXParserFactory parserFactory = SAXParserFactory.newInstance();
 	private static final String PLUGIN_ID = Activator.ID;
 	private static final String SITE = "site"; //$NON-NLS-1$
@@ -112,58 +111,10 @@
 		}
 	}
 
-	static URLEntry[] getMirrors(String mirrorsURL) {
-
-		try {
-			String countryCode = Locale.getDefault().getCountry().toLowerCase();
-			int timeZone = (new GregorianCalendar()).get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000);
-
-			if (mirrorsURL.indexOf("?") != -1) { //$NON-NLS-1$
-				mirrorsURL = mirrorsURL + "&"; //$NON-NLS-1$
-			} else {
-				mirrorsURL = mirrorsURL + "?"; //$NON-NLS-1$
-			}
-			mirrorsURL = mirrorsURL + "countryCode=" + countryCode + "&timeZone=" + timeZone + "&responseType=xml"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
-			DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
-			DocumentBuilder builder = domFactory.newDocumentBuilder();
-			Document document = builder.parse(mirrorsURL);
-			if (document == null)
-				return null;
-			NodeList mirrorNodes = document.getElementsByTagName(MIRROR);
-			URLEntry[] mirrors = new URLEntry[mirrorNodes.getLength()];
-			for (int i = 0; i < mirrorNodes.getLength(); i++) {
-				Element mirrorNode = (Element) mirrorNodes.item(i);
-				mirrors[i] = new URLEntry();
-				String infoURL = mirrorNode.getAttribute("url"); //$NON-NLS-1$
-				String label = mirrorNode.getAttribute("label"); //$NON-NLS-1$
-				mirrors[i].setURL(infoURL);
-				mirrors[i].setAnnotation(label);
-
-				if (Tracing.DEBUG_GENERATOR_PARSING)
-					debug("Processed mirror: url:" + infoURL + " label:" + label); //$NON-NLS-1$ //$NON-NLS-2$
-			}
-			return mirrors;
-		} catch (Exception e) {
-			// log if absolute url
-			if (mirrorsURL != null && (mirrorsURL.startsWith("http://") //$NON-NLS-1$
-					|| mirrorsURL.startsWith("https://") //$NON-NLS-1$
-					|| mirrorsURL.startsWith("file://") //$NON-NLS-1$
-					|| mirrorsURL.startsWith("ftp://") //$NON-NLS-1$
-			|| mirrorsURL.startsWith("jar://"))) //$NON-NLS-1$
-				LogHelper.log(new Status(IStatus.ERROR, Activator.ID, Messages.DefaultSiteParser_mirrors, e));
-			return null;
-		}
-	}
-
 	static void log(Exception e) {
 		LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Internal Error", e)); //$NON-NLS-1$
 	}
 
-	static void log(IStatus error) {
-		LogHelper.log(error);
-	}
-
 	static void log(String message) {
 		LogHelper.log(new Status(IStatus.WARNING, Activator.ID, message, null));
 	}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/features/SiteModel.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/features/SiteModel.java
index 6fe043d..eec0158 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/features/SiteModel.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/p2/metadata/generator/features/SiteModel.java
@@ -34,7 +34,6 @@
 	private List features;
 	private URL locationURL;
 	private String locationURLString;
-	private List /* of URLEntry */mirrors;
 	private String mirrorsURLString;
 	private boolean supportsPack200;
 	private String type;
@@ -93,26 +92,6 @@
 	}
 
 	/**
-	 * Adds a mirror site.
-	 * 
-	 * @param mirror mirror model 
-	 * @since 3.1
-	 */
-	public void addMirror(URLEntry mirror) {
-		if (this.mirrors == null)
-			this.mirrors = new ArrayList();
-		if (!this.mirrors.contains(mirror))
-			this.mirrors.add(mirror);
-	}
-
-	private void doSetMirrorSiteEntryModels(URLEntry[] newMirrors) {
-		if (newMirrors == null || newMirrors.length == 0)
-			this.mirrors = null;
-		else
-			this.mirrors = new ArrayList(Arrays.asList(newMirrors));
-	}
-
-	/**
 	 * Returns an array of plug-in and non-plug-in archive reference models
 	 * on this site
 	 * 
@@ -218,24 +197,6 @@
 	}
 
 	/**
-	 * Return an array of update site mirrors
-	 * 
-	 * @return an array of mirror entries, or an empty array.
-	 * @since 3.1
-	 */
-	public URLEntry[] getMirrors() {
-		//delayedResolve(); no delay;
-		if (mirrors == null || mirrors.size() == 0)
-			// see if we can get mirrors from the provided url
-			if (mirrorsURLString != null)
-				doSetMirrorSiteEntryModels(DefaultSiteParser.getMirrors(mirrorsURLString));
-
-		if (mirrors == null || mirrors.size() == 0)
-			return new URLEntry[0];
-		return (URLEntry[]) mirrors.toArray(new URLEntry[0]);
-	}
-
-	/**
 	 * Returns the URL from which the list of mirrors of this site can be retrieved.
 	 * 
 	 * @since org.eclipse.equinox.p2.metadata.generator 1.0
@@ -259,41 +220,6 @@
 	}
 
 	/**
-	 * Resolve the model object.
-	 * Any URL strings in the model are resolved relative to the 
-	 * base URL argument. Any translatable strings in the model that are
-	 * specified as translation keys are localized using the supplied 
-	 * resource bundle.
-	 * 
-	 * @param base URL
-	 * @param bundleURL resource bundle URL
-	 * @exception MalformedURLException
-	 * @since 2.0
-	 */
-	public void resolve(URL base, URL bundleURL) throws MalformedURLException {
-
-		// Archives and feature are relative to location URL
-		// if the Site element has a URL tag: see spec	
-		//		locationURL = resolveURL(base, bundleURL, getLocationURLString());
-		//		if (locationURL == null)
-		//			locationURL = base;
-		//		resolveListReference(getFeatureReferenceModels(), locationURL, bundleURL);
-		//		resolveListReference(getArchiveReferenceModels(), locationURL, bundleURL);
-		//
-		//		resolveReference(getDescriptionModel(), base, bundleURL);
-		//		resolveListReference(getCategoryModels(), base, bundleURL);
-		//
-		//		URL url = resolveURL(base, bundleURL, mirrorsURLString);
-		//		if (url != null)
-		//			mirrorsURLString = url.toString();
-		//
-		//		if ((this instanceof ExtendedSite) && ((ExtendedSite) this).isDigestExist()) {
-		//			ExtendedSite extendedSite = (ExtendedSite) this;
-		//			extendedSite.setLiteFeatures(UpdateManagerUtils.getLightFeatures(extendedSite));
-		//		}
-	}
-
-	/**
 	 * Sets the site description.
 	 * 
 	 * @param description site description
@@ -343,16 +269,6 @@
 	}
 
 	/**
-	 * Sets additional mirror sites
-	 * 
-	 * @param mirrors additional update site mirrors
-	 * @since 3.1
-	 */
-	public void setMirrors(URLEntry[] mirrors) {
-		doSetMirrorSiteEntryModels(mirrors);
-	}
-
-	/**
 	 * Sets the mirrors url. Mirror sites will then be obtained from this mirror url later.
 	 * This method is complementary to setMirrorsiteEntryModels(), and only one of these 
 	 * methods should be called.
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/DefaultSiteParser.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/DefaultSiteParser.java
index 659c047..dac965c 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/DefaultSiteParser.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/DefaultSiteParser.java
@@ -38,7 +38,6 @@
 	private static final String DESCRIPTION = "description"; //$NON-NLS-1$
 	private static final String FEATURE = "feature"; //$NON-NLS-1$
 	private static final String FEATURES = "features/"; //$NON-NLS-1$
-	private static final String MIRROR = "mirror"; //$NON-NLS-1$
 	private final static SAXParserFactory parserFactory = SAXParserFactory.newInstance();
 	private static final String PLUGIN_ID = Activator.ID;
 	private static final String SITE = "site"; //$NON-NLS-1$
@@ -111,58 +110,10 @@
 		}
 	}
 
-	static URLEntry[] getMirrors(String mirrorsURL) {
-
-		try {
-			String countryCode = Locale.getDefault().getCountry().toLowerCase();
-			int timeZone = (new GregorianCalendar()).get(Calendar.ZONE_OFFSET) / (60 * 60 * 1000);
-
-			if (mirrorsURL.indexOf("?") != -1) { //$NON-NLS-1$
-				mirrorsURL = mirrorsURL + "&"; //$NON-NLS-1$
-			} else {
-				mirrorsURL = mirrorsURL + "?"; //$NON-NLS-1$
-			}
-			mirrorsURL = mirrorsURL + "countryCode=" + countryCode + "&timeZone=" + timeZone + "&responseType=xml"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
-			DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
-			DocumentBuilder builder = domFactory.newDocumentBuilder();
-			Document document = builder.parse(mirrorsURL);
-			if (document == null)
-				return null;
-			NodeList mirrorNodes = document.getElementsByTagName(MIRROR);
-			URLEntry[] mirrors = new URLEntry[mirrorNodes.getLength()];
-			for (int i = 0; i < mirrorNodes.getLength(); i++) {
-				Element mirrorNode = (Element) mirrorNodes.item(i);
-				mirrors[i] = new URLEntry();
-				String infoURL = mirrorNode.getAttribute("url"); //$NON-NLS-1$
-				String label = mirrorNode.getAttribute("label"); //$NON-NLS-1$
-				mirrors[i].setURL(infoURL);
-				mirrors[i].setAnnotation(label);
-
-				if (Tracing.DEBUG_GENERATOR_PARSING)
-					debug("Processed mirror: url:" + infoURL + " label:" + label); //$NON-NLS-1$ //$NON-NLS-2$
-			}
-			return mirrors;
-		} catch (Exception e) {
-			// log if absolute url
-			if (mirrorsURL != null && (mirrorsURL.startsWith("http://") //$NON-NLS-1$
-					|| mirrorsURL.startsWith("https://") //$NON-NLS-1$
-					|| mirrorsURL.startsWith("file://") //$NON-NLS-1$
-					|| mirrorsURL.startsWith("ftp://") //$NON-NLS-1$
-			|| mirrorsURL.startsWith("jar://"))) //$NON-NLS-1$
-				LogHelper.log(new Status(IStatus.ERROR, Activator.ID, Messages.DefaultSiteParser_mirrors, e));
-			return null;
-		}
-	}
-
 	static void log(Exception e) {
 		LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Internal Error", e)); //$NON-NLS-1$
 	}
 
-	static void log(IStatus error) {
-		LogHelper.log(error);
-	}
-
 	static void log(String message) {
 		LogHelper.log(new Status(IStatus.WARNING, Activator.ID, message, null));
 	}
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteModel.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteModel.java
index 3db8a96..1dba49b 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteModel.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteModel.java
@@ -10,11 +10,10 @@
  *******************************************************************************/
 package org.eclipse.equinox.internal.p2.updatesite;
 
-import org.eclipse.equinox.p2.publisher.eclipse.URLEntry;
-
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.*;
+import org.eclipse.equinox.p2.publisher.eclipse.URLEntry;
 
 /**
  * A model of an update site.
@@ -35,7 +34,6 @@
 	private List features;
 	private URL locationURL;
 	private String locationURLString;
-	private List /* of URLEntry */mirrors;
 	private String mirrorsURLString;
 	private boolean supportsPack200;
 	private String type;
@@ -94,26 +92,6 @@
 	}
 
 	/**
-	 * Adds a mirror site.
-	 * 
-	 * @param mirror mirror model 
-	 * @since 3.1
-	 */
-	public void addMirror(URLEntry mirror) {
-		if (this.mirrors == null)
-			this.mirrors = new ArrayList();
-		if (!this.mirrors.contains(mirror))
-			this.mirrors.add(mirror);
-	}
-
-	private void doSetMirrorSiteEntryModels(URLEntry[] newMirrors) {
-		if (newMirrors == null || newMirrors.length == 0)
-			this.mirrors = null;
-		else
-			this.mirrors = new ArrayList(Arrays.asList(newMirrors));
-	}
-
-	/**
 	 * Returns an array of plug-in and non-plug-in archive reference models
 	 * on this site
 	 * 
@@ -219,24 +197,6 @@
 	}
 
 	/**
-	 * Return an array of update site mirrors
-	 * 
-	 * @return an array of mirror entries, or an empty array.
-	 * @since 3.1
-	 */
-	public URLEntry[] getMirrors() {
-		//delayedResolve(); no delay;
-		if (mirrors == null || mirrors.size() == 0)
-			// see if we can get mirrors from the provided url
-			if (mirrorsURLString != null)
-				doSetMirrorSiteEntryModels(DefaultSiteParser.getMirrors(mirrorsURLString));
-
-		if (mirrors == null || mirrors.size() == 0)
-			return new URLEntry[0];
-		return (URLEntry[]) mirrors.toArray(new URLEntry[0]);
-	}
-
-	/**
 	 * Returns the URL from which the list of mirrors of this site can be retrieved.
 	 * 
 	 * @since org.eclipse.equinox.p2.metadata.generator 1.0
@@ -260,41 +220,6 @@
 	}
 
 	/**
-	 * Resolve the model object.
-	 * Any URL strings in the model are resolved relative to the 
-	 * base URL argument. Any translatable strings in the model that are
-	 * specified as translation keys are localized using the supplied 
-	 * resource bundle.
-	 * 
-	 * @param base URL
-	 * @param bundleURL resource bundle URL
-	 * @exception MalformedURLException
-	 * @since 2.0
-	 */
-	public void resolve(URL base, URL bundleURL) throws MalformedURLException {
-
-		// Archives and feature are relative to location URL
-		// if the Site element has a URL tag: see spec	
-		//		locationURL = resolveURL(base, bundleURL, getLocationURLString());
-		//		if (locationURL == null)
-		//			locationURL = base;
-		//		resolveListReference(getFeatureReferenceModels(), locationURL, bundleURL);
-		//		resolveListReference(getArchiveReferenceModels(), locationURL, bundleURL);
-		//
-		//		resolveReference(getDescriptionModel(), base, bundleURL);
-		//		resolveListReference(getCategoryModels(), base, bundleURL);
-		//
-		//		URL url = resolveURL(base, bundleURL, mirrorsURLString);
-		//		if (url != null)
-		//			mirrorsURLString = url.toString();
-		//
-		//		if ((this instanceof ExtendedSite) && ((ExtendedSite) this).isDigestExist()) {
-		//			ExtendedSite extendedSite = (ExtendedSite) this;
-		//			extendedSite.setLiteFeatures(UpdateManagerUtils.getLightFeatures(extendedSite));
-		//		}
-	}
-
-	/**
 	 * Sets the site description.
 	 * 
 	 * @param description site description
@@ -344,16 +269,6 @@
 	}
 
 	/**
-	 * Sets additional mirror sites
-	 * 
-	 * @param mirrors additional update site mirrors
-	 * @since 3.1
-	 */
-	public void setMirrors(URLEntry[] mirrors) {
-		doSetMirrorSiteEntryModels(mirrors);
-	}
-
-	/**
 	 * Sets the mirrors url. Mirror sites will then be obtained from this mirror url later.
 	 * This method is complementary to setMirrorsiteEntryModels(), and only one of these 
 	 * methods should be called.