Browse Source

going to lunch, made progress

Keith Brinker 6 years ago
parent
commit
105c9871ea

+ 40
- 0
Client/src/main/java/Messages.java View File

24
                 '}';
24
                 '}';
25
     }
25
     }
26
 
26
 
27
+    public String getSequence() {
28
+        return sequence;
29
+    }
30
+
31
+    public void setSequence(String sequence) {
32
+        this.sequence = sequence;
33
+    }
34
+
35
+    public String getTimestamp() {
36
+        return timestamp;
37
+    }
38
+
39
+    public void setTimestamp(String timestamp) {
40
+        this.timestamp = timestamp;
41
+    }
42
+
43
+    public String getFromid() {
44
+        return fromid;
45
+    }
46
+
47
+    public void setFromid(String fromid) {
48
+        this.fromid = fromid;
49
+    }
50
+
51
+    public String getToid() {
52
+        return toid;
53
+    }
54
+
55
+    public void setToid(String toid) {
56
+        this.toid = toid;
57
+    }
58
+
59
+    public String getMessage() {
60
+        return message;
61
+    }
62
+
63
+    public void setMessage(String message) {
64
+        this.message = message;
65
+    }
66
+
27
 
67
 
28
 //timestamp = "2018-03-21T01:00:00.0Z"
68
 //timestamp = "2018-03-21T01:00:00.0Z"
29
 
69
 

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

1
+import com.fasterxml.jackson.databind.ObjectMapper;
2
+
1
 import java.io.BufferedReader;
3
 import java.io.BufferedReader;
2
 import java.io.IOException;
4
 import java.io.IOException;
3
 import java.io.InputStream;
5
 import java.io.InputStream;
10
 
12
 
11
     public static void prettyPrint(String output) {
13
     public static void prettyPrint(String output) {
12
         // yep, make an effort to format things nicely, eh?
14
         // yep, make an effort to format things nicely, eh?
15
+        ObjectMapper mapper = new ObjectMapper();
16
+        try {
17
+            Object json = mapper.readValue(output, Object.class);
18
+            String prettyPrint = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json);
19
+            System.out.println(prettyPrint);
20
+        } catch (IOException e) {
21
+            e.printStackTrace();
22
+        }
23
+
13
         System.out.println(output);
24
         System.out.println(output);
14
     }
25
     }
15
     public static void main(String[] args) throws java.io.IOException {
26
     public static void main(String[] args) throws java.io.IOException {
18
         String commandLine;
29
         String commandLine;
19
         BufferedReader console = new BufferedReader
30
         BufferedReader console = new BufferedReader
20
                 (new InputStreamReader(System.in));
31
                 (new InputStreamReader(System.in));
21
-
32
+        ObjectMapper mapper = new ObjectMapper();
22
         ProcessBuilder pb = new ProcessBuilder();
33
         ProcessBuilder pb = new ProcessBuilder();
23
         List<String> history = new ArrayList<String>();
34
         List<String> history = new ArrayList<String>();
24
         int index = 0;
35
         int index = 0;
59
                 // Specific Commands.
70
                 // Specific Commands.
60
 
71
 
61
                 // ids
72
                 // ids
62
-                if (list.contains("ids")) {
73
+                if (list.contains("ids") && list.size() ==1) {
63
                     String results = webber.get_ids();
74
                     String results = webber.get_ids();
64
                     SimpleShell.prettyPrint(results);
75
                     SimpleShell.prettyPrint(results);
65
                     continue;
76
                     continue;
66
                 }
77
                 }
67
 
78
 
79
+                if (list.contains("ids") && list.size() ==3){
80
+                    String name = list.get(1); //name
81
+                    String github= list.get(2);
82
+                    User user = new User(name, github);
83
+                    String newUserInfo = mapper.writeValueAsString(user);
84
+                    webber.MakeURLCall("/ids", "POST",newUserInfo);
85
+                    continue;
86
+                }
87
+
68
                 // messages
88
                 // messages
69
                 if (list.contains("messages")) {
89
                 if (list.contains("messages")) {
70
                     String results = webber.get_messages();
90
                     String results = webber.get_messages();

+ 24
- 0
Client/src/main/java/User.java View File

25
                 ", github='" + github + '\'' +
25
                 ", github='" + github + '\'' +
26
                 '}';
26
                 '}';
27
     }
27
     }
28
+
29
+    public String getUserid() {
30
+        return userid;
31
+    }
32
+
33
+    public void setUserid(String userid) {
34
+        this.userid = userid;
35
+    }
36
+
37
+    public String getName() {
38
+        return name;
39
+    }
40
+
41
+    public void setName(String name) {
42
+        this.name = name;
43
+    }
44
+
45
+    public String getGithub() {
46
+        return github;
47
+    }
48
+
49
+    public void setGithub(String github) {
50
+        this.github = github;
51
+    }
28
 }
52
 }

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

1
+import com.fasterxml.jackson.databind.ObjectMapper;
1
 import jdk.nashorn.internal.ir.RuntimeNode;
2
 import jdk.nashorn.internal.ir.RuntimeNode;
2
 import okhttp3.*;
3
 import okhttp3.*;
3
 
4
 
15
         YouAreEll urlhandler = new YouAreEll();
16
         YouAreEll urlhandler = new YouAreEll();
16
         System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
17
         System.out.println(urlhandler.MakeURLCall("/ids", "GET", ""));
17
         System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
18
         System.out.println(urlhandler.MakeURLCall("/messages", "GET", ""));
18
-    }
19
+
20
+
21
+//            ObjectMapper mapper = new ObjectMapper();
22
+//            jpayload = mapper.writeValueAsString();
23
+
24
+
25
+        }
26
+
27
+
28
+
19
 
29
 
20
     public String get_ids() {
30
     public String get_ids() {
21
         return MakeURLCall("/ids", "GET", "");
31
         return MakeURLCall("/ids", "GET", "");
37
             } catch (IOException ioe) {
47
             } catch (IOException ioe) {
38
                 ioe.printStackTrace();
48
                 ioe.printStackTrace();
39
             }
49
             }
40
-        } else if (method.equals("PUT")) {
50
+        } else if (method.equals("POST")) {
41
             RequestBody body = RequestBody.create(JSON, jpayload);
51
             RequestBody body = RequestBody.create(JSON, jpayload);
42
             Request request = new Request.Builder().url(myUrl).post(body).build();
52
             Request request = new Request.Builder().url(myUrl).post(body).build();
43
 
53
 
47
                 e.printStackTrace();
57
                 e.printStackTrace();
48
             }
58
             }
49
         }
59
         }
60
+
50
         return "nada";
61
         return "nada";
51
     }
62
     }
52
 
63