Project

General

Profile

1 1112 tao
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2000 Regents of the University of California and the
4
 *              National Center for Ecological Analysis and Synthesis
5
 *  Purpose: To test the MetaCatURL class by JUnit
6 3080 jones
 *    Authors: Jing Tao
7 1112 tao
 *
8
 *   '$Author$'
9
 *     '$Date$'
10
 * '$Revision$'
11
 *
12
 * This program is free software; you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation; either version 2 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
 */
26
27 1118 tao
package edu.ucsb.nceas.metacattest;
28 1112 tao
29 4301 daigle
import edu.ucsb.nceas.MCTestCase;
30 4080 daigle
import edu.ucsb.nceas.metacat.service.PropertyService;
31 1822 jones
import edu.ucsb.nceas.utilities.HttpMessage;
32 4080 daigle
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
33 1112 tao
import junit.framework.Test;
34
import junit.framework.TestSuite;
35
36
import java.io.*;
37
import java.net.*;
38
import java.util.*;
39
40
/**
41
 * A JUnit test for testing Step class processing
42
 */
43 4301 daigle
public class MetaCatServletTest extends MCTestCase {
44 4080 daigle
	private static String metacatURL;
45
	private String serialNumber;
46 4301 daigle
47
	/* Initialize properties */
48 4080 daigle
	static {
49
		try {
50 4231 daigle
			metacatURL = PropertyService.getProperty("test.metacatUrl");
51 4301 daigle
		} catch (PropertyNotFoundException pnfe) {
52
			System.err.println("Could not get property in static block: "
53
					+ pnfe.getMessage());
54 4080 daigle
		}
55
	}
56 1112 tao
57 4080 daigle
	/**
58
	 * Constructor to build the test
59 4301 daigle
	 *
60
	 * @param name
61
	 *            the name of the test method
62 4080 daigle
	 */
63
	public MetaCatServletTest(String name) {
64
		super(name);
65
	}
66 1112 tao
67 4080 daigle
	/**
68
	 * Constructor to build the test
69 4301 daigle
	 *
70
	 * @param name
71
	 *            the name of the test method
72 4080 daigle
	 */
73
	public MetaCatServletTest(String name, String serial) {
74
		super(name);
75
		serialNumber = serial;
76
	}
77 1112 tao
78 4080 daigle
	/**
79
	 * Establish a testing framework by initializing appropriate objects
80
	 */
81
	public void setUp() {
82 1112 tao
83 4080 daigle
	}
84 1112 tao
85 4080 daigle
	/**
86
	 * Release any objects after tests are complete
87
	 */
88
	public void tearDown() {
89
	}
90 1112 tao
91 4080 daigle
	/**
92
	 * Create a suite of tests to be run together
93
	 */
94
	public static Test suite() {
95
		double number = 0;
96
		String serial = null;
97 1112 tao
98 4080 daigle
		TestSuite suite = new TestSuite();
99
		suite.addTest(new MetaCatServletTest("initialize"));
100
		suite.addTest(new MetaCatServletTest("testLterReferralLogin"));
101
		suite.addTest(new MetaCatServletTest("testLterReferralLoginFail"));
102
		suite.addTest(new MetaCatServletTest("testPiscoReferralLogin"));
103
		suite.addTest(new MetaCatServletTest("testPiscoReferralLoginFail"));
104
		suite.addTest(new MetaCatServletTest("testNCEASLoginFail"));
105 4301 daigle
		// Should put a login successfully at the end of login test
106
		// So insert or update can have cookie.
107 4080 daigle
		suite.addTest(new MetaCatServletTest("testNCEASLogin"));
108 1112 tao
109 4301 daigle
		// create random number for docid, so it can void repeat
110 4080 daigle
		number = Math.random() * 100000;
111
		serial = Integer.toString(((new Double(number)).intValue()));
112 4301 daigle
		debug("serial: " + serial);
113 4080 daigle
		suite.addTest(new MetaCatServletTest("testInsertXMLDocument", serial));
114
		suite.addTest(new MetaCatServletTest("testReadXMLDocumentXMLFormat", serial));
115
		suite.addTest(new MetaCatServletTest("testUpdateXMLDocument", serial));
116 1112 tao
117 4080 daigle
		suite.addTest(new MetaCatServletTest("testReadXMLDocumentHTMLFormat", serial));
118
		suite.addTest(new MetaCatServletTest("testReadXMLDocumentZipFormat", serial));
119 1112 tao
120 4080 daigle
		suite.addTest(new MetaCatServletTest("testDeleteXMLDocument", serial));
121 1112 tao
122 4301 daigle
		// insert invalid xml document
123 4080 daigle
		number = Math.random() * 100000;
124
		serial = Integer.toString(((new Double(number)).intValue()));
125
		suite.addTest(new MetaCatServletTest("testInsertInvalidateXMLDocument", serial));
126 4301 daigle
		// insert non well formed document
127 4080 daigle
		number = Math.random() * 100000;
128
		serial = Integer.toString(((new Double(number)).intValue()));
129
		suite
130
				.addTest(new MetaCatServletTest("testInsertNonWellFormedXMLDocument",
131
						serial));
132 1112 tao
133 4080 daigle
		suite.addTest(new MetaCatServletTest("testLogOut"));
134 1112 tao
135 4080 daigle
		return suite;
136
	}
137 1112 tao
138 4080 daigle
	/**
139 4301 daigle
	 * Run an initial test that always passes to check that the test harness is
140
	 * working.
141 4080 daigle
	 */
142
	public void initialize() {
143
		assertTrue(1 == 1);
144
	}
145 1112 tao
146 4080 daigle
	/**
147
	 * Test the login to neceas succesfully
148
	 */
149
	public void testNCEASLogin() {
150 4301 daigle
		debug("\nRunning: testNCEASLogin test");
151 4080 daigle
		String user = "uid=john,o=NCEAS,dc=ecoinformatics,dc=org";
152
		String passwd = "123456";
153
		assertTrue(logIn(user, passwd));
154 4301 daigle
		// assertTrue( withProtocol.getProtocol().equals("http"));
155 4080 daigle
	}
156
157
	/**
158
	 * Test the login to neceas failed
159
	 */
160
	public void testNCEASLoginFail() {
161 4301 daigle
		debug("\nRunning: testNCEASLoginFail test");
162 4080 daigle
		String user = "uid=john,o=NCEAS,dc=ecoinformatics,dc=org";
163
		String passwd = "12345678";
164
		assertTrue(!logIn(user, passwd));
165
166
	}
167
168
	/**
169
	 * Test the login to lter succesfully
170
	 */
171
	public void testLterReferralLogin() {
172 4301 daigle
		debug("\nRunning: testLterReferralLogin test");
173 4080 daigle
		String user = null;
174
		String passwd = null;
175
		try {
176 4231 daigle
			user = PropertyService.getProperty("test.lterUser");
177
			passwd = PropertyService.getProperty("test.lterPassword");
178 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
179
			fail("Could not find property: " + pnfe.getMessage());
180
		}
181 4301 daigle
182
		debug("Logging into lter: " + user + " : " + passwd);
183 4080 daigle
		assertTrue(logIn(user, passwd));
184
185
	}
186
187
	/**
188
	 * Test the login to lter failed
189
	 */
190
	public void testLterReferralLoginFail() {
191 4301 daigle
		debug("\nRunning: testLterReferralLoginFail test");
192 4080 daigle
		String user = "uid=jtao,o=LTER,dc=ecoinformatics,dc=org";
193
		String passwd = "qVyGpveb";
194
		assertTrue(!logIn(user, passwd));
195 4301 daigle
		// assertTrue( withProtocol.getProtocol().equals("http"));
196 4080 daigle
	}
197
198
	/**
199
	 * Test the login to pisco succesfully
200
	 */
201
	public void testPiscoReferralLogin() {
202 4301 daigle
		debug("\nRunning: testPiscoReferralLogin test");
203 4080 daigle
		String user = null;
204
		String passwd = null;
205
		try {
206 4231 daigle
			user = PropertyService.getProperty("test.piscoUser");
207
			passwd = PropertyService.getProperty("test.piscoPassword");
208 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
209
			fail("Could not find property: " + pnfe.getMessage());
210
		}
211 4301 daigle
		debug("logging in pisco user: " + user + ":" + passwd);
212 4080 daigle
		assertTrue(logIn(user, passwd));
213
		// assertTrue( withProtocol.getProtocol().equals("http"));
214
	}
215
216
	/**
217
	 * Test the login to pisco failed
218
	 */
219
	public void testPiscoReferralLoginFail() {
220 4301 daigle
		debug("\nRunning: testPiscoReferralLoginFail test");
221 4080 daigle
		String user = "uid=tao,o=PISCO,dc=ecoinformatics,dc=org";
222
		String passwd = "hello";
223
		assertTrue(!logIn(user, passwd));
224 4301 daigle
		// assertTrue( withProtocol.getProtocol().equals("http"));
225 4080 daigle
	}
226
227
	/**
228
	 * Test insert a xml document successfully
229
	 */
230
	public void testInsertXMLDocument() {
231 4301 daigle
		debug("\nRunning: testInsertXMLDocument test");
232 4080 daigle
		String name = null;
233
		try {
234 4301 daigle
			name = "john" + PropertyService.getProperty("document.accNumSeparator")
235
					+ serialNumber
236 4212 daigle
					+ PropertyService.getProperty("document.accNumSeparator") + "1";
237 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
238
			fail("Could not find property: " + pnfe.getMessage());
239
		}
240 4301 daigle
		debug("insert docid: " + name);
241 4080 daigle
		String content = "<?xml version=\"1.0\"?>"
242
				+ "<!DOCTYPE acl PUBLIC \"-//ecoinformatics.org//"
243
				+ "eml-access-2.0.0beta6//EN\" \"http://pine.nceas.ucsb."
244
				+ "edu:8080/tao/dtd/eml-access-2.0.0beta6.dtd\">"
245
				+ "<acl authSystem=\"knb\" order=\"allowFirst\">" + "<identifier>" + name
246
				+ "</identifier>" + "<allow>"
247
				+ "<principal>uid=john,o=NCEAS,dc=ecoinformatics,dc=org</principal>"
248
				+ "<permission>all</permission>" + "</allow>" + "<allow>"
249
				+ "<principal>public</principal>" + "<permission>read</permission>"
250
				+ "</allow>" + "</acl>";
251 4301 daigle
		debug("xml document: " + content);
252 4080 daigle
		assertTrue(handleXMLDocument(content, name, "insert"));
253
254
	}
255
256
	/**
257 4301 daigle
	 * Test insert a invalidate xml document successfully In the String, there
258
	 * is no <!Doctype ... Public/System/>
259 4080 daigle
	 */
260
	public void testInsertInvalidateXMLDocument() {
261 4301 daigle
		debug("\nRunning: testInsertInvalidateXMLDocument test");
262 4080 daigle
		String name = null;
263
		try {
264 4301 daigle
			name = "john" + PropertyService.getProperty("document.accNumSeparator")
265
					+ serialNumber
266
					+ PropertyService.getProperty("document.accNumSeparator") + "1";
267 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
268
			fail("Could not find property: " + pnfe.getMessage());
269
		}
270 4301 daigle
		debug("insert docid: " + name);
271 4080 daigle
		String content = "<?xml version=\"1.0\"?>"
272
				+ "<acl authSystem=\"knb\" order=\"allowFirst\">" + "<identifier>" + name
273
				+ "</identifier>" + "<allow>"
274
				+ "<principal>uid=john,o=NCEAS,dc=ecoinformatics,dc=org</principal>"
275
				+ "<permission>all</permission>" + "</allow>" + "<allow>"
276
				+ "<principal>public</principal>" + "<permission>read</permission>"
277
				+ "</allow>" + "</acl>";
278 4301 daigle
		debug("xml document: " + content);
279 4080 daigle
		assertTrue(handleXMLDocument(content, name, "insert"));
280
	}
281
282
	/**
283 4301 daigle
	 * Test insert a non well-formed xml document successfully There is no
284
	 * </acl> in this string
285 4080 daigle
	 */
286
	public void testInsertNonWellFormedXMLDocument() {
287 4301 daigle
		debug("\nRunning: testInsertNonWellFormedXMLDocument test");
288 4080 daigle
		String name = null;
289
		try {
290 4301 daigle
			name = "john" + PropertyService.getProperty("document.accNumSeparator")
291
					+ serialNumber
292
					+ PropertyService.getProperty("document.accNumSeparator") + "1";
293 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
294
			fail("Could not find property: " + pnfe.getMessage());
295
		}
296 4301 daigle
		debug("insert non well-formed docid: " + name);
297 4080 daigle
		String content = "<?xml version=\"1.0\"?>"
298
				+ "<acl authSystem=\"knb\" order=\"allowFirst\">" + "<identifier>" + name
299
				+ "</identifier>" + "<allow>"
300
				+ "<principal>uid=john,o=NCEAS,dc=ecoinformatics,dc=org</principal>"
301
				+ "<permission>all</permission>" + "</allow>" + "<allow>"
302
				+ "<principal>public</principal>" + "<permission>read</permission>"
303
				+ "</allow>";
304
305 4301 daigle
		debug("xml document: " + content);
306 4080 daigle
		assertTrue(!handleXMLDocument(content, name, "insert"));
307
	}
308
309
	/**
310 4301 daigle
	 * Test read a xml document in xml format successfully
311 4080 daigle
	 */
312
	public void testReadXMLDocumentXMLFormat() {
313 4301 daigle
		debug("\nRunning: testReadXMLDocumentXMLFormat test");
314 4080 daigle
		String name = null;
315
		try {
316 4301 daigle
			name = "john" + PropertyService.getProperty("document.accNumSeparator")
317
					+ serialNumber
318
					+ PropertyService.getProperty("document.accNumSeparator") + "1";
319 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
320
			fail("Could not find property: " + pnfe.getMessage());
321
		}
322
		assertTrue(handleReadAction(name, "xml"));
323
324
	}
325
326
	/**
327 4301 daigle
	 * Test read a xml document in html format successfully
328 4080 daigle
	 */
329
	public void testReadXMLDocumentHTMLFormat() {
330 4301 daigle
		debug("\nRunning: testReadXMLDocumentHTMLFormat test");
331 4080 daigle
		String name = null;
332
		try {
333 4301 daigle
			name = "john" + PropertyService.getProperty("document.accNumSeparator")
334
					+ serialNumber
335
					+ PropertyService.getProperty("document.accNumSeparator") + "1";
336 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
337
			fail("Could not find property: " + pnfe.getMessage());
338 4301 daigle
		}
339 4080 daigle
		assertTrue(handleReadAction(name, "html"));
340
341
	}
342
343
	/**
344 4301 daigle
	 * Test read a xml document in zip format successfully
345 4080 daigle
	 */
346
	public void testReadXMLDocumentZipFormat() {
347 4301 daigle
		debug("\nRunning: testReadXMLDocumentZipFormat test");
348 4080 daigle
		String name = null;
349
		try {
350 4301 daigle
			name = "john" + PropertyService.getProperty("document.accNumSeparator")
351
					+ serialNumber
352
					+ PropertyService.getProperty("document.accNumSeparator") + "1";
353 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
354
			fail("Could not find property: " + pnfe.getMessage());
355 4301 daigle
		}
356 4080 daigle
		assertTrue(handleReadAction(name, "zip"));
357
358
	}
359
360
	/**
361
	 * Test insert a xml document successfully
362
	 */
363
	public void testUpdateXMLDocument() {
364 4301 daigle
		debug("\nRunning: testUpdateXMLDocument test");
365 4080 daigle
		String name = null;
366
		try {
367 4301 daigle
			name = "john" + PropertyService.getProperty("document.accNumSeparator")
368
					+ serialNumber
369
					+ PropertyService.getProperty("document.accNumSeparator") + "2";
370 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
371
			fail("Could not find property: " + pnfe.getMessage());
372 4301 daigle
		}
373
		debug("update docid: " + name);
374 4080 daigle
		String content = "<?xml version=\"1.0\"?>"
375
				+ "<!DOCTYPE acl PUBLIC \"-//ecoinformatics.org//"
376
				+ "eml-access-2.0.0beta6//EN\" \"http://pine.nceas.ucsb."
377
				+ "edu:8080/tao/dtd/eml-access-2.0.0beta6.dtd\">"
378
				+ "<acl authSystem=\"knb\" order=\"allowFirst\">" + "<identifier>" + name
379
				+ "</identifier>" + "<allow>"
380
				+ "<principal>uid=john,o=NCEAS,dc=ecoinformatics,dc=org</principal>"
381
				+ "<permission>all</permission>" + "</allow>" + "<allow>"
382
				+ "<principal>public</principal>" + "<permission>read</permission>"
383
				+ "</allow>" + "</acl>";
384 4301 daigle
		debug("xml document: " + content);
385 4080 daigle
		assertTrue(handleXMLDocument(content, name, "update"));
386
387
	}
388
389
	/**
390
	 * Test delete a xml document successfully
391
	 */
392
	public void testDeleteXMLDocument() {
393 4301 daigle
		debug("\nRunning: testDeleteXMLDocument test");
394 4080 daigle
		String name = null;
395
		try {
396 4301 daigle
			name = "john" + PropertyService.getProperty("document.accNumSeparator")
397
					+ serialNumber
398
					+ PropertyService.getProperty("document.accNumSeparator") + "2";
399 4080 daigle
		} catch (PropertyNotFoundException pnfe) {
400
			fail("Could not find property: " + pnfe.getMessage());
401
		}
402 4301 daigle
		debug("delete docid: " + name);
403 4080 daigle
		assertTrue(handleDeleteFile(name));
404
405
	}
406
407
	/**
408
	 * Test logout action
409
	 */
410
	public void testLogOut() {
411 4301 daigle
		debug("\nRunning: testLogOut test");
412 4080 daigle
		assertTrue(handleLogOut());
413
414
	}
415
416
	/**
417
	 * Method to hanld login action
418 4301 daigle
	 *
419
	 * @param usrerName,
420
	 *            the DN name of the test method
421
	 * @param passWord,
422
	 *            the passwd of the user
423 4080 daigle
	 */
424
425
	public boolean logIn(String userName, String passWord) {
426
		Properties prop = new Properties();
427
		prop.put("action", "login");
428
		prop.put("qformat", "xml");
429
		prop.put("username", userName);
430
		prop.put("password", passWord);
431
432
		// Now contact metacat
433
		String response = getMetacatString(prop);
434 4301 daigle
		debug("Login Message: " + response);
435 4080 daigle
		boolean connected = false;
436
		if (response.indexOf("<login>") != -1) {
437
			connected = true;
438
		} else {
439
440
			connected = false;
441
		}
442
443
		return connected;
444
	}
445
446
	/**
447
	 * Method to hanld logout action
448 4301 daigle
	 *
449
	 * @param usrerName,
450
	 *            the DN name of the test method
451
	 * @param passWord,
452
	 *            the passwd of the user
453 4080 daigle
	 */
454
455
	public boolean handleLogOut() {
456
		boolean disConnected = false;
457
		Properties prop = new Properties();
458
		prop.put("action", "logout");
459
		prop.put("qformat", "xml");
460
461
		String response = getMetacatString(prop);
462 4301 daigle
		debug("Logout Message: " + response);
463 4080 daigle
		HttpMessage.setCookie(null);
464
465
		if (response.indexOf("<logout>") != -1) {
466
			disConnected = true;
467
		} else {
468
			disConnected = false;
469
		}
470
471
		return disConnected;
472
	}
473
474
	/**
475
	 * Method to hanld read both xml and data file
476 4301 daigle
	 *
477
	 * @param docid,
478
	 *            the docid of the document want to read
479
	 * @param qformat,
480
	 *            the format of document user want to get
481 4080 daigle
	 */
482
	public boolean handleReadAction(String docid, String qformat) {
483
		Properties prop = new Properties();
484
		String message = "";
485
		prop.put("action", "read");
486
		prop.put("qformat", qformat);
487
		prop.put("docid", docid);
488
489
		message = getMetacatString(prop);
490
		message = message.trim();
491 4301 daigle
		if (message == null || message.equals("") || message.indexOf("<error>") != -1) {// there
492
																						// was
493
																						// an
494
																						// error
495 4080 daigle
496
			return false;
497 4301 daigle
		} else {// successfully
498 4080 daigle
			return true;
499
		}
500
501
	}
502
503
	/**
504
	 * Method to hanld inset or update xml document
505 4301 daigle
	 *
506
	 * @param xmlDocument,
507
	 *            the content of xml qformat
508
	 * @param docid,
509
	 *            the docid of the document
510
	 * @param action,
511
	 *            insert or update
512 4080 daigle
	 */
513
	public boolean handleXMLDocument(String xmlDocument, String docid, String action)
514
515 4301 daigle
	{ // -attempt to write file to metacat
516 4080 daigle
		String access = "no";
517
		StringBuffer fileText = new StringBuffer();
518
		StringBuffer messageBuf = new StringBuffer();
519
		String accessFileId = null;
520
		Properties prop = new Properties();
521
		prop.put("action", action);
522 4301 daigle
		prop.put("public", access); // This is the old way of controlling access
523 4080 daigle
		prop.put("doctext", xmlDocument);
524
		prop.put("docid", docid);
525
526
		String message = getMetacatString(prop);
527 4301 daigle
		debug("Insert or Update Message: " + message);
528
		if (message.indexOf("<error>") != -1) {// there was an error
529 4080 daigle
530
			return false;
531 4301 daigle
		} else if (message.indexOf("<success>") != -1) {// the operation worked
532
			// write the file to the cache and return the file object
533 4080 daigle
			return true;
534
535 4301 daigle
		} else {// something weird happened.
536 4080 daigle
			return false;
537
		}
538
539
	}
540
541
	public boolean handleDeleteFile(String name) {
542
543
		Properties prop = new Properties();
544
		prop.put("action", "delete");
545
		prop.put("docid", name);
546
547
		String message = getMetacatString(prop);
548 4301 daigle
		debug("Delete Message: " + message);
549
		if (message.indexOf("<error>") != -1) {// there was an error
550 4080 daigle
551
			return false;
552 4301 daigle
		} else if (message.indexOf("<success>") != -1) {// the operation worked
553
			// write the file to the cache and return the file object
554 4080 daigle
			return true;
555
556 4301 daigle
		} else {// something weird happened.
557 4080 daigle
			return false;
558
		}
559
	}
560
561
	public String getMetacatString(Properties prop) {
562
		String response = null;
563
564
		// Now contact metacat and send the request
565
		try {
566
			InputStreamReader returnStream = new InputStreamReader(
567
					getMetacatInputStream(prop));
568
			StringWriter sw = new StringWriter();
569
			int len;
570
			char[] characters = new char[512];
571
			while ((len = returnStream.read(characters, 0, 512)) != -1) {
572
				sw.write(characters, 0, len);
573
			}
574
			returnStream.close();
575
			response = sw.toString();
576
			sw.close();
577
		} catch (Exception e) {
578
			return null;
579
		}
580
581
		return response;
582
	}
583
584
	/**
585
	 * Send a request to Metacat
586 4301 daigle
	 *
587
	 * @param prop
588
	 *            the properties to be sent to Metacat
589 4080 daigle
	 * @return InputStream as returned by Metacat
590
	 */
591
	public InputStream getMetacatInputStream(Properties prop) {
592
		InputStream returnStream = null;
593
		// Now contact metacat and send the request
594
		try {
595
596
			URL url = new URL(metacatURL);
597
			HttpMessage msg = new HttpMessage(url);
598
			returnStream = msg.sendPostMessage(prop);
599
			return returnStream;
600
		} catch (Exception e) {
601
			e.printStackTrace(System.err);
602
603
		}
604
		return returnStream;
605
606
	}
607
608 1112 tao
}