Project

General

Profile

« Previous | Next » 

Revision 3140

Added by berkley over 17 years ago

added getalldocids function to get all docids that match a certain scope.

View differences:

MetaCatServlet.java
104 104
 * <br>
105 105
 * valtext -- XML text to be validated <br>
106 106
 * action=getaccesscontrol -- retrieve acl info for Metacat document <br>
107
 * action=getalldocids -- retrieves a list of all docids registered with the system<br>
108
 * scope --can limit the query by the scope of the id
107 109
 * action=getdoctypes -- retrieve all doctypes (publicID) <br>
108 110
 * action=getdtdschema -- retrieve a DTD or Schema file <br>
109 111
 * action=getdataguide -- retrieve a Data Guide <br>
......
699 701
                PrintWriter out = response.getWriter();
700 702
                handleGetMaxDocidAction(out, params, response);
701 703
                out.close();
704
            } else if (action.equals("getalldocids")) {
705
                PrintWriter out = response.getWriter();
706
                handleGetAllDocidsAction(out, params, response);
707
                out.close();
702 708
            } else if (action.equals("getrevisionanddoctype")) {
703 709
                PrintWriter out = response.getWriter();
704 710
                handleGetRevisionAndDocTypeAction(out, params);
......
2495 2501
        }
2496 2502

  
2497 2503
    }
2504
    
2505
    /**
2506
     * Handle the "getalldocids" action. return a list of all docids registered
2507
     * in the system
2508
     */
2509
    private void handleGetAllDocidsAction(PrintWriter out, Hashtable params,
2510
            HttpServletResponse response)
2511
    {
2512
        String scope = null;
2513
        if(params.get("scope") != null)
2514
        {
2515
          scope = ((String[]) params.get("scope"))[0];
2516
        }
2517
        
2518
        try {
2519
            DBUtil dbutil = new DBUtil();
2520
            Vector docids = dbutil.getAllDocids(scope);
2521
            out.println("<?xml version=\"1.0\"?>");
2522
            out.println("<idList>");
2523
            out.println("  <scope>" + scope + "</scope>");
2524
            for(int i=0; i<docids.size(); i++)
2525
            {
2526
              String docid = (String)docids.elementAt(i);
2527
              out.println("  <docid>" + docid + "</docid>");
2528
            }
2529
            out.println("</idList>");
2498 2530

  
2531
        } catch (Exception e) {
2532
            out.println("<?xml version=\"1.0\"?>");
2533
            out.println("<error>");
2534
            out.println(e.getMessage());
2535
            out.println("</error>");
2536
        }
2537
    }
2538

  
2499 2539
    /**
2500 2540
     * Handle the "getlastdocid" action. Get the latest docid with rev number
2501 2541
     * from db connection in XML format

Also available in: Unified diff