Revision 1482
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
836 | 836 |
ZipOutputStream zout = null; |
837 | 837 |
PrintWriter pw = null; |
838 | 838 |
boolean zip = false; |
839 |
boolean withInlineData = true; |
|
839 | 840 |
|
840 | 841 |
try { |
841 | 842 |
String[] docs = new String[0]; |
... | ... | |
850 | 851 |
if (params.containsKey("qformat")) { |
851 | 852 |
qformat = ((String[])params.get("qformat"))[0]; |
852 | 853 |
} |
854 |
// the param for only metadata (eml) |
|
855 |
if (params.containsKey("inlinedata")) |
|
856 |
{ |
|
857 |
|
|
858 |
String inlineData = ((String[])params.get("inlinedata"))[0]; |
|
859 |
if (inlineData.equalsIgnoreCase("false")) |
|
860 |
{ |
|
861 |
withInlineData = false; |
|
862 |
} |
|
863 |
} |
|
853 | 864 |
if (params.containsKey("abstractpath")) { |
854 | 865 |
abstrpath = ((String[])params.get("abstractpath"))[0]; |
855 | 866 |
if ( !abstrpath.equals("") && (abstrpath != null) ) { |
... | ... | |
878 | 889 |
addDocToZip(docid, zout, user, groups); |
879 | 890 |
} else { |
880 | 891 |
readFromMetacat(response, docid, qformat, abstrpath, |
881 |
user, groups, zip, zout); |
|
892 |
user, groups, zip, zout, withInlineData);
|
|
882 | 893 |
} |
883 | 894 |
|
884 | 895 |
// case docid="http://.../filename" |
... | ... | |
898 | 909 |
addDocToZip(docid, zout, user, groups); |
899 | 910 |
} else { |
900 | 911 |
readFromMetacat(response, docid, qformat, abstrpath, |
901 |
user, groups, zip, zout); |
|
912 |
user, groups, zip, zout, withInlineData);
|
|
902 | 913 |
} |
903 | 914 |
} |
904 | 915 |
|
... | ... | |
1024 | 1035 |
|
1025 | 1036 |
} |
1026 | 1037 |
|
1027 |
System.out.println("Error in MetacatServlet.handleReadAction: " +
|
|
1028 |
e.getMessage());
|
|
1029 |
e.printStackTrace(System.out); |
|
1038 |
MetaCatUtil.debugMessage("Error in MetacatServlet.handleReadAction: " +
|
|
1039 |
e.getMessage(), 30);
|
|
1040 |
//e.printStackTrace(System.out);
|
|
1030 | 1041 |
} |
1031 | 1042 |
|
1032 | 1043 |
} |
... | ... | |
1034 | 1045 |
// read metadata or data from Metacat |
1035 | 1046 |
private void readFromMetacat(HttpServletResponse response, String docid, |
1036 | 1047 |
String qformat, String abstrpath, String user, |
1037 |
String[] groups, boolean zip, ZipOutputStream zout) |
|
1048 |
String[] groups, boolean zip, |
|
1049 |
ZipOutputStream zout, boolean withInlineData) |
|
1038 | 1050 |
throws ClassNotFoundException, IOException, SQLException, |
1039 | 1051 |
McdbException, Exception |
1040 | 1052 |
{ |
... | ... | |
1109 | 1121 |
// set content type first |
1110 | 1122 |
response.setContentType("text/xml"); //MIME type |
1111 | 1123 |
PrintWriter out = response.getWriter(); |
1112 |
doc.toXml(out, user, groups); |
|
1124 |
doc.toXml(out, user, groups, withInlineData);
|
|
1113 | 1125 |
} else { |
1114 | 1126 |
response.setContentType("text/html"); //MIME type |
1115 | 1127 |
PrintWriter out = response.getWriter(); |
... | ... | |
1118 | 1130 |
String doctype = doc.getDoctype(); |
1119 | 1131 |
// Transform the document to the new doctype |
1120 | 1132 |
DBTransform dbt = new DBTransform(); |
1121 |
dbt.transformXMLDocument(doc.toString(user, groups), |
|
1133 |
dbt.transformXMLDocument(doc.toString(user, groups, withInlineData),
|
|
1122 | 1134 |
doctype,"-//W3C//HTML//EN", qformat, out); |
1123 | 1135 |
} |
1124 | 1136 |
|
Also available in: Unified diff
Add a flag in read action that the user want inline data in xml document or not.