Project

General

Profile

« Previous | Next » 

Revision 2703

Added by Jing Tao about 19 years ago

Add code to handle catalog is null when inserting xml_revisions table.

View differences:

src/edu/ucsb/nceas/metacat/DocumentImpl.java
3622 3622
               sql = "INSERT INTO xml_revisions "
3623 3623
                   + "(docid, docname, doctype, user_owner, "
3624 3624
                   + "user_updated, date_created, date_updated, "
3625
                   + "public_access, catalog_id, server_location, rev) "
3625
                   + "public_access, server_location, rev) "
3626 3626
                   + "VALUES (?, ?, ?, ?, ?, " + createDate + ", "
3627
                   + updateDate + ", ?, ?, ?, ?)";
3627
                   + updateDate + ", ?, ?, ?)";
3628 3628
            }
3629 3629
            else
3630 3630
            {
3631
            	sql = "INSERT INTO xml_revisions "
3632
                + "(docid, docname, doctype, user_owner, "
3633
                + "user_updated, date_created, date_updated, "
3634
                + "public_access, catalog_id, server_location, rev, rootnodeid ) "
3635
                + "VALUES (?, ?, ?, ?, ?, " + createDate + ", "
3636
                + updateDate + ", ?, ?, ?, ?, ?)";
3631
            	if (catalogid != null)
3632
                {
3633
                    sql = "INSERT INTO xml_revisions "
3634
                    + "(docid, docname, doctype, user_owner, "
3635
                    + "user_updated, date_created, date_updated, "
3636
                    + "public_access, server_location, rev, catalog_id, rootnodeid ) "
3637
                    + "VALUES (?, ?, ?, ?, ?, " + createDate + ", "
3638
                    + updateDate + ", ?, ?, ?, ?, ?)";
3639
                }
3640
                else
3641
                {
3642
                    sql = "INSERT INTO xml_revisions "
3643
                        + "(docid, docname, doctype, user_owner, "
3644
                        + "user_updated, date_created, date_updated, "
3645
                        + "public_access, server_location, rev, rootnodeid ) "
3646
                        + "VALUES (?, ?, ?, ?, ?, " + createDate + ", "
3647
                        + updateDate + ", ?, ?, ?, ?)";
3648
                }
3637 3649
            }
3638 3650
            pstmt = con.prepareStatement(sql);
3639 3651
             // Increase dbconnection usage count
......
3651 3663
            pstmt.setString(5, user);
3652 3664
            logMetacat.info("update user is "+user);
3653 3665
            pstmt.setInt(6, 0);
3654
            pstmt.setInt(7, (new Integer(catalogid)).intValue());
3655
            logMetacat.info("catalogid is "+catalogid);
3656
            pstmt.setInt(8, serverCode);
3666
            
3667
            pstmt.setInt(7, serverCode);
3657 3668
            logMetacat.info("server code is "+serverCode);
3658
            pstmt.setInt(9, Integer.parseInt(rev));
3669
            pstmt.setInt(8, Integer.parseInt(rev));
3659 3670
            logMetacat.info("rev is "+rev);
3660 3671
            
3661 3672
            if (rootNodeId >0 )
3662 3673
            {
3663
              pstmt.setLong(10, rootNodeId);
3664
              logMetacat.info("root id is "+rootNodeId);
3674
              if (catalogid != null)
3675
              {
3676
                pstmt.setInt(9, (new Integer(catalogid)).intValue());
3677
                logMetacat.info("catalogid is "+catalogid);
3678
                pstmt.setLong(10, rootNodeId);
3679
                logMetacat.info("root id is "+rootNodeId);
3680
              }
3681
              else
3682
              {
3683
                 pstmt.setLong(9, rootNodeId);
3684
                 logMetacat.info("root id is "+rootNodeId); 
3685
              }
3665 3686
            }
3666 3687
            // Do the insertion
3667 3688
            pstmt.execute();

Also available in: Unified diff