Browse Source

contact with the world successful

Eric Barnaba 6 years ago
parent
commit
2a29fcbde8
2 changed files with 37 additions and 13 deletions
  1. 20
    0
      Client/src/main/java/Message.java
  2. 17
    13
      Client/src/main/java/YouAreEll.java

+ 20
- 0
Client/src/main/java/Message.java View File

29
         this.message = message;
29
         this.message = message;
30
     }
30
     }
31
 
31
 
32
+    public String getSequence() {
33
+        return sequence;
34
+    }
35
+
36
+    public String getTimestamp() {
37
+        return timestamp;
38
+    }
39
+
40
+    public String getFromid() {
41
+        return fromid;
42
+    }
43
+
44
+    public String getToid() {
45
+        return toid;
46
+    }
47
+
48
+    public String getMessage() {
49
+        return message;
50
+    }
51
+
32
 
52
 
33
 }
53
 }

+ 17
- 13
Client/src/main/java/YouAreEll.java View File

20
         ObjectMapper mapper = new ObjectMapper();
20
         ObjectMapper mapper = new ObjectMapper();
21
         YouAreEll urlhandler = new YouAreEll();
21
         YouAreEll urlhandler = new YouAreEll();
22
 //        Id ericB = new Id("EricB", "EricBarnaba");
22
 //        Id ericB = new Id("EricB", "EricBarnaba");
23
+//        Message testMessage = new Message("EricBarnaba", "Now that I've made contact with the world it's time for dinner!");
23
 //        try {
24
 //        try {
24
-//            String json = mapper.writeValueAsString(ericB);
25
-//            urlhandler.MakeURLCall("/ids", "POST", json );
25
+//            String json = mapper.writeValueAsString(testMessage);
26
+//            urlhandler.MakeURLCall("/ids/EricBarnaba/messages", "POST", json );
26
 //            //System.out.println(json);
27
 //            //System.out.println(json);
27
 //        }
28
 //        }
28
 //        catch(JsonProcessingException jpe){
29
 //        catch(JsonProcessingException jpe){
46
 
47
 
47
         if(method.equals("GET")){
48
         if(method.equals("GET")){
48
             try{
49
             try{
49
-                System.out.println(Request.Get(url)
50
-                        .execute().returnContent());
50
+                return Request.Get(url).execute().returnContent().asString();
51
             }
51
             }
52
             catch(IOException ioe){
52
             catch(IOException ioe){
53
                 System.out.println(ioe.getMessage());
53
                 System.out.println(ioe.getMessage());
56
         }
56
         }
57
         else if (method.equals("POST")){
57
         else if (method.equals("POST")){
58
             try {
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();
59
+                return Request.Post(url)
60
+                        .bodyString(jpayload, ContentType.APPLICATION_JSON)
61
+                        .execute().returnContent().asString();
64
             }
62
             }
65
             catch(IOException ioe){
63
             catch(IOException ioe){
66
                 System.out.println(ioe.getMessage());
64
                 System.out.println(ioe.getMessage());
67
             }
65
             }
68
-
69
-
70
         }
66
         }
71
-        else if (method.equals("PUT")){
72
 
67
 
68
+        else if (method.equals("PUT")){
69
+            try {
70
+                System.out.println(jpayload);
71
+                Request.Put(url)
72
+                        .useExpectContinue().bodyString(jpayload, ContentType.APPLICATION_JSON)
73
+                        .execute().returnContent().asString();
74
+            }
75
+            catch(IOException ioe){
76
+                System.out.println(ioe.getMessage());
77
+            }
73
         }
78
         }
74
-
75
         return "nada";
79
         return "nada";
76
     }
80
     }
77
 }
81
 }