|
@@ -1,10 +1,34 @@
|
|
1
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
2
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
3
|
+import org.apache.http.client.fluent.Form;
|
|
4
|
+import org.apache.http.client.fluent.Request;
|
|
5
|
+import org.apache.http.entity.ContentType;
|
|
6
|
+import org.apache.http.entity.StringEntity;
|
|
7
|
+
|
|
8
|
+import java.io.IOException;
|
|
9
|
+import java.io.UnsupportedEncodingException;
|
|
10
|
+
|
1
|
11
|
public class YouAreEll {
|
2
|
12
|
|
|
13
|
+
|
|
14
|
+
|
3
|
15
|
YouAreEll() {
|
|
16
|
+
|
4
|
17
|
}
|
5
|
18
|
|
6
|
19
|
public static void main(String[] args) {
|
|
20
|
+ ObjectMapper mapper = new ObjectMapper();
|
7
|
21
|
YouAreEll urlhandler = new YouAreEll();
|
|
22
|
+// Id ericB = new Id("EricB", "EricBarnaba");
|
|
23
|
+// try {
|
|
24
|
+// String json = mapper.writeValueAsString(ericB);
|
|
25
|
+// urlhandler.MakeURLCall("/ids", "POST", json );
|
|
26
|
+// //System.out.println(json);
|
|
27
|
+// }
|
|
28
|
+// catch(JsonProcessingException jpe){
|
|
29
|
+// System.out.println(jpe.getMessage());
|
|
30
|
+// }
|
|
31
|
+
|
8
|
32
|
System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
|
9
|
33
|
System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
|
10
|
34
|
}
|
|
@@ -18,6 +42,36 @@ public class YouAreEll {
|
18
|
42
|
}
|
19
|
43
|
|
20
|
44
|
public String MakeURLCall(String mainurl, String method, String jpayload) {
|
|
45
|
+ String url = "http://zipcode.rocks:8085" + mainurl;
|
|
46
|
+
|
|
47
|
+ if(method.equals("GET")){
|
|
48
|
+ try{
|
|
49
|
+ System.out.println(Request.Get(url)
|
|
50
|
+ .execute().returnContent());
|
|
51
|
+ }
|
|
52
|
+ catch(IOException ioe){
|
|
53
|
+ System.out.println(ioe.getMessage());
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ }
|
|
57
|
+ else if (method.equals("POST")){
|
|
58
|
+ try {
|
|
59
|
+ //StringEntity json = new StringEntity(jpayload);
|
|
60
|
+ System.out.println(jpayload);
|
|
61
|
+ Request.Post(url)
|
|
62
|
+ .useExpectContinue().bodyString(jpayload, ContentType.DEFAULT_TEXT)
|
|
63
|
+ .execute().returnContent();
|
|
64
|
+ }
|
|
65
|
+ catch(IOException ioe){
|
|
66
|
+ System.out.println(ioe.getMessage());
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+ }
|
|
71
|
+ else if (method.equals("PUT")){
|
|
72
|
+
|
|
73
|
+ }
|
|
74
|
+
|
21
|
75
|
return "nada";
|
22
|
76
|
}
|
23
|
77
|
}
|