Revision 5177
Added by daigle almost 15 years ago
src/edu/ucsb/nceas/metacat/DBEntityResolver.java | ||
---|---|---|
97 | 97 |
public InputSource resolveEntity (String publicId, String systemId) |
98 | 98 |
throws SAXException |
99 | 99 |
{ |
100 |
logMetacat.debug("in DBEntityResolver.resolveEntity");
|
|
100 |
logMetacat.debug("DBEntityResolver.resolveEntity - in resolveEntity");
|
|
101 | 101 |
String dbSystemID; |
102 | 102 |
String doctype = null; |
103 | 103 |
|
... | ... | |
111 | 111 |
// public ID is doctype |
112 | 112 |
if (publicId != null) { |
113 | 113 |
doctype = publicId; |
114 |
logMetacat.info("in get type from publicId and doctype is: "
|
|
115 |
+doctype); |
|
114 |
logMetacat.debug("DBEntityResolver.resolveEntity - in get type from publicId and doctype is: "
|
|
115 |
+ doctype);
|
|
116 | 116 |
// assume public ID (doctype) is docname |
117 | 117 |
} else if (systemId != null) { |
118 | 118 |
doctype = dhandler.getDocname(); |
... | ... | |
136 | 136 |
// get System ID for doctype |
137 | 137 |
if (doctype != null) { |
138 | 138 |
// look at db XML Catalog for System ID |
139 |
logMetacat.info("get systemId from doctype: "+doctype);
|
|
139 |
logMetacat.info("DBEntityResolver.resolveEntity - get systemId from doctype: " + doctype);
|
|
140 | 140 |
dbSystemID = getDTDSystemID(doctype); |
141 |
logMetacat.info("The Systemid is: "+dbSystemID);
|
|
141 |
logMetacat.info("DBEntityResolver.resolveEntity - The Systemid is: " + dbSystemID);
|
|
142 | 142 |
// check that it is accessible on our system before getting too far |
143 | 143 |
try { |
144 | 144 |
InputStream in = checkURLConnection(dbSystemID); |
145 |
} catch (Exception e) {
|
|
145 |
} catch (SAXException se) {
|
|
146 | 146 |
// after an upgrade, the dtd will not exist on disk, but it is in xml catalog. The db system id may be pointing |
147 | 147 |
// back at this system Try and download it from the original system id and see if we still have a problem |
148 | 148 |
// checking the URL connection. |
149 |
logMetacat.warn("dtd for doc type " + doctype + " existed in xml catalog, but not on disk. Uploading from: " + systemId); |
|
149 |
logMetacat.warn("DBEntityResolver.resolveEntity - Problem when checking URL Connection: " + se.getMessage()); |
|
150 |
logMetacat.warn("DBEntityResolver.resolveEntity - Probably, dtd for doc type " + doctype + " existed in xml catalog, but not on disk. Uploading from: " + systemId); |
|
150 | 151 |
InputStream istream = checkURLConnection(systemId); |
151 | 152 |
uploadDTDFromURL(istream, systemId); |
152 | 153 |
try { |
154 |
Thread.currentThread().sleep(6000); |
|
153 | 155 |
checkURLConnection(dbSystemID); |
154 | 156 |
} catch (Exception e2) { |
155 |
logMetacat.error("still could not find dtd for doc type " + doctype + " at " |
|
157 |
logMetacat.error("DBEntityResolver.resolveEntity - still could not find dtd for doc type " + doctype + " at "
|
|
156 | 158 |
+ dbSystemID + " : " + e2.getMessage()); |
157 | 159 |
dbSystemID = null; |
158 | 160 |
} |
159 |
} |
|
161 |
}
|
|
160 | 162 |
boolean doctypeIsInDB = true; |
161 | 163 |
// no System ID found in db XML Catalog |
162 | 164 |
if (dbSystemID == null) { |
... | ... | |
165 | 167 |
if (systemId != null) { |
166 | 168 |
dbSystemID = systemId; |
167 | 169 |
} |
168 |
logMetacat.info("If above Systemid is null and then get "
|
|
169 |
+" system id from file" + dbSystemID);
|
|
170 |
logMetacat.info("DBEntityResolver.resolveEntity - If above Systemid is null, then get "
|
|
171 |
+ "system id from file: " + dbSystemID);
|
|
170 | 172 |
} |
171 | 173 |
// there are dtd text provided; try to upload on Metacat |
172 | 174 |
if ( dtdtext != null ) { |
... | ... | |
199 | 201 |
return is; |
200 | 202 |
} else { |
201 | 203 |
// use provided systemId for the other cases |
202 |
logMetacat.info("doctype is null and using system id from file"); |
|
204 |
logMetacat.info("DBEntityResolver.resolveEntity - doctype is null and using system id from file");
|
|
203 | 205 |
InputStream istream = checkURLConnection(systemId); |
204 | 206 |
return null; |
205 | 207 |
|
... | ... | |
252 | 254 |
}//try |
253 | 255 |
catch (SQLException sqlE) |
254 | 256 |
{ |
255 |
logMetacat.error("SQL error in DBEntityReolver.getDTDSystemId: " |
|
256 |
+sqlE.getMessage()); |
|
257 |
logMetacat.error("DBEntityResolver.getDTDSystemId - SQL error: " + sqlE.getMessage()); |
|
257 | 258 |
}//catch |
258 | 259 |
finally |
259 | 260 |
{ |
... | ... | |
274 | 275 |
{ |
275 | 276 |
String existingSystemId = getDTDSystemID(doctype); |
276 | 277 |
if (existingSystemId != null && existingSystemId.equals(systemId)) { |
277 |
logMetacat.warn("doctype/systemId already registered in DB: " + doctype); |
|
278 |
logMetacat.warn("DBEntityResolver.registerDTD - doctype/systemId already registered in DB: " + doctype);
|
|
278 | 279 |
return; |
279 | 280 |
} |
280 | 281 |
//DBConnection conn = null; |
... | ... | |
299 | 300 |
// Do the insertion |
300 | 301 |
pstmt.execute(); |
301 | 302 |
int updateCnt = pstmt.getUpdateCount(); |
302 |
logMetacat.debug("DBEntityReolver.registerDTD: DTDs registered: " + updateCnt);
|
|
303 |
logMetacat.debug("DBEntityReolver.registerDTD - DTDs registered: " + updateCnt);
|
|
303 | 304 |
pstmt.close(); |
304 | 305 |
} catch (SQLException e) { |
305 | 306 |
throw new SAXException |
... | ... | |
313 | 314 |
}//try |
314 | 315 |
catch (SQLException sqlE) |
315 | 316 |
{ |
316 |
logMetacat.error("SQL error in DBEntityReolver.registerDTD: " |
|
317 |
+sqlE.getMessage()); |
|
317 |
logMetacat.error("DBEntityResolver.registerDTD - SQL error: " + sqlE.getMessage()); |
|
318 | 318 |
}//catch |
319 | 319 |
//DBConnectionPool.returnDBConnection(conn, serialNumber); |
320 | 320 |
}//finally |
... | ... | |
432 | 432 |
synchronized (f) { |
433 | 433 |
try { |
434 | 434 |
if (f.exists()) { |
435 |
logMetacat.warn("File already exist, overwriting: " |
|
436 |
+ f.getCanonicalFile()); |
|
435 |
logMetacat.warn("DBEntityResolver.uploadDTDFromURL - File already exists: " + f.getCanonicalFile()); |
|
437 | 436 |
//return dtdURL + filename; |
438 | 437 |
//throw new IOException("File already exist: " |
439 | 438 |
// + f.getCanonicalFile()); |
Also available in: Unified diff
Add a sleep statement between getting the dtd from source and checking for it via url. Add method names to log output.