Revision 1466
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
121 | 121 |
private static final String SUCCESSCLOSE = "</success>"; |
122 | 122 |
private static final String ERROR = "<error>"; |
123 | 123 |
private static final String ERRORCLOSE = "</error>"; |
124 |
public static final String SCHEMALOCATIONKEYWORD = "xsi:schemaLocation"; |
|
124 |
public static final String SCHEMALOCATIONKEYWORD = ":schemaLocation"; |
|
125 |
public static final String NONAMESPACELOCATION = ":noNamespaceSchemaLocation"; |
|
125 | 126 |
public static final String EML2KEYWORD ="<eml:eml"; |
126 | 127 |
|
127 | 128 |
/** |
... | ... | |
1437 | 1438 |
newdocid = documentWrapper.write(dbConn, xml, pub, dtd, doAction, |
1438 | 1439 |
null, user, groups); |
1439 | 1440 |
}//catch |
1441 |
|
|
1440 | 1442 |
}//try |
1441 | 1443 |
finally |
1442 | 1444 |
{ |
... | ... | |
1451 | 1453 |
out.println("<docid>" + newdocid + "</docid>"); |
1452 | 1454 |
out.println("</success>"); |
1453 | 1455 |
|
1454 |
} catch (NullPointerException npe) { |
|
1456 |
} |
|
1457 |
catch (NullPointerException npe) |
|
1458 |
{ |
|
1455 | 1459 |
//response.setContentType("text/xml"); |
1456 | 1460 |
out.println("<?xml version=\"1.0\"?>"); |
1457 | 1461 |
out.println("<error>"); |
1458 | 1462 |
out.println(npe.getMessage()); |
1459 | 1463 |
out.println("</error>"); |
1460 | 1464 |
} |
1461 |
} catch (Exception e) { |
|
1465 |
} |
|
1466 |
catch (Exception e) |
|
1467 |
{ |
|
1462 | 1468 |
//response.setContentType("text/xml"); |
1463 | 1469 |
out.println("<?xml version=\"1.0\"?>"); |
1464 | 1470 |
out.println("<error>"); |
1465 | 1471 |
out.println(e.getMessage()); |
1466 |
if (e instanceof SAXException) { |
|
1467 |
Exception e2 = ((SAXException)e).getException(); |
|
1468 |
out.println("<error>"); |
|
1469 |
try |
|
1470 |
{ |
|
1471 |
out.println(e2.getMessage()); |
|
1472 |
} |
|
1473 |
catch(NullPointerException npe) |
|
1474 |
{ |
|
1475 |
out.println(e.getMessage()); |
|
1476 |
} |
|
1477 |
out.println("</error>"); |
|
1478 |
} |
|
1479 |
//e.printStackTrace(out); |
|
1480 | 1472 |
out.println("</error>"); |
1481 | 1473 |
} |
1482 | 1474 |
} |
... | ... | |
1551 | 1543 |
needSchemaValidate, 10); |
1552 | 1544 |
return needSchemaValidate; |
1553 | 1545 |
} |
1554 |
else if (xml.indexOf(SCHEMALOCATIONKEYWORD) != -1) |
|
1546 |
else if (xml.indexOf(SCHEMALOCATIONKEYWORD) != -1 || |
|
1547 |
xml.indexOf(NONAMESPACELOCATION) != -1 ) |
|
1555 | 1548 |
{ |
1556 | 1549 |
// if contains schema location key word, should be validate |
1557 | 1550 |
needSchemaValidate = true; |
... | ... | |
1579 | 1572 |
needEml2Validate = true; |
1580 | 1573 |
} |
1581 | 1574 |
|
1582 |
MetaCatUtil.debugMessage("Validation for schema is " +
|
|
1575 |
MetaCatUtil.debugMessage("Validation for eml is " +
|
|
1583 | 1576 |
needEml2Validate, 10); |
1584 | 1577 |
return needEml2Validate; |
1585 | 1578 |
|
Also available in: Unified diff
Add code to handle validate xml instance by noNamespaceSchemaLocation.