Project

General

Profile

« Previous | Next » 

Revision 2731

Added by sgarg about 19 years ago

Removed the call to indexing function in DBSAXHandler and added a call to indexing function IndexingQueue

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
1211 1211
        //DocumentIdentifier doc = null;
1212 1212
        //String doc = MetaCatUtil.getDocIdFromAccessionNumber(docid);
1213 1213
        String doc = docid;
1214
        //System.out.println("The doc is-----!!!!!!!!!!!!!!!!!! "+doc);
1215 1214
        /*try {
1216 1215
            doc = new DocumentIdentifier(docid);
1217 1216
        } catch (AccessionNumberException e){
......
1255 1254
            // Step through all of the node records we were given
1256 1255
            // and build the new index and update the database
1257 1256
            it = nodeRecordLists.iterator();
1258
            //System.out.println("before iterator!!!!!!!!!!!1");
1259 1257
            while (it.hasNext()) {
1260
                //System.out.println("here!!!!!!!!!!!!!!!");
1261 1258
                NodeRecord currentNode = (NodeRecord) it.next();
1262 1259
                HashMap pathList = new HashMap();
1263 1260
                if (currentNode.nodetype.equals("ELEMENT") ||
......
1314 1311
                                            + " xml_nodes n, xml_index i WHERE"
1315 1312
                                            + " (" + pathList
1316 1313
                                            + " ) AND n.parentnodeid=i.nodeid AND"
1317
                                            + " n.nodetype LIKE 'TEXT' and n.docid = ?");
1314
                                            + " n.nodetype LIKE 'TEXT' and n.docid = ?"
1315
                                            + " order by n.parentnodeid");
1318 1316

  
1319 1317
            pstmt.setString(1, doc);
1320 1318

  
1321 1319
            pstmt.execute();
1322 1320
            rs = pstmt.getResultSet();
1321
            dbConn.increaseUsageCount(1);
1323 1322

  
1324 1323
            int count = 0;
1325 1324

  
......
1345 1344

  
1346 1345
                    pstmt1.execute();
1347 1346
                    pstmt1.close();
1348

  
1347
                    dbConn.increaseUsageCount(1);
1348
                    
1349 1349
                    count++;
1350 1350
                }
1351 1351
            }
......
1355 1355
            dbConn.increaseUsageCount(1);
1356 1356

  
1357 1357
            logMetacat.warn("Indexed " + count
1358
                                              + " records from xml_nodes");
1358
                                              + " records for docid: " + docid);
1359 1359

  
1360 1360
            dbConn.commit();
1361 1361
        } catch (SQLException e) {
......
2238 2238
                    conn.setAutoCommit(true);
2239 2239

  
2240 2240
                    // write to xml_node complete. start the indexing thread.
2241
                    DBSAXHandler dbx = (DBSAXHandler) parser.getContentHandler();
2242
                    dbx.runIndexingThread();
2243
                } catch (Exception e) {
2241
                    addDocidToIndexingQueue(docid, rev);
2242
               } catch (Exception e) {
2244 2243
                    conn.rollback();
2245 2244
                    conn.setAutoCommit(true);
2246 2245
                    //if it is a eml2 document, we need delete online data
......
2309 2308
            //System.out.println("commit!!!!!!!!!!!!!!!!!111");
2310 2309
            conn.commit();
2311 2310
            conn.setAutoCommit(true);
2312
            
2313
            // write to xml_node complete. start the indexing thread.
2314
            DBSAXHandler dbx = (DBSAXHandler) parser.getContentHandler();
2315
            //System.out.println("here!!!!!!!adf");
2316
            dbx.runIndexingThread();
2317
            //System.out.println("here!!!!!!!adfadfa");
2311

  
2312
            addDocidToIndexingQueue(docid, rev);
2318 2313
        } catch (Exception e) {
2319 2314
            e.printStackTrace();
2320 2315
            conn.rollback();
......
2368 2363
        return (accnum);
2369 2364
    }
2370 2365

  
2366
    
2367
    private static void addDocidToIndexingQueue(String docid, String rev){
2368
        boolean useXMLIndex =
2369
            (new Boolean(MetaCatUtil.getOption("usexmlindex"))).booleanValue();
2370
        if (useXMLIndex) {
2371
            	IndexingQueue.getInstance().add(docid + "." + rev);
2372
        }
2373
    }
2374

  
2371 2375
    /**
2372 2376
     * Write an XML file to the database during replication
2373 2377
     *
......
2464 2468
            
2465 2469
            // write to xml_node complete. start the indexing thread.
2466 2470
            // this only for xml_documents
2467
            DBSAXHandler dbx = (DBSAXHandler) parser.getContentHandler();
2468 2471
            if (!isRevision)
2469 2472
            {
2470
                dbx.runIndexingThread();
2473
            	addDocidToIndexingQueue(docid, rev);
2471 2474
            }
2475
            
2476
            DBSAXHandler dbx = (DBSAXHandler) parser.getContentHandler();
2472 2477
            rootId = dbx.getRootNodeId();
2473 2478
            docType = dbx.getDocumentType();
2474 2479
            docName = dbx.getDocumentName();

Also available in: Unified diff