Skip to content

Commit

Permalink
factor web protocol (http(s)) to RESTful
Browse files Browse the repository at this point in the history
  • Loading branch information
slogan621 committed Jun 9, 2018
1 parent a991b12 commit 9bc77ab
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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());

Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ public String getIP() {
String val = sharedPref.getString("ipAddress", "");
return val;
}

public String getProtocol() {
return "https";
}
}

0 comments on commit 9bc77ab

Please sign in to comment.