[SCM] eclipse-wtp packaging branch, master, updated. upstream/3.4.1-29-g4c69b22
Jakub Adam
jakub.adam at ktknet.cz
Sat Oct 20 22:39:45 UTC 2012
The following commit has been merged in the master branch:
commit 4c69b220cf3bfce9ae876d37adeb8e39937058f3
Author: Jakub Adam <jakub.adam at ktknet.cz>
Date: Sun Oct 21 00:18:30 2012 +0200
Improve system XML catalog integration
diff --git a/debian/patches/add-debian-system-catalog-reader.patch b/debian/patches/add-debian-system-catalog-reader.patch
index 5b2723c..8e42b25 100644
--- a/debian/patches/add-debian-system-catalog-reader.patch
+++ b/debian/patches/add-debian-system-catalog-reader.patch
@@ -5,13 +5,13 @@ Subject: add-debian-system-catalog-reader
---
org.eclipse.wst.xml.core/META-INF/MANIFEST.MF | 3 +-
.../wst/xml/core/internal/catalog/Catalog.java | 1 +
- .../catalog/DebianSystemCatalogReader.java | 98 ++++++++++++++++++++
+ .../catalog/DebianSystemCatalogReader.java | 186 ++++++++++++++++++++
org.eclipse.wst.xml_core.feature/feature.xml | 4 +-
- 4 files changed, 103 insertions(+), 3 deletions(-)
+ 4 files changed, 191 insertions(+), 3 deletions(-)
create mode 100644 org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/DebianSystemCatalogReader.java
diff --git a/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF b/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF
-index 7def97c..5199c6a 100755
+index bd55c3f..8b4886b 100644
--- a/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.wst.xml.core/META-INF/MANIFEST.MF
@@ -322,6 +322,7 @@ Require-Bundle: org.apache.xerces;bundle-version="[2.9.0,3.0.0)";visibility:=ree
@@ -24,7 +24,7 @@ index 7def97c..5199c6a 100755
Bundle-ActivationPolicy: lazy; exclude:="org.eclipse.wst.xml.core.internal.contenttype"
Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java b/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java
-index b6c322c..701bc83 100755
+index b6c322c..701bc83 100644
--- a/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java
+++ b/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java
@@ -389,6 +389,7 @@ public class Catalog implements ICatalog
@@ -37,12 +37,12 @@ index b6c322c..701bc83 100755
* Here we save the file in order to 'reflect' the catalog that
diff --git a/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/DebianSystemCatalogReader.java b/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/DebianSystemCatalogReader.java
new file mode 100644
-index 0000000..1a5643c
+index 0000000..a6fc98a
--- /dev/null
+++ b/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/DebianSystemCatalogReader.java
-@@ -0,0 +1,98 @@
+@@ -0,0 +1,186 @@
+/*******************************************************************************
-+ * Copyright (c) 2011 Jakub Adam <jakub.adam at ktknet.cz>.
++ * Copyright (c) 2011-2012 Jakub Adam <jakub.adam at ktknet.cz>.
+ * 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
@@ -51,6 +51,9 @@ index 0000000..1a5643c
+
+package org.eclipse.wst.xml.core.internal.catalog;
+
++import java.io.ByteArrayInputStream;
++import java.io.IOException;
++import java.net.MalformedURLException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
@@ -58,92 +61,177 @@ index 0000000..1a5643c
+import org.apache.xml.resolver.Catalog;
+import org.apache.xml.resolver.CatalogEntry;
+import org.apache.xml.resolver.CatalogManager;
++import org.apache.xml.resolver.helpers.BootstrapResolver;
+import org.eclipse.wst.xml.core.internal.Logger;
+import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
++import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogElement;
+import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
++import org.eclipse.wst.xml.core.internal.catalog.provisional.IDelegateCatalog;
++import org.eclipse.wst.xml.core.internal.catalog.provisional.IRewriteEntry;
++import org.xml.sax.InputSource;
+
+public class DebianSystemCatalogReader {
+
+ private ICatalog wstCatalog;
-+
-+ private Set parsedCatalogs = new HashSet();
++
+ private CatalogManager manager;
+
++ private Set pendingEntries = new HashSet() ;
++
+ DebianSystemCatalogReader(ICatalog catalog) {
+ manager = new CatalogManager();
-+ manager.setCatalogClassName(CatalogReader.class.getName());
++ manager.setCatalogClassName(SystemCatalog.class.getName());
+ manager.setUseStaticCatalog(false);
++ manager.setBootstrapResolver(new BootstrapResolver() {
++ public InputSource resolveEntity(String publicId, String systemId) {
++ InputSource src = super.resolveEntity(publicId, systemId);
++ if (src == null) {
++ return new InputSource(new ByteArrayInputStream("".getBytes()));
++ }
++
++ return src;
++ }
++ });
+
+ wstCatalog = catalog;
+ }
+
-+ public class CatalogReader extends Catalog {
-+ public void read() {
-+ parsedCatalogs.add(base.toString());
-+
++ private class SystemCatalog extends Catalog {
++ public void readCatalog() {
+ for (Iterator it = catalogEntries.iterator(); it.hasNext(); ) {
+ CatalogEntry entry = (CatalogEntry) it.next();
+
-+ if (entry.getEntryType() == PUBLIC ||
-+ entry.getEntryType() == SYSTEM ||
-+ entry.getEntryType() == URI)
-+ insertEntry(entry);
-+ else if (entry.getEntryType() == DELEGATE_SYSTEM ||
-+ entry.getEntryType() == DELEGATE_PUBLIC ||
-+ entry.getEntryType() == DELEGATE_URI) {
-+ if (!parsedCatalogs.contains(entry.getEntryArg(1)))
-+ readCatalog(entry.getEntryArg(1));
-+ }
-+ }
++ int entryType = entryTypeToCatalogType(entry.getEntryType());
++ if (entryType == 0)
++ return;
+
-+ for (Iterator it = catalogs.iterator(); it.hasNext(); ) {
-+ readCatalog((String)it.next());
++ pendingEntries.add(new PendingCatalogEntry(entryType, entry.getEntryArg(0), entry.getEntryArg(1)));
+ }
+ }
+
-+ private void insertEntry(CatalogEntry entry) {
-+ int type;
++ private int entryTypeToCatalogType(int type) {
++ if (type == PUBLIC)
++ return ICatalogEntry.ENTRY_TYPE_PUBLIC;
++ if (type == SYSTEM)
++ return ICatalogEntry.ENTRY_TYPE_SYSTEM;
++ if (type == URI)
++ return ICatalogEntry.ENTRY_TYPE_URI;
++ if (type == DELEGATE_PUBLIC)
++ return IDelegateCatalog.DELEGATE_TYPE_PUBLIC;
++ if (type == DELEGATE_SYSTEM)
++ return IDelegateCatalog.DELEGATE_TYPE_SYSTEM;
++ if (type == DELEGATE_URI)
++ return IDelegateCatalog.DELEGATE_TYPE_URI;
++ if (type == REWRITE_SYSTEM)
++ return IRewriteEntry.REWRITE_TYPE_SYSTEM;
++ if (type == REWRITE_URI)
++ return IRewriteEntry.REWRITE_TYPE_URI;
++
++ return 0;
++ }
+
-+ ICatalogEntry wstEntry;
++ protected Catalog newCatalog() {
++ SystemCatalog c = new SystemCatalog();
++ c.setCatalogManager(catalogManager);
++ copyReaders(c);
++ return c;
++ }
+
-+ if (entry.getEntryType() == PUBLIC) {
-+ type = ICatalogEntry.ENTRY_TYPE_PUBLIC;
-+ } else if (entry.getEntryType() == SYSTEM) {
-+ type = ICatalogEntry.ENTRY_TYPE_SYSTEM;
-+ } else {
-+ type = ICatalogEntry.ENTRY_TYPE_URI;
++ public synchronized void parseCatalog(String fileName) throws MalformedURLException, IOException {
++ try {
++ super.parseCatalog(fileName);
++ readCatalog();
++ parseAllCatalogs();
++ } catch (Exception e) {
++ Logger.logException("Couldn't read catalog " + fileName, e);
+ }
-+
-+ wstEntry = (ICatalogEntry)wstCatalog.createCatalogElement(type);
-+ wstEntry.setKey(entry.getEntryArg(0));
-+ wstEntry.setURI(entry.getEntryArg(1));
-+
-+ wstCatalog.addCatalogElement(wstEntry);
+ }
+ }
+
+ public void readCatalog() {
+ readCatalog("/etc/xml/catalog"); //$NON-NLS-1$
-+ readCatalog("/etc/sgml/catalog"); //$NON-NLS-1$
+ }
+
-+ private void readCatalog(String catalog) {
-+ CatalogReader reader = new CatalogReader();
-+ reader.setCatalogManager(manager);
-+ reader.setupReaders();
++ private void readCatalog(String catalogFileName) {
++ SystemCatalog catalog = new SystemCatalog();
++ catalog.setCatalogManager(manager);
++ catalog.setupReaders();
+ try {
-+ reader.parseCatalog(catalog);
-+ reader.read();
++ catalog.parseCatalog(catalogFileName);
++
++ for (Iterator it = pendingEntries.iterator(); it.hasNext(); ) {
++ PendingCatalogEntry entry = (PendingCatalogEntry)it.next();
++
++ ICatalogElement wstElement = wstCatalog.createCatalogElement(entry.type);
++
++ if (wstElement == null) {
++ continue;
++ }
++
++ switch (entry.type) {
++ case ICatalogEntry.ENTRY_TYPE_PUBLIC:
++ case ICatalogEntry.ENTRY_TYPE_SYSTEM:
++ case ICatalogEntry.ENTRY_TYPE_URI:
++ ICatalogEntry catalogEntry = (ICatalogEntry)wstElement;
++ catalogEntry.setKey(entry.arg1);
++ catalogEntry.setURI(entry.arg2);
++ break;
++ case IDelegateCatalog.DELEGATE_TYPE_PUBLIC:
++ case IDelegateCatalog.DELEGATE_TYPE_SYSTEM:
++ case IDelegateCatalog.DELEGATE_TYPE_URI:
++ IDelegateCatalog delegateEntry = (IDelegateCatalog)wstElement;
++ delegateEntry.setStartString(entry.arg1);
++ delegateEntry.setCatalogLocation(entry.arg2);
++ break;
++ case IRewriteEntry.REWRITE_TYPE_SYSTEM:
++ case IRewriteEntry.REWRITE_TYPE_URI:
++ IRewriteEntry rewriteEntry = (IRewriteEntry)wstElement;
++ rewriteEntry.setStartString(entry.arg1);
++ rewriteEntry.setRewritePrefix(entry.arg2);
++ break;
++ }
++
++ wstCatalog.addCatalogElement(wstElement);
++ }
++
+ } catch (Exception e) {
-+ Logger.logException("Couldn't read catalog " + catalog, e);
++ Logger.logException("Couldn't read catalog " + catalogFileName, e);
++ }
++ }
++
++ private class PendingCatalogEntry {
++ int type;
++ String arg1;
++ String arg2;
++
++ public PendingCatalogEntry(int type, String key, String uri) {
++ this.type = type;
++ this.arg1 = key;
++ this.arg2 = uri;
++ }
++
++ public boolean equals(Object obj) {
++ if (!(obj instanceof PendingCatalogEntry))
++ return false;
++ PendingCatalogEntry other = (PendingCatalogEntry) obj;
++ return (type == other.type && arg1.equals(other.arg1) && arg2.equals(other.arg2));
++ }
++
++ public int hashCode() {
++ final int prime = 31;
++ int result = 1;
++ result = prime * result + ((arg1 == null) ? 0 : arg1.hashCode());
++ result = prime * result + ((arg2 == null) ? 0 : arg2.hashCode());
++ result = prime * result + type;
++ return result;
+ }
+ }
+}
diff --git a/org.eclipse.wst.xml_core.feature/feature.xml b/org.eclipse.wst.xml_core.feature/feature.xml
-index bc31a94..8d0ab9b 100755
+index 5af3c54..1b51e35 100644
--- a/org.eclipse.wst.xml_core.feature/feature.xml
+++ b/org.eclipse.wst.xml_core.feature/feature.xml
-@@ -38,12 +38,12 @@
+@@ -40,12 +40,12 @@
version="0.0.0"
unpack="false"/>
@@ -158,4 +246,3 @@ index bc31a94..8d0ab9b 100755
<plugin
id="org.eclipse.wst.xml.core"
---
--
eclipse-wtp packaging
More information about the pkg-java-commits
mailing list