Revision 204
Added by Matt Jones almost 24 years ago
DBEntityResolver.java | ||
---|---|---|
31 | 31 |
*/ |
32 | 32 |
public class DBEntityResolver implements EntityResolver |
33 | 33 |
{ |
34 |
|
|
35 |
static String doctype = null; |
|
36 | 34 |
private Connection conn = null; |
37 |
private int pIdCounter = 0; |
|
38 |
private long currentElementNo; |
|
35 |
private DBSAXHandler handler; |
|
39 | 36 |
|
40 | 37 |
/** Construct an instance of the DBEntityResolver clas |
41 | 38 |
* |
42 | 39 |
* @param conn the JDBC connection to which information is written |
43 | 40 |
*/ |
44 |
public DBEntityResolver(Connection conn) |
|
41 |
public DBEntityResolver(Connection conn, DBSAXHandler handler)
|
|
45 | 42 |
{ |
46 | 43 |
this.conn = conn; |
44 |
this.handler = handler; |
|
47 | 45 |
} |
48 | 46 |
|
49 |
|
|
50 | 47 |
/** |
51 | 48 |
* The Parser call this method before opening any external entity |
52 | 49 |
* except the top-level document entity (including the external DTD subset, |
... | ... | |
57 | 54 |
throws MalformedURLException, IOException |
58 | 55 |
{ |
59 | 56 |
String dbSystemId; |
57 |
String doctype = null; |
|
60 | 58 |
|
61 |
currentElementNo = DBSAXHandler.elementNo; |
|
62 |
|
|
63 |
if (currentElementNo == 0) { |
|
64 |
if (publicId != null) { |
|
65 |
pIdCounter += 1; |
|
59 |
// Only process entities if its the DTD |
|
60 |
if (handler.atFirstElement()) { |
|
61 |
if (publicId != null) { // If we have a public ID, use it |
|
66 | 62 |
doctype = publicId; |
67 |
} else if ( systemId != null) { |
|
68 |
doctype = DBSAXHandler.docname; |
|
63 |
MetaCatUtil.debugMessage("DOCTYPE-c: " + doctype); |
|
64 |
} else if ( systemId != null) { // Otherwise, use system id if we can |
|
65 |
doctype = handler.getDocname(); |
|
66 |
MetaCatUtil.debugMessage("DOCTYPE-d: " + doctype); |
|
69 | 67 |
} |
70 |
// look at the db XML Catalog and get dbSystemId by this doctype
|
|
68 |
// look at the db XML Catalog and get dbSystemId for this doctype
|
|
71 | 69 |
dbSystemId = getDTDSystemID (conn, doctype); |
72 | 70 |
if (dbSystemId == "") { |
71 |
// if it is not found inthe database, then |
|
73 | 72 |
// register publicId in db and use the provided systemId |
74 | 73 |
if (systemId != "") { |
75 | 74 |
checkURLConnection(systemId); |
... | ... | |
77 | 76 |
return null; |
78 | 77 |
} |
79 | 78 |
} else { |
79 |
// If it is in the database, return the systemid fromthe database |
|
80 | 80 |
checkURLConnection(dbSystemId); |
81 | 81 |
return new InputSource(dbSystemId); |
82 | 82 |
} |
83 | 83 |
} |
84 | 84 |
|
85 |
// use the default behaviour |
|
85 |
// use the default behaviour for other cases
|
|
86 | 86 |
checkURLConnection(systemId); |
87 | 87 |
return null; |
88 | 88 |
} |
... | ... | |
175 | 175 |
|
176 | 176 |
/** |
177 | 177 |
* '$Log$ |
178 |
* 'Revision 1.11 2000/06/26 10:35:04 jones |
|
179 |
* 'Merged in substantial changes to DBWriter and associated classes and to |
|
180 |
* 'the MetaCatServlet in order to accomodate the new UPDATE and DELETE |
|
181 |
* 'functions. The command line tools and the parameters for the |
|
182 |
* 'servlet have changed substantially. |
|
183 |
* ' |
|
178 | 184 |
* 'Revision 1.10.2.2 2000/06/25 23:38:16 jones |
179 | 185 |
* 'Added RCSfile keyword |
180 | 186 |
* ' |
Also available in: Unified diff
Fixed bugs associated with the new UPDATE and DELETE functions of
DBWriter. There were problematic interactions between some static
variables used in DBEntityResolver and the way in which the
Servlet objects are re-used across multiple client invocations.
Generally cleaned up error reporting. Now all errors and success
results are reported as XML documents from MetaCatServlet. Need
to make the command line tools do the same.