Mitch Taylor пре 6 година
родитељ
комит
22d1f9e2bd
2 измењених фајлова са 7 додато и 9 уклоњено
  1. 3
    0
      Client/src/main/java/SimpleShell.java
  2. 4
    9
      Client/src/main/java/YouAreEll.java

+ 3
- 0
Client/src/main/java/SimpleShell.java Прегледај датотеку

@@ -1,3 +1,5 @@
1
+import com.fasterxml.jackson.databind.ObjectMapper;
2
+
1 3
 import java.io.BufferedReader;
2 4
 import java.io.IOException;
3 5
 import java.io.InputStream;
@@ -19,6 +21,7 @@ public class SimpleShell {
19 21
         BufferedReader console = new BufferedReader
20 22
                 (new InputStreamReader(System.in));
21 23
 
24
+        ObjectMapper mapper = new ObjectMapper();
22 25
         ProcessBuilder pb = new ProcessBuilder();
23 26
         List<String> history = new ArrayList<String>();
24 27
         int index = 0;

+ 4
- 9
Client/src/main/java/YouAreEll.java Прегледај датотеку

@@ -41,14 +41,11 @@ public class YouAreEll {
41 41
     public String MakeURLCall(String mainUrl, String method, String jpayload) {
42 42
         String fullUrl = baseUrl + mainUrl;
43 43
         Request request = null;
44
-
45
-        if (method.equalsIgnoreCase("get")) {
44
+        if (method.equalsIgnoreCase("GET")) {
46 45
             request = new Request.Builder()
47 46
                     .url(fullUrl)
48 47
                     .build();
49 48
         }
50
-
51
-
52 49
         if (method.equalsIgnoreCase("POST")) {
53 50
             RequestBody body = RequestBody.create(JSON, jpayload);
54 51
             request = new Request.Builder()
@@ -56,7 +53,6 @@ public class YouAreEll {
56 53
                     .post(body)
57 54
                     .build();
58 55
         }
59
-
60 56
         if (method.equalsIgnoreCase("PUT")) {
61 57
             RequestBody body = RequestBody.create(JSON, jpayload);
62 58
             request = new Request.Builder()
@@ -64,15 +60,14 @@ public class YouAreEll {
64 60
                     .put(body)
65 61
                     .build();
66 62
         }
67
-
68 63
         if (request != null) {
69 64
             try (Response response = client.newCall(request).execute()) {
70
-                return response.body().string();
71
-            } catch (IOException e) {
65
+                return response.body().toString();
66
+            } catch (Exception e) {
72 67
                 e.printStackTrace();
73 68
             }
74 69
         }
75
-
76 70
         return "error: bad method " + method;
77 71
     }
72
+
78 73
 }