Project

General

Profile

« Previous | Next » 

Revision 847

Added by Matt Jones over 22 years ago

Fixed the function to return the max id for a given scope. Now the function
takes a parameter named 'scope' and returns the largest docid that has been
used under that scope in this metacat instance (it used to return the most
recently created docid, which is clearly different). For compatibility with
older versions of metacat the routine falls back to using the username
parameter if scope is not provided, but this is deprecated in favor of using
the scope parameter.

View differences:

MetaCatServlet.java
327 327
        handleGetDataGuideAction(out, params, response);  
328 328
      } else if (action.equals("getlastdocid")) {
329 329
        PrintWriter out = response.getWriter();
330
        handleGetLastDocidAction(out, params, response);  
330
        handleGetMaxDocidAction(out, params, response);  
331 331
      } else if (action.equals("login") || action.equals("logout")) {
332 332
      } else if (action.equals("protocoltest")) {
333 333
        String testURL = "metacat://dev.nceas.ucsb.edu/NCEAS.897766.9";
......
1445 1445
   * Handle the "getlastdocid" action.
1446 1446
   * Get the latest docid with rev number from db connection in XML format
1447 1447
   */
1448
  private void handleGetLastDocidAction(PrintWriter out, Hashtable params, 
1448
  private void handleGetMaxDocidAction(PrintWriter out, Hashtable params, 
1449 1449
                                        HttpServletResponse response) {
1450 1450

  
1451 1451
    Connection conn = null;
1452
    String username = ((String[])params.get("username"))[0];
1452
    String scope = ((String[])params.get("scope"))[0];
1453
    if (scope == null) {
1454
        scope = ((String[])params.get("username"))[0];
1455
    }
1453 1456

  
1454 1457
    try {
1455 1458

  
1456 1459
        // get connection from the pool
1457 1460
        conn = util.getConnection();
1458 1461
        DBUtil dbutil = new DBUtil(conn);
1459
        String lastDocid = dbutil.getLastDocid(username);
1462
        String lastDocid = dbutil.getMaxDocid(scope);
1460 1463
        out.println("<?xml version=\"1.0\"?>");
1461 1464
        out.println("<lastDocid>");
1462
        out.println("  <username>" + username + "</username>");
1465
        out.println("  <scope>" + scope + "</scope>");
1463 1466
        out.println("  <docid>" + lastDocid + "</docid>");
1464 1467
        out.println("</lastDocid>");
1465 1468

  

Also available in: Unified diff