Revision 8948
Added by Jing Tao over 9 years ago
D1NodeService.java | ||
---|---|---|
402 | 402 |
if ( isScienceMetadata(sysmeta) ) { |
403 | 403 |
|
404 | 404 |
// CASE METADATA: |
405 |
String objectAsXML = ""; |
|
405 |
//String objectAsXML = "";
|
|
406 | 406 |
try { |
407 |
objectAsXML = IOUtils.toString(object, "UTF-8"); |
|
408 |
localId = insertOrUpdateDocument(objectAsXML, pid, session, "insert");
|
|
407 |
//objectAsXML = IOUtils.toString(object, "UTF-8");
|
|
408 |
localId = insertOrUpdateDocument(object,"UTF-8", pid, session, "insert");
|
|
409 | 409 |
//localId = im.getLocalId(pid.getValue()); |
410 | 410 |
|
411 | 411 |
} catch (IOException e) { |
... | ... | |
1148 | 1148 |
* @return localId - the resulting docid of the document created or updated |
1149 | 1149 |
* |
1150 | 1150 |
*/ |
1151 |
public String insertOrUpdateDocument(String xml, Identifier pid,
|
|
1151 |
public String insertOrUpdateDocument(InputStream xml, String encoding, Identifier pid,
|
|
1152 | 1152 |
Session session, String insertOrUpdate) |
1153 |
throws ServiceFailure { |
|
1153 |
throws ServiceFailure, IOException {
|
|
1154 | 1154 |
|
1155 | 1155 |
logMetacat.debug("Starting to insert xml document..."); |
1156 | 1156 |
IdentifierManager im = IdentifierManager.getInstance(); |
1157 | 1157 |
|
1158 | 1158 |
// generate pid/localId pair for sysmeta |
1159 | 1159 |
String localId = null; |
1160 |
|
|
1160 |
byte[] xmlBytes = IOUtils.toByteArray(xml); |
|
1161 |
String xmlStr = new String(xmlBytes, encoding); |
|
1161 | 1162 |
if(insertOrUpdate.equals("insert")) { |
1162 | 1163 |
localId = im.generateLocalId(pid.getValue(), 1); |
1163 | 1164 |
|
... | ... | |
1197 | 1198 |
docid[0] = localId; |
1198 | 1199 |
params.put("docid", docid); |
1199 | 1200 |
String[] doctext = new String[1]; |
1200 |
doctext[0] = xml; |
|
1201 |
doctext[0] = xmlStr;
|
|
1201 | 1202 |
params.put("doctext", doctext); |
1202 | 1203 |
|
1203 | 1204 |
String username = Constants.SUBJECT_PUBLIC; |
... | ... | |
1218 | 1219 |
// do the insert or update action |
1219 | 1220 |
handler = new MetacatHandler(new Timer()); |
1220 | 1221 |
String result = handler.handleInsertOrUpdateAction(request.getRemoteAddr(), request.getHeader("User-Agent"), null, |
1221 |
null, params, username, groupnames, false, false); |
|
1222 |
null, params, username, groupnames, false, false, xmlBytes);
|
|
1222 | 1223 |
|
1223 | 1224 |
if(result.indexOf("<error>") != -1) { |
1224 | 1225 |
String detailCode = ""; |
Also available in: Unified diff
Write the input stream into the file system without alteration in dataone create and update methods.