Project

General

Profile

« Previous | Next » 

Revision 6595

View differences:

DocumentImpl.java
46 46
import java.sql.Statement;
47 47
import java.sql.Timestamp;
48 48
import java.util.Calendar;
49
import java.util.Date;
49 50
import java.util.Hashtable;
50 51
import java.util.HashMap;
51 52
import java.util.Iterator;
......
165 166
    protected String docname = null;
166 167
    protected String doctype = null;
167 168
    private String validateType = null; //base on dtd or schema
168
    private String createdate = null;
169
    private String updatedate = null;
169
    private Date createdate = null;
170
    private Date updatedate = null;
170 171
    private String system_id = null;
171 172
    private String userowner = null;
172 173
    private String userupdated = null;
......
291 292
    public DocumentImpl(DBConnection conn, long rootNodeId, String docName,
292 293
            String docType, String docId, String newRevision, String action,
293 294
            String user, String pub, String catalogId, int serverCode, 
294
            String createDate, String updateDate)
295
            Date createDate, Date updateDate)
295 296
            throws SQLException, Exception
296 297
    {
297 298
        this.connection = conn;
......
434 435
     */
435 436
    public static void registerDocumentInReplication(String docname,
436 437
            String doctype, String accnum, String user, int serverCode, 
437
            String tableName, String createDate, String updateDate)
438
            String tableName, Date createDate, Date updateDate)
438 439
            throws SQLException, AccessionNumberException, Exception
439 440
    {
440 441
        DBConnection conn = null;
......
492 493
    */
493 494
   private static void modifyRecordsInGivenTable(String tableName, String action,
494 495
                       String docid, String doctype, String docname, String user,
495
                       String rev, int serverCode, String createDate, String updateDate,
496
                       String rev, int serverCode, Date createDate, Date updateDate,
496 497
                       DBConnection dbconn) throws Exception
497 498
   {
498 499
      
499 500
      PreparedStatement pstmt = null;
500 501
      int revision = (new Integer(rev)).intValue();
501 502
      String sqlDateString = DatabaseService.getInstance().getDBAdapter().getDateTimeFunction();
502
      if (createDate == null)
503
      {
504
          createDate = sqlDateString;
503
      Date today = new Date(Calendar.getInstance().getTimeInMillis());
504
      
505
      if (createDate == null){
506
          createDate = today;
505 507
      }
506
      else
507
      {
508
          createDate = DatabaseService.getInstance().getDBAdapter().toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
508
      
509
      if (updateDate == null) {
510
          updateDate = today;
509 511
      }
510 512
      
511
      if (updateDate == null)
512
      {
513
          updateDate = sqlDateString;
514
      }
515
      else
516
      {
517
          updateDate = DatabaseService.getInstance().getDBAdapter().toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
518
      }
519
      try
520
      {
513
      try {
521 514
        
522 515
        StringBuffer sql = new StringBuffer();
523 516
        if (action != null && action.equals("INSERT")) {
524 517
            
525 518
            sql.append("insert into ");
526 519
            sql.append(tableName);
527
            sql.append(" (docid, docname, " +
528
                       "doctype, ");
529
            sql.append("user_owner, user_updated, server_location, " +
530
                       "rev,date_created");
531
            sql.append(", date_updated, public_access) values ('");
532
            sql.append(docid).append("','");
533
            sql.append(docname).append("','");
534
            sql.append(doctype).append("','");
535
            sql.append(user).append("','");
536
            sql.append(user).append("','");
537
            sql.append(serverCode).append("',");
538
            sql.append(revision).append(",");
539
            sql.append(createDate).append(",");
540
            sql.append(updateDate).append(",");
520
            sql.append(" (docid, docname, doctype, ");
521
            sql.append("user_owner, user_updated, server_location, rev, date_created, ");
522
            sql.append("date_updated, public_access) values (");
523
            sql.append("?, ");
524
            sql.append("?, ");
525
            sql.append("?, ");
526
            sql.append("?, ");
527
            sql.append("?, ");
528
            sql.append("?, ");
529
            sql.append("?, ");
530
            sql.append("?, ");
531
            sql.append("?, ");
541 532
            sql.append("'0')");
533
            // set the values
534
            pstmt = dbconn.prepareStatement(sql.toString());
535
            pstmt.setString(1, docid);
536
            pstmt.setString(2, docname);
537
            pstmt.setString(3, doctype);
538
            pstmt.setString(4, user);
539
            pstmt.setString(5, user);
540
            pstmt.setInt(6, serverCode);
541
            pstmt.setInt(7, revision);
542
            pstmt.setTimestamp(8, new Timestamp(createDate.getTime()));
543
            pstmt.setTimestamp(9, new Timestamp(updateDate.getTime()));
544

  
542 545
        } else if (action != null && action.equals("UPDATE")) {
543 546
            
544
            sql.append("update xml_documents set docname ='");
545
            sql.append(docname).append("', ");
546
            sql.append("user_updated='");
547
            sql.append(user).append("', ");
548
            sql.append("server_location='");
549
            sql.append(serverCode).append("',");
550
            sql.append("rev=");
551
            sql.append(revision).append(",");
552
            sql.append("date_updated=");
553
            sql.append(updateDate);
554
            sql.append(" where docid='");
555
            sql.append(docid).append("'");
547
            sql.append("update xml_documents set docname = ?,");
548
            sql.append("user_updated = ?, ");
549
            sql.append("server_location= ?, ");
550
            sql.append("rev = ?, ");
551
            sql.append("date_updated = ?");
552
            sql.append(" where docid = ? ");
553
            // set the values
554
            pstmt = dbconn.prepareStatement(sql.toString());
555
            pstmt.setString(1, docname);
556
            pstmt.setString(2, user);
557
            pstmt.setInt(3, serverCode);
558
            pstmt.setInt(4, revision);
559
            pstmt.setTimestamp(5, new Timestamp(updateDate.getTime()));
560
            pstmt.setString(6, docid);
556 561
        }
557
        pstmt = dbconn.prepareStatement(sql.toString());
558 562
        logMetacat.debug("DocumentImpl.modifyRecordsInGivenTable - executing SQL: " + pstmt.toString());
559 563
        pstmt.execute();
560 564
        pstmt.close();
......
599 603
    public static void writeDataFileInReplication(InputStream input,
600 604
            String filePath, String docname, String doctype, String accnum,
601 605
            String user, String docHomeServer, String notificationServer, 
602
            String tableName, boolean timedReplication, String createDate, String updateDate)
606
            String tableName, boolean timedReplication, Date createDate, Date updateDate)
603 607
            throws SQLException, AccessionNumberException, Exception
604 608
    {
605 609
        int serverCode = -2;
......
880 884
    /**
881 885
     * get the creation date
882 886
     */
883
    public String getCreateDate()
887
    public Date getCreateDate()
884 888
    {
885 889
        return createdate;
886 890
    }
......
888 892
    /**
889 893
     * get the update date
890 894
     */
891
    public String getUpdateDate()
895
    public Date getUpdateDate()
892 896
    {
893 897
        return updatedate;
894 898
    }
......
2029 2033
                    .getDBConnection("DocumentImpl.isRevisionOnly");
2030 2034
            serialNumber = dbconn.getCheckOutSerialNumber();
2031 2035
            pstmt = dbconn.prepareStatement("select rev from xml_documents "
2032
                    + "where docid like '" + newid + "'");
2036
                    + "where docid like ?");
2037
            pstmt.setString(1, newid);
2033 2038
            logMetacat.debug("DocumentImpl.isRevisionOnly - executing SQL: " + pstmt.toString());
2034 2039
            pstmt.execute();
2035 2040
            ResultSet rs = pstmt.getResultSet();
......
2135 2140
            sql.append("date_created, date_updated, user_owner, user_updated,");
2136 2141
            sql.append(" server_location, public_access, rev");
2137 2142
            sql.append(" FROM ").append(table);
2138
            sql.append(" WHERE docid LIKE '").append(docid);
2139
            sql.append("' and rev = ").append(revision);
2143
            sql.append(" WHERE docid LIKE ? ");
2144
            sql.append(" and rev = ? ");
2140 2145

  
2141 2146
            pstmt = dbconn.prepareStatement(sql.toString());
2147
            pstmt.setString(1, docid);
2148
            pstmt.setInt(2, revision);
2142 2149

  
2143 2150
            logMetacat.debug("DocumentImpl.getDocumentInfo - executing SQL: " + pstmt.toString());
2144 2151
            pstmt.execute();
......
2148 2155
                this.docname = rs.getString(1);
2149 2156
                this.doctype = rs.getString(2);
2150 2157
                this.rootnodeid = rs.getLong(3);
2151
                this.createdate = rs.getString(4);
2152
                this.updatedate = rs.getString(5);
2158
                this.createdate = rs.getTimestamp(4);
2159
                this.updatedate = rs.getTimestamp(5);
2153 2160
                this.userowner = rs.getString(6);
2154 2161
                this.userupdated = rs.getString(7);
2155 2162
                this.serverlocation = rs.getInt(8);
......
2335 2342

  
2336 2343
    /** creates SQL code and inserts new document into DB connection */
2337 2344
    private void writeDocumentToDB(String action, String user, String pub,
2338
            String catalogid, int serverCode, String createDate, String updateDate) throws SQLException, Exception
2345
            String catalogid, int serverCode, Date createDate, Date updateDate) throws SQLException, Exception
2339 2346
    {
2340 2347
        //System.out.println("!!!!!!!!1write document to db  " +docid +"."+rev);
2341 2348
        String sysdate = DatabaseService.getInstance().getDBAdapter().getDateTimeFunction();
2342
        if (createDate == null)
2343
        {
2344
            createDate = sysdate;
2349
        Date today = Calendar.getInstance().getTime();
2350
        if (createDate == null) {
2351
            createDate = today;
2345 2352
        }
2346
        else
2347
        {
2348
            createDate = DatabaseService.getInstance().getDBAdapter().toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
2353
        if (updateDate == null) {
2354
            updateDate = today;
2349 2355
        }
2350
        if (updateDate == null)
2351
        {
2352
            updateDate = sysdate;
2353
        }
2354
        else
2355
        {
2356
            updateDate = DatabaseService.getInstance().getDBAdapter().toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
2357
        }
2358 2356
        DocumentImpl thisdoc = null;
2359 2357

  
2360 2358
        try {
......
2370 2368
                        + "(docid, rootnodeid, docname, doctype, user_owner, "
2371 2369
                        + "user_updated, date_created, date_updated, "
2372 2370
                        + "public_access, server_location, rev, catalog_id) "
2373
                        + "VALUES (?, ?, ?, ?, ?, ?, " + createDate + ", "
2374
                        + updateDate + ", ?, ?, ?, ?)";
2371
                        + "VALUES (?, ?, ?, ?, ?, ?, ?, "
2372
                        +  "?, ?, ?, ?, ?)";
2375 2373
                }
2376 2374
                else
2377 2375
                {
......
2379 2377
                        + "(docid, rootnodeid, docname, doctype, user_owner, "
2380 2378
                        + "user_updated, date_created, date_updated, "
2381 2379
                        + "public_access, server_location, rev) "
2382
                        + "VALUES (?, ?, ?, ?, ?, ?, " + createDate + ", "
2383
                        + updateDate + ", ?, ?, ?)";
2380
                        + "VALUES (?, ?, ?, ?, ?, ?, ?, "
2381
                        + "?, ?, ?, ?)";
2384 2382
                }
2385 2383
                /*pstmt = connection
2386 2384
                        .prepareStatement("INSERT INTO xml_documents "
......
2404 2402
                pstmt.setString(4, doctype);
2405 2403
                pstmt.setString(5, user);
2406 2404
                pstmt.setString(6, user);
2405
                // dates
2406
                pstmt.setTimestamp(7, new Timestamp(createDate.getTime()));
2407
                pstmt.setTimestamp(8, new Timestamp(updateDate.getTime()));
2407 2408
                //public access is usefulless, so set it to null
2408
                pstmt.setInt(7, 0);
2409
                pstmt.setInt(9, 0);
2409 2410
                /*
2410 2411
                 * if ( pub == null ) { pstmt.setString(7, null); } else if (
2411 2412
                 * pub.toUpperCase().equals("YES") || pub.equals("1") ) {
......
2413 2414
                 * pub.toUpperCase().equals("NO") || pub.equals("0") ) {
2414 2415
                 * pstmt.setInt(7, 0); }
2415 2416
                 */
2416
                pstmt.setInt(8, serverCode);
2417
                pstmt.setInt(9, rev);
2417
                pstmt.setInt(10, serverCode);
2418
                pstmt.setInt(11, rev);
2418 2419
               
2419 2420
                if (catalogid != null)
2420 2421
                {
2421
                  pstmt.setInt(10, (new Integer(catalogid)).intValue());
2422
                  pstmt.setInt(12, (new Integer(catalogid)).intValue());
2422 2423
                }
2423 2424
                
2424 2425
                
......
2466 2467
                {
2467 2468
                	updateSql = "UPDATE xml_documents "
2468 2469
                        + "SET rootnodeid = ?, docname = ?, doctype = ?, "
2469
                        + "user_updated = ?, date_updated = "
2470
                        + updateDate
2471
                        + ", "
2470
                        + "user_updated = ?, date_updated = ?, "
2472 2471
                        + "server_location = ?, rev = ?, public_access = ?, "
2473 2472
                        + "catalog_id = ? "
2474 2473
                        + "WHERE docid = ?";
......
2477 2476
                {
2478 2477
                	updateSql = "UPDATE xml_documents "
2479 2478
                        + "SET rootnodeid = ?, docname = ?, doctype = ?, "
2480
                        + "user_updated = ?, date_updated = "
2481
                        + updateDate
2482
                        + ", "
2479
                        + "user_updated = ?, date_updated = ?, "
2483 2480
                        + "server_location = ?, rev = ?, public_access = ? "
2484 2481
                        + "WHERE docid = ?";
2485 2482
                }
2486
                /*pstmt = connection
2487
                        .prepareStatement("UPDATE xml_documents "
2488
                        + "SET rootnodeid = ?, docname = ?, doctype = ?, "
2489
                        + "user_updated = ?, date_updated = "
2490
                        + updateDate
2491
                        + ", "
2492
                        + "server_location = ?, rev = ?, public_access = ?, "
2493
                        + "catalog_id = ? "
2494
                        + "WHERE docid = ?");*/
2495 2483
                // Increase dbconnection usage count
2496 2484
                pstmt = connection.prepareStatement(updateSql);
2497 2485
                connection.increaseUsageCount(1);
......
2500 2488
                pstmt.setString(2, docname);
2501 2489
                pstmt.setString(3, doctype);
2502 2490
                pstmt.setString(4, user);
2503
                pstmt.setInt(5, serverCode);
2504
                pstmt.setInt(6, thisrev);
2505
                pstmt.setInt(7, 0);
2491
                pstmt.setTimestamp(5, new Timestamp(updateDate.getTime()));
2492
                pstmt.setInt(6, serverCode);
2493
                pstmt.setInt(7, thisrev);
2494
                pstmt.setInt(8, 0);
2506 2495
                /*
2507 2496
                 * if ( pub == null ) { pstmt.setString(7, null); } else if (
2508 2497
                 * pub.toUpperCase().equals("YES") || pub.equals("1") ) { pstmt
......
2511 2500
                 */
2512 2501
                if (catalogid != null)
2513 2502
                {
2514
                  pstmt.setInt(8, (new Integer(catalogid)).intValue());
2515
                  pstmt.setString(9, this.docid);
2503
                  pstmt.setInt(9, (new Integer(catalogid)).intValue());
2504
                  pstmt.setString(10, this.docid);
2516 2505
                }
2517 2506
                else
2518 2507
                {
2519
                  pstmt.setString(8, this.docid);
2508
                  pstmt.setString(9, this.docid);
2520 2509
                }
2521 2510

  
2522 2511
            } else {
......
2907 2896
            String pub, Reader dtd, String action, String accnum, String user,
2908 2897
            String[] groups, String homeServer, String notifyServer,
2909 2898
            String ruleBase, boolean needValidation, String tableName, 
2910
            boolean timedReplication, String createDate, String updateDate) throws Exception
2899
            boolean timedReplication, Date createDate, Date updateDate) throws Exception
2911 2900
    {
2912 2901
    	// Get the xml as a string so we can write to file later
2913 2902
    	StringReader xmlReader = new StringReader(xmlString);
......
3495 3484
            String action, String docid, Reader xml, String rev, String user,
3496 3485
            String[] groups, String pub, int serverCode, Reader dtd,
3497 3486
            String ruleBase, boolean needValidation, boolean isRevision,
3498
            String createDate, String updateDate, String encoding) throws Exception
3487
            Date createDate, Date updateDate, String encoding) throws Exception
3499 3488
    {
3500 3489
        XMLReader parser = null;
3501 3490
        try {
......
3880 3869
            serialNumber = conn.getCheckOutSerialNumber();
3881 3870
            //delete a record
3882 3871
            pStmt = conn.prepareStatement(
3883
                    "DELETE FROM xml_documents WHERE docid = '" + docId + "'");
3872
                    "DELETE FROM xml_documents WHERE docid = ? ");
3873
            pStmt.setString(1, docId);
3884 3874
            logMetacat.debug("DocumentImpl.deleteXMLDocuments - executing SQL: " + pStmt.toString());
3885 3875
            pStmt.execute();
3886 3876
        } finally {
......
3921 3911
            serialNumber = conn.getCheckOutSerialNumber();
3922 3912

  
3923 3913
            pStmt = conn
3924
                    .prepareStatement("SELECT server_location FROM xml_documents WHERE docid='"
3925
                            + docId + "'");
3914
                    .prepareStatement("SELECT server_location FROM xml_documents WHERE docid = ?");
3915
            pStmt.setString(1, docId);
3926 3916
            pStmt.execute();
3927 3917

  
3928 3918
            ResultSet rs = pStmt.getResultSet();
......
3982 3972
                    .getDBConnection("DocumentImpl.getServerCode");
3983 3973
            serialNumber = dbConn.getCheckOutSerialNumber();
3984 3974
            pStmt = dbConn
3985
                    .prepareStatement("SELECT serverid FROM xml_replication WHERE server='"
3986
                            + serverName + "'");
3975
                    .prepareStatement("SELECT serverid FROM xml_replication WHERE server = ?");
3976
            pStmt.setString(1, serverName);
3987 3977
            pStmt.execute();
3988 3978

  
3989 3979
            ResultSet rs = pStmt.getResultSet();
......
4040 4030

  
4041 4031
            // Compare the server to dabase
4042 4032
            pStmt = dbConn
4043
                    .prepareStatement("SELECT serverid FROM xml_replication WHERE server='"
4044
                            + server + "'");
4033
                    .prepareStatement("SELECT serverid FROM xml_replication WHERE server = ?");
4034
            pStmt.setString(1, server);
4045 4035
            pStmt.execute();
4046 4036
            ResultSet rs = pStmt.getResultSet();
4047 4037
            boolean hasRow = rs.next();
......
4063 4053
                 * 'MM/DD/YY'), '" + replicate +"', '"+dataReplicate+"','"+ hub +
4064 4054
                 * "')");
4065 4055
                 */
4056
                
4057
                Calendar cal = Calendar.getInstance();
4058
                cal.set(1980, 1, 1);
4066 4059
                pStmt = dbConn
4067 4060
                        .prepareStatement("INSERT INTO xml_replication "
4068 4061
                                + "(server, last_checked, replicate, datareplicate, hub) "
4069
                                + "VALUES ('" + server + "', "
4070
                                + DatabaseService.getInstance().getDBAdapter().toDate("01/01/1980", "MM/DD/YYYY")
4071
                                + ", '" + replicate + "', '" + dataReplicate
4072
                                + "','" + hub + "')");
4062
                                + "VALUES (?, ?, ?, ?, ?)");
4063
                pStmt.setString(1, server);
4064
				pStmt.setTimestamp(2, new Timestamp(cal.getTimeInMillis()) );
4065
                pStmt.setInt(3, replicate);
4066
                pStmt.setInt(4, dataReplicate);
4067
                pStmt.setInt(5, hub);
4073 4068

  
4074 4069
                logMetacat.debug("DocumentImpl.insertServerIntoReplicationTable - executing SQL: " + pStmt.toString());
4075 4070
                pStmt.execute();
......
4255 4250
     */
4256 4251
    private static void writeDocumentToRevisionTable(DBConnection con, String docId, 
4257 4252
            String rev, String docType, String docName, String user, 
4258
            String catalogid, int serverCode, long rootNodeId, String createDate, String updateDate) throws SQLException, Exception
4253
            String catalogid, int serverCode, long rootNodeId, Date createDate, Date updateDate) throws SQLException, Exception
4259 4254
    {
4260 4255
        
4261 4256
        try 
4262 4257
        {
4258
            Date today = Calendar.getInstance().getTime();
4259
            if (createDate == null){
4260
                createDate = today;
4261
            }
4263 4262
            
4264
            if (createDate == null)
4265
            {
4266
                createDate = DatabaseService.getInstance().getDBAdapter().getDateTimeFunction();
4267
            }
4268
            else
4269
            {
4270
                createDate = DatabaseService.getInstance().getDBAdapter().toDate(createDate, "YYYY-MM-DD HH24:MI:SS");
4271
            }
4272 4263
            logMetacat.debug("DocumentImpl.writeDocumentToRevisionTable - the create date is "+createDate);
4273
            if (updateDate == null)
4274
            {
4275
                updateDate = DatabaseService.getInstance().getDBAdapter().getDateTimeFunction();
4264
            if (updateDate == null){
4265
                updateDate = today;
4276 4266
            }
4277
            else
4278
            {
4279
                updateDate = DatabaseService.getInstance().getDBAdapter().toDate(updateDate, "YYYY-MM-DD HH24:MI:SS");
4280
            }
4281 4267
            logMetacat.debug("DocumentImpl.writeDocumentToRevisionTable - the update date is "+updateDate);
4282 4268
            PreparedStatement pstmt = null;
4283 4269
            String sql = null;
......
4289 4275
                   + "(docid, docname, doctype, user_owner, "
4290 4276
                   + "user_updated, date_created, date_updated, "
4291 4277
                   + "public_access, server_location, rev) "
4292
                   + "VALUES (?, ?, ?, ?, ?, " + createDate + ", "
4293
                   + updateDate + ", ?, ?, ?)";
4278
                   + "VALUES (?, ?, ?, ?, ?, ?,"
4279
                   + " ?, ?, ?, ?)";
4294 4280
            }
4295 4281
            else
4296 4282
            {
......
4300 4286
                    + "(docid, docname, doctype, user_owner, "
4301 4287
                    + "user_updated, date_created, date_updated, "
4302 4288
                    + "public_access, server_location, rev, catalog_id, rootnodeid ) "
4303
                    + "VALUES (?, ?, ?, ?, ?, " + createDate + ", "
4304
                    + updateDate + ", ?, ?, ?, ?, ?)";
4289
                    + "VALUES (?, ?, ?, ?, ?, ?, "
4290
                    + "?, ?, ?, ?, ?)";
4305 4291
                }
4306 4292
                else
4307 4293
                {
......
4309 4295
                        + "(docid, docname, doctype, user_owner, "
4310 4296
                        + "user_updated, date_created, date_updated, "
4311 4297
                        + "public_access, server_location, rev, rootnodeid ) "
4312
                        + "VALUES (?, ?, ?, ?, ?, " + createDate + ", "
4313
                        + updateDate + ", ?, ?, ?, ?)";
4298
                        + "VALUES (?, ?, ?, ?, ?, ?, "
4299
                        + "?, ?, ?, ?, ?)";
4314 4300
                }
4315 4301
            }
4316 4302
            pstmt = con.prepareStatement(sql);
......
4328 4314
            logMetacat.debug("DocumentImpl.writeDocumentToRevisionTable - onwer is "+user);
4329 4315
            pstmt.setString(5, user);
4330 4316
            logMetacat.debug("DocumentImpl.writeDocumentToRevisionTable - update user is "+user);
4331
            pstmt.setInt(6, 0);
4317
            pstmt.setTimestamp(6, new Timestamp(createDate.getTime()));
4318
            pstmt.setTimestamp(7, new Timestamp(updateDate.getTime()));
4332 4319
            
4333
            pstmt.setInt(7, serverCode);
4320
            pstmt.setInt(8, 0);
4321
            
4322
            pstmt.setInt(9, serverCode);
4334 4323
            logMetacat.debug("DocumentImpl.writeDocumentToRevisionTable - server code is "+serverCode);
4335
            pstmt.setInt(8, Integer.parseInt(rev));
4324
            pstmt.setInt(10, Integer.parseInt(rev));
4336 4325
            logMetacat.debug("DocumentImpl.writeDocumentToRevisionTable - rev is "+rev);
4337 4326
            
4338
            if (rootNodeId >0 )
4327
            if (rootNodeId > 0 )
4339 4328
            {
4340 4329
              if (catalogid != null)
4341 4330
              {
4342
                pstmt.setInt(9, (new Integer(catalogid)).intValue());
4331
                pstmt.setInt(11, (new Integer(catalogid)).intValue());
4343 4332
                logMetacat.debug("DocumentImpl.writeDocumentToRevisionTable - catalog id is "+catalogid);
4344
                pstmt.setLong(10, rootNodeId);
4333
                pstmt.setLong(12, rootNodeId);
4345 4334
                logMetacat.debug("DocumentImpl.writeDocumentToRevisionTable - root id is "+rootNodeId);
4346 4335
              }
4347 4336
              else
4348 4337
              {
4349
                 pstmt.setLong(9, rootNodeId);
4338
                 pstmt.setLong(11, rootNodeId);
4350 4339
                 logMetacat.debug("DocumentImpl.writeDocumentToRevisionTable - root id is "+rootNodeId); 
4351 4340
              }
4352 4341
            }
......
4379 4368
     */
4380 4369
    static private void registerDeletedDataFile(String docname,
4381 4370
            String doctype, String accnum, String user, int serverCode, 
4382
            String createDate, String updateDate) throws Exception
4371
            Date createDate, Date updateDate) throws Exception
4383 4372
    {
4384 4373
        DBConnection dbconn = null;
4385 4374
        int serialNumber = -1;
......
4421 4410
    	logMetacat.debug("DocumentImpl.deleteXMLNodes - for root Id: " + rootId);
4422 4411
        PreparedStatement pstmt = null;
4423 4412
        double start = System.currentTimeMillis()/1000;
4424
        String sql = "DELETE FROM xml_nodes WHERE rootnodeid ="+ rootId;
4413
        String sql = "DELETE FROM xml_nodes WHERE rootnodeid = ? ";
4425 4414
        pstmt = dbconn.prepareStatement(sql);
4415
        pstmt.setLong(1, rootId);
4426 4416
        // Increase dbconnection usage count
4427 4417
        dbconn.increaseUsageCount(1);
4428 4418
        logMetacat.debug("DocumentImpl.deleteXMLNodes - executing SQL: " + pstmt.toString());

Also available in: Unified diff