Revision 1041
Added by Jing Tao over 22 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
1683 | 1683 |
Connection conn = null; |
1684 | 1684 |
String action = null; |
1685 | 1685 |
String docid = null; |
1686 |
|
|
1686 |
|
|
1687 | 1687 |
response.setContentType("text/xml"); |
1688 |
try { |
|
1688 |
try |
|
1689 |
{ |
|
1689 | 1690 |
out = response.getWriter(); |
1690 |
} catch (IOException ioe2) { |
|
1691 |
} |
|
1692 |
catch (IOException ioe2) |
|
1693 |
{ |
|
1691 | 1694 |
System.err.println("Fatal Error: couldn't get response output stream."); |
1692 | 1695 |
} |
1693 | 1696 |
|
1694 |
if (params.containsKey("docid")) { |
|
1697 |
if (params.containsKey("docid")) |
|
1698 |
{ |
|
1695 | 1699 |
docid = (String)params.get("docid"); |
1696 | 1700 |
} |
1697 | 1701 |
|
... | ... | |
1722 | 1726 |
if ((util.getOption("replicationdata")).equals("on")) |
1723 | 1727 |
{ |
1724 | 1728 |
// force replcation data file if metacat was configured |
1725 |
ForceReplicationHandler frh = new |
|
1726 |
ForceReplicationHandler(docid, "insert", false); |
|
1727 |
} |
|
1729 |
if (ReplicationHandler.getServerLocation(docid)==1) |
|
1730 |
{//local host document |
|
1731 |
conn=util.getConnection(); |
|
1732 |
ForceReplicationHandler frh = new ForceReplicationHandler |
|
1733 |
(docid, "insert", false, ReplicationHandler.buildServerList(conn)); |
|
1734 |
util.returnConnection(conn); |
|
1735 |
}//if |
|
1736 |
else |
|
1737 |
{ |
|
1738 |
//if it is super hub, replication to server list |
|
1739 |
if ((util.getOption("hub")).equals("super")) |
|
1740 |
{ |
|
1741 |
ForceReplicationHandler frh = new ForceReplicationHandler |
|
1742 |
(docid,true, ReplicationHandler.buildServerList(conn)); |
|
1743 |
util.returnConnection(conn); |
|
1744 |
}//if |
|
1745 |
else |
|
1746 |
{ |
|
1747 |
//only replicate to home host of the document |
|
1748 |
String id=util.getDocIdFromString(docid); |
|
1749 |
ForceReplicationHandler frh = new ForceReplicationHandler |
|
1750 |
(docid, true, ReplicationHandler.getHomeServer(id)); |
|
1751 |
}//else |
|
1752 |
}//else |
|
1753 |
}//if |
|
1728 | 1754 |
// set content type and other response header fields first |
1729 | 1755 |
out.println("<?xml version=\"1.0\"?>"); |
1730 | 1756 |
out.println("<success>"); |
1731 | 1757 |
out.println("<docid>" + docid + "</docid>"); |
1732 | 1758 |
out.println("<size>" + size + "</size>"); |
1733 | 1759 |
out.println("</success>"); |
1734 |
}//if
|
|
1760 |
}//if |
|
1735 | 1761 |
|
1736 | 1762 |
} //try |
1737 |
catch (Exception e) { |
|
1763 |
catch (Exception e) |
|
1764 |
{ |
|
1738 | 1765 |
out.println("<?xml version=\"1.0\"?>"); |
1739 | 1766 |
out.println("<error>"); |
1740 | 1767 |
out.println(e.getMessage()); |
1741 | 1768 |
out.println("</error>"); |
1742 | 1769 |
} |
1743 |
} else { |
|
1770 |
finally |
|
1771 |
{ |
|
1772 |
util.returnConnection(conn); |
|
1773 |
} |
|
1774 |
} |
|
1775 |
else |
|
1776 |
{ |
|
1744 | 1777 |
// the field did not contain a file |
1745 | 1778 |
out.println("<?xml version=\"1.0\"?>"); |
1746 | 1779 |
out.println("<error>"); |
1747 | 1780 |
out.println("The uploaded data did not contain a valid file."); |
1748 | 1781 |
out.println("</error>"); |
1749 | 1782 |
} |
1750 |
} else { |
|
1783 |
} |
|
1784 |
else |
|
1785 |
{ |
|
1751 | 1786 |
// Error bcse docid missing or file missing |
1752 | 1787 |
out.println("<?xml version=\"1.0\"?>"); |
1753 | 1788 |
out.println("<error>"); |
Also available in: Unified diff
Adding a hub control to data file in handleUpLoad method. Data file was changed can be replicate to all server or only home host.