Commit ab8a8a47 by Yujin Seo

Merge branch 'feature/contract/sato/1.0.301_fix_java8' into 'contract/sato/1.0.301'

Java8依存のコードを代替コードに変更

See merge request !311
parents e320c8a6 f32439b4
// Copyright 2002, Google, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package jp.agentec.abook.abv.bl.common.util;
/**
* Exception thrown when encountering an invalid Base64 input character.
*
* @author nelson
*/
public class Base64DecoderException extends Exception {
public Base64DecoderException() {
super();
}
public Base64DecoderException(String s) {
super(s);
}
private static final long serialVersionUID = 1L;
}
package jp.agentec.abook.abv.bl.data.dao;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import jp.agentec.abook.abv.bl.common.db.Cursor;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.bl.common.util.Base64DecoderException;
import jp.agentec.abook.abv.bl.dto.TaskReportDto;
import jp.agentec.adf.util.DateTimeFormat;
import jp.agentec.adf.util.DateTimeUtil;
......@@ -616,13 +616,18 @@ public class TaskReportDao extends AbstractDao {
if (plain == null) {
return null;
}
return Base64.getEncoder().encodeToString(plain.getBytes());
return jp.agentec.abook.abv.bl.common.util.Base64.encode(plain.getBytes());
}
public static String decode(String encoded) {
if (encoded == null) {
return null;
}
return new String(Base64.getDecoder().decode(encoded));
try {
return new String(jp.agentec.abook.abv.bl.common.util.Base64.decode(encoded));
} catch (Base64DecoderException e) {
Logger.e(TAG, e);
return null;
}
}
}
......@@ -98,8 +98,8 @@ public class ABookCheckWebViewHelper extends ABookHelper {
case ABookKeys.CMD_UPDATE_TASK_REPORT: {
// もとから作業中だったかを調べる
TaskReportDao taskReportDao = AbstractDao.getDao(TaskReportDao.class);
int reportId = Integer.parseInt(String.valueOf(param.getOrDefault(TaskReportId, "0")));
String startDate = param.getOrDefault(ReportStartDate, null);
int reportId = Integer.parseInt(String.valueOf(getOrZero(param, TaskReportId)));
String startDate = getOrNull(param, ReportStartDate);
boolean isLocalSaved = taskReportDao.isLocalSaved(taskKey, reportId, startDate);
boolean isCompleted = taskReportDao.isCompleted(taskKey, reportId, startDate);
boolean isWorking = taskReportDao.isWorking(taskKey, reportId, startDate);
......@@ -124,8 +124,8 @@ public class ABookCheckWebViewHelper extends ABookHelper {
case ABookKeys.CMD_LOCAL_SAVE_TASK_REPORT: // 一時保存
// もとから作業中だったかを調べる
TaskReportDao taskReportDao = AbstractDao.getDao(TaskReportDao.class);
int rportId = Integer.parseInt(String.valueOf(param.getOrDefault(TaskReportId, "0")));
String startDate = param.getOrDefault(ReportStartDate, null);
int rportId = Integer.parseInt(String.valueOf(getOrZero(param, TaskReportId)));
String startDate = getOrNull(param, ReportStartDate);
boolean isLocalSaved = taskReportDao.isLocalSaved(taskKey, rportId, startDate);
// 報告書の更新
insertOrUpdateTaskReport(taskKey, enableReportHistory, operationId, contentId, param, contentPath, reportType, taskReportLevel, true);
......@@ -629,4 +629,20 @@ public class ABookCheckWebViewHelper extends ABookHelper {
return rotationAngle;
}
private String getOrZero(Map<String, String> param, String key) {
if (param.containsKey(key)) {
return param.get(key);
} else {
return "0";
}
}
private String getOrNull(Map<String, String> param, String key) {
if (param.containsKey(key)) {
return param.get(key);
} else {
return null;
}
}
}
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