Commit 058b4364 by onuma

#46980 ABookCheck, eXFrame 各アプリ規約同意

parent af412954
package jp.agentec.abook.abv.bl.acms.client.json;
import org.json.adf.JSONException;
import org.json.adf.JSONObject;
import jp.agentec.abook.abv.bl.common.exception.AcmsException;
import jp.agentec.abook.abv.bl.common.exception.JSONValidationException;
/**
* 利用規約に同意するで取得するテキストを格納するJSON
*/
public class TermsOfUseJson extends AcmsCommonJSON {
public String message;
public TermsOfUseJson(String jsonString) throws AcmsException {
super(jsonString);
}
@Override
protected void parse(JSONObject json) throws JSONValidationException, JSONException {
super.parse(json);
message = getString(json, "message", null);
}
}
package jp.agentec.abook.abv.bl.logic;
import org.json.adf.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
......@@ -7,8 +9,10 @@ import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Locale;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
import jp.agentec.abook.abv.bl.acms.client.json.TermsOfUseJson;
import jp.agentec.abook.abv.bl.acms.client.parameters.AcmsParameters;
import jp.agentec.abook.abv.bl.acms.type.SecurityPolicyType;
import jp.agentec.abook.abv.bl.acms.type.ServiceOption.ServiceOptionId;
......@@ -368,38 +372,18 @@ public class ContractLogic extends AbstractLogic {
* @param url 取得しに行くURL
* @return 取得した文字列(失敗したらnullが返る)
*/
public String getTermsOfServiceText(String url, String laungage) {
HttpResponse response = new HttpResponse();
HttpURLConnection conn = null;
public String getTermsOfServiceText(String url) {
String requestUrl = url + "?language=" + Locale.getDefault().getLanguage();
try {
URL requestUrl = new URL(url + "?language=" + laungage);
conn = HttpRequestSender.openConnection("GET", requestUrl, "UTF-8", null, null, 5000);
Logger.i(TAG,"responseCode : " + conn.getResponseCode());
response.httpResponseCode = conn.getResponseCode();
if (response.httpResponseCode != 200) {
return null;
}
response.httpResponseMessage = conn.getResponseMessage();
response.contentLength = NumericUtil.parseLong(conn.getHeaderField("Content-Length"), 0);
InputStream inputStream = conn.getInputStream();
BufferedReader bufferReader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String resultJson = new String();
String str;
while ( null != ( str = bufferReader.readLine() ) ) {
resultJson = resultJson + str;
}
bufferReader.close();
Logger.d(TAG,"response JSON : " + resultJson);
return resultJson;
} catch (IOException e) {
Logger.e(e.getMessage());
} catch (NumberFormatException e) {
Logger.e(e.getMessage());
} finally {
if (conn != null) {
conn.disconnect();
}
HttpResponse response = AcmsClient.getInstance(ABVEnvironment.getInstance().networkAdapter).send(requestUrl, "", null);
TermsOfUseJson resultJson = new TermsOfUseJson(response.httpResponseBody);
return resultJson.message;
} catch (NetworkDisconnectedException e) {
Logger.e(TAG,"" + e);
} catch (AcmsException e) {
Logger.e(TAG,"" + e);
} catch (Exception e) {
Logger.e(TAG,"" + e);
}
return null;
}
......
......@@ -280,21 +280,13 @@ public class LoginActivity extends ABVLoginActivity {
// CMSより文言を取得し、ダイアログで表示する。
ContractLogic logic = AbstractLogic.getLogic(ContractLogic.class);
String language = Locale.getDefault().getLanguage();
termsOfUseText = logic.getTermsOfServiceText(termsOfUseUrl, language);
termsOfUseText = logic.getTermsOfServiceText(termsOfUseUrl);
runOnUiThread(new Runnable() {
@Override
public void run() {
String messageText = getString(R.string.err_gert_term_of_use_text);
if (termsOfUseText != null) {
JSONObject detail_json = new JSONObject(termsOfUseText);
Locale locale = Locale.getDefault();
if (locale.getLanguage().equals("ja")) {
messageText = detail_json.getString("ja");
} else if (locale.getLanguage().equals("ko")) {
messageText = detail_json.getString("ko");
} else {
messageText = detail_json.getString("en");
}
messageText = termsOfUseText;
}
AlertDialogUtil.showAlertDialog(LoginActivity.this, getString(R.string.error), messageText, true, new DialogInterface.OnClickListener() {
@Override
......
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