Commit c7799992 by Yujin Seo

Merge branch 'contract/sato/1.0.301_53022_group_id' into 'contract/sato/1.0.301'

API呼び出し失敗時にリトライするようにした。

See merge request !312
parents 252457ed 0d5f3bea
apply plugin: 'java'
sourceCompatibility = 1.6
targetCompatibility = 1.6
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.0'
......
......@@ -832,11 +832,15 @@ public class AcmsClient implements AcmsClientResponseListener {
Logger.d(TAG, "[url : %s], [param : %s]", apiUrl, param==null?"":param.toHttpParameterString());
HttpTaskWorker<HttpParameterObject> httpTaskThread = new HttpTaskWorker<HttpParameterObject>(methodName, apiUrl, param);
HttpTaskWorker<HttpParameterObject> httpTaskThread = null;
try {
httpTaskThread.start();
httpTaskThread.join(HttpRequestSender.DefaultConnectionTimeout);
long t = HttpRequestSender.DefaultConnectionTimeout * 2;
for (int i = 0; i < 3; i++, t *= 2) {
httpTaskThread = new HttpTaskWorker<HttpParameterObject>(methodName, apiUrl, param);
httpTaskThread.start();
httpTaskThread.join(t);
}
} catch (Exception e) {
Logger.e(TAG, e);
Logger.d(TAG, ExceptionDetailMessage.SERVER_IS_DISCONNECTED);
......@@ -880,12 +884,14 @@ public class AcmsClient implements AcmsClientResponseListener {
}
String apiUrl = url;
HttpMultipartTaskWorker<HttpMultipart> httpTaskThread = new HttpMultipartTaskWorker<HttpMultipart>(apiUrl, param);
HttpMultipartTaskWorker<HttpMultipart> httpTaskThread = null;
try{
httpTaskThread.start();
httpTaskThread.join(HttpRequestSender.DefaultConnectionTimeout);
long t = HttpRequestSender.DefaultConnectionTimeout * 2;
for (int i = 0; i < 3; i++, t *= 2) {
httpTaskThread = new HttpMultipartTaskWorker<HttpMultipart>(apiUrl, param);
httpTaskThread.start();
httpTaskThread.join(t);
}
} catch (Exception e) {
Logger.d(TAG, ExceptionDetailMessage.SERVER_IS_DISCONNECTED);
// サーバとの通信中、予期せぬ問題が発生しました。(1)
......
......@@ -86,10 +86,6 @@ import jp.agentec.adf.util.DateTimeUtil;
private ContentRefresher() {
}
public void setContentDownloadListener(ContentDownloadListener contentDownloadListener) {
this.contentDownloadListener = contentDownloadListener;
}
/**
* コンテンツ情報をACMSから更新します。
* @throws ABVException キャッシュにユーザ情報がありません。再度ログインする必要があります。
......@@ -415,7 +411,7 @@ import jp.agentec.adf.util.DateTimeUtil;
*/
private void resendEnquete() {
List<EnqueteDto> dtoList = enqueteLogic.getReplyEnquete();
if (dtoList != null && dtoList.size() > 0) {
for (EnqueteDto dto : dtoList) {
long contentId = dto.contentId;
......
......@@ -9,6 +9,7 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.FetchDateParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.exception.ABVException;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.NetworkDisconnectedException;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.adf.util.FileUtil;
......@@ -25,7 +26,7 @@ public class MasterDataLogic extends AbstractLogic {
* @throws Exception その他、例外です。
* @since 1.0.0
*/
public String initializeMasterData(String lastFetchDate) {
public String initializeMasterData(String lastFetchDate) throws AcmsException, NetworkDisconnectedException, IOException {
String fetchDate = null;
try {
FetchDateParameters param = new FetchDateParameters(cache.getMemberInfo().sid, lastFetchDate);
......@@ -47,6 +48,7 @@ public class MasterDataLogic extends AbstractLogic {
fetchDate = masterDataJson.fetchDate;
} catch (Exception e) {
Logger.e(TAG, "masterDataSend error : ", e);
throw e;
}
// masterData の fetchDateを渡す。
return fetchDate;
......
......@@ -42,10 +42,10 @@ public class HttpRequestSender {
/**
* ホストに接続するまでのタイムアウト時間をミリ秒で設定します。<br>
* デフォルトは20,000ミリ秒(20秒)です。
* デフォルトは5,000ミリ秒(5秒)です。
* @since 1.0.0
*/
public static final int DefaultConnectionTimeout = 20 * 1000;
public static final int DefaultConnectionTimeout = 5 * 1000;
/**
* 通信に利用する既定の文字セットです。UTF-8となります。
* @since 1.0.0
......
......@@ -1462,4 +1462,5 @@
<string name="msg_permission_dialog_bluetooth">Bluetooth利用権限が必要です。\nアプリ設定画面へ遷移します。</string>
<string name="dashboard">ダッシュボード</string>
<string name="failed_get_master_data">マスタデータの取得に失敗しました。画面を更新してください。</string>
</resources>
......@@ -1475,4 +1475,5 @@
<string name="msg_permission_dialog_bluetooth">Bluetooth usage authority is required. \n To transition to the application setting screen.</string>
<string name="dashboard">Dashboard</string>
<string name="failed_get_master_data">Failed to get master data. Refresh Home screen.</string>
</resources>
\ No newline at end of file
......@@ -423,10 +423,23 @@ public class OperationListActivity extends OperationActivity {
@Override
public void onRefreshedContent(final boolean result, long contentId, Exception e) {
super.onRefreshedContent(result, contentId, e);
final Exception ex = e;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (ex != null) {
// ヘッダーの新着更新処理を完了にさせる
stopUpdateAnimation();
final ABookAlertDialog messageDialog = AlertDialogUtil.createAlertDialog(OperationListActivity.this, R.string.app_name);
messageDialog.setMessage(getString(R.string.failed_get_master_data));
messageDialog.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
messageDialog.dismiss();
}
});
messageDialog.show();
}
if (!contentRefresher.isRefreshing()) {
// 新着処理が終わったら以下の処理が実行
stopUpdateAnimation();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment