Project

General

Profile

« Previous | Next » 

Revision 1342

Added by Jing Tao almost 22 years ago

Change the code for validation.

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
338 338
        out.close();
339 339
      } else if (action.equals("validate")) {
340 340
        PrintWriter out = response.getWriter();
341
        handleValidateAction(out, params, response);
341
        handleValidateAction(out, params);
342 342
        out.close();
343 343
      } else if (action.equals("getaccesscontrol")) {
344 344
        PrintWriter out = response.getWriter();
......
1543 1543
  /** 
1544 1544
   * Handle the validation request and return the results to the requestor
1545 1545
   */
1546
  private void handleValidateAction(PrintWriter out, Hashtable params, 
1547
               HttpServletResponse response) {
1546
  private void handleValidateAction(PrintWriter out, Hashtable params) {
1548 1547

  
1549 1548
    // Get the document indicated
1550 1549
    String valtext = null;
......
1567 1566
        valtext = xmldoc.toString();
1568 1567

  
1569 1568
      } catch (NullPointerException npe) {
1570
        response.setContentType("text/xml");
1569
        
1571 1570
        out.println("<error>Error getting document ID: " + docid + "</error>");
1572 1571
        //if ( conn != null ) { util.returnConnection(conn); }
1573 1572
        return;
1574 1573
      } catch (Exception e) {
1575
        response.setContentType("text/html");
1574
       
1576 1575
        out.println(e.getMessage()); 
1577 1576
      } 
1578 1577
    }
......
1587 1586
      boolean valid = valobj.validateString(valtext);
1588 1587

  
1589 1588
      // set content type and other response header fields first
1590
      response.setContentType("text/xml");
1589
      
1591 1590
      out.println(valobj.returnErrors());
1592 1591

  
1593 1592
    } catch (NullPointerException npe2) {
1594 1593
      // set content type and other response header fields first
1595
      response.setContentType("text/xml");
1594
      
1596 1595
      out.println("<error>Error validating document.</error>"); 
1597 1596
    } catch (Exception e) {
1598
      response.setContentType("text/html");
1597
     
1599 1598
      out.println(e.getMessage()); 
1600 1599
    } finally {
1601 1600
      // Return db connection

Also available in: Unified diff