monitor.incProgress(1);\r
\r
mFetchError = null;\r
+ String[] validationError = new String[] { null };\r
Exception[] exception = new Exception[] { null };\r
ByteArrayInputStream xml = fetchUrl(url, exception);\r
Document validatedDoc = null;\r
+ boolean usingAlternateXml = false;\r
String validatedUri = null;\r
if (xml != null) {\r
monitor.setDescription("Validate XML");\r
- String uri = validateXml(xml, url, monitor);\r
+ String uri = validateXml(xml, url, validationError);\r
if (uri != null) {\r
validatedDoc = getDocument(xml, monitor);\r
validatedUri = uri;\r
} else {\r
validatedDoc = findAlternateToolsXml(xml);\r
- validatedUri = SdkRepository.NS_SDK_REPOSITORY;\r
+ if (validatedDoc != null) {\r
+ validationError[0] = null; // remove error from XML validation\r
+ validatedUri = SdkRepository.NS_SDK_REPOSITORY;\r
+ usingAlternateXml = true;\r
+ }\r
}\r
}\r
\r
\r
xml = fetchUrl(url, exception);\r
if (xml != null) {\r
- String uri = validateXml(xml, url, monitor);\r
+ String uri = validateXml(xml, url, validationError);\r
if (uri != null) {\r
validatedDoc = getDocument(xml, monitor);\r
validatedUri = uri;\r
} else {\r
validatedDoc = findAlternateToolsXml(xml);\r
- validatedUri = SdkRepository.NS_SDK_REPOSITORY;\r
+ if (validatedDoc != null) {\r
+ validationError[0] = null; // remove error from XML validation\r
+ validatedUri = SdkRepository.NS_SDK_REPOSITORY;\r
+ usingAlternateXml = true;\r
+ }\r
}\r
}\r
\r
monitor.setResult("Failed to fetch URL %1$s, reason: %2$s", url, reason);\r
}\r
\r
+ if(validationError[0] != null) {\r
+ monitor.setResult("%s", validationError[0]); //$NON-NLS-1$\r
+ }\r
+\r
// Stop here if we failed to validate the XML. We don't want to load it.\r
if (validatedDoc == null) {\r
return;\r
}\r
\r
+ if (usingAlternateXml) {\r
+ String info = "This repository requires a more recent version of the Tools. Please update.";\r
+ mFetchError = mFetchError == null ? info : mFetchError + ". " + info;\r
+ mDescription = "This repository requires a more recent version of the Tools.\nYou must update it before you can see other new packages.";\r
+ }\r
+\r
monitor.incProgress(1);\r
\r
if (xml != null) {\r
* If the XML was correctly validated, returns the schema that worked.\r
* If no schema validated the XML, returns null.\r
*/\r
- private String validateXml(ByteArrayInputStream xml, String url, ITaskMonitor monitor) {\r
+ private String validateXml(ByteArrayInputStream xml, String url, String[] outError) {\r
\r
String lastError = null;\r
String extraError = null;\r
}\r
\r
if (lastError != null) {\r
- monitor.setResult(lastError, url, extraError);\r
+ outError[0] = String.format(lastError, url, extraError);\r
}\r
return null;\r
}\r
packages = null;\r
}\r
\r
- if (packages == null && source.getFetchError() != null) {\r
- // Return a dummy entry to display the fetch error\r
- return new Object[] { new RepoSourceError(source) };\r
+ ArrayList<Object> results = new ArrayList<Object>();\r
+\r
+ if (source.getFetchError() != null) {\r
+ // Insert a dummy entry to display the fetch error\r
+ results.add(new RepoSourceError(source));\r
}\r
\r
// Either return a non-null package list or create a new empty node\r
if (packages != null) {\r
- return packages;\r
+ for (Package p : packages) {\r
+ results.add(p);\r
+ }\r
} else {\r
- return new Object[] { new RepoSourceEmpty(source, !wasEmptyBeforeFilter) } ;\r
+ results.add(new RepoSourceEmpty(source, !wasEmptyBeforeFilter));\r
}\r
+\r
+ return results.toArray();\r
}\r
\r
/**\r