Kaynağa Gözat

contact with the world successful

Eric Barnaba 6 yıl önce
ebeveyn
işleme
2a29fcbde8

+ 20
- 0
Client/src/main/java/Message.java Dosyayı Görüntüle

@@ -29,5 +29,25 @@ public class Message {
29 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 Dosyayı Görüntüle

@@ -20,9 +20,10 @@ public class YouAreEll {
20 20
         ObjectMapper mapper = new ObjectMapper();
21 21
         YouAreEll urlhandler = new YouAreEll();
22 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 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 27
 //            //System.out.println(json);
27 28
 //        }
28 29
 //        catch(JsonProcessingException jpe){
@@ -46,8 +47,7 @@ public class YouAreEll {
46 47
 
47 48
         if(method.equals("GET")){
48 49
             try{
49
-                System.out.println(Request.Get(url)
50
-                        .execute().returnContent());
50
+                return Request.Get(url).execute().returnContent().asString();
51 51
             }
52 52
             catch(IOException ioe){
53 53
                 System.out.println(ioe.getMessage());
@@ -56,22 +56,26 @@ public class YouAreEll {
56 56
         }
57 57
         else if (method.equals("POST")){
58 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 63
             catch(IOException ioe){
66 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 79
         return "nada";
76 80
     }
77 81
 }