Commit 7e1e33dd by Kazuyuki Hida

checkapi/taskData/ のレスポンスをJSのコールバックにextParamとして渡すようにした(暫定的な実装)。

parent e38d4b24
package jp.agentec.abook.abv.bl.acms.client;
import org.json.adf.JSONObject;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
......@@ -81,6 +83,7 @@ import jp.agentec.abook.abv.bl.dto.GroupDto;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.dto.ServiceOptionDto;
import jp.agentec.abook.abv.bl.dto.TaskReportDto;
import jp.agentec.abook.abv.bl.logic.ReportStatusLogic;
import jp.agentec.adf.net.http.HttpDownloadState;
import jp.agentec.adf.net.http.HttpFileDownloader;
import jp.agentec.adf.net.http.HttpMultipart;
......@@ -569,6 +572,14 @@ public class AcmsClient implements AcmsClientResponseListener {
AcmsMessageJSON json = new AcmsMessageJSON(result.httpResponseBody);
// JSのコールバックに渡すために必要な情報をストックしておく(暫定的な実装 fixme )
if (apiUrl.contains(AcmsApis.ApiSendTaskData)) {
JSONObject res = new JSONObject(result.httpResponseBody);
int reportStatus = res.has("reportStatus") ? res.getInt("reportStatus") : null;
String message = res.has("message") ? res.getString("message") : null;
ReportStatusLogic.TaskReportExtParam.stock(String.valueOf(reportStatus), message);
}
Logger.d(TAG, "sendTaskData res: %s", json);
if (json.errorMessage != null) {
......
......@@ -51,4 +51,44 @@ public class ReportStatusLogic extends AbstractLogic {
}
}
}
/**
* API checkapi/taskData/で得られた、
*   reportStatus
*   message
* をJavaScriptのコールバックを呼び出すときに使用するため保持しておくところ。
* スレッドセーフにはなっていないし、スコープはpublicだしという行儀の悪い実装方法であるが、
* APIの呼び出しとコールバックの呼び出しが、コードとして遠くに離れているので、
* 適切な方法がないため、やむなくこのような実装になっている。
*/
public static class TaskReportExtParam {
public String reportStatus; // 0:成功、2:承認中、999:その他エラー
public String message; // reportStatus = 0 以外の時のエラーメッセージ reportStatus = 0 の時は無し
private static TaskReportExtParam instance = null;
public static void stock(String reportStatus, String message) {
if (instance == null) {
instance = new TaskReportExtParam();
}
instance.reportStatus = reportStatus;
instance.message = message;
}
public static TaskReportExtParam pick() {
if (instance == null || instance.reportStatus == null) {
return null;
} else {
return instance;
}
}
public static void clear() {
if (instance != null) {
instance.message = null;
instance.reportStatus = null;
}
}
}
}
Subproject commit 30c9f2ce9b4bb74e8851afb11b2b4670bca6ce68
Subproject commit 92bfa7ec340bfa215d0b1f2e06ef8e318c1dddad
......@@ -56,6 +56,7 @@ import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.ContentReadingLogLogic;
import jp.agentec.abook.abv.bl.logic.LockReportLogic;
import jp.agentec.abook.abv.bl.logic.OperationLogic;
import jp.agentec.abook.abv.bl.logic.ReportStatusLogic;
import jp.agentec.abook.abv.bl.logic.UnlockReportLogic;
import jp.agentec.abook.abv.bl.websocket.MeetingManager;
import jp.agentec.abook.abv.cl.environment.DeviceInfo;
......@@ -975,8 +976,15 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
afterABookCheckApi(mCmd, mTaskKey, 0, "", null, isOperationPdf());
return null;
}
if (mAddReport) { // 作業追加ありの場合
if (mCmd.equals(ABookKeys.CMD_INSERT_TASK_REPORT) || mCmd.equals(ABookKeys.CMD_UPDATE_TASK_REPORT)) {
ReportStatusLogic.TaskReportExtParam extParam = ReportStatusLogic.TaskReportExtParam.pick();
JSONObject extJson = new JSONObject();
if (extParam != null) {
extJson.put("reportStatus", extParam.reportStatus);
extJson.put("message", extParam.message);
}
afterABookCheckApi(mCmd, mTaskKey, 0, "", extJson.toString(), isOperationPdf());
} else if (mAddReport) { // 作業追加ありの場合
// コールバック処理のみ行う。
afterABookCheckApi(mCmd, mTaskKey, 0, "", null, isOperationPdf());
} else {
......
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