Commit e488e53a by onuma

#47940 前回の入力内容をデフォルトに設定 仕様ミスを修正

parent c2cfed5a
......@@ -157,8 +157,6 @@ public class ABVEnvironment {
public static final String ContinuousTaskReportJsonDirFormat = ContentCacheDirectoryFormat + "/processList/phaseList/phase_%d";
// アルコールチェッカー(userDataKey)を保存する場所
public static final String userDataDir = "/userData/";
// 保存するファイル名
public static final String userDataKeyFile = "userDataKey";
/**
* コンテンツのファイルを暗号化するときに、暗号化するサイズをバイト単位で指定します。
......
......@@ -88,6 +88,7 @@ public class ABookKeys {
public static final String ATTACHED_CHANGE_FLAG = "attachedChangeFlag";
public static final String ROUTINE_TASK_FLAG = "routineTaskFlag";
public static final String UPDATE_HOTSPOT_ONLY_FLAG = "updateHotSpotOnlyFlag";
public static final String USER_DATA = "userData";
//Webviewから呼び出すApiキー
public static final class CMD_KEY{
......
......@@ -1209,7 +1209,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
} else if (mCmd.equals(ABookKeys.CMD_SAVE_USER_DATA)) {
// 入力内容を保存する
Logger.i(TAG,"save taskKey = " + abookCheckParam.get(ABookKeys.TASK_KEY));
saveUserDataKey(abookCheckParam.get(ABookKeys.TASK_KEY));
Logger.i(TAG,"save userData = " + abookCheckParam.get(ABookKeys.USER_DATA));
saveUserDataKey(abookCheckParam.get(ABookKeys.TASK_KEY), abookCheckParam.get(ABookKeys.USER_DATA));
}
}
......@@ -1226,12 +1227,14 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
/**
* JSから送られてきたキーデータを保存する
* @param userDataKey 保存するユーザーキー
* @param userKeyFileName 保存するユーザーキーファイル名
* @param userData 保存するデータ
*/
private void saveUserDataKey(String userDataKey) {
if (StringUtil.isNullOrEmpty(userDataKey)) {
private void saveUserDataKey(String userKeyFileName, String userData) {
if (StringUtil.isNullOrEmpty(userKeyFileName)) {
Logger.d(TAG,"userKeyFileName is null or empty.");
// 読み込むためのキーがない
afterABookCheckApi(ABookKeys.CMD_SAVE_USER_DATA, userDataKey, 1, "", "");
afterABookCheckApi(ABookKeys.CMD_SAVE_USER_DATA, userKeyFileName, 1, "", "");
return;
}
......@@ -1251,46 +1254,50 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
if (!ABVDataCache.getInstance().getMemberInfo().loginId.equals(userId)) {
// ログインしているユーザー以外のものは削除
FileUtil.delete(dir);
continue;
}
BufferedWriter bw = null;
if (userDataKey != null) {
if (userData != null) {
try {
FileOutputStream fo = new FileOutputStream(userDataFolderRoot + "/" + userId + "/" + ABVEnvironment.getInstance().userDataKeyFile);
FileOutputStream fo = new FileOutputStream(userDataFolderRoot + "/" + userId + "/" + userKeyFileName);
OutputStreamWriter osw = new OutputStreamWriter(fo, StandardCharsets.UTF_8);
bw = new BufferedWriter(osw);
bw.write(userDataKey);
bw.write(userData);
bw.close();
} catch (IOException e) {
Logger.e(TAG, "" + e);
} finally {
try {
bw.close();
if (bw != null) {
bw.close();
}
} catch (IOException e) {
e.printStackTrace();
Logger.e(TAG,"" + e);
}
}
afterABookCheckApi(ABookKeys.CMD_SAVE_USER_DATA, userDataKey, 0, "", "");
break;
afterABookCheckApi(ABookKeys.CMD_SAVE_USER_DATA, userKeyFileName, 0, "", "");
}
} catch (IndexOutOfBoundsException iobex) {
Logger.e(TAG,"" + iobex);
}
}
}
/**
* キーデータファイルを読み込んで、JSにわたす
* @param userKeyFileName ファイル名
*/
private void loadUserDataKey(String userDataKey) {
private void loadUserDataKey(String userKeyFileName) {
if (StringUtil.isNullOrEmpty(userDataKey)) {
Logger.d(TAG,"key is not found.");
// 読み込むためのキーがない
afterABookCheckApi(ABookKeys.CMD_LOAD_USER_DATA, userDataKey, 1, "", "");
if (StringUtil.isNullOrEmpty(userKeyFileName)) {
Logger.d(TAG,"userKeyFileName is null or Empty");
// ファイル名が指定されていない
afterABookCheckApi(ABookKeys.CMD_LOAD_USER_DATA, userKeyFileName, 1, "", "");
return;
}
String keyFilePath = getUserDataDirRoot() + "/" + ABVDataCache.getInstance().getMemberInfo().loginId + "/" + ABVEnvironment.getInstance().userDataKeyFile;
String keyFilePath = getUserDataDirRoot() + "/" + ABVDataCache.getInstance().getMemberInfo().loginId + "/" + userKeyFileName;
Logger.d(TAG,"keyFilePath = " + keyFilePath);
FileInputStream fi = null;
......@@ -1308,11 +1315,12 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
}
isr.close();
Logger.d(TAG,"result = " + sb.toString());
afterABookCheckApi(ABookKeys.CMD_LOAD_USER_DATA, userDataKey, 0, "", sb.toString());
} catch (FileNotFoundException fnfex) {
afterABookCheckApi(ABookKeys.CMD_LOAD_USER_DATA, userKeyFileName, 0, "", sb.toString());
return;
} catch (FileNotFoundException fex) {
Logger.e(TAG,"" + fex);
} catch (IOException e) {
Logger.e(TAG,"" + e);
} finally {
try {
if (isr != null) {
......@@ -1322,6 +1330,8 @@ public abstract class ABVContentViewActivity extends ABVAuthenticatedActivity {
e.printStackTrace();
}
}
// 何かしらのExceptionが発生した
afterABookCheckApi(ABookKeys.CMD_LOAD_USER_DATA, userKeyFileName, 1, "", "");
}
public void commonAttachedDataUrl (String taskKey, String data) {
......
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