Commit af412954 by onuma

利用規約文言取得APIをcontentsLogic から contractLogicへ移動した。

parent e67f928b
...@@ -521,45 +521,4 @@ public class ContentLogic extends AbstractLogic { ...@@ -521,45 +521,4 @@ public class ContentLogic extends AbstractLogic {
} }
return new ContentJSON(text); return new ContentJSON(text);
} }
/**
* 利用規約の詳細文を取得する
* @param url 取得しに行くURL
* @return 取得した文字列(失敗したらnullが返る)
*/
public String getTermsOfServiceText(String url, String laungage) {
HttpResponse response = new HttpResponse();
HttpURLConnection conn = null;
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();
}
}
return null;
}
} }
package jp.agentec.abook.abv.bl.logic; package jp.agentec.abook.abv.bl.logic;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List; import java.util.List;
import jp.agentec.abook.abv.bl.acms.client.AcmsClient; import jp.agentec.abook.abv.bl.acms.client.AcmsClient;
...@@ -15,6 +21,8 @@ import jp.agentec.abook.abv.bl.data.dao.AcmsDao; ...@@ -15,6 +21,8 @@ import jp.agentec.abook.abv.bl.data.dao.AcmsDao;
import jp.agentec.abook.abv.bl.data.dao.ServiceOptionDao; import jp.agentec.abook.abv.bl.data.dao.ServiceOptionDao;
import jp.agentec.abook.abv.bl.dto.AcmsDto; import jp.agentec.abook.abv.bl.dto.AcmsDto;
import jp.agentec.abook.abv.bl.dto.ServiceOptionDto; import jp.agentec.abook.abv.bl.dto.ServiceOptionDto;
import jp.agentec.adf.net.http.HttpRequestSender;
import jp.agentec.adf.net.http.HttpResponse;
import jp.agentec.adf.util.NumericUtil; import jp.agentec.adf.util.NumericUtil;
import jp.agentec.adf.util.StringUtil; import jp.agentec.adf.util.StringUtil;
...@@ -354,4 +362,45 @@ public class ContractLogic extends AbstractLogic { ...@@ -354,4 +362,45 @@ public class ContractLogic extends AbstractLogic {
public static boolean getBooleanValue(String value) { public static boolean getBooleanValue(String value) {
return True.equals(value); return True.equals(value);
} }
/**
* 利用規約の詳細文を取得する
* @param url 取得しに行くURL
* @return 取得した文字列(失敗したらnullが返る)
*/
public String getTermsOfServiceText(String url, String laungage) {
HttpResponse response = new HttpResponse();
HttpURLConnection conn = null;
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();
}
}
return null;
}
} }
...@@ -278,7 +278,7 @@ public class LoginActivity extends ABVLoginActivity { ...@@ -278,7 +278,7 @@ public class LoginActivity extends ABVLoginActivity {
@Override @Override
public void run() { public void run() {
// CMSより文言を取得し、ダイアログで表示する。 // CMSより文言を取得し、ダイアログで表示する。
ContentLogic logic = AbstractLogic.getLogic(ContentLogic.class); ContractLogic logic = AbstractLogic.getLogic(ContractLogic.class);
String language = Locale.getDefault().getLanguage(); String language = Locale.getDefault().getLanguage();
termsOfUseText = logic.getTermsOfServiceText(termsOfUseUrl, language); termsOfUseText = logic.getTermsOfServiceText(termsOfUseUrl, language);
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
......
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