[157731] TaglibIndex returns incorrect URIs for TLDs in XML Catalog
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java
index 8d2aabe..12c1f16 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java
@@ -569,8 +569,26 @@
fClasspathReferences = new Hashtable(0);
}
- private ITaglibRecord createCatalogRecord(String urlString) {
+ /**
+ * @param catalogEntry
+ * a XML catalog entry pointing to a .jar or .tld file
+ * @return an ITaglibRecord describing a TLD contributed to the
+ * XMLCatalog, if one was found at the given location
+ */
+ private ITaglibRecord createCatalogRecord(ICatalogEntry catalogEntry) {
+ return createCatalogRecord(catalogEntry.getKey(), catalogEntry.getURI());
+ }
+
+ /**
+ * @param uri -
+ * the key value that will become the returned record's "URI"
+ * @param urlString -
+ * the string indicating where the TLD really is
+ * @return an ITaglibRecord describing a TLD contributed to the XMLCatalog
+ */
+ private ITaglibRecord createCatalogRecord(String uri, String urlString) {
ITaglibRecord record = null;
+ // handle "file:" URLs that point to a .jar file on disk (1.1 mode)
if (urlString.toLowerCase(Locale.US).endsWith((".jar")) && urlString.startsWith("file:")) { //$NON-NLS-1$ //$NON-NLS-2$
String fileLocation = null;
try {
@@ -590,6 +608,12 @@
InputStream contents = JarUtilities.getInputStream(fileLocation, entries[jEntry]);
if (contents != null) {
TaglibInfo info = extractInfo(fileLocation, contents);
+ /*
+ * the record's reported URI should match the
+ * catalog entry's "key" so replace the
+ * detected value
+ */
+ info.uri = uri;
jarRecord.info = info;
}
try {
@@ -608,6 +632,7 @@
}
}
+ // The rest are URLs into a plug-in...somewhere
else {
URL url = null;
ByteArrayInputStream cachedContents = null;
@@ -619,7 +644,7 @@
tldStream = connection.getInputStream();
}
catch (Exception e1) {
- Logger.logException(e1);
+ Logger.logException("Exception reading TLD contributed to the XML Catalog", e1);
}
int c;
@@ -646,6 +671,11 @@
URLRecord urlRecord = null;
TaglibInfo info = extractInfo(urlString, cachedContents);
if (info != null) {
+ /*
+ * the record's reported URI should match the catalog entry's
+ * "key" so replace the detected value
+ */
+ info.uri = uri;
urlRecord = new URLRecord();
urlRecord.info = info;
urlRecord.baseLocation = urlString;
@@ -814,7 +844,7 @@
// Process default catalog
ICatalogEntry[] entries = defaultCatalog.getCatalogEntries();
for (int entry = 0; entry < entries.length; entry++) {
- ITaglibRecord record = createCatalogRecord(entries[entry].getURI());
+ ITaglibRecord record = createCatalogRecord(entries[entry]);
records.add(record);
}
@@ -828,7 +858,7 @@
if (uri != null) {
uri = uri.toLowerCase(Locale.US);
if (uri.endsWith((".jar")) || uri.endsWith((".tld"))) {
- ITaglibRecord record = createCatalogRecord(uri);
+ ITaglibRecord record = createCatalogRecord(entries2[entry]);
records.add(record);
}
}
@@ -1273,7 +1303,7 @@
Logger.logException(e);
}
if (resolvedString != null && resolvedString.trim().length() > 0) {
- record = createCatalogRecord(resolvedString);
+ record = createCatalogRecord(reference, resolvedString);
}
}
}
@@ -1498,10 +1528,10 @@
/**
* <pre>
- * 1.0.1
- * Save classpath information (| is field delimiter)
- * Jars are saved as "JAR:"+ has11TLD + jar path
- * URLRecords as "URL:"+URL
+ * 1.0.1
+ * Save classpath information (| is field delimiter)
+ * Jars are saved as "JAR:"+ has11TLD + jar path
+ * URLRecords as "URL:"+URL
* </pre>
*/
try {