Project

General

Profile

« Previous | Next » 

Revision 5169

Added by Duane Costa over 14 years ago

Fix for Bug #4637 - Metacat Harvester fails to catch some insert and update failures. As per comments in the bug entry, the Metacat Harvester logic has been modified to examine the Metacat client return string to confirm that it contains the substring "<success>" following an insert or update operation. It no longer considers just the absence of an exception as indicative of a successful operation.

View differences:

HarvestDocument.java
198 198
  
199 199

  
200 200
  /**
201
   * Boolean to determine whether the string returned by the Metacat client for
202
   * an insert or update operation indicates that the operation succeeded.
203
   * 
204
   * @param metacatReturnString     The string returned by the Metacat client.
205
   * @return true if the return string indicates success, else false
206
   */
207
  private boolean isMetacatSuccessString(String metacatReturnString) {
208
    boolean isMetacatSuccessString = false;
209
    
210
    if ((metacatReturnString != null) &&
211
        (metacatReturnString.contains("<success>"))
212
       ) {
213
      isMetacatSuccessString = true;
214
    }
215
    
216
    return isMetacatSuccessString;
217
  }
218
 
219
 
220
  /**
201 221
   * Logs a metacat document error to the harvest detail log. 
202 222
   *
203 223
   * @param insert               true if insert operation, false is update
......
304 324
    
305 325
    if (harvester.connectToMetacat()) {
306 326
      try {
327
        String harvestOperationCode = "";
328
        
307 329
        if (insert) {
330
          harvestOperationCode = "harvester.InsertDocSuccess";
308 331
          metacatReturnString = metacat.insert(docidFull, stringReader, null);
309
          inserted = true;
310
          harvester.addLogEntry(0, docidFull + " : " + metacatReturnString, 
311
                                "harvester.InsertDocSuccess", 
312
                                harvestSiteSchedule.siteScheduleID, 
313
                                null, "");
332
          this.inserted = true;
314 333
        }
315 334
        else if (update) {
335
          harvestOperationCode = "harvester.UpdateDocSuccess";
316 336
          metacatReturnString = metacat.update(docidFull, stringReader, null);
317
          updated = true;
318
          harvester.addLogEntry(0, docidFull + " : " + metacatReturnString, 
319
                                "harvester.UpdateDocSuccess", 
320
                                harvestSiteSchedule.siteScheduleID, 
321
                                null, "");
337
          this.updated = true;
322 338
        }
339
        
340
        if (isMetacatSuccessString(metacatReturnString)) {
341
          String message = docidFull + " : " + metacatReturnString;
342
          harvester.addLogEntry(0, message, harvestOperationCode, 
343
                                harvestSiteSchedule.siteScheduleID, null, "");
344
        }
345
        else {
346
          this.inserted = false;
347
          this.updated = false;
348
          final String exceptionName = "UnreportedMetacatException";
349
          final String exceptionMessage = 
350
                    "Metacat insert/update failed without reporting an exception";
351
          Exception e = new Exception(exceptionMessage);
352
          logMetacatError(insert, metacatReturnString, exceptionName, e);
353
        }
323 354
      }
324 355
      catch (MetacatInaccessibleException e) {
325 356
        logMetacatError(insert, metacatReturnString, 
......
335 366
      catch (IOException e) {
336 367
        logMetacatError(insert, metacatReturnString, "IOException", e);
337 368
      }
369
      catch (Exception e) {
370
        logMetacatError(insert, metacatReturnString, "Exception", e);
371
      }
338 372
    }
339 373
  }
340 374
  

Also available in: Unified diff