Revision 9974
Added by Jing Tao about 8 years ago
src/edu/ucsb/nceas/metacat/DBEntityResolver.java | ||
---|---|---|
104 | 104 |
|
105 | 105 |
// Won't have a handler under all cases |
106 | 106 |
if ( handler != null ) { |
107 |
String message = "Metacat can't determine the public id or the name of the root element of the document, so the validation can't be applied and the document is rejected"; |
|
107 | 108 |
logMetacat.debug("DBEntityResolver.resolveEntity - the handler class is "+handler.getClass().getCanonicalName()); |
108 | 109 |
if ( handler instanceof DBSAXHandler ) { |
109 | 110 |
DBSAXHandler dhandler = null; |
... | ... | |
121 | 122 |
logMetacat.debug("DBEntityResolver.resolveEntity - the publicId is null and we treat the doc name(the root element name) as the doc type. The doctype is: " |
122 | 123 |
+ doctype); |
123 | 124 |
} |
125 |
|
|
126 |
if(doctype == null || doctype.trim().equals("")) { |
|
127 |
//we can't determine the public id or the name of the root element in for this dtd defined xml document |
|
128 |
logMetacat.error("DBEntityResolver.resolveEntity - "+message); |
|
129 |
throw new SAXException(message); |
|
130 |
} else { |
|
131 |
logMetacat.debug("DBEntityResolver.resolveEntity - the final doctype for DBSAXHandler "+doctype); |
|
132 |
} |
|
124 | 133 |
} |
125 | 134 |
} else if ( handler instanceof AccessControlList ) { |
126 | 135 |
logMetacat.debug("DBEntityResolver.resolveEntity - in the branch of the handler class is AccessControlList"); |
127 | 136 |
AccessControlList ahandler = null; |
128 | 137 |
ahandler = (AccessControlList)handler; |
129 |
//if ( ahandler.processingDTD() ) {
|
|
138 |
if ( ahandler.processingDTD() ) { |
|
130 | 139 |
// public ID is doctype |
131 | 140 |
if (publicId != null) { |
132 | 141 |
doctype = publicId; |
142 |
logMetacat.debug("DBEntityResolver.resolveEntity - the publicId is not null, so the publicId is the doctype. The doctype in AccessControlList is: " |
|
143 |
+ doctype); |
|
133 | 144 |
// assume public ID (doctype) is docname |
134 | 145 |
} else { |
135 | 146 |
doctype = ahandler.getDocname(); |
147 |
logMetacat.debug("DBEntityResolver.resolveEntity - the publicId is null and we treat the doc name(the root element name) as the doc type. The doctype in AccessControlList is: " |
|
148 |
+ doctype); |
|
136 | 149 |
} |
137 |
//} |
|
150 |
if(doctype == null || doctype.trim().equals("")) { |
|
151 |
//we can't determine the public id or the name of the root element in for this dtd defined xml document |
|
152 |
logMetacat.error("DBEntityResolver.resolveEntity - "+message); |
|
153 |
throw new SAXException(message); |
|
154 |
} else { |
|
155 |
logMetacat.debug("DBEntityResolver.resolveEntity - the final doctype for AccessControList "+doctype); |
|
156 |
} |
|
157 |
} else { |
|
158 |
logMetacat.debug("DBEntityResolver.resolveEntity - the method resolverEntity for the AccessControList class is not processing a dtd"); |
|
159 |
} |
|
138 | 160 |
} else { |
139 | 161 |
logMetacat.debug("DBEntityResolver.resolveEntity - in the branch of the other handler class"); |
140 |
doctype = publicId; |
|
141 | 162 |
} |
142 | 163 |
} else { |
143 | 164 |
logMetacat.debug("DBEntityResolver.resolveEntity - the xml handler is null. So we can't find the doctype."); |
... | ... | |
217 | 238 |
is.setByteStream(istream); |
218 | 239 |
return is;*/ |
219 | 240 |
} else { |
220 |
//we can't determine the public id or the name of the root element in for this dtd defined xml document |
|
221 |
String message = "Metacat can't determine the public id or the name of the root element of the document, so the validation can't be imposed and the document is rejected"; |
|
222 |
logMetacat.error("DBEntityResolver.resolveEntity - "+message); |
|
223 |
throw new SAXException(message); |
|
241 |
|
|
224 | 242 |
//InputStream istream = checkURLConnection(systemId); |
225 | 243 |
//return null; |
226 | 244 |
} |
Also available in: Unified diff
Add code to check if a dtd is registered when the parser processes the dtd part.