Project

General

Profile

« Previous | Next » 

Revision 834

Added by Matt Jones over 22 years ago

Fixed bug in metacat where an Exception was thrown when a search returned
an empty resultset. Now we avoid the function call that threw the exeption.

View differences:

DBQuery.java
381 381
            doclist.append((String)keylist.nextElement());
382 382
            doclist.append("',");
383 383
          }
384
          doclist.deleteCharAt(doclist.length()-1); //remove the last comma
385
          //pstmt.close();
386
          pstmt = dbconn.prepareStatement(qspec.printExtendedSQL(
384
          if (doclist.length() > 0) {
385
            doclist.deleteCharAt(doclist.length()-1); //remove the last comma
386
            //pstmt.close();
387
            pstmt = dbconn.prepareStatement(qspec.printExtendedSQL(
387 388
                                        doclist.toString()));
388
          pstmt.execute();
389
          rs = pstmt.getResultSet();
390
          tableHasRows = rs.next();
391
          while(tableHasRows) 
392
          {
393
            docid = rs.getString(1).trim();
394
            if ( !hasPermission(dbconn, user, groups, docid) ) {
395
              // Advance to the next record in the cursor
396
              tableHasRows = rs.next();
397
              continue;
398
            }
399
            fieldname = rs.getString(2);
400
            fielddata = rs.getString(3);
401
            
402
            document = new StringBuffer();
403

  
404
            document.append("<param name=\"");
405
            document.append(fieldname);
406
            document.append("\">");
407
            document.append(fielddata);
408
            document.append("</param>");
409

  
389
            pstmt.execute();
390
            rs = pstmt.getResultSet();
410 391
            tableHasRows = rs.next();
411
            if (docListResult.containsKey(docid))
392
            while(tableHasRows) 
412 393
            {
413
              String removedelement = (String)docListResult.remove(docid);
414
              docListResult.put(docid, removedelement + document.toString());
394
              docid = rs.getString(1).trim();
395
              if ( !hasPermission(dbconn, user, groups, docid) ) {
396
                // Advance to the next record in the cursor
397
                tableHasRows = rs.next();
398
                continue;
399
              }
400
              fieldname = rs.getString(2);
401
              fielddata = rs.getString(3);
402
              
403
              document = new StringBuffer();
404
  
405
              document.append("<param name=\"");
406
              document.append(fieldname);
407
              document.append("\">");
408
              document.append(fielddata);
409
              document.append("</param>");
410
  
411
              tableHasRows = rs.next();
412
              if (docListResult.containsKey(docid))
413
              {
414
                String removedelement = (String)docListResult.remove(docid);
415
                docListResult.put(docid, removedelement + document.toString());
416
              }
417
              else
418
              {
419
                docListResult.put(docid, document.toString()); 
420
              }
415 421
            }
416
            else
417
            {
418
              docListResult.put(docid, document.toString()); 
419
            }
420 422
          }
421 423
          rs.close();
422 424
        }

Also available in: Unified diff