Project

General

Profile

« Previous | Next » 

Revision 421

Added by bojilova about 24 years ago

cleared static methods in AccessionNumber classes for fixing bug found
when multiple requests to the servlet at a time.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
354 354
                  throws IOException, SQLException, 
355 355
                         ClassNotFoundException, AccessionNumberException {
356 356

  
357
    String newdocid = AccessionNumber.generate(docid, "DELETE");
357
    AccessionNumber ac = new AccessionNumber();
358
    String newdocid = ac.generate(docid, "DELETE");
358 359

  
359 360
    conn.setAutoCommit(false);
360 361
    // Copy the record to the xml_revisions table
......
375 376
      PreparedStatement pstmt = null;
376 377

  
377 378
      if (action.equals("INSERT")) {
378
        this.docid = AccessionNumber.generate(docid, "INSERT");
379
        AccessionNumber ac = new AccessionNumber();
380
        this.docid = ac.generate(docid, "INSERT");
379 381
        pstmt = conn.prepareStatement(
380 382
            "INSERT INTO xml_documents " +
381 383
            "(docid, rootnodeid, docname, doctype, " +
......
389 391
      } else if (action.equals("UPDATE")) {
390 392

  
391 393
        // Determine if the docid is OK for an UPDATE
392
        this.docid = AccessionNumber.generate(docid, "UPDATE");
394
        AccessionNumber ac = new AccessionNumber();
395
        this.docid = ac.generate(docid, "UPDATE");
393 396

  
394 397
        // Save the old document entry in a backup table
395 398
        DocumentImpl.archiveDocRevision( conn, docid );
src/edu/ucsb/nceas/metacat/AccessionNumber.java
36 36
     * When "UPDATE", accession # is required. 
37 37
     * When "DELETE", accession # is required. 
38 38
     */
39
    public static String generate (String accNumber, String action) 
39
    public String generate (String accNumber, String action) 
40 40
        throws AccessionNumberException, SQLException, ClassNotFoundException
41 41
    {
42 42
        
......
98 98
    }    
99 99

  
100 100
    /** put unique accession # into db connection */
101
    private static String put (Connection conn, String globalName, 
101
    private String put (Connection conn, String globalName, 
102 102
                String localId, String sep) 
103 103
                throws SQLException
104 104
    {
......
133 133
    }
134 134

  
135 135
    /** check for existence of Accesssion Number xml_acc_numbers table */
136
    private static boolean accNumberUsed(Connection conn, String globalName, 
136
    private boolean accNumberUsed(Connection conn, String globalName, 
137 137
                String localId) throws SQLException {
138 138
        
139 139
      boolean hasAccNumber = false;
......
160 160
    }    
161 161
    
162 162
    /** check for existence of Accesssion Number in xml_documents table */
163
    private static boolean accNumberIsCurrent(
163
    private boolean accNumberIsCurrent(
164 164
                Connection conn, String accNumber) throws SQLException {
165 165
        
166 166
      boolean hasCurrentAccNumber = false;
......
186 186
    }    
187 187

  
188 188
    /** get the last in order local ID by a given global name */
189
    private static int get (Connection conn, String globalName) 
189
    private int get (Connection conn, String globalName) 
190 190
                throws SQLException
191 191
    {
192 192
        try {
......
214 214

  
215 215
    
216 216
    // get the global part of the accession number
217
    private static String getGlobalName (String accNumber, String sep) 
217
    private String getGlobalName (String accNumber, String sep) 
218 218
        throws StringIndexOutOfBoundsException {
219 219
        
220 220
        return accNumber.substring(0, accNumber.lastIndexOf(sep));
221 221
    }    
222 222

  
223 223
    // get the local part of the accession number
224
    private static String getLocalId (String accNumber, String sep)
224
    private String getLocalId (String accNumber, String sep)
225 225
        throws StringIndexOutOfBoundsException {
226 226

  
227 227
        return accNumber.substring(accNumber.lastIndexOf(sep)+1);
......
230 230

  
231 231
/**
232 232
 * '$Log$
233
 * 'Revision 1.11  2000/08/14 20:53:33  jones
234
 * 'Added "release" keyword to all metacat source files so that the release
235
 * 'number will be evident in software distributions.
236
 * '
233 237
 * 'Revision 1.10  2000/06/27 04:31:07  jones
234 238
 * 'Fixed bugs associated with the new UPDATE and DELETE functions of
235 239
 * 'DBWriter.  There were problematic interactions between some static

Also available in: Unified diff