Project

General

Profile

Revision 4803

Fixes include:
-Overwriting existing DTDs on the filesystem if they exist and registration in the DB failed
-only registering a DTD once

View differences:

src/edu/ucsb/nceas/metacat/DBEntityResolver.java
137 137
      logMetacat.info("get systemId from doctype: "+doctype);
138 138
      dbSystemID = getDTDSystemID(doctype);
139 139
      logMetacat.info("The Systemid is: "+dbSystemID);
140
      // check that it is accessible on our system before getting too far
141
      try {
142
    	  InputStream in = checkURLConnection(dbSystemID);
143
	  }
144
      catch (Exception e) {
145
    	  dbSystemID = null;
146
	  }
140 147
      boolean doctypeIsInDB = true;
141 148
      // no System ID found in db XML Catalog
142 149
      if (dbSystemID == null) {
......
252 259
  private void registerDTD ( String doctype, String systemId )
253 260
                 throws SAXException
254 261
  {
262
	  String existingSystemId = getDTDSystemID(doctype);
263
	  if (existingSystemId != null && existingSystemId.equals(systemId)) {
264
		  logMetacat.warn("doctype/systemId already registered in DB: " + doctype);
265
		  return;
266
	  }
255 267
    //DBConnection conn = null;
256 268
    //int serialNumber = -1;
257 269
    PreparedStatement pstmt = null;
......
273 285
      pstmt.setString(2, systemId);
274 286
      // Do the insertion
275 287
      pstmt.execute();
288
      int updateCnt = pstmt.getUpdateCount();
289
      logMetacat.debug("DBEntityReolver.registerDTD: DTDs registered: " + updateCnt);
276 290
      pstmt.close();
277 291
    } catch (SQLException e) {
278 292
      throw new SAXException
......
405 419
			synchronized (f) {
406 420
				try {
407 421
					if (f.exists()) {
408
						throw new IOException("File already exist: "
422
						logMetacat.warn("File already exist, overwriting: "
409 423
								+ f.getCanonicalFile());
424
						//return dtdURL + filename;
425
						//throw new IOException("File already exist: "
426
						//		+ f.getCanonicalFile());
410 427
						//if ( f.exists() && !f.canWrite() ) {
411 428
						//  throw new IOException("Not writable: " + f.getCanonicalFile());
412 429
					}

Also available in: Unified diff