Revision 245
Added by Matt Jones over 24 years ago
src/edu/ucsb/nceas/metacat/DBEntityResolver.java | ||
---|---|---|
19 | 19 |
import java.io.File; |
20 | 20 |
import java.io.FileReader; |
21 | 21 |
import java.io.InputStream; |
22 |
import java.io.InputStreamReader; |
|
23 | 22 |
import java.io.IOException; |
24 | 23 |
import java.net.URL; |
25 | 24 |
import java.net.URLConnection; |
... | ... | |
92 | 91 |
// if it is not found in the database, then |
93 | 92 |
// register publicId in db and use the provided systemId |
94 | 93 |
if (systemId != null) { |
95 |
InputStreamReader isr = checkURLConnection(systemId);
|
|
94 |
InputStream istream = checkURLConnection(systemId);
|
|
96 | 95 |
if (handler != null) { // Won't have a handler under all cases |
97 | 96 |
if (handler.processingDTD()) { |
98 | 97 |
registerDTDSystemID (conn, doctype, doctype, systemId); |
... | ... | |
103 | 102 |
} else { |
104 | 103 |
MetaCatUtil.debugMessage(" RESOLVED SYSTEMID: " + dbSystemId); |
105 | 104 |
// If it is in the database, return the systemid from the database |
106 |
InputStreamReader isr = checkURLConnection(dbSystemId);
|
|
105 |
InputStream istream = checkURLConnection(dbSystemId);
|
|
107 | 106 |
InputSource is = new InputSource(dbSystemId); |
108 |
is.setCharacterStream(isr);
|
|
107 |
is.setByteStream(istream);
|
|
109 | 108 |
MetaCatUtil.debugMessage(" INPUTSOURCE SYSTEMID: " |
110 | 109 |
+ is.getSystemId()); |
111 | 110 |
return is; |
... | ... | |
113 | 112 |
} |
114 | 113 |
|
115 | 114 |
// use the provided systemID for other cases |
116 |
InputStreamReader isr = checkURLConnection(systemId);
|
|
115 |
InputStream istream = checkURLConnection(systemId);
|
|
117 | 116 |
return null; |
118 | 117 |
} |
119 | 118 |
|
... | ... | |
185 | 184 |
} |
186 | 185 |
|
187 | 186 |
/** |
188 |
* Check URL Connection for systemId, and return an InputStreamReader
|
|
187 |
* Check URL Connection for systemId, and return an InputStream |
|
189 | 188 |
* that can be used to read from the systemId URL. The parser ends |
190 | 189 |
* up using this via the InputSource to read the DTD. |
191 | 190 |
* |
192 | 191 |
* @param systemID a URI (in practice URL) to be checked and opened |
193 | 192 |
*/ |
194 |
private InputStreamReader checkURLConnection (String systemId)
|
|
193 |
private InputStream checkURLConnection (String systemId) |
|
195 | 194 |
throws MalformedURLException, IOException |
196 | 195 |
{ |
197 | 196 |
try { |
198 |
InputStreamReader isr = new InputStreamReader( |
|
199 |
new URL(systemId).openStream());
|
|
200 |
return isr; |
|
197 |
|
|
198 |
return (new URL(systemId).openStream());
|
|
199 |
|
|
201 | 200 |
} catch (MalformedURLException e) { |
202 | 201 |
System.out.println("from checkURLConnection(): " + e.getMessage()); |
203 | 202 |
throw e; |
... | ... | |
210 | 209 |
|
211 | 210 |
/** |
212 | 211 |
* '$Log$ |
212 |
* 'Revision 1.13 2000/06/29 23:27:08 jones |
|
213 |
* 'Fixed bug in DBEntityResolver so that it now properly delegates to |
|
214 |
* 'the system id found inthe database. |
|
215 |
* 'Changed DBValidate to use DBEntityResolver, rather than the OASIS |
|
216 |
* 'catalog, and to return validation results in XML format. |
|
217 |
* ' |
|
213 | 218 |
* 'Revision 1.12 2000/06/27 04:31:07 jones |
214 | 219 |
* 'Fixed bugs associated with the new UPDATE and DELETE functions of |
215 | 220 |
* 'DBWriter. There were problematic interactions between some static |
Also available in: Unified diff
changed char stream to byte stream