Revision 5760
Added by ben leinfelder over 13 years ago
MetacatPopulator.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
import org.apache.commons.io.IOUtils; |
43 | 43 |
|
44 |
import edu.ucsb.nceas.metacat.MetaCatServlet; |
|
44 | 45 |
import edu.ucsb.nceas.metacat.MetacatHandler; |
45 | 46 |
import edu.ucsb.nceas.metacat.MetacatResultSet; |
46 | 47 |
import edu.ucsb.nceas.metacat.MetacatResultSet.Document; |
... | ... | |
194 | 195 |
checksum.setAlgorithm(ca); |
195 | 196 |
checksum.setValue(checksum(dataDocIs)); |
196 | 197 |
dataDocSysMeta.setChecksum(checksum); |
197 |
dataDocSysMeta.setSize(dataDocText.getBytes().length); |
|
198 |
dataDocSysMeta.setSize(dataDocText.getBytes(MetaCatServlet.DEFAULT_ENCODING).length);
|
|
198 | 199 |
dataDocSysMeta.addDescribedBy(sysmeta.getIdentifier()); |
199 | 200 |
boolean error = false; |
200 | 201 |
//create the data doc on d1 |
... | ... | |
294 | 295 |
sm.setObjectFormat(format); |
295 | 296 |
|
296 | 297 |
//create the checksum |
297 |
ByteArrayInputStream bais = new ByteArrayInputStream(doc.doctext.getBytes()); |
|
298 |
ByteArrayInputStream bais = new ByteArrayInputStream(doc.doctext.getBytes(MetaCatServlet.DEFAULT_ENCODING));
|
|
298 | 299 |
String checksumS = checksum(bais); |
299 | 300 |
ChecksumAlgorithm ca = ChecksumAlgorithm.convert("MD5"); |
300 | 301 |
Checksum checksum = new Checksum(); |
... | ... | |
303 | 304 |
sm.setChecksum(checksum); |
304 | 305 |
|
305 | 306 |
//set the size |
306 |
sm.setSize(doc.doctext.getBytes().length); |
|
307 |
sm.setSize(doc.doctext.getBytes(MetaCatServlet.DEFAULT_ENCODING).length);
|
|
307 | 308 |
|
308 | 309 |
//submitter |
309 | 310 |
Principal p = new Principal(); |
... | ... | |
622 | 623 |
private InputStream stringToStream(String s) |
623 | 624 |
throws Exception |
624 | 625 |
{ |
625 |
ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes()); |
|
626 |
ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes(MetaCatServlet.DEFAULT_ENCODING));
|
|
626 | 627 |
return bais; |
627 | 628 |
} |
628 | 629 |
|
Also available in: Unified diff
use detected document encoding or Metacat's default encoding (UTF-8)