@Test public void sendRequest() { long ts = System.currentTimeMillis(); String seed = UUID.randomUUID().toString(); }
public void sendRequest(String seed, long ts_start, long ts_end, double lat, double longi, int precision) { if (ts_start > ts_end) { ts_end = ts_start; } JSONObject announceRequestObj = null; try { announceRequestObj = SelfReportRequest.toJson(new String[]{seed}, new long[]{ts_start}, new long[]{ts_end}, lat, longi, precision); } catch(Exception e) { Log.e("err",e.getMessage()); } if (announceRequestObj == null) { status = false; return; } String selfReportRequest = SelfReportRequest.toHttpString(); Log.e("net", "send request to "+selfReportRequest); try { Log.e("net", "payload " + announceRequestObj.toString(2)); } catch(Exception e) { Log.e("net",e.getMessage()); status = false; } JSONObject resp = NetworkHelper.sendRequest(selfReportRequest, Request.Method.PUT, announceRequestObj); try { if (resp == null || (resp.has("statusCode") && resp.getInt("statusCode") != 200)) { Utils.mkSnack(av, view, context.getString(R.string.error_submitting_data)); status = false; return; } else { Utils.mkSnack(av, view, context.getString(R.string.report_has_been_submitted)); DiagnosisFragment.updateSubmissionView(av, context, view, true); status = true; return; } } catch(Exception e) { Log.e("status",e.getMessage()); status = false; return; } }
SendInfectedUserData extends AsyncTask<Void, Void, Void> { public void sendRequest(String seed, long ts_start, long ts_end, double lat, double longi, int precision) { if (ts_start > ts_end) { ts_end = ts_start; } JSONObject announceRequestObj = null; try { announceRequestObj = SelfReportRequest.toJson(new String[]{seed}, new long[]{ts_start}, new long[]{ts_end}, lat, longi, precision); } catch(Exception e) { Log.e("err",e.getMessage()); } if (announceRequestObj == null) { status = false; return; } String selfReportRequest = SelfReportRequest.toHttpString(); Log.e("net", "send request to "+selfReportRequest); try { Log.e("net", "payload " + announceRequestObj.toString(2)); } catch(Exception e) { Log.e("net",e.getMessage()); status = false; } JSONObject resp = NetworkHelper.sendRequest(selfReportRequest, Request.Method.PUT, announceRequestObj); try { if (resp == null || (resp.has("statusCode") && resp.getInt("statusCode") != 200)) { Utils.mkSnack(av, view, context.getString(R.string.error_submitting_data)); status = false; return; } else { Utils.mkSnack(av, view, context.getString(R.string.report_has_been_submitted)); DiagnosisFragment.updateSubmissionView(av, context, view, true); status = true; return; } } catch(Exception e) { Log.e("status",e.getMessage()); status = false; return; } } }
SendInfectedUserData extends AsyncTask<Void, Void, Void> { public void sendRequest(String seed, long ts_start, long ts_end, double lat, double longi, int precision) { if (ts_start > ts_end) { ts_end = ts_start; } JSONObject announceRequestObj = null; try { announceRequestObj = SelfReportRequest.toJson(new String[]{seed}, new long[]{ts_start}, new long[]{ts_end}, lat, longi, precision); } catch(Exception e) { Log.e("err",e.getMessage()); } if (announceRequestObj == null) { status = false; return; } String selfReportRequest = SelfReportRequest.toHttpString(); Log.e("net", "send request to "+selfReportRequest); try { Log.e("net", "payload " + announceRequestObj.toString(2)); } catch(Exception e) { Log.e("net",e.getMessage()); status = false; } JSONObject resp = NetworkHelper.sendRequest(selfReportRequest, Request.Method.PUT, announceRequestObj); try { if (resp == null || (resp.has("statusCode") && resp.getInt("statusCode") != 200)) { Utils.mkSnack(av, view, context.getString(R.string.error_submitting_data)); status = false; return; } else { Utils.mkSnack(av, view, context.getString(R.string.report_has_been_submitted)); DiagnosisFragment.updateSubmissionView(av, context, view, true); status = true; return; } } catch(Exception e) { Log.e("status",e.getMessage()); status = false; return; } } SendInfectedUserData(Context context, Activity av, View view); }
SendInfectedUserData extends AsyncTask<Void, Void, Void> { public void sendRequest(String seed, long ts_start, long ts_end, double lat, double longi, int precision) { if (ts_start > ts_end) { ts_end = ts_start; } JSONObject announceRequestObj = null; try { announceRequestObj = SelfReportRequest.toJson(new String[]{seed}, new long[]{ts_start}, new long[]{ts_end}, lat, longi, precision); } catch(Exception e) { Log.e("err",e.getMessage()); } if (announceRequestObj == null) { status = false; return; } String selfReportRequest = SelfReportRequest.toHttpString(); Log.e("net", "send request to "+selfReportRequest); try { Log.e("net", "payload " + announceRequestObj.toString(2)); } catch(Exception e) { Log.e("net",e.getMessage()); status = false; } JSONObject resp = NetworkHelper.sendRequest(selfReportRequest, Request.Method.PUT, announceRequestObj); try { if (resp == null || (resp.has("statusCode") && resp.getInt("statusCode") != 200)) { Utils.mkSnack(av, view, context.getString(R.string.error_submitting_data)); status = false; return; } else { Utils.mkSnack(av, view, context.getString(R.string.report_has_been_submitted)); DiagnosisFragment.updateSubmissionView(av, context, view, true); status = true; return; } } catch(Exception e) { Log.e("status",e.getMessage()); status = false; return; } } SendInfectedUserData(Context context, Activity av, View view); void sendRequest(String seed, long ts_start, long ts_end, double lat, double longi, int precision); void testDatabase(); }
SendInfectedUserData extends AsyncTask<Void, Void, Void> { public void sendRequest(String seed, long ts_start, long ts_end, double lat, double longi, int precision) { if (ts_start > ts_end) { ts_end = ts_start; } JSONObject announceRequestObj = null; try { announceRequestObj = SelfReportRequest.toJson(new String[]{seed}, new long[]{ts_start}, new long[]{ts_end}, lat, longi, precision); } catch(Exception e) { Log.e("err",e.getMessage()); } if (announceRequestObj == null) { status = false; return; } String selfReportRequest = SelfReportRequest.toHttpString(); Log.e("net", "send request to "+selfReportRequest); try { Log.e("net", "payload " + announceRequestObj.toString(2)); } catch(Exception e) { Log.e("net",e.getMessage()); status = false; } JSONObject resp = NetworkHelper.sendRequest(selfReportRequest, Request.Method.PUT, announceRequestObj); try { if (resp == null || (resp.has("statusCode") && resp.getInt("statusCode") != 200)) { Utils.mkSnack(av, view, context.getString(R.string.error_submitting_data)); status = false; return; } else { Utils.mkSnack(av, view, context.getString(R.string.report_has_been_submitted)); DiagnosisFragment.updateSubmissionView(av, context, view, true); status = true; return; } } catch(Exception e) { Log.e("status",e.getMessage()); status = false; return; } } SendInfectedUserData(Context context, Activity av, View view); void sendRequest(String seed, long ts_start, long ts_end, double lat, double longi, int precision); void testDatabase();  }