Project

General

Profile

« Previous | Next » 

Revision 1782

Added by Jing Tao over 20 years ago

If uploading failed, the inline data will be deleted either.

View differences:

src/edu/ucsb/nceas/metacat/EmlSAXHandler.java
98 98
   private FileWriter inlineDataFileWriter = null;
99 99
   private String inlineDataFileName = null;
100 100
   private int inLineDataIndex = 0;
101
   private Vector inlineFileIDList = new Vector();
101 102
 
102 103
   // Constant
103 104
   private static final String EML ="eml";
......
309 310
       inlineDataFileName = docidWithoutRev + seperator+revision+seperator +
310 311
                         inLineDataIndex;
311 312
       inlineDataFileWriter = createInlineDataFileWriter(inlineDataFileName);
313
       // put the inline file id into a vector. If upload failed, metacat will
314
       // delete the inline data file
315
       inlineFileIDList.add(inlineDataFileName);
316
       
312 317
     }
313 318
     
314 319
     
......
957 962
          textBuffer = new StringBuffer(inlineDataFileName);
958 963
          // write file name into db
959 964
          endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer, currentNode);
965
          // reset textbuff
966
          textBuffer = null;
967
          textBuffer = new StringBuffer(); 
960 968
          return;
961 969
    }
962 970
    
......
2185 2193
    return same;
2186 2194
  }
2187 2195
  
2196
  // if xml file failed to upload, we need to call this method to delete
2197
  // the inline data already in file system
2198
  public void deleteInlineFiles()
2199
  {
2200
     if (!inlineFileIDList.isEmpty())
2201
     {
2202
       for ( int i=0; i<inlineFileIDList.size(); i++)
2203
       {
2204
         String fileName = (String) inlineFileIDList.elementAt(i);
2205
         deleteInlineDataFile(fileName);
2206
       }
2207
     }
2208
  }
2209
  
2188 2210
  /* delete the inline data file */
2189 2211
  private void deleteInlineDataFile(String fileName)
2190 2212
  {
......
2299 2321
    }//finally
2300 2322
    
2301 2323
  }//writeOnlineDataFileIdIntoRelationTable
2324
  
2325
 
2302 2326
}

Also available in: Unified diff