From 9bc77ab13e81ab60fa95a8d82ffb7d35a5615cb0 Mon Sep 17 00:00:00 2001 From: Syd Logan Date: Sat, 9 Jun 2018 10:11:34 -0700 Subject: [PATCH] factor web protocol (http(s)) to RESTful --- .../org/thousandsmiles/tscharts_lib/ClinicREST.java | 2 +- .../org/thousandsmiles/tscharts_lib/ImageREST.java | 8 ++++---- .../org/thousandsmiles/tscharts_lib/LoginREST.java | 4 ++-- .../tscharts_lib/MedicalHistoryREST.java | 10 +++++----- .../thousandsmiles/tscharts_lib/MedicationsREST.java | 2 +- .../java/org/thousandsmiles/tscharts_lib/RESTful.java | 4 ++++ 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/thousandsmiles/tscharts_lib/ClinicREST.java b/app/src/main/java/org/thousandsmiles/tscharts_lib/ClinicREST.java index 58f2b4d..bcabe0f 100644 --- a/app/src/main/java/org/thousandsmiles/tscharts_lib/ClinicREST.java +++ b/app/src/main/java/org/thousandsmiles/tscharts_lib/ClinicREST.java @@ -126,7 +126,7 @@ public Object getClinicData(int year, int month, int day) { RequestQueue queue = volley.getQueue(); - String url = String.format("http://%s:%s/tscharts/v1/clinic/?date=%s/%s/%s", getIP(), getPort(), month, day, year); + String url = String.format("%s://%s:%s/tscharts/v1/clinic/?date=%s/%s/%s", getProtocol(), getIP(), getPort(), month, day, year); AuthJSONObjectRequest request = new AuthJSONObjectRequest(Request.Method.GET, url, null, new ResponseListener(), new ErrorListener()); diff --git a/app/src/main/java/org/thousandsmiles/tscharts_lib/ImageREST.java b/app/src/main/java/org/thousandsmiles/tscharts_lib/ImageREST.java index b812ca1..8c73c97 100644 --- a/app/src/main/java/org/thousandsmiles/tscharts_lib/ImageREST.java +++ b/app/src/main/java/org/thousandsmiles/tscharts_lib/ImageREST.java @@ -193,7 +193,7 @@ public Object getImageData(int imageid, File file) { m_queue = volley.getQueue(); - String url = String.format("http://%s:%s/tscharts/v1/image/%d/", getIP(), getPort(), imageid); + String url = String.format("%s://%s:%s/tscharts/v1/image/%d/", getProtocol(), getIP(), getPort(), imageid); ImageREST.AuthJSONObjectRequest request = new ImageREST.AuthJSONObjectRequest(Request.Method.GET, url, null, new ImageREST.ResponseListener(), new ImageREST.ErrorListener()); @@ -211,7 +211,7 @@ public Object getMostRecentPatientImageData(int patientid, File file) { volley.initQueueIf(getContext()); - String url = String.format("http://%s:%s/tscharts/v1/image?patient=%d&newest=true", getIP(), getPort(), patientid); + String url = String.format("%s://%s:%s/tscharts/v1/image?patient=%d&newest=true", getProtocol(), getIP(), getPort(), patientid); ImageREST.AuthJSONObjectRequest request = new ImageREST.AuthJSONObjectRequest(Request.Method.GET, url, null, new ImageREST.ResponseListener(), new ImageREST.ErrorListener()); @@ -263,7 +263,7 @@ public Object createImage(File file) { // fail } - String url = String.format("http://%s:%s/tscharts/v1/image/", getIP(), getPort()); + String url = String.format("%s://%s:%s/tscharts/v1/image/", getProtocol(), getIP(), getPort()); ImageREST.AuthJSONObjectRequest request = new ImageREST.AuthJSONObjectRequest(Request.Method.POST, url, data, new PostResponseListener(), new ErrorListener()); request.setRetryPolicy(new DefaultRetryPolicy(getTimeoutInMillis(), getRetries(), DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); @@ -288,7 +288,7 @@ public Object getAllPatientImages(int patientid, File file, boolean sort) { RequestQueue queue = volley.getQueue(); - String url = String.format("http://%s:%s/tscharts/v1/image?patient=%d&sort=%s", getIP(), getPort(), patientid, sortArg); + String url = String.format("%s://%s:%s/tscharts/v1/image?patient=%d&sort=%s", getProtocol(), getIP(), getPort(), patientid, sortArg); AuthJSONArrayRequest request = new AuthJSONArrayRequest(url, null, new ArrayResponseListener(), new ErrorListener()); request.setRetryPolicy(new DefaultRetryPolicy( 50000, 5, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); diff --git a/app/src/main/java/org/thousandsmiles/tscharts_lib/LoginREST.java b/app/src/main/java/org/thousandsmiles/tscharts_lib/LoginREST.java index 9dcd533..95a3aa3 100644 --- a/app/src/main/java/org/thousandsmiles/tscharts_lib/LoginREST.java +++ b/app/src/main/java/org/thousandsmiles/tscharts_lib/LoginREST.java @@ -115,7 +115,7 @@ public Object signIn(String username, String password) { RequestQueue queue = volley.getQueue(); - String url = String.format("http://%s:%s/tscharts/v1/login/", getIP(), getPort()); + String url = String.format("%s://%s:%s/tscharts/v1/login/", getProtocol(), getIP(), getPort()); JSONObject data = new JSONObject(); @@ -143,7 +143,7 @@ public Object signOut() { RequestQueue queue = volley.getQueue(); - String url = String.format("http://%s/tscharts/v1/logout/", getIP()); + String url = String.format("%s://%s/tscharts/v1/logout/", getProtocol(), getIP()); JSONObject data = new JSONObject(); diff --git a/app/src/main/java/org/thousandsmiles/tscharts_lib/MedicalHistoryREST.java b/app/src/main/java/org/thousandsmiles/tscharts_lib/MedicalHistoryREST.java index 347be7c..f3a3257 100644 --- a/app/src/main/java/org/thousandsmiles/tscharts_lib/MedicalHistoryREST.java +++ b/app/src/main/java/org/thousandsmiles/tscharts_lib/MedicalHistoryREST.java @@ -160,7 +160,7 @@ public Object createMedicalHistory(MedicalHistory mh) { JSONObject data = mh.toJSONObject(false); - String url = String.format("http://%s:%s/tscharts/v1/medicalhistory/", getIP(), getPort()); + String url = String.format("%s://%s:%s/tscharts/v1/medicalhistory/", getProtocol(), getIP(), getPort()); MedicalHistoryREST.AuthJSONObjectRequest request = new MedicalHistoryREST.AuthJSONObjectRequest(Request.Method.POST, url, data, new PostResponseListener(), new ErrorListener()); request.setRetryPolicy(new DefaultRetryPolicy(getTimeoutInMillis(), getRetries(), DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); @@ -178,7 +178,7 @@ public Object getMedicalHistoryData(int historyid) { RequestQueue queue = volley.getQueue(); - String url = String.format("http://%s:%s/tscharts/v1/medicalhistory/%d/", getIP(), getPort(), historyid); + String url = String.format("%s://%s:%s/tscharts/v1/medicalhistory/%d/", getProtocol(), getIP(), getPort(), historyid); AuthJSONObjectRequest request = new AuthJSONObjectRequest(Request.Method.GET, url, null, new ResponseListener(), new ErrorListener()); request.setRetryPolicy(new DefaultRetryPolicy(getTimeoutInMillis(), getRetries(), DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); @@ -196,8 +196,8 @@ public Object getMedicalHistoryData(int clinicid, int patientid) { RequestQueue queue = volley.getQueue(); - String url = String.format("http://%s:%s/tscharts/v1/medicalhistory/?clinic=%d&patient=%d", - getIP(), getPort(), clinicid, patientid); + String url = String.format("%s://%s:%s/tscharts/v1/medicalhistory/?clinic=%d&patient=%d", + getProtocol(), getIP(), getPort(), clinicid, patientid); AuthJSONObjectRequest request = new AuthJSONObjectRequest(Request.Method.GET, url, null, new ResponseListener(), new ErrorListener()); request.setRetryPolicy(new DefaultRetryPolicy(getTimeoutInMillis(), getRetries(), DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); @@ -217,7 +217,7 @@ public Object updateMedicalHistory(MedicalHistory mh) { JSONObject data = mh.toJSONObject(true); - String url = String.format("http://%s:%s/tscharts/v1/medicalhistory/%d/", getIP(), getPort(), mh.getId()); + String url = String.format("%s://%s:%s/tscharts/v1/medicalhistory/%d/", getProtocol(), getIP(), getPort(), mh.getId()); AuthJSONObjectRequest request = new AuthJSONObjectRequest(Request.Method.PUT, url, data, new PutResponseListener(), new ErrorListener()); request.setRetryPolicy(new DefaultRetryPolicy(getTimeoutInMillis(), getRetries(), DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); diff --git a/app/src/main/java/org/thousandsmiles/tscharts_lib/MedicationsREST.java b/app/src/main/java/org/thousandsmiles/tscharts_lib/MedicationsREST.java index ef2e946..e045459 100644 --- a/app/src/main/java/org/thousandsmiles/tscharts_lib/MedicationsREST.java +++ b/app/src/main/java/org/thousandsmiles/tscharts_lib/MedicationsREST.java @@ -132,7 +132,7 @@ public Object getMedicationsList() { RequestQueue queue = volley.getQueue(); - String url = String.format("http://%s:%s/tscharts/v1/medications/", getIP(), getPort()); + String url = String.format("%s://%s:%s/tscharts/v1/medications/", getProtocol(), getIP(), getPort()); AuthJSONArrayRequest request = new AuthJSONArrayRequest(url, null, new GetMedicationsResponseListener(), new ErrorListener()); request.setRetryPolicy(new DefaultRetryPolicy(getTimeoutInMillis(), getRetries(), DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); diff --git a/app/src/main/java/org/thousandsmiles/tscharts_lib/RESTful.java b/app/src/main/java/org/thousandsmiles/tscharts_lib/RESTful.java index 21da5e0..6a678b6 100644 --- a/app/src/main/java/org/thousandsmiles/tscharts_lib/RESTful.java +++ b/app/src/main/java/org/thousandsmiles/tscharts_lib/RESTful.java @@ -89,4 +89,8 @@ public String getIP() { String val = sharedPref.getString("ipAddress", ""); return val; } + + public String getProtocol() { + return "https"; + } }