Project

General

Profile

« Previous | Next » 

Revision 1629

Added by Jing Tao over 21 years ago

Add code to hanlder wirte and update funtion.

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
1725 1725
                               needSchemaValidate, 10);
1726 1726
      return needSchemaValidate;
1727 1727
    }
1728
    else if (xml.indexOf(SCHEMALOCATIONKEYWORD) != -1 ||
1729
             xml.indexOf(NONAMESPACELOCATION) != -1 )
1728
    String targetLine = getSchemaLine(xml);
1729
    // to see if the second line contain some keywords 
1730
    if (targetLine != null && (targetLine.indexOf(SCHEMALOCATIONKEYWORD) != -1||
1731
             targetLine.indexOf(NONAMESPACELOCATION) != -1 ))
1730 1732
    {
1731 1733
      // if contains schema location key word, should be validate
1732 1734
      needSchemaValidate = true;
......
1749 1751
                               needEml2Validate, 10);
1750 1752
      return needEml2Validate;
1751 1753
    }
1752
    else if (xml.indexOf(EML2KEYWORD) != -1 && xml.indexOf(emlNameSpace) != -1)
1754
    String targetLine = getSchemaLine(xml);
1755
    
1756
    if (targetLine != null && targetLine.indexOf(EML2KEYWORD) != -1 && 
1757
        targetLine.indexOf(emlNameSpace) != -1)
1753 1758
    {
1754 1759
      // if contains schema location key word, should be validate
1755 1760
      needEml2Validate = true;
......
1761 1766
   
1762 1767
  }
1763 1768
  
1769
  private String getSchemaLine(String xml)
1770
  {
1771
    // find the line
1772
    String secondLine = null;
1773
    int count =0;
1774
    int endIndex = 0;
1775
    int startIndex = 0;
1776
    final int TARGETNUM = 2;
1777
    for (int i=0; i<xml.length(); i++)
1778
    {
1779
      // didn't count comment
1780
      if (xml.charAt(i) =='<' && xml.charAt(i+1) != '!')
1781
      {
1782
        count ++;
1783
        //find start index
1784
        if (count == TARGETNUM)
1785
        {
1786
          startIndex = i;
1787
        }
1788
      }//if
1789
      // find the end index
1790
      if (count== TARGETNUM && xml.charAt(i) =='>')
1791
      {
1792
        endIndex = i;
1793
        break;
1794
      }//if
1795
    }//for
1796
    // get the second line string 
1797
    MetaCatUtil.debugMessage("The start index for second line: "+startIndex, 25);
1798
    MetaCatUtil.debugMessage("The end index for second line: "+endIndex, 25);
1799
    if (startIndex != 0 && endIndex != 0)
1800
    {
1801
      secondLine = xml.substring(startIndex+1, endIndex);
1802
      
1803
    }//if
1804
    MetaCatUtil.debugMessage("the second line string is: "+secondLine, 25);
1805
    return secondLine;
1806
  }
1807
  
1764 1808
  // DELETE SECTION
1765 1809
  /**
1766 1810
   * Handle the database delete request and delete an XML document

Also available in: Unified diff