Project

General

Profile

« Previous | Next » 

Revision 7445

rollback the delete() when there is an error performing part of it -- don't want to end up with partial delete.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
3402 3402

  
3403 3403
            double afterDeleteXMLNodes = System.currentTimeMillis()/1000;
3404 3404
            logMetacat.info("DocumentImpl.delete - Deleting xml_nodes time is "+(afterDeleteXMLNodes-afterDeleteDoc));
3405
            conn.commit();
3406
            conn.setAutoCommit(true);
3407
        
3408
            // add force delete replcation document here.
3409
            ForceReplicationHandler frh = new ForceReplicationHandler(
3410
                             accnum, ForceReplicationHandler.DELETE, isXML, notifyServer);
3411
            logMetacat.debug("DocumentImpl.delete - ForceReplicationHandler created: " + frh.toString());
3412
            // clear cache after inserting or updating a document
3413
            if (PropertyService.getProperty("database.queryCacheOn").equals("true")) {
3414
            	//System.out.println("the string stored into cache is "+ resultsetBuffer.toString());
3415
            	DBQuery.clearQueryResultCache();
3416
            }
3417 3405
            
3418 3406
            // remove the file if called for
3419 3407
            if (removeAll) {
......
3431 3419
				HazelcastService.getInstance().getSystemMetadataMap().put(guid, sysMeta);
3432 3420
            }
3433 3421
            
3422
            // clear cache after inserting or updating a document
3423
            if (PropertyService.getProperty("database.queryCacheOn").equals("true")) {
3424
            	//System.out.println("the string stored into cache is "+ resultsetBuffer.toString());
3425
            	DBQuery.clearQueryResultCache();
3426
            }
3427
            
3428
            // only commit if all of this was successful
3429
            conn.commit();
3430
            conn.setAutoCommit(true);
3431
                        
3432
            // add force delete replcation document here.
3433
            ForceReplicationHandler frh = new ForceReplicationHandler(
3434
                             accnum, ForceReplicationHandler.DELETE, isXML, notifyServer);
3435
            logMetacat.debug("DocumentImpl.delete - ForceReplicationHandler created: " + frh.toString());
3436
            
3434 3437
           double end = System.currentTimeMillis()/1000;
3435 3438
           logMetacat.info("DocumentImpl.delete - total delete time is:  " + (end - start));
3436 3439

  
3437
        } catch ( SQLException sqle ) {
3438
          logMetacat.error("DocumentImpl.delete - SQL error: " + sqle.getMessage());
3439
          throw sqle;
3440
          
3441 3440
        } catch ( Exception e ) {
3442
            logMetacat.error("DocumentImpl.delete - General error: " + e.getMessage());
3441
        	// rollback the delete if there was an error
3442
        	conn.rollback();
3443
            logMetacat.error("DocumentImpl.delete -  Error: " + e.getMessage());
3443 3444
            throw e;
3444 3445
        } finally {
3445 3446

  

Also available in: Unified diff