Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2011-01-27 14:29:54 -0500
committerDJ Houghton2011-01-27 14:29:54 -0500
commiteff1605e5781ebcd8688b21831bf5f003ea3f410 (patch)
tree68e4d7ade3120e5c6852d84eb1f712d5986028a0 /bundles/org.eclipse.equinox.p2.repository
parent2e968b58d5c48d4e873e49bc3a20e9681c7f5721 (diff)
downloadrt.equinox.p2-eff1605e5781ebcd8688b21831bf5f003ea3f410.tar.gz
rt.equinox.p2-eff1605e5781ebcd8688b21831bf5f003ea3f410.tar.xz
rt.equinox.p2-eff1605e5781ebcd8688b21831bf5f003ea3f410.zip
Bug 335414 - Site parsing errors should mention the URL of the site being parsed and erroneous bit of XML for easier debuggery
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.repository')
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeRepositoryIO.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java9
3 files changed, 17 insertions, 8 deletions
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java
index c3d91c1ab..a112f8b86 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,15 +10,14 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.persistence;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
-
import java.io.*;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.xml.sax.*;
@@ -170,6 +169,9 @@ public class CompositeParser extends XMLParser implements XMLConstants {
}
public void parse(File file) throws IOException {
+ // don't overwrite if we already have a filename/location
+ if (errorContext == null)
+ setErrorContext(file.getAbsolutePath());
parse(new FileInputStream(file));
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeRepositoryIO.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeRepositoryIO.java
index 2a5b1672c..5b14902ee 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeRepositoryIO.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/CompositeRepositoryIO.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * Copyright (c) 2008, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,13 +10,12 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.persistence;
-import org.eclipse.equinox.p2.core.ProvisionException;
-
import java.io.*;
import java.net.URL;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.Activator;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.osgi.util.NLS;
/**
@@ -61,6 +60,7 @@ public class CompositeRepositoryIO {
try {
bufferedInput = new BufferedInputStream(input);
CompositeParser repositoryParser = new CompositeParser(Activator.getContext(), Activator.ID, type);
+ repositoryParser.setErrorContext(location.toExternalForm());
repositoryParser.parse(input);
IStatus result = repositoryParser.getStatus();
switch (result.getSeverity()) {
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java
index b26843f37..01aa1a396 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/persistence/XMLParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -39,6 +39,7 @@ public abstract class XMLParser extends DefaultHandler implements XMLConstants {
protected String bundleId; // parser class bundle id
protected XMLReader xmlReader; // the XML reader for the parser
+ protected String errorContext; // some context of what we are parsing in case there is an error
protected MultiStatus status = null; // accumulation of non-fatal errors
protected Locator locator = null; // document locator, if supported by the parser
@@ -527,6 +528,8 @@ public abstract class XMLParser extends DefaultHandler implements XMLConstants {
: " (" + getRootObject() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
if (this.locator != null) {
String name = this.locator.getSystemId();
+ if (errorContext != null && (name == null || name.trim().length() == 0))
+ name = errorContext;
line = this.locator.getLineNumber();
column = this.locator.getColumnNumber();
if (line > 0) {
@@ -724,6 +727,10 @@ public abstract class XMLParser extends DefaultHandler implements XMLConstants {
return -1;
}
+ public void setErrorContext(String errorContext) {
+ this.errorContext = errorContext;
+ }
+
// public class BadStateError extends AssertionError {
// private static final long serialVersionUID = 1L; // not serialized
//

Back to the top