aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2010-04-05 16:44:31 -0700
committerRaphael <raphael@google.com>2010-04-06 07:56:38 -0700
commit1534fb8b47de1dcb92a8d0a0b67521b1c4de58ca (patch)
treead6c5755337135a1a9d3e3cdba86c7eb34fa48e3
parent5f3bb57d677abc71a3ef6fc2d8e880ede3f61ce9 (diff)
downloadsdk-1534fb8b47de1dcb92a8d0a0b67521b1c4de58ca.zip
sdk-1534fb8b47de1dcb92a8d0a0b67521b1c4de58ca.tar.gz
sdk-1534fb8b47de1dcb92a8d0a0b67521b1c4de58ca.tar.bz2
SDK Manager: fix error message when missing XML validator.
SDK Bug 2306644 (merge Change I2e698ea0 from master) Change-Id: Ia4be1d58c11ebccb811005ac21cf19b8d734e0c1
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java
index dd590f6..a7bc3f3 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/RepoSource.java
@@ -160,6 +160,7 @@ public class RepoSource implements IDescription {
monitor.incProgress(1);
mFetchError = null;
+ Boolean[] validatorFound = new Boolean[] { Boolean.FALSE };
String[] validationError = new String[] { null };
Exception[] exception = new Exception[] { null };
ByteArrayInputStream xml = fetchUrl(url, exception);
@@ -168,17 +169,23 @@ public class RepoSource implements IDescription {
String validatedUri = null;
if (xml != null) {
monitor.setDescription("Validate XML");
- String uri = validateXml(xml, url, validationError);
+ String uri = validateXml(xml, url, validationError, validatorFound);
if (uri != null) {
+ // Validation was successful
validatedDoc = getDocument(xml, monitor);
validatedUri = uri;
- } else {
+ } else if (validatorFound[0].equals(Boolean.TRUE)) {
+ // An XML validator was found and the XML failed to validate.
+ // Let's see if we can find an alternate tools upgrade to perform.
validatedDoc = findAlternateToolsXml(xml);
if (validatedDoc != null) {
validationError[0] = null; // remove error from XML validation
validatedUri = SdkRepository.NS_SDK_REPOSITORY;
usingAlternateXml = true;
}
+ } else {
+ // Validation failed because this JVM lacks a proper XML Validator
+ mFetchError = "No suitable XML Schema Validator could be found in your Java environment. Please update your version of Java.";
}
}
@@ -192,17 +199,24 @@ public class RepoSource implements IDescription {
xml = fetchUrl(url, exception);
if (xml != null) {
- String uri = validateXml(xml, url, validationError);
+ String uri = validateXml(xml, url, validationError, validatorFound);
if (uri != null) {
+ // Validation was successful
+ validationError[0] = null; // remove error from previous XML validation
validatedDoc = getDocument(xml, monitor);
validatedUri = uri;
- } else {
+ } else if (validatorFound[0].equals(Boolean.TRUE)) {
+ // An XML validator was found and the XML failed to validate.
+ // Let's see if we can find an alternate tools upgrade to perform.
validatedDoc = findAlternateToolsXml(xml);
if (validatedDoc != null) {
validationError[0] = null; // remove error from XML validation
validatedUri = SdkRepository.NS_SDK_REPOSITORY;
usingAlternateXml = true;
}
+ } else {
+ // Validation failed because this JVM lacks a proper XML Validator
+ mFetchError = "No suitable XML Schema Validator could be found in your Java environment. Please update your version of Java.";
}
}
@@ -359,7 +373,8 @@ public class RepoSource implements IDescription {
* If the XML was correctly validated, returns the schema that worked.
* If no schema validated the XML, returns null.
*/
- private String validateXml(ByteArrayInputStream xml, String url, String[] outError) {
+ private String validateXml(ByteArrayInputStream xml, String url,
+ String[] outError, Boolean[] validatorFound) {
String lastError = null;
String extraError = null;
@@ -369,9 +384,11 @@ public class RepoSource implements IDescription {
if (validator == null) {
lastError = "XML verification failed for %1$s.\nNo suitable XML Schema Validator could be found in your Java environment. Please consider updating your version of Java.";
+ validatorFound[0] = Boolean.FALSE;
continue;
}
+ validatorFound[0] = Boolean.TRUE;
xml.reset();
// Validation throws a bunch of possible Exceptions on failure.
validator.validate(new StreamSource(xml));