Commit 28d506aa by Kang Donghun

#73190 更新チェック用API(Android)

parent 36fd7757
...@@ -24,7 +24,6 @@ import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON; ...@@ -24,7 +24,6 @@ import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.DashboardStatusJSON; import jp.agentec.abook.abv.bl.acms.client.json.DashboardStatusJSON;
import jp.agentec.abook.abv.bl.acms.client.json.GroupsJSON; import jp.agentec.abook.abv.bl.acms.client.json.GroupsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.LockReportJSON; import jp.agentec.abook.abv.bl.acms.client.json.LockReportJSON;
import jp.agentec.abook.abv.bl.acms.client.json.LogSendFlagJSON;
import jp.agentec.abook.abv.bl.acms.client.json.MasterDataJSON; import jp.agentec.abook.abv.bl.acms.client.json.MasterDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.NewAppStoreLoginJSON; import jp.agentec.abook.abv.bl.acms.client.json.NewAppStoreLoginJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationGroupMasterJSON; import jp.agentec.abook.abv.bl.acms.client.json.OperationGroupMasterJSON;
...@@ -33,6 +32,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.RequirePasswordChangeJSON; ...@@ -33,6 +32,7 @@ import jp.agentec.abook.abv.bl.acms.client.json.RequirePasswordChangeJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ResultJSON; import jp.agentec.abook.abv.bl.acms.client.json.ResultJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ServerTimeZoneJSON; import jp.agentec.abook.abv.bl.acms.client.json.ServerTimeZoneJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ServiceOptionsJSON; import jp.agentec.abook.abv.bl.acms.client.json.ServiceOptionsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ShopSyncWatermarkJSON;
import jp.agentec.abook.abv.bl.acms.client.json.FixPushMessageJSON; import jp.agentec.abook.abv.bl.acms.client.json.FixPushMessageJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON; import jp.agentec.abook.abv.bl.acms.client.json.OperationDataJSON;
import jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON; import jp.agentec.abook.abv.bl.acms.client.json.OperationListJSON;
...@@ -44,7 +44,6 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentParameters; ...@@ -44,7 +44,6 @@ import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsContentParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AddMemberGroupParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.AddMemberGroupParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.AppStoreNewLoginParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.AppStoreNewLoginParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.CheckSendLogParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.ContentReadingLogParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.ContentReadingLogParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.EnqueteReplyParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.EnqueteReplyParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.EnterpriseLoginParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.EnterpriseLoginParameters;
...@@ -506,13 +505,6 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -506,13 +505,6 @@ public class AcmsClient implements AcmsClientResponseListener {
return json.result; return json.result;
} }
public int checkSendLogFile(CheckSendLogParameters param) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.CheckSendLogFileFormat, param);
LogSendFlagJSON json = new LogSendFlagJSON(response.httpResponseBody);
Logger.d(TAG, "[checkSendLogFile]: returnValue=" + json.logSendFlg);
return json.logSendFlg;
}
//プロジェクト取得 //プロジェクト取得
public OperationListJSON getOperationList(AcmsParameters param) throws NetworkDisconnectedException, AcmsException { public OperationListJSON getOperationList(AcmsParameters param) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApiOperationList, param); HttpResponse response = send(AcmsApis.ApiOperationList, param);
...@@ -989,7 +981,8 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -989,7 +981,8 @@ public class AcmsClient implements AcmsClientResponseListener {
AcmsApis.ApiSendPushMessage, AcmsApis.ApiSendPushMessage,
AcmsApis.ApiLockReport, AcmsApis.ApiLockReport,
AcmsApis.ApiUnlockReport, AcmsApis.ApiUnlockReport,
AcmsApis.ApiGetDashboardStatus AcmsApis.ApiGetDashboardStatus,
AcmsApis.ApiShopSyncWatermark
}; };
public HttpTaskWorker(String methodName, String apiUrl, T param) { public HttpTaskWorker(String methodName, String apiUrl, T param) {
...@@ -1065,6 +1058,14 @@ public class AcmsClient implements AcmsClientResponseListener { ...@@ -1065,6 +1058,14 @@ public class AcmsClient implements AcmsClientResponseListener {
} }
/** /**
* DB同期の必要性を判定するウォーターマーク情報を取得する
*/
public ShopSyncWatermarkJSON checkShopSyncWatermark(AcmsParameters param) throws NetworkDisconnectedException, AcmsException {
HttpResponse response = send(AcmsApis.ApiShopSyncWatermark, param);
return new ShopSyncWatermarkJSON(response.httpResponseBody);
}
/**
* プッシュメッセージ情報の取得 * プッシュメッセージ情報の取得
* @param param 送信パラメータ情報 * @param param 送信パラメータ情報
* @return 通信結果JSON * @return 通信結果JSON
......
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONObject;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
/**
* ACMSからのJSONがbooleanのresultという項目を予め持っているクラスです。booleanのresultを持つJSONに対応するクラスを作成するときはこのクラスを継承してください。
*
*/
public class LogSendFlagJSON extends AcmsCommonJSON {
public static final String JSONPropertyResult = "logSendFlg";
public int logSendFlg;
public LogSendFlagJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
super.parse(json);
logSendFlg = getInt(json, JSONPropertyResult, 0);
}
}
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONObject;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
/**
* checkapi/shopSyncWatermark/ のレスポンスを変換するクラス
*/
public class ShopSyncWatermarkJSON extends AcmsCommonJSON {
public static final String NeedsFullSync = "needsFullSync";
public static final String LastChangedAt = "lastChangedAt";
public boolean needsFullSync = true;
public String lastChangedAt;
public ShopSyncWatermarkJSON(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException {
super.parse(json);
if (json.has(NeedsFullSync)) {
Object value = json.get(NeedsFullSync);
if (value instanceof Boolean) {
needsFullSync = (Boolean) value;
} else if (value instanceof Number) {
needsFullSync = ((Number) value).intValue() != 0;
} else if (value instanceof String) {
String lowerValue = ((String) value).toLowerCase();
needsFullSync = "true".equals(lowerValue) || "1".equals(lowerValue);
}
}
lastChangedAt = getStringOrNull(json, LastChangedAt);
}
}
package jp.agentec.abook.abv.bl.acms.client.parameters;
import jp.agentec.adf.net.http.HttpParameterObject;
public class CheckSendLogParameters extends HttpParameterObject {
/**
* ユーザ認証キー
* @since 1.0.0
*/
protected String sid;
/**
* 端末タイプ
* @since 1.0.0
*/
protected int deviceTypeId;
/**
* 端末ID
* @since 1.0.0
*/
protected String uid;
/**
* 端末のMACアドレス
* @since 1.0.0
*/
protected String ma;
/**
* {@link NewAppStoreLoginParameters} クラスのインスタンスを初期化します。
* @param sid ユーザのログインIDです。半角英数字と'_'、'-'のみ使えます。
* @param deviceTypeId 端末タイプです。
* @param uid 端末IDです。
* @param ma 端末のMACアドレスです。
* @throws IllegalArgumentException 引数のどれかが半角英数字と'_'、'-'ではありません。
* @since 1.0.0
*/
public CheckSendLogParameters(String sid, int deviceTypeId, String uid, String ma) throws IllegalArgumentException {
this.sid = sid;
this.deviceTypeId = deviceTypeId;
this.uid = uid;
this.ma = ma;
}
public String getSid() {
return sid;
}
public void setSid(String sid) {
this.sid = sid;
}
public int getDeviceTypeId() {
return deviceTypeId;
}
public void setDeviceTypeId(int deviceTypeId) {
this.deviceTypeId = deviceTypeId;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getMa() {
return ma;
}
public void setMa(String ma) {
this.ma = ma;
}
}
...@@ -156,6 +156,8 @@ public class AcmsApis { ...@@ -156,6 +156,8 @@ public class AcmsApis {
public static final String ApiGetMasterData = "getMasterData"; public static final String ApiGetMasterData = "getMasterData";
// 作業種別データ取得 // 作業種別データ取得
public static final String ApiOperationGroupMaster = "operationGroupMaster"; public static final String ApiOperationGroupMaster = "operationGroupMaster";
// DB同期必要性チェック
public static final String ApiShopSyncWatermark = "shopSyncWatermark";
// 簡易帳票一覧取得 // 簡易帳票一覧取得
public static final String ApiQuickReportSearch = "quickReportSearch"; public static final String ApiQuickReportSearch = "quickReportSearch";
// 簡易帳票リビジョン一覧取得 // 簡易帳票リビジョン一覧取得
...@@ -185,12 +187,6 @@ public class AcmsApis { ...@@ -185,12 +187,6 @@ public class AcmsApis {
public static final String DownloadApplicationAPKFile = "%s/%s/appdl/downloadApp/android/3/%s/%s"; public static final String DownloadApplicationAPKFile = "%s/%s/appdl/downloadApp/android/3/%s/%s";
/**
* 端末からログ取得要求があるかどうかを判定する
* @since 1.8.4
*/
public static final String CheckSendLogFileFormat = "checkSendLogFile";
public static final String GetTaskFileUrlFormat = "%s/%s/checkapi/getTaskFile"; public static final String GetTaskFileUrlFormat = "%s/%s/checkapi/getTaskFile";
...@@ -216,6 +212,7 @@ public class AcmsApis { ...@@ -216,6 +212,7 @@ public class AcmsApis {
methodName.equals(ApiGetTaskFile) || methodName.equals(ApiSceneEntry) || methodName.equals(ApiTaskContentEntry) || methodName.equals(ApiGetTaskFile) || methodName.equals(ApiSceneEntry) || methodName.equals(ApiTaskContentEntry) ||
methodName.equals(ApiSendPushMessage) || methodName.equals(ApiGetPushMessages) || methodName.equals(ApiSendRoutineTaskData) || methodName.equals(ApiSendPushMessage) || methodName.equals(ApiGetPushMessages) || methodName.equals(ApiSendRoutineTaskData) ||
methodName.equals(ApiGetMasterData) || methodName.equals(ApiGetMasterData) ||
methodName.equals(ApiShopSyncWatermark) ||
// カテゴリ選択機能、IO帳票で3つ追加 // カテゴリ選択機能、IO帳票で3つ追加
methodName.equals(ApiOperationGroupMaster) || methodName.equals(ApiQuickReportSearch) || methodName.equals(ApiQuickReportRevision) || methodName.equals(ApiOperationGroupMaster) || methodName.equals(ApiQuickReportSearch) || methodName.equals(ApiQuickReportRevision) ||
// ダッシュボード、ロック追加 // ダッシュボード、ロック追加
......
...@@ -19,7 +19,7 @@ import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase; ...@@ -19,7 +19,7 @@ import jp.agentec.abook.abv.bl.common.db.SQLiteDatabase;
public class DBConnector { public class DBConnector {
private static volatile DBConnector dbConnector = null; private static volatile DBConnector dbConnector = null;
public static final String DatabaseName = "ABVJE"; public static final String DatabaseName = "ABVJE";
public static final int DatabaseVersion = DatabaseVersions.Ver1_0_612; public static final int DatabaseVersion = DatabaseVersions.Ver1_0_613;
protected SQLiteDatabase db = null; protected SQLiteDatabase db = null;
......
...@@ -8,4 +8,5 @@ public class DatabaseVersions { ...@@ -8,4 +8,5 @@ public class DatabaseVersions {
public static final int Ver1_0_4 = 31; // @From ロック、ダッシュボード対応 public static final int Ver1_0_4 = 31; // @From ロック、ダッシュボード対応
public static final int Ver1_0_5 = 32; // Ver.1.0.600 プッシュメッセージ仕様変更対応 public static final int Ver1_0_5 = 32; // Ver.1.0.600 プッシュメッセージ仕様変更対応
public static final int Ver1_0_612 = 33; public static final int Ver1_0_612 = 33;
public static final int Ver1_0_613 = 43; // shopSyncWatermark lastFetchDate
} }
...@@ -41,6 +41,10 @@ public class AcmsDao extends AbstractDao { ...@@ -41,6 +41,10 @@ public class AcmsDao extends AbstractDao {
if (colnum != -1) { if (colnum != -1) {
dto.contentVersionLastFetchDate = cursor.getString(colnum); dto.contentVersionLastFetchDate = cursor.getString(colnum);
} }
colnum = cursor.getColumnIndex("shopsyncwatermark_last_fetch_date");
if (colnum != -1) {
dto.shopSyncWatermarkLastFetchDate = cursor.getString(colnum);
}
return dto; return dto;
} }
...@@ -54,7 +58,7 @@ public class AcmsDao extends AbstractDao { ...@@ -54,7 +58,7 @@ public class AcmsDao extends AbstractDao {
} }
public void insert(AcmsDto acmsDto) { public void insert(AcmsDto acmsDto) {
insert("insert into m_acms (url_path, acms_address,download_server_address, websocket_server_http_url, websocket_server_ws_url, schedulelist_last_fetch_date, contentversion_last_fetch_date) values (?,?,?,?,?,?,?)", acmsDto.getInsertValues()); insert("insert into m_acms (url_path, acms_address,download_server_address, websocket_server_http_url, websocket_server_ws_url, schedulelist_last_fetch_date, contentversion_last_fetch_date, shopsyncwatermark_last_fetch_date) values (?,?,?,?,?,?,?,?)", acmsDto.getInsertValues());
} }
public boolean isTodayLastAnnounceChangePasswordDate() { public boolean isTodayLastAnnounceChangePasswordDate() {
...@@ -84,6 +88,15 @@ public class AcmsDao extends AbstractDao { ...@@ -84,6 +88,15 @@ public class AcmsDao extends AbstractDao {
return count > 0; return count > 0;
} }
public String selectShopSyncWatermarkLastFetchDate() {
return rawQueryGetString("select shopsyncwatermark_last_fetch_date from m_acms order by shopsyncwatermark_last_fetch_date desc limit 1", null);
}
public boolean updateShopSyncWatermarkLastFetchDate(String fetchDate) {
long count = update("update m_acms set shopsyncwatermark_last_fetch_date=?", new Object[]{fetchDate});
return count > 0;
}
public void clearFetchDate() { public void clearFetchDate() {
updateScheduleListLastFetchDate(""); updateScheduleListLastFetchDate("");
updateContentVersionLastFetchDate(""); updateContentVersionLastFetchDate("");
......
...@@ -29,6 +29,7 @@ public class MAcms extends SQLiteTableScript { ...@@ -29,6 +29,7 @@ public class MAcms extends SQLiteTableScript {
sql.append(" , websocket_server_ws_url VARCHAR(256) "); sql.append(" , websocket_server_ws_url VARCHAR(256) ");
sql.append(" , schedulelist_last_fetch_date VARCHAR(256) "); sql.append(" , schedulelist_last_fetch_date VARCHAR(256) ");
sql.append(" , contentversion_last_fetch_date VARCHAR(256) "); sql.append(" , contentversion_last_fetch_date VARCHAR(256) ");
sql.append(" , shopsyncwatermark_last_fetch_date VARCHAR(256) ");
sql.append(" , PRIMARY KEY (url_path) "); sql.append(" , PRIMARY KEY (url_path) ");
sql.append(" ) "); sql.append(" ) ");
...@@ -44,7 +45,11 @@ public class MAcms extends SQLiteTableScript { ...@@ -44,7 +45,11 @@ public class MAcms extends SQLiteTableScript {
@Override @Override
public List<String> getUpgradeScript(int oldVersion, int newVersion) { public List<String> getUpgradeScript(int oldVersion, int newVersion) {
return null; List<String> ddl = new ArrayList<String>();
if (oldVersion < DatabaseVersions.Ver1_0_613) {
ddl.add("ALTER TABLE m_acms ADD COLUMN shopsyncwatermark_last_fetch_date VARCHAR(256)");
}
return ddl;
} }
} }
...@@ -7,6 +7,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -7,6 +7,7 @@ import java.util.concurrent.ConcurrentHashMap;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient; import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON; import jp.agentec.abook.abv.bl.acms.client.json.ContentVersionsJSON;
import jp.agentec.abook.abv.bl.acms.client.json.ShopSyncWatermarkJSON;
import jp.agentec.abook.abv.bl.acms.client.parameters.ContentDownloadLogParameters; import jp.agentec.abook.abv.bl.acms.client.parameters.ContentDownloadLogParameters;
import jp.agentec.abook.abv.bl.acms.client.parameters.FetchDateParameters; 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.ABVEnvironment;
...@@ -65,6 +66,8 @@ import jp.agentec.adf.util.DateTimeUtil; ...@@ -65,6 +66,8 @@ import jp.agentec.adf.util.DateTimeUtil;
private ContentDownloadListener contentDownloadListener; private ContentDownloadListener contentDownloadListener;
private RefreshContentWorker refreshWorker = null; private RefreshContentWorker refreshWorker = null;
private String shopSyncWatermarkLastChangedAt;
private boolean performedFullSyncByWatermark;
private Map<Long, Boolean> refreshingContentMap = new ConcurrentHashMap<Long, Boolean>(); // TODO: 値は使っていないのでSetに変更する private Map<Long, Boolean> refreshingContentMap = new ConcurrentHashMap<Long, Boolean>(); // TODO: 値は使っていないのでSetに変更する
private boolean initializingRefreshing = false; private boolean initializingRefreshing = false;
...@@ -161,38 +164,45 @@ import jp.agentec.adf.util.DateTimeUtil; ...@@ -161,38 +164,45 @@ import jp.agentec.adf.util.DateTimeUtil;
List<ContentDto> localContents = contentDao.getAllContents(); List<ContentDto> localContents = contentDao.getAllContents();
if (networkAdapter.isNetworkConnected()) { // オンライン時の処理 if (networkAdapter.isNetworkConnected()) { // オンライン時の処理
resendLog(); // ログ送信 resendLog(); // ログ送信
contractLogic.initializeContractServiceOption(); // サービスオプション関連処理
groupLogic.initializeGroups(); // グループ設定(グループ変更の場合、FetchDateをクリアする) boolean needsFullSync = shouldRunFullSyncByShopSyncWatermark();
categoryLogic.initializeCategories(); // カテゴリ設定 performedFullSyncByWatermark = needsFullSync;
if (needsFullSync) {
// マスタデータの最新更新された時のFetchDateを一時に保存する。 contractLogic.initializeContractServiceOption(); // サービスオプション関連処理
Logger.d(TAG, "before fetchDate : " + ABVDataCache.getInstance().tempMasterDataFetchDate); groupLogic.initializeGroups(); // グループ設定(グループ変更の場合、FetchDateをクリアする)
categoryLogic.initializeCategories(); // カテゴリ設定
// CMSでメンテナンスされるHACCPマスタデータをアプリから取得できるようにJSONファイルを生成する。
String fetchDate = null; // マスタデータの最新更新された時のFetchDateを一時に保存する。
//失敗時、3回リトライ処理 Logger.d(TAG, "before fetchDate : " + ABVDataCache.getInstance().tempMasterDataFetchDate);
for (int i = 0; i < 4; i++) {
try { // CMSでメンテナンスされるHACCPマスタデータをアプリから取得できるようにJSONファイルを生成する。
fetchDate = masterDataLogic.initializeMasterData(ABVDataCache.getInstance().tempMasterDataFetchDate, i); String fetchDate = null;
break; //失敗時、3回リトライ処理
} catch (Exception e) { for (int i = 0; i < 4; i++) {
Logger.e(TAG, "initializeMasterData Exception", e); try {
if (i == 3) { //3回目のリトライ失敗時、例外処理投げる。 fetchDate = masterDataLogic.initializeMasterData(ABVDataCache.getInstance().tempMasterDataFetchDate, i);
throw new Exception("initializeMasterData"); break;
} else { } catch (Exception e) {
Thread.sleep(500); //0.5秒間隔でリトライ処理を実行 Logger.e(TAG, "initializeMasterData Exception", e);
if (i == 3) { //3回目のリトライ失敗時、例外処理投げる。
throw new Exception("initializeMasterData");
} else {
Thread.sleep(500); //0.5秒間隔でリトライ処理を実行
}
} }
} }
}
Logger.d(TAG, "after fetchDate : " + fetchDate); Logger.d(TAG, "after fetchDate : " + fetchDate);
if (fetchDate != null) { if (fetchDate != null) {
// マスタデータの最新更新された時のFetchDateを一時に保存する。 // マスタデータの最新更新された時のFetchDateを一時に保存する。
ABVDataCache.getInstance().tempMasterDataFetchDate = fetchDate; ABVDataCache.getInstance().tempMasterDataFetchDate = fetchDate;
} }
// 作業種別情報を取得 // 作業種別情報を取得
operationGroupMasterLogic.setOperationGroupMaster(); operationGroupMasterLogic.setOperationGroupMaster();
} else {
Logger.d(TAG, "skip full DB sync by shopSyncWatermark.");
}
if (interrupt) { // この時点で停止要求が来た場合先には進まない。(ServiceOption/Group/Categoryの更新は1セットで行う(トランザクションはそれぞれ別)) if (interrupt) { // この時点で停止要求が来た場合先には進まない。(ServiceOption/Group/Categoryの更新は1セットで行う(トランザクションはそれぞれ別))
Logger.d(TAG, "stop refresh worker before content update."); Logger.d(TAG, "stop refresh worker before content update.");
...@@ -200,7 +210,10 @@ import jp.agentec.adf.util.DateTimeUtil; ...@@ -200,7 +210,10 @@ import jp.agentec.adf.util.DateTimeUtil;
updateRefreshContentListState(-1L, null); updateRefreshContentListState(-1L, null);
return; return;
} }
isFinishedContentCheck = retrieveServerContent(localContents); // ContentVersionAPIを呼出し新規と更新の場合ContentInfoをDLする if (needsFullSync) {
isFinishedContentCheck = retrieveServerContent(localContents); // ContentVersionAPIを呼出し新規と更新の場合ContentInfoをDLする
}
saveShopSyncWatermarkLastFetchDateWithRefresh(performedFullSyncByWatermark);
} }
deleteLocalContent(localContents, isFinishedContentCheck); // コンテンツ削除処理 deleteLocalContent(localContents, isFinishedContentCheck); // コンテンツ削除処理
...@@ -382,6 +395,42 @@ import jp.agentec.adf.util.DateTimeUtil; ...@@ -382,6 +395,42 @@ import jp.agentec.adf.util.DateTimeUtil;
} }
return true; return true;
} }
private boolean shouldRunFullSyncByShopSyncWatermark() {
try {
AcmsDao dao = AbstractDao.getDao(AcmsDao.class);
String lastFetchDate = dao.selectShopSyncWatermarkLastFetchDate();
FetchDateParameters param = new FetchDateParameters(cache.getMemberInfo().sid, lastFetchDate);
ShopSyncWatermarkJSON json = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).checkShopSyncWatermark(param);
shopSyncWatermarkLastChangedAt = json.lastChangedAt;
return json.needsFullSync;
} catch (Exception e) {
// フェイルセーフ: 判定できない場合は従来通りフル同期を実施
Logger.w(TAG, "shopSyncWatermark check failed. run full sync.", e);
shopSyncWatermarkLastChangedAt = null;
return true;
}
}
private void saveShopSyncWatermarkLastFetchDateWithRefresh(boolean shouldRefreshFromServer) {
String lastChangedAt = shopSyncWatermarkLastChangedAt;
try {
if (shouldRefreshFromServer) {
FetchDateParameters latestParam = new FetchDateParameters(cache.getMemberInfo().sid, null);
ShopSyncWatermarkJSON latestJson = AcmsClient.getInstance(cache.getUrlPath(), networkAdapter).checkShopSyncWatermark(latestParam);
if (latestJson != null && latestJson.lastChangedAt != null && latestJson.lastChangedAt.length() > 0) {
lastChangedAt = latestJson.lastChangedAt;
}
}
if (lastChangedAt == null || lastChangedAt.length() == 0) {
return;
}
AcmsDao dao = AbstractDao.getDao(AcmsDao.class);
dao.updateShopSyncWatermarkLastFetchDate(lastChangedAt);
} catch (Exception e) {
Logger.w(TAG, "failed to save shopSyncWatermark lastFetchDate.", e);
}
}
} }
public void updateRefreshContentListState(long contentId, Exception e) { public void updateRefreshContentListState(long contentId, Exception e) {
......
...@@ -8,6 +8,7 @@ public class AcmsDto extends AbstractDto { ...@@ -8,6 +8,7 @@ public class AcmsDto extends AbstractDto {
public String websocketServerWsUrl; public String websocketServerWsUrl;
public String contentVersionLastFetchDate; // 保存のみ、内部で比較しない public String contentVersionLastFetchDate; // 保存のみ、内部で比較しない
public String scheduleListLastFetchDate; // 保存のみ、内部で比較しない public String scheduleListLastFetchDate; // 保存のみ、内部で比較しない
public String shopSyncWatermarkLastFetchDate; // DB同期判定用の最終取得日時
public AcmsDto() { public AcmsDto() {
} }
...@@ -20,6 +21,7 @@ public class AcmsDto extends AbstractDto { ...@@ -20,6 +21,7 @@ public class AcmsDto extends AbstractDto {
this.websocketServerWsUrl = websocketServerWsUrl; this.websocketServerWsUrl = websocketServerWsUrl;
this.contentVersionLastFetchDate = ""; this.contentVersionLastFetchDate = "";
this.scheduleListLastFetchDate = ""; this.scheduleListLastFetchDate = "";
this.shopSyncWatermarkLastFetchDate = "";
} }
@Override @Override
...@@ -29,7 +31,7 @@ public class AcmsDto extends AbstractDto { ...@@ -29,7 +31,7 @@ public class AcmsDto extends AbstractDto {
@Override @Override
public Object[] getInsertValues() { public Object[] getInsertValues() {
return new Object[]{urlPath, acmsAddress, downloadServerAddress, websocketServerHttpUrl, websocketServerWsUrl, contentVersionLastFetchDate, scheduleListLastFetchDate}; return new Object[]{urlPath, acmsAddress, downloadServerAddress, websocketServerHttpUrl, websocketServerWsUrl, scheduleListLastFetchDate, contentVersionLastFetchDate, shopSyncWatermarkLastFetchDate};
} }
} }
...@@ -23,7 +23,6 @@ import jp.agentec.abook.abv.ui.common.constant.NaviConsts; ...@@ -23,7 +23,6 @@ import jp.agentec.abook.abv.ui.common.constant.NaviConsts;
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog; import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.util.ABVToastUtil; import jp.agentec.abook.abv.ui.common.util.ABVToastUtil;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil; import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
import jp.agentec.abook.abv.ui.common.util.LogUtil;
import jp.agentec.abook.abv.ui.home.activity.ABookSettingActivity; import jp.agentec.abook.abv.ui.home.activity.ABookSettingActivity;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper; import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
...@@ -170,8 +169,6 @@ public abstract class ABVUIActivity extends ABVAuthenticatedActivity { ...@@ -170,8 +169,6 @@ public abstract class ABVUIActivity extends ABVAuthenticatedActivity {
// onCreateでrefresh処理をcallしたときに起きる // onCreateでrefresh処理をcallしたときに起きる
contentRefresher.refreshContentList(this); contentRefresher.refreshContentList(this);
// ログ送信可否を確認
LogUtil.checkSendLogFlag();
} }
} catch (NetworkDisconnectedException e) { } catch (NetworkDisconnectedException e) {
refreshContentException(); refreshContentException();
......
package jp.agentec.abook.abv.ui.common.util;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.parameters.CheckSendLogParameters;
import jp.agentec.abook.abv.bl.common.ABVEnvironment;
import jp.agentec.abook.abv.bl.common.Constant;
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.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.cl.helper.ABVUncaughtExceptionHandler;
import jp.agentec.abook.abv.ui.home.helper.ActivityHandlingHelper;
/**
* Created by jang on 2017/07/07.
*/
public class LogUtil {
private static final String TAG = "LogUtil";
/**
* ExportログをCMS側に送るかどうかのチェックを行う
*/
public static void checkSendLogFlag() {
Logger.d(TAG, "[checkSendLogFlag]: start--");
ABVDataCache dataCache = ABVDataCache.getInstance();
AcmsClient client = AcmsClient.getInstance(dataCache.getUrlPath(), ABVEnvironment.getInstance().networkAdapter);
try {
CheckSendLogParameters parameters;
if (ABVEnvironment.getInstance().deviceIdType == Constant.DeviceIdType.MAC_ADDRESS) {
parameters = new CheckSendLogParameters(dataCache.getMemberInfo().sid, ABVEnvironment.DeviceTypeId, null, ABVEnvironment.getInstance().deviceId);
} else {
// Android 6以上の場合
parameters = new CheckSendLogParameters(dataCache.getMemberInfo().sid, ABVEnvironment.DeviceTypeId, ABVEnvironment.getInstance().deviceId, null);
}
int status = client.checkSendLogFile(parameters);
if (status == 1) {
boolean result = ABVUncaughtExceptionHandler.getInstancer().sendLogFileToAcms(ActivityHandlingHelper.getInstance().getCurrentActivity());
Logger.i(TAG, "[checkSendLogFlag]: result=" + result);
}
} catch (NetworkDisconnectedException e) {
Logger.d(TAG, "[checkSendLogFlag]: NetworkDisconnectedException");
} catch (AcmsException e) {
Logger.e(TAG, "[checkSendLogFlag]: " + e.getMessage(), e);
}
}
}
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