Revision 1028
Added by Jing Tao over 22 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
1706 | 1706 |
// Check if the right file existed in the uploaded data |
1707 | 1707 |
if (fileName != null) { |
1708 | 1708 |
|
1709 |
try { |
|
1710 |
// register the file in the database (which generates an exception if |
|
1711 |
// the docid is not acceptable or other untoward things happen |
|
1712 |
DocumentImpl.registerDocument(fileName, "BIN", docid, username, 1); |
|
1709 |
try |
|
1710 |
{ |
|
1711 |
//If document get lock data file grant |
|
1712 |
if (DocumentImpl.getDataFileLockGrant(docid)) |
|
1713 |
{ |
|
1714 |
// register the file in the database (which generates an exception |
|
1715 |
//if the docid is not acceptable or other untoward things happen |
|
1716 |
DocumentImpl.registerDocument(fileName, "BIN", docid, username); |
|
1713 | 1717 |
|
1714 |
// Save the data file to disk using "docid" as the name |
|
1715 |
dataDirectory.mkdirs(); |
|
1716 |
File newFile = new File(dataDirectory, docid); |
|
1717 |
long size = filePart.writeTo(newFile); |
|
1718 |
|
|
1719 |
// set content type and other response header fields first |
|
1720 |
out.println("<?xml version=\"1.0\"?>"); |
|
1721 |
out.println("<success>"); |
|
1722 |
out.println("<docid>" + docid + "</docid>"); |
|
1723 |
out.println("<size>" + size + "</size>"); |
|
1724 |
out.println("</success>"); |
|
1718 |
// Save the data file to disk using "docid" as the name |
|
1719 |
dataDirectory.mkdirs(); |
|
1720 |
File newFile = new File(dataDirectory, docid); |
|
1721 |
long size = filePart.writeTo(newFile); |
|
1722 |
if ((util.getOption("replicationdata")).equals("on")) |
|
1723 |
{ |
|
1724 |
// force replcation data file if metacat was configured |
|
1725 |
ForceReplicationHandler frh = new |
|
1726 |
ForceReplicationHandler(docid, "insert", false); |
|
1727 |
} |
|
1728 |
// set content type and other response header fields first |
|
1729 |
out.println("<?xml version=\"1.0\"?>"); |
|
1730 |
out.println("<success>"); |
|
1731 |
out.println("<docid>" + docid + "</docid>"); |
|
1732 |
out.println("<size>" + size + "</size>"); |
|
1733 |
out.println("</success>"); |
|
1734 |
}//if |
|
1725 | 1735 |
|
1726 |
} catch (Exception e) { |
|
1736 |
} //try |
|
1737 |
catch (Exception e) { |
|
1727 | 1738 |
out.println("<?xml version=\"1.0\"?>"); |
1728 | 1739 |
out.println("<error>"); |
1729 | 1740 |
out.println(e.getMessage()); |
Also available in: Unified diff
Adding a new feature that in uploaddatafile that the datafile can be replicated.