Project

General

Profile

« Previous | Next » 

Revision 899

Added by berkley over 22 years ago

made a ton of changes related to keeping oracle SQL code out of the main classes. fixed a bug where the timing of the index thread was off so when it went to index a document, the document was not already in xml_documents thus breaking the FK relation between xml_documents and xml_index. I think that bug might be the reason for the blank resultset screens in morpho. made the postgres implementation much more robust.

View differences:

lib/metacat.properties
7 7
password=@password@
8 8
defaultDB=@jdbc-connect@
9 9
dbDriver=@dbDriver@
10
dbAdapter=edu.ucsb.nceas.dbadapter.OracleAdapter
10
dbAdapter=edu.ucsb.nceas.dbadapter.PostgresqlAdapter
11 11
initialConnections=5
12 12
incrementConnections=5
13 13
maximumConnections=10
src/xmltables_postgres.sql
119 119
	user_owner VARCHAR(100),	-- the user owned the document
120 120
	user_updated VARCHAR(100),	-- the user updated the document
121 121
	server_location INT8,	-- the server on which this document resides
122
	rev INT8,   -- the revision number of the document
122
	rev INT8 default 1,   -- the revision number of the document
123 123
	date_created DATE,
124 124
	date_updated DATE,
125 125
	public_access INT8,	-- flag for public access
src/edu/ucsb/nceas/dbadapter/PostgresqlAdapter.java
95 95
   */
96 96
  public String getStringDelimiter() {
97 97

  
98
    return "'";
98
    return "\"";
99 99
  }
100 100
  
101 101
}
src/edu/ucsb/nceas/metacat/QuerySpecification.java
30 30

  
31 31
package edu.ucsb.nceas.metacat;
32 32

  
33
import edu.ucsb.nceas.dbadapter.*;
34

  
33 35
import java.io.*;
34 36
import java.util.Stack;
35 37
import java.util.Vector;
......
76 78
  private String currentPathexpr;
77 79
  private String parserName = null;
78 80
  private String accNumberSeparator = null;
81
  private static final AbstractDatabase dbAdapter = MetaCatUtil.dbAdapter;
79 82

  
83

  
80 84
  /**
81 85
   * construct an instance of the QuerySpecification class 
82 86
   *
......
558 562
    self.append("xml_nodes x, xml_nodes y, xml_nodes z ");
559 563
    self.append("where s.parentnodeid = rel.parentnodeid ");
560 564
    self.append("and rel.parentnodeid = o.parentnodeid ");
561
    self.append("and x.parentnodeid in rel.nodeid ");
562
    self.append("and y.parentnodeid in o.nodeid ");
563
    self.append("and z.parentnodeid in s.nodeid ");
565
    self.append("and x.parentnodeid in (rel.nodeid) ");
566
    self.append("and y.parentnodeid in (o.nodeid) ");
567
    self.append("and z.parentnodeid in (s.nodeid) ");
564 568
    //self.append("and z.nodedata like '%");
565 569
    //self.append(docid);
566 570
    //self.append("%'");
......
585 589
    self.append("xml_nodes x, xml_nodes y, xml_nodes z ");
586 590
    self.append("where s.parentnodeid = rel.parentnodeid ");
587 591
    self.append("and rel.parentnodeid = o.parentnodeid ");
588
    self.append("and x.parentnodeid in rel.nodeid ");
589
    self.append("and y.parentnodeid in o.nodeid ");
590
    self.append("and z.parentnodeid in s.nodeid ");
592
    self.append("and x.parentnodeid in (rel.nodeid) ");
593
    self.append("and y.parentnodeid in (o.nodeid) ");
594
    self.append("and z.parentnodeid in (s.nodeid) ");
591 595
    self.append("and z.docid like '").append(docid).append("'");
592 596
    
593 597
    return self.toString();
......
612 616
    self.append("xml_nodes x, xml_nodes y, xml_nodes z ");
613 617
    self.append("where s.parentnodeid = rel.parentnodeid ");
614 618
    self.append("and rel.parentnodeid = o.parentnodeid ");
615
    self.append("and x.parentnodeid in rel.nodeid ");
616
    self.append("and y.parentnodeid in o.nodeid ");
617
    self.append("and z.parentnodeid in s.nodeid ");
619
    self.append("and x.parentnodeid in (rel.nodeid) ");
620
    self.append("and y.parentnodeid in (o.nodeid) ");
621
    self.append("and z.parentnodeid in (s.nodeid) ");
618 622
    self.append("and (z.nodedata like '");
619 623
    self.append(subDocidURL);
620 624
    self.append("' or y.nodedata like '");
src/edu/ucsb/nceas/metacat/DBSAXHandler.java
251 251
      MetaCatUtil util = new MetaCatUtil();
252 252
      dbconn = util.openDBConnection();
253 253
      dbconn.setAutoCommit(false);
254

  
254
      
255
      //the following while loop construct checks to make sure that the docid
256
      //of the document that we are trying to index is already
257
      //in the xml_documents table.  if this is not the case, the foreign
258
      //key relationship between xml_documents and xml_index is temporarily
259
      //broken causing multiple problems.
260
      boolean inxmldoc = false;
261
      while(!inxmldoc)
262
      {
263
        String xmlDocumentsCheck = "select distinct docid from xml_documents";
264
        PreparedStatement xmlDocCheck = dbconn.prepareStatement(xmlDocumentsCheck);
265
        xmlDocCheck.execute();
266
        ResultSet doccheckRS = xmlDocCheck.getResultSet();
267
        boolean tableHasRows = doccheckRS.next();
268
        Vector docids = new Vector();
269
        while(tableHasRows) 
270
        {
271
          docids.add(doccheckRS.getString(1).trim());
272
          tableHasRows = doccheckRS.next();
273
        }
274
        
275
        for(int i=0; i<docids.size(); i++)
276
        {
277
          String d = ((String)docids.elementAt(i)).trim();
278
          if(docid.trim().equals(d))
279
          {
280
            inxmldoc = true;
281
          }
282
        }
283
        xmlDocCheck.close();
284
      }
285
      
255 286
      // Going through the elements of the document and writing its Index
256 287
      Enumeration nodes = nodeIndex.elements();
257 288
      while ( nodes.hasMoreElements() ) {
src/edu/ucsb/nceas/metacat/DocumentImpl.java
692 692
    String nodename = null;
693 693
    String nodeprefix = null;
694 694
    String nodedata = null;
695
    String quotechar = dbAdapter.getStringDelimiter();
695 696

  
696 697
    try {
697 698
      pstmt =
698 699
      conn.prepareStatement("SELECT nodeid,parentnodeid,nodeindex, " +
699
           "nodetype,nodename,nodeprefix,"+               
700
           "nodetype,nodename,nodeprefix,nodedata " +               
701
           /*"replace(" +
700 702
           "replace(" +
701
           "replace(" +
702
           "replace(nodedata,'&','&amp;') " +
703
           ",'<','&lt;') " +
704
           ",'>','&gt;') " +
703
           "replace(nodedata," + quotechar + "&" + quotechar + "," + quotechar + "&amp;" +
704
           quotechar + ") " +
705
           "," + quotechar + "<" + quotechar + "," + quotechar + "&lt;" + 
706
           quotechar + ") " +
707
           "," + quotechar + ">" + quotechar + "," + quotechar + "&gt;" + 
708
           quotechar + ") " +*/
705 709
           "FROM xml_nodes WHERE rootnodeid = ?");
706 710

  
707 711
      // Bind the values to the query
......
718 722
        nodename = rs.getString(5);
719 723
        nodeprefix = rs.getString(6);
720 724
        nodedata = rs.getString(7);
721

  
725
        nodedata = MetaCatUtil.normalize(nodedata);
722 726
        // add the data to the node record list hashtable
723 727
        NodeRecord currentRecord = new NodeRecord(nodeid,parentnodeid,nodeindex,
724 728
                                       nodetype, nodename, nodeprefix, nodedata);
src/edu/ucsb/nceas/metacat/DBSAXNode.java
389 389
              "INSERT INTO xml_index (nodeid, path, docid, doctype, " + 
390 390
               "parentnodeid) " + 
391 391
              "VALUES (?, ?, ?, ?, ?)");
392
      //((OraclePreparedStatement)pstmt).setExecuteBatch(counter);
393 392
  
394 393
      pstmt.setString(3, docid);
395 394
      pstmt.setString(4, doctype);
......
402 401
        Long nodeid = (Long)pathlist.get(path);
403 402
        pstmt.setLong(1, nodeid.longValue());
404 403
        pstmt.setString(2, path);
404
        
405 405
        pstmt.executeUpdate();
406
  
407
        //System.out.println(nodeid + " ==> " + path);
408 406
      }
409

  
410 407
      // Close the database statement
411 408
      pstmt.close();
412 409
    } catch (SQLException sqe) {
413 410
      System.err.println("SQL Exception while inserting path to index in " +
414
                         "DBSAXNode.updateNodeIndex");
411
                         "DBSAXNode.updateNodeIndex for document " + docid);
415 412
      System.err.println(sqe.getMessage());
416 413
      throw new SAXException(sqe.getMessage());
417 414
    }
src/edu/ucsb/nceas/metacat/AccessControlList.java
319 319

  
320 320
        // insert into db calculated permission for the list of principals
321 321
        try {
322
// System.out.println("before insertPermission " +leavingTagName);
323 322
          // go through the objects in xml_relation about this acl doc
324 323
          for (int i=0; i < aclObjects.size(); i++) {
325 324
            // docid of the current object
326 325
            String docid = (String)aclObjects.elementAt(i); 
327 326
            DocumentIdentifier docID = new DocumentIdentifier(docid);
328 327
            docid = docID.getIdentifier();
329
// System.out.println(docid);
330 328
            insertPermissions(docid,leavingTagName);
331 329
          }
332 330

  
......
433 431
          throws SQLException 
434 432
  {
435 433
    PreparedStatement pstmt;
436
 
437 434
    try {
438 435
      pstmt = conn.prepareStatement(
439 436
              "INSERT INTO xml_access " + 
......
451 448
      if ( ticketCount > 0 ) {
452 449
        pstmt.setString(8, "" + ticketCount);
453 450
      } else {
454
        pstmt.setString(8, "");
451
        pstmt.setString(8, null);
455 452
      }
456 453

  
457 454
      String prName;
build.xml
32 32
<project name="metacat" default="jar" basedir=".">
33 33
   <target name="init">
34 34
      <property name="jdbc-connect" 
35
                value="jdbc:oracle:thin:@dev.nceas.ucsb.edu:1521:exp"/>
36
      <property name="installdir" value="/opt/tomcat/webapps/metacat" />
37
      <property name="dbDriver" value="oracle.jdbc.driver.OracleDriver"/>
35
                value="jdbc:postgresql://localhost/berkley"/>
36
      <property name="installdir" value="/home/berkley/tomcat/webapps/metacat" />
37
      <property name="dbDriver" value="org.postgresql.Driver"/>
38 38
      <property name="name" value="metacat"/>
39 39
      <property name="Name" value="MetaCat"/>
40 40
      <property name="release" value="1.0.3"/>
41 41
      <property name="web-base-url" 
42
                value="http://knb.ecoinformatics.org"/>
42
                value="http://alpha.nceas.ucsb.edu:8080/"/>
43 43

  
44 44
      <property name="replication-path" value="/servlet/replication"/>
45 45
      <property name="servlet-path" value="/metacat/servlet/metacat"/>
46 46
      <property name="html-path" value="/metacat"/>
47 47
      <property name="image-path" value="/img/metacat" />
48 48
      <property name="style-path" value="/metacat/style"/>
49
      <property name="server" value="dev.nceas.ucsb.edu"/>
50
      <property name="replication-log" value="/tmp/metacatreplication.log"/>
51
      <property name="user" value="metacat_username"/>
52
      <property name="password" value="your_pw_here"/>
49
      <property name="server" value="alpha.nceas.ucsb.edu:8080"/>
50
      <property name="replication-log" value="/home/berkley/tomcat/webapps/metacat/metacatreplication.log"/>
51
      <property name="user" value="berkley"/>
52
      <property name="password" value=""/>
53 53
      <property name="config-dir" value="${installdir}" />
54 54
      <property name="default-style" value="knb" />
55 55
      <property name="eml-module" value="mdstandards/eml" />
......
99 99
      <property name="toolsdir" 
100 100
                value="/usr/local/devtools" />
101 101
      <property name="xmlp" 
102
                value="${toolsdir}/OracleXSU111/lib/xmlparserv2.jar" />
102
                value="./lib/xmlparserv2.jar" />
103 103
      <property name="xmlp2" 
104
                value="${toolsdir}/xerces-1_1_3/xerces.jar" />
104
                value="./lib/xerces.jar" />
105 105
      <property name="jdbc" 
106
                value="${oracle_home}/jdbc/lib/classes111.zip" />
106
                value="/home/berkley/xmltodb/lib/jdbc7.1-1.2.jar" />
107 107
      <property name="jserv" 
108 108
                value="/usr/lib/apache/ApacheJServ.jar" />
109 109
      <property name="jsdk" 
110
                value="${toolsdir}/jakarta-tomcat/lib/servlet.jar" />
110
                value="/home/berkley/tomcat/lib/common/servlet.jar" />
111 111
      <property name="srb" 
112 112
                value="lib/srbrmi" />
113 113
      <property name="cos" 

Also available in: Unified diff