You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
5.0 KiB
Java
134 lines
5.0 KiB
Java
/* */ import java.io.BufferedInputStream;
|
|
/* */ import java.io.BufferedOutputStream;
|
|
/* */ import java.io.BufferedReader;
|
|
/* */ import java.io.FileInputStream;
|
|
/* */ import java.io.InputStream;
|
|
/* */ import java.io.InputStreamReader;
|
|
/* */ import java.net.HttpURLConnection;
|
|
/* */ import java.net.URL;
|
|
/* */ import java.util.Properties;
|
|
/* */ import org.apache.log4j.Logger;
|
|
/* */ import org.apache.log4j.PropertyConfigurator;
|
|
/* */ import org.json.simple.JSONObject;
|
|
/* */
|
|
/* */
|
|
/* */ public class CallServerStatusInfo
|
|
/* */ {
|
|
/* 17 */ private String[] g_strFTP = new String[6];
|
|
/* 18 */ private final Logger logger = Logger.getLogger(CallServerStatusInfo.class);
|
|
/* */
|
|
/* */
|
|
/* */ public CallServerStatusInfo() {
|
|
/* 22 */ PropertyConfigurator.configure("./log4j.properties");
|
|
/* */
|
|
/* */
|
|
/* */ try {
|
|
/* 26 */ String propFile = "./config.properties";
|
|
/* */
|
|
/* */
|
|
/* 29 */ Properties props = new Properties();
|
|
/* */
|
|
/* */
|
|
/* 32 */ FileInputStream fis = new FileInputStream(propFile);
|
|
/* */
|
|
/* */
|
|
/* 35 */ props.load(new BufferedInputStream(fis));
|
|
/* */
|
|
/* */
|
|
/* 38 */ this.g_strFTP[0] = props.getProperty("server_type_code");
|
|
/* 39 */ this.g_strFTP[4] = props.getProperty("api_url_server_stat");
|
|
/* */
|
|
/* 41 */ props.clear();
|
|
/* 42 */ props = null;
|
|
/* */
|
|
/* 44 */ JSONObject jsonParam = new JSONObject();
|
|
/* 45 */ jsonParam.put("sysTyCode", this.g_strFTP[0]);
|
|
/* 46 */ jsonParam.put("sysSttuscode", "2");
|
|
/* 47 */ callApi(jsonParam.toJSONString());
|
|
/* */ }
|
|
/* 49 */ catch (Exception e) {
|
|
/* 50 */ this.logger.info("Exception : " + e);
|
|
/* */ }
|
|
/* */ }
|
|
/* */
|
|
/* */
|
|
/* */ private void callApi(String strJson) {
|
|
/* 56 */ HttpURLConnection connection = null;
|
|
/* 57 */ InputStream is = null;
|
|
/* 58 */ InputStreamReader isr = null;
|
|
/* 59 */ BufferedReader br = null;
|
|
/* */
|
|
/* */ try {
|
|
/* 62 */ URL url = new URL(this.g_strFTP[4]);
|
|
/* 63 */ this.logger.info("==== 수집서버 주소 : " + this.g_strFTP[4]);
|
|
/* */
|
|
/* 65 */ connection = (HttpURLConnection)url.openConnection();
|
|
/* */
|
|
/* 67 */ connection.setDoInput(true);
|
|
/* 68 */ connection.setDoOutput(true);
|
|
/* 69 */ connection.setUseCaches(false);
|
|
/* 70 */ connection.setRequestMethod("POST");
|
|
/* */
|
|
/* 72 */ connection.setConnectTimeout(30000);
|
|
/* */
|
|
/* 74 */ connection.setReadTimeout(30000);
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* 78 */ connection.setRequestProperty("Accept", "application/json");
|
|
/* 79 */ connection.setRequestProperty("Content-Type", "application/json");
|
|
/* */
|
|
/* */
|
|
/* 82 */ BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
|
|
/* 83 */ bos.write(strJson.getBytes("UTF-8"));
|
|
/* 84 */ bos.flush();
|
|
/* 85 */ bos.close();
|
|
/* */
|
|
/* 87 */ int resCode = connection.getResponseCode();
|
|
/* 88 */ StringBuffer sb = new StringBuffer();
|
|
/* 89 */ String inputLine = null;
|
|
/* */
|
|
/* 91 */ this.logger.info("==== : " + resCode);
|
|
/* 92 */ if (resCode == 200) {
|
|
/* 93 */ is = connection.getInputStream();
|
|
/* 94 */ isr = new InputStreamReader(is, "UTF-8");
|
|
/* 95 */ br = new BufferedReader(isr);
|
|
/* */
|
|
/* 97 */ while ((inputLine = br.readLine()) != null) {
|
|
/* 98 */ sb.append(inputLine);
|
|
/* */ }
|
|
/* */
|
|
/* 101 */ this.logger.info("==== " + sb.toString());
|
|
/* */ }
|
|
/* 103 */ else if (connection.getErrorStream() != null) {
|
|
/* 104 */ br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "UTF-8"));
|
|
/* */
|
|
/* 106 */ while ((inputLine = br.readLine()) != null) {
|
|
/* 107 */ sb.append(inputLine);
|
|
/* */ }
|
|
/* 109 */ this.logger.info("==== Http Error Resopnse : " + sb.toString());
|
|
/* */ } else {
|
|
/* 111 */ this.logger.info("==== Http Error Resopnse : " + sb.toString());
|
|
/* */ }
|
|
/* */
|
|
/* 114 */ } catch (Exception e) {
|
|
/* 115 */ this.logger.info("Exception : " + e);
|
|
/* 116 */ this.logger.info("==== Http Error Resopnse : ");
|
|
/* */ } finally {
|
|
/* */ try {
|
|
/* 119 */ if (is != null)
|
|
/* 120 */ is.close();
|
|
/* 121 */ if (isr != null)
|
|
/* 122 */ isr.close();
|
|
/* 123 */ if (br != null)
|
|
/* 124 */ br.close();
|
|
/* 125 */ } catch (Exception exception) {}
|
|
/* */ }
|
|
/* */ }
|
|
/* */ }
|
|
|
|
|
|
/* Location: C:\Users\XIT_LBJ\Desktop\남산 혼잡통행료\운영환경 실 파일\3호 연계서버\car이미지자르\서버스테이터스센드\ServerStatusSend.jar!\CallServerStatusInfo.class
|
|
* Java compiler version: 8 (52.0)
|
|
* JD-Core Version: 1.1.3
|
|
*/ |