Project

General

Profile

« Previous | Next » 

Revision 790

Added by bojilova over 23 years ago

added constructor in DocumentImpl for use in DBQuery.findDocuments();
this new constructor is used with getDocumentInfo() to get the doc info only;
because the other constructor builds the whole xml doc which is not needed here and time consuming;
this happens on backtracking only.

View differences:

src/edu/ucsb/nceas/metacat/DBQuery.java
221 221
          dbconn = conn;
222 222
        }
223 223
        // problem with ODBC driver multi-threading
224
        dbconn2 = util.openDBConnection(); // for use by AccessControlList
224
     //   dbconn2 = util.openDBConnection(); // for use by AccessControlList
225 225
        
226 226
        // Get the XML query and covert it into a SQL statment
227 227
        QuerySpecification qspec = new QuerySpecification(xmlquery, 
228 228
                                   parserName, 
229 229
                                   util.getOption("accNumSeparator"));
230
  //System.out.println(qspec.printSQL(useXMLIndex)); 
230 231
        pstmt = dbconn.prepareStatement( qspec.printSQL(useXMLIndex) );
231

  
232
  
232 233
        // Execute the SQL query using the JDBC connection
233 234
        pstmt.execute();
234 235
        ResultSet rs = pstmt.getResultSet();
......
236 237
        while (tableHasRows) 
237 238
        {
238 239
          docid = rs.getString(1).trim();
239
          if ( !hasPermission(dbconn2, user, group, docid) ) {
240
          if ( !hasPermission(dbconn, user, group, docid) ) {
240 241
            // Advance to the next record in the cursor
241 242
            tableHasRows = rs.next();
242 243
            continue;
......
283 284
            { //there was a backtrackable document found
284 285
              DocumentImpl xmldoc = null;
285 286
              String packageDocid = btrs.getString(1);
286
              //MetacatURL objURL = new MetacatURL(packageDocid);
287 287
              try
288 288
              {
289
                //xmldoc = new DocumentImpl(dbconn, objURL.getParam(0)[1]);
290
                xmldoc = new DocumentImpl(dbconn, packageDocid);
289
              //  THIS CONSTRUCTOR BUILDS THE WHOLE XML doc not needed here
290
              //  xmldoc = new DocumentImpl(dbconn, packageDocid);
291
              //  thus use the following to get the doc info only
292
                xmldoc = new DocumentImpl(dbconn);
293
                xmldoc.getDocumentInfo(packageDocid);
291 294
              }
292 295
              catch(Exception e)
293 296
              {
......
380 383
          while(tableHasRows) 
381 384
          {
382 385
            docid = rs.getString(1).trim();
383
            if ( !hasPermission(dbconn2, user, group, docid) ) {
386
            if ( !hasPermission(dbconn, user, group, docid) ) {
384 387
              // Advance to the next record in the cursor
385 388
              tableHasRows = rs.next();
386 389
              continue;
......
482 485
        try
483 486
        {
484 487
          dbconn.close();
485
          dbconn2.close();
488
        //  dbconn2.close();
486 489
        }
487 490
        catch(SQLException sqle)
488 491
        {
src/edu/ucsb/nceas/metacat/DocumentImpl.java
86 86
  private long rootnodeid;
87 87
  private ElementNode rootNode = null;
88 88
  private TreeSet nodeRecordList = null;
89
  
90
  /**
91
   * Constructor used from DBQuery.findDocuments();
92
   * used with getDocumentInfo() to get document info from xml_documents
93
   *
94
   * @param conn the database connection from which to read the document
95
   */
96
  public DocumentImpl(Connection conn) throws McdbException 
97
  {
98
    this.conn = conn;
99
  }
89 100

  
90 101
  /**
91 102
   * Constructor, creates document from database connection, used 
......
100 111
      this.conn = conn;
101 112
      this.docid = docid;
102 113
      
103
      DocumentIdentifier id = new DocumentIdentifier(docid);
104
      
114
      // NOT NEEDED
115
      //DocumentIdentifier id = new DocumentIdentifier(docid);
105 116
  
106 117
      // Look up the document information
107 118
      getDocumentInfo(docid);
......
464 475
                        "' does not exist");
465 476
  }
466 477

  
467
  private void getDocumentInfo(String docid) throws McdbException, 
478
  public void getDocumentInfo(String docid) throws McdbException, 
468 479
                                                    AccessionNumberException
469 480
  {
470 481
    getDocumentInfo(new DocumentIdentifier(docid));

Also available in: Unified diff