Revision 8802
Added by ben leinfelder over 10 years ago
test/edu/ucsb/nceas/metacattest/MetaCatServletTest.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
import edu.ucsb.nceas.MCTestCase; |
30 | 30 |
import edu.ucsb.nceas.metacat.IdentifierManager; |
31 |
import edu.ucsb.nceas.metacat.client.MetacatClient; |
|
32 |
import edu.ucsb.nceas.metacat.client.MetacatFactory; |
|
33 |
import edu.ucsb.nceas.metacat.client.MetacatInaccessibleException; |
|
31 | 34 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
32 |
import edu.ucsb.nceas.utilities.HttpMessage; |
|
33 | 35 |
import edu.ucsb.nceas.utilities.PropertyNotFoundException; |
34 | 36 |
|
35 | 37 |
import junit.framework.Test; |
... | ... | |
45 | 47 |
*/ |
46 | 48 |
public class MetaCatServletTest extends MCTestCase { |
47 | 49 |
private static String metacatURL; |
50 |
private MetacatClient metacat = null; |
|
48 | 51 |
private String serialNumber; |
49 | 52 |
|
50 | 53 |
/* Initialize properties */ |
... | ... | |
82 | 85 |
* Establish a testing framework by initializing appropriate objects |
83 | 86 |
*/ |
84 | 87 |
public void setUp() { |
88 |
try { |
|
89 |
metacat = (MetacatClient) MetacatFactory.createMetacatConnection(metacatURL); |
|
90 |
} catch (MetacatInaccessibleException e) { |
|
91 |
fail("Could not initialize MetacatClient: " + e.getMessage()); |
|
92 |
e.printStackTrace(); |
|
93 |
} |
|
85 | 94 |
|
86 | 95 |
} |
87 | 96 |
|
... | ... | |
496 | 505 |
|
497 | 506 |
String response = getMetacatString(prop); |
498 | 507 |
debug("Logout Message: " + response); |
499 |
HttpMessage.setCookie(null); |
|
500 | 508 |
|
501 | 509 |
if (response.indexOf("<logout>") != -1) { |
502 | 510 |
disConnected = true; |
... | ... | |
629 | 637 |
// Now contact metacat and send the request |
630 | 638 |
try { |
631 | 639 |
|
632 |
URL url = new URL(metacatURL); |
|
633 |
HttpMessage msg = new HttpMessage(url); |
|
634 |
returnStream = msg.sendPostMessage(prop); |
|
640 |
returnStream = metacat.sendParameters(prop); |
|
635 | 641 |
return returnStream; |
636 | 642 |
} catch (Exception e) { |
637 | 643 |
e.printStackTrace(System.err); |
src/edu/ucsb/nceas/metacat/RemoteDocument.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
package edu.ucsb.nceas.metacat; |
28 | 28 |
|
29 |
import edu.ucsb.nceas.metacat.client.MetacatClient; |
|
30 |
import edu.ucsb.nceas.metacat.client.MetacatFactory; |
|
29 | 31 |
import edu.ucsb.nceas.metacat.properties.PropertyService; |
30 | 32 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
31 |
import edu.ucsb.nceas.utilities.HttpMessage; |
|
32 | 33 |
import javax.servlet.ServletOutputStream; |
33 | 34 |
|
34 | 35 |
import org.apache.log4j.Logger; |
... | ... | |
48 | 49 |
*/ |
49 | 50 |
public class RemoteDocument |
50 | 51 |
{ |
52 |
|
|
53 |
private MetacatClient metacat = null; |
|
54 |
|
|
51 | 55 |
private String docIdWithoutRevision = null; //Docid for this document |
52 | 56 |
private String revision = null; // Reviseion number for this document |
53 | 57 |
private String dataSetId = null; // Data set document Id which contains |
... | ... | |
79 | 83 |
// Get data set id for the given docid |
80 | 84 |
dataSetId = DBUtil.findDataSetDocIdForGivenDocument(docIdWithoutRevision); |
81 | 85 |
documentHomeServerURL = getMetacatURLForGivenDocId(dataSetId); |
86 |
|
|
87 |
|
|
88 |
// make sure we initialize the client for making remote calls |
|
89 |
this.metacat = (MetacatClient) MetacatFactory.createMetacatConnection(documentHomeServerURL); |
|
90 |
|
|
82 | 91 |
// Get revisionAndDocType |
83 | 92 |
getRevisionAndDocTypeString(); |
84 | 93 |
revision = myRevision; |
... | ... | |
241 | 250 |
*/ |
242 | 251 |
private void getRevisionAndDocTypeString() |
243 | 252 |
{ |
253 |
|
|
244 | 254 |
// Set property for login action |
245 | 255 |
Properties prop = new Properties(); |
246 | 256 |
// Set action = getrevisionanddoctype |
... | ... | |
455 | 465 |
String response = getMetacatString(prop); |
456 | 466 |
logMetacat.debug("Logout Message: "+response); |
457 | 467 |
// Set cookie to null |
458 |
HttpMessage.setCookie(null); |
|
459 | 468 |
|
460 | 469 |
}//logout |
461 | 470 |
|
... | ... | |
506 | 515 |
* @param prop the properties to be sent to Metacat |
507 | 516 |
*/ |
508 | 517 |
private InputStream getMetacatInputStream(Properties prop) throws Exception |
509 |
{ |
|
518 |
{
|
|
510 | 519 |
// Variable to store the returned input stream |
511 |
InputStream returnStream = null; |
|
512 |
// Create a URL for remtate |
|
513 |
URL url = new URL(documentHomeServerURL); |
|
514 |
HttpMessage msg = new HttpMessage(url); |
|
515 |
// Now contact metacat and send the request |
|
516 |
returnStream = msg.sendPostMessage(prop); |
|
520 |
InputStream returnStream = metacat.sendParameters(prop); |
|
517 | 521 |
return returnStream; |
518 | 522 |
|
519 | 523 |
}//getMetacatInputStream |
Also available in: Unified diff
remove dependency on HttpMessage that was in the utilities project but is now removed in favor of newer (standard) http client library code.