View | Details | Raw Unified | Return to bug 189192 | Differences between
and this patch

Collapse All | Expand All

(-)data/help/dynamic/xhtml_expected.txt (-2 / +2 lines)
Lines 9-15 Link Here
9
9
10
<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css" />
10
<link rel="STYLESHEET" href="../book.css" charset="ISO-8859-1" type="text/css" />
11
<title>Exporting files</title>
11
<title>Exporting files</title>
12
<script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script>
12
<script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js" xml:space="preserve"> </script>
13
</head>
13
</head>
14
14
15
<body bgcolor="#ffffff">
15
<body bgcolor="#ffffff">
Lines 21-27 Link Here
21
  <li> <img align="texttop" border="0" src="../images/win_only.png" alt="Windows only" />
21
  <li> <img align="texttop" border="0" src="../images/win_only.png" alt="Windows only" />
22
    Copying and pasting to the file system, or</li>
22
    Copying and pasting to the file system, or</li>
23
  <li> Using the
23
  <li> Using the
24
  <a class="command-link" href="javascript:executeCommand(&quot;org.eclipse.ui.file.export&quot;)">
24
  <a class="command-link" href="javascript:executeCommand(&quot;org.eclipse.ui.file.export&quot;)" shape="rect">
25
  <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"/>
25
  <img src="PLUGINS_ROOT/org.eclipse.help/command_link.png"/>
26
  <b>Export wizard</b></a>.</li>
26
  <b>Export wizard</b></a>.</li>
27
</ul>
27
</ul>
(-)src/org/eclipse/help/internal/UAElement.java (-10 / +1 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.help.internal;
11
package org.eclipse.help.internal;
12
12
13
import java.io.StringReader;
14
import java.lang.reflect.Array;
13
import java.lang.reflect.Array;
15
import java.util.ArrayList;
14
import java.util.ArrayList;
16
import java.util.List;
15
import java.util.List;
Lines 31-40 Link Here
31
import org.w3c.dom.Document;
30
import org.w3c.dom.Document;
32
import org.w3c.dom.Element;
31
import org.w3c.dom.Element;
33
import org.w3c.dom.Node;
32
import org.w3c.dom.Node;
34
import org.xml.sax.EntityResolver;
35
import org.xml.sax.InputSource;
36
import org.xml.sax.SAXException;
37
38
/*
33
/*
39
 * Base class for UA model elements.
34
 * Base class for UA model elements.
40
 */
35
 */
Lines 137-147 Link Here
137
			if (builder == null) {
132
			if (builder == null) {
138
				try {
133
				try {
139
					builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
134
					builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
140
					builder.setEntityResolver(new EntityResolver() {
135
					builder.setEntityResolver(new CachedEntityResolver());
141
						public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
142
							return new InputSource(new StringReader("")); //$NON-NLS-1$
143
						}
144
					});
145
				}
136
				}
146
				catch (ParserConfigurationException e) {
137
				catch (ParserConfigurationException e) {
147
					String msg = "Error creating document builder"; //$NON-NLS-1$
138
					String msg = "Error creating document builder"; //$NON-NLS-1$
(-)src/org/eclipse/help/internal/HelpPlugin.java (+21 lines)
Lines 10-24 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.help.internal;
11
package org.eclipse.help.internal;
12
12
13
import java.io.File;
13
import java.io.InputStream;
14
import java.io.InputStream;
15
import java.net.URL;
14
16
15
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Platform;
16
import org.eclipse.core.runtime.Plugin;
19
import org.eclipse.core.runtime.Plugin;
17
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.Status;
18
import org.eclipse.help.internal.context.ContextManager;
21
import org.eclipse.help.internal.context.ContextManager;
19
import org.eclipse.help.internal.extension.ContentExtensionManager;
22
import org.eclipse.help.internal.extension.ContentExtensionManager;
20
import org.eclipse.help.internal.index.IndexManager;
23
import org.eclipse.help.internal.index.IndexManager;
21
import org.eclipse.help.internal.toc.TocManager;
24
import org.eclipse.help.internal.toc.TocManager;
25
import org.eclipse.osgi.service.datalocation.Location;
22
import org.osgi.framework.BundleContext;
26
import org.osgi.framework.BundleContext;
23
27
24
/**
28
/**
Lines 40-45 Link Here
40
	private ContentExtensionManager contentExtensionManager;
44
	private ContentExtensionManager contentExtensionManager;
41
	private IndexManager indexManager;
45
	private IndexManager indexManager;
42
	private IHelpProvider helpProvider;
46
	private IHelpProvider helpProvider;
47
	private File configurationDirectory;
43
48
44
	public static void logWarning(String message) {
49
	public static void logWarning(String message) {
45
		Status errorStatus = new Status(IStatus.WARNING, PLUGIN_ID, IStatus.OK, message, null);
50
		Status errorStatus = new Status(IStatus.WARNING, PLUGIN_ID, IStatus.OK, message, null);
Lines 131-136 Link Here
131
	public void start(BundleContext context) throws Exception {
136
	public void start(BundleContext context) throws Exception {
132
		super.start(context);
137
		super.start(context);
133
		plugin = this;
138
		plugin = this;
139
		
140
		// determine configuration location for this plug-in
141
		Location location = Platform.getConfigurationLocation();
142
		if (location != null) {
143
			URL configURL = location.getURL();
144
			if (configURL != null && configURL.getProtocol().startsWith("file")) { //$NON-NLS-1$
145
				configurationDirectory = new File(configURL.getFile(), PLUGIN_ID);
146
			}
147
		}
148
		if (configurationDirectory == null) {
149
			configurationDirectory = getStateLocation().toFile();
150
		}
151
	}
152
153
	public static File getConfigurationDirectory() {
154
		return getDefault().configurationDirectory;
134
	}
155
	}
135
156
136
	/* (non-Javadoc)
157
	/* (non-Javadoc)
(-)src/org/eclipse/help/internal/dynamic/DocumentReader.java (-7 / +4 lines)
Lines 13-30 Link Here
13
import java.io.IOException;
13
import java.io.IOException;
14
import java.io.InputStream;
14
import java.io.InputStream;
15
import java.io.InputStreamReader;
15
import java.io.InputStreamReader;
16
import java.io.StringReader;
17
16
18
import javax.xml.parsers.DocumentBuilder;
17
import javax.xml.parsers.DocumentBuilder;
19
import javax.xml.parsers.DocumentBuilderFactory;
18
import javax.xml.parsers.DocumentBuilderFactory;
20
import javax.xml.parsers.ParserConfigurationException;
19
import javax.xml.parsers.ParserConfigurationException;
21
20
21
import org.eclipse.help.internal.CachedEntityResolver;
22
import org.eclipse.help.internal.UAElement;
22
import org.eclipse.help.internal.UAElement;
23
import org.eclipse.help.internal.UAElementFactory;
23
import org.eclipse.help.internal.UAElementFactory;
24
import org.w3c.dom.Document;
24
import org.w3c.dom.Document;
25
import org.xml.sax.EntityResolver;
25
import org.xml.sax.ErrorHandler;
26
import org.xml.sax.InputSource;
26
import org.xml.sax.InputSource;
27
import org.xml.sax.SAXException;
27
import org.xml.sax.SAXException;
28
import org.xml.sax.SAXParseException;
28
29
29
public class DocumentReader {
30
public class DocumentReader {
30
31
Lines 40-50 Link Here
40
			factory.setNamespaceAware(false);
41
			factory.setNamespaceAware(false);
41
			factory.setExpandEntityReferences(false);
42
			factory.setExpandEntityReferences(false);
42
			builder = factory.newDocumentBuilder();
43
			builder = factory.newDocumentBuilder();
43
			builder.setEntityResolver(new EntityResolver() {
44
			builder.setEntityResolver(new CachedEntityResolver());
44
				public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
45
					return new InputSource(new StringReader("")); //$NON-NLS-1$
46
				}
47
			});
48
		}
45
		}
49
		InputSource input = null;
46
		InputSource input = null;
50
		if (charset != null) {
47
		if (charset != null) {
(-)src/org/eclipse/help/internal/CachedEntityResolver.java (+58 lines)
Added Link Here
1
package org.eclipse.help.internal;
2
3
import java.io.BufferedReader;
4
import java.io.BufferedWriter;
5
import java.io.File;
6
import java.io.FileNotFoundException;
7
import java.io.FileReader;
8
import java.io.FileWriter;
9
import java.io.IOException;
10
import java.io.InputStreamReader;
11
import java.io.StringReader;
12
import java.net.URL;
13
import java.net.URLConnection;
14
15
import org.xml.sax.EntityResolver;
16
import org.xml.sax.InputSource;
17
18
19
public class CachedEntityResolver implements EntityResolver {
20
21
	public InputSource resolveEntity(String publicId, String systemId) {
22
        int index = systemId.lastIndexOf("/"); //$NON-NLS-1$
23
        File cachedCopy = null;
24
        if (index != -1) {
25
        	cachedCopy = new File(HelpPlugin.getConfigurationDirectory(), "/DTDs"); //$NON-NLS-1$
26
        	cachedCopy.mkdirs();
27
        	cachedCopy = new File(cachedCopy, systemId.substring(index));
28
        }
29
        if (cachedCopy != null) {
30
        	if (!cachedCopy.exists()) {
31
				try {
32
					URL system = new URL(systemId);
33
			        URLConnection sc = system.openConnection();
34
			        BufferedReader in = new BufferedReader(
35
			                                new InputStreamReader(
36
			                                sc.getInputStream()));
37
			        String inputLine;
38
			        BufferedWriter out = new BufferedWriter(new FileWriter(cachedCopy));
39
			        while ((inputLine = in.readLine()) != null) {
40
			            out.write(inputLine);
41
			        	out.newLine();
42
			        }
43
			        in.close();
44
			        out.flush();
45
			        out.close();
46
				} catch (IOException e) {}
47
        	}
48
	        try {
49
	        	InputSource is = new InputSource(new FileReader(cachedCopy));
50
	        	is.setSystemId(systemId);
51
	        	is.setPublicId(publicId);
52
	        	return is;
53
	        } catch (FileNotFoundException e) {}
54
        }
55
    	return new InputSource(new StringReader("")); //$NON-NLS-1$
56
	}
57
58
}

Return to bug 189192