Browse Source

Pausing until further notice

PeterMcCormick 6 years ago
parent
commit
157716d57c
2 changed files with 40 additions and 3 deletions
  1. 16
    1
      Client/src/main/java/Message.java
  2. 24
    2
      Client/src/main/java/SimpleShell.java

+ 16
- 1
Client/src/main/java/Message.java View File

1
 public class Message {
1
 public class Message {
2
 
2
 
3
     private String sequence;
3
     private String sequence;
4
-    private String timestamp = "2018-03-21T01:00:00:0Z";
4
+    private String timestamp;
5
     private String fromid;
5
     private String fromid;
6
     private String toid;
6
     private String toid;
7
     private String message;
7
     private String message;
15
 
15
 
16
     }
16
     }
17
 
17
 
18
+    public Message() {
19
+
20
+    }
21
+
18
     public Message(String fromid, String toid, String message) {
22
     public Message(String fromid, String toid, String message) {
19
         this.fromid = fromid;
23
         this.fromid = fromid;
20
         this.toid = toid;
24
         this.toid = toid;
21
         this.message = message;
25
         this.message = message;
22
     }
26
     }
23
 
27
 
28
+    @Override
29
+    public String toString() {
30
+        return "Message{" +
31
+                "sequence='" + sequence + '\'' +
32
+                ", timestamp='" + timestamp + '\'' +
33
+                ", fromid='" + fromid + '\'' +
34
+                ", toid='" + toid + '\'' +
35
+                ", message='" + message + '\'' +
36
+                '}';
37
+    }
38
+
24
     public Message(String fromid, String message) {
39
     public Message(String fromid, String message) {
25
         this.fromid = fromid;
40
         this.fromid = fromid;
26
         this.message = message;
41
         this.message = message;

+ 24
- 2
Client/src/main/java/SimpleShell.java View File

15
         ObjectMapper mapper = new ObjectMapper();
15
         ObjectMapper mapper = new ObjectMapper();
16
         try {
16
         try {
17
             Object json = mapper.readValue(output, Object.class);
17
             Object json = mapper.readValue(output, Object.class);
18
-            String indented = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json);
19
-            System.out.println(indented);
18
+            String prettyPrintSets = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json);
19
+            System.out.println(prettyPrintSets);
20
         } catch (IOException e) {
20
         } catch (IOException e) {
21
             e.printStackTrace();
21
             e.printStackTrace();
22
         }
22
         }
83
                 }
83
                 }
84
                 // you need to add a bunch more.
84
                 // you need to add a bunch more.
85
 
85
 
86
+                if (list.contains("messages") && list.size() == 2) {
87
+                    String myGithub = list.get(1);
88
+                    String results = webber.MakeURLCall("/ids/" +  myGithub + "/messages",
89
+                            "GET", "");
90
+                    SimpleShell.prettyPrint(results);
91
+                    continue;
92
+                }
93
+
94
+                if (list.contains("send")) {
95
+                    String groupedMessage = "";
96
+                    if (list.get(list.size()-2).equals("to"));
97
+                    for (int i = 2; i < list.size()-2; i++) {
98
+                        groupedMessage += list.get(i) + " ";
99
+                    }
100
+                    String trimmedMessage = groupedMessage.trim();
101
+                    Message newMessage = new Message(list.get(1), list.get(list.size()-1), trimmedMessage);
102
+                    String newMessageInfo = objectMapper.writeValueAsString(newMessage);
103
+                    webber.MakeURLCall("/ids/" + list.get(1) + "/messages", "POST", newMessageInfo);
104
+                    SimpleShell.prettyPrint(newMessageInfo);
105
+                    continue;
106
+                }
107
+
86
                 if (list.contains("ids") && list.size() == 3) {
108
                 if (list.contains("ids") && list.size() == 3) {
87
                     String name = list.get(1);
109
                     String name = list.get(1);
88
                     String gitHubId = list.get(2);
110
                     String gitHubId = list.get(2);