Revision 2251
Added by sgarg over 20 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
1755 | 1755 |
|
1756 | 1756 |
String[] docid = (String[]) params.get("docid"); |
1757 | 1757 |
|
1758 |
// delete the document from the database |
|
1759 |
try { |
|
1758 |
if(docid == null){ |
|
1759 |
response.setContentType("text/xml"); |
|
1760 |
out.println("<?xml version=\"1.0\"?>"); |
|
1761 |
out.println("<error>"); |
|
1762 |
out.println("No docid specified."); |
|
1763 |
out.println("</error>"); |
|
1764 |
} else { |
|
1760 | 1765 |
|
1761 |
// NOTE -- NEED TO TEST HERE |
|
1762 |
// FOR EXISTENCE OF DOCID PARAM |
|
1763 |
// BEFORE ACCESSING ARRAY |
|
1766 |
// delete the document from the database |
|
1764 | 1767 |
try { |
1765 |
DocumentImpl.delete(docid[0], user, groups); |
|
1766 |
EventLog.getInstance().log(request.getRemoteAddr(), |
|
1767 |
user, docid[0], "delete"); |
|
1768 |
|
|
1769 |
try { |
|
1770 |
DocumentImpl.delete(docid[0], user, groups); |
|
1771 |
EventLog.getInstance().log(request.getRemoteAddr(), |
|
1772 |
user, docid[0], "delete"); |
|
1773 |
response.setContentType("text/xml"); |
|
1774 |
out.println("<?xml version=\"1.0\"?>"); |
|
1775 |
out.println("<success>"); |
|
1776 |
out.println("Document deleted."); |
|
1777 |
out.println("</success>"); |
|
1778 |
} |
|
1779 |
catch (AccessionNumberException ane) { |
|
1780 |
response.setContentType("text/xml"); |
|
1781 |
out.println("<?xml version=\"1.0\"?>"); |
|
1782 |
out.println("<error>"); |
|
1783 |
out.println("Error deleting document!!!"); |
|
1784 |
out.println(ane.getMessage()); |
|
1785 |
out.println("</error>"); |
|
1786 |
} |
|
1787 |
} |
|
1788 |
catch (Exception e) { |
|
1768 | 1789 |
response.setContentType("text/xml"); |
1769 | 1790 |
out.println("<?xml version=\"1.0\"?>"); |
1770 |
out.println("<success>"); |
|
1771 |
out.println("Document deleted."); |
|
1772 |
out.println("</success>"); |
|
1773 |
} catch (AccessionNumberException ane) { |
|
1774 |
response.setContentType("text/xml"); |
|
1775 |
out.println("<?xml version=\"1.0\"?>"); |
|
1776 | 1791 |
out.println("<error>"); |
1777 |
out.println("Error deleting document!!!"); |
|
1778 |
out.println(ane.getMessage()); |
|
1792 |
out.println(e.getMessage()); |
|
1779 | 1793 |
out.println("</error>"); |
1780 | 1794 |
} |
1781 |
} catch (Exception e) { |
|
1782 |
response.setContentType("text/xml"); |
|
1783 |
out.println("<?xml version=\"1.0\"?>"); |
|
1784 |
out.println("<error>"); |
|
1785 |
out.println(e.getMessage()); |
|
1786 |
out.println("</error>"); |
|
1787 | 1795 |
} |
1788 | 1796 |
} |
1789 | 1797 |
|
Also available in: Unified diff
Added check for null condition so that proper error text is returned to user.