List of usage examples for java.net HttpURLConnection setReadTimeout
public void setReadTimeout(int timeout)
From source file:com.canappi.connector.yp.yhere.RepairView.java
public ArrayList<Element> searchRepairByZip(HashMap<String, String> requestParameters) { ArrayList<Element> data = new ArrayList<Element>(); System.setProperty("http.keepAlive", "false"); System.setProperty("javax.net.debug", "all"); // _FakeX509TrustManager.allowAllSSL(); //Protocol::: HTTP GET StringBuffer query = new StringBuffer(); HttpURLConnection connection = null; try {//ww w.j a va 2s . c om URL url; if (requestParameters != null) { String key; query.append( "http://api2.yp.com/listings/v1/search?format=xml&sort=distance&radius=5&term=auto+repair&listingcount=10&key=5d0b448ba491c2dff5a36040a125df0a"); query.append("&"); key = "searchloc"; String searchlocValue = requestParameters.get(key); String searchlocDefaultValue = retrieveFromUserDefaultsFor(key); if (searchlocValue.length() > 0) { query.append("" + key + "=" + requestParameters.get(key)); } else { //try to find the value in the user defaults if (searchlocDefaultValue != null) { query.append("" + key + "=" + retrieveFromUserDefaultsFor(key)); } } url = new URL(query.toString()); } else { url = new URL( "http://api2.yp.com/listings/v1/search?format=xml&sort=distance&radius=5&term=auto+repair&listingcount=10&key=5d0b448ba491c2dff5a36040a125df0a"); } connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(5000); connection.setReadTimeout(5000); connection.setUseCaches(false); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); int rc = connection.getResponseCode(); Log.i("Response code", String.valueOf(rc)); InputStream is; if (rc <= 400) { is = connection.getInputStream(); } else { /* error from server */ is = connection.getErrorStream(); } //XML ResultSet try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource isrc = new InputSource(); isrc.setByteStream(is); Document doc = db.parse(isrc); NodeList nodes = doc.getElementsByTagName("searchListings"); if (nodes.getLength() > 0) { Element list = (Element) nodes.item(0); NodeList l = list.getChildNodes(); for (int i = 0; i < l.getLength(); i++) { Node n = l.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { Element row = (Element) l.item(i); data.add(row); } } } } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } finally { connection.disconnect(); } return data; }
From source file:com.cr_wd.android.network.HttpClient.java
/** * Performs a HTTP GET/POST Request/* w w w .j ava 2 s . c o m*/ * * @return id of the request */ protected int doRequest(final Method method, final String url, HttpHeaders headers, HttpParams params, final HttpHandler handler) { if (headers == null) { headers = new HttpHeaders(); } if (params == null) { params = new HttpParams(); } handler.client = this; final int requestId = incrementRequestId(); class HandlerRunnable extends Handler implements Runnable { private final Method method; private String url; private final HttpHeaders headers; private final HttpParams params; private final HttpHandler handler; private HttpResponse response; private boolean canceled = false; private int retries = 0; protected HandlerRunnable(final Method method, final String url, final HttpHeaders headers, final HttpParams params, final HttpHandler handler) { this.method = method; this.url = url; this.headers = headers; this.params = params; this.handler = handler; } @Override public void run() { execute(); } private void execute() { response = new HttpResponse(requestId, method, url); HttpURLConnection conn = null; try { /* append query string for GET requests */ if (method == Method.GET) { if (!params.urlParams.isEmpty()) { url += ('?' + params.getParamString()); } } /* setup headers for POST requests */ if (method == Method.POST) { headers.addHeader("Accept-Charset", requestOptions.encoding); if (params.hasMultipartParams()) { final SimpleMultipart multipart = params.getMultipart(); headers.addHeader("Content-Type", multipart.getContentType()); } else { headers.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=" + requestOptions.encoding); } } if (canceled) { postCancel(); return; } /* open and configure the connection */ conn = (HttpURLConnection) new URL(url).openConnection(); postStart(); if (method == Method.GET) { conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestMethod("GET"); } else if (method == Method.POST) { conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setDoInput(true); conn.setUseCaches(false); } conn.setAllowUserInteraction(false); conn.setReadTimeout(requestOptions.readTimeout); conn.setConnectTimeout(requestOptions.connectTimeout); /* add headers to the connection */ for (final Map.Entry<String, List<String>> entry : headers.getHeaders().entrySet()) { for (final String value : entry.getValue()) { conn.addRequestProperty(entry.getKey(), value); } } if (canceled) { try { conn.disconnect(); } catch (final Exception e) { } postCancel(); return; } response.requestProperties = conn.getRequestProperties(); /* do post */ if (method == Method.POST) { InputStream is; if (params.hasMultipartParams()) { is = params.getMultipart().getContent(); } else { is = new ByteArrayInputStream(params.getParamString().getBytes()); } final OutputStream os = conn.getOutputStream(); writeStream(os, is); } else { conn.connect(); } if (canceled) { try { conn.disconnect(); } catch (final Exception e) { } postCancel(); return; } response.contentEncoding = conn.getContentEncoding(); response.contentLength = conn.getContentLength(); response.contentType = conn.getContentType(); response.date = conn.getDate(); response.expiration = conn.getExpiration(); response.headerFields = conn.getHeaderFields(); response.ifModifiedSince = conn.getIfModifiedSince(); response.lastModified = conn.getLastModified(); response.responseCode = conn.getResponseCode(); response.responseMessage = conn.getResponseMessage(); /* do get */ if (conn.getResponseCode() < 400) { response.responseBody = readStream(conn.getInputStream()); postSuccess(); } else { response.responseBody = readStream(conn.getErrorStream()); response.throwable = new Exception(response.responseMessage); postError(); } } catch (final Exception e) { if (retries < requestOptions.maxRetries) { retries++; postRetry(); execute(); } else { response.responseBody = e.getMessage(); response.throwable = e; postError(); } } finally { if (conn != null) { conn.disconnect(); } } } private String readStream(final InputStream is) throws IOException { final BufferedInputStream bis = new BufferedInputStream(is); final ByteArrayBuffer baf = new ByteArrayBuffer(50); int read = 0; final byte[] buffer = new byte[8192]; while (true) { if (canceled) { break; } read = bis.read(buffer); if (read == -1) { break; } baf.append(buffer, 0, read); } try { bis.close(); } catch (final IOException e) { } try { is.close(); } catch (final IOException e) { } return new String(baf.toByteArray()); } private void writeStream(final OutputStream os, final InputStream is) throws IOException { final BufferedInputStream bis = new BufferedInputStream(is); int read = 0; final byte[] buffer = new byte[8192]; while (true) { if (canceled) { break; } read = bis.read(buffer); if (read == -1) { break; } os.write(buffer, 0, read); } if (!canceled) { os.flush(); } try { os.close(); } catch (final IOException e) { } try { bis.close(); } catch (final IOException e) { } try { is.close(); } catch (final IOException e) { } } @Override public void handleMessage(final Message msg) { if (msg.what == HttpHandler.MESSAGE_CANCEL) { canceled = true; } } private void postSuccess() { postMessage(HttpHandler.MESSAGE_SUCCESS); } private void postError() { postMessage(HttpHandler.MESSAGE_ERROR); } private void postCancel() { postMessage(HttpHandler.MESSAGE_CANCEL); } private void postStart() { postMessage(HttpHandler.MESSAGE_START); } private void postRetry() { postMessage(HttpHandler.MESSAGE_RETRY); } private void postMessage(final int what) { final Message msg = handler.obtainMessage(); msg.what = what; msg.arg1 = requestId; msg.obj = response; handler.sendMessage(msg); } } ; /* Create a new HandlerRunnable and start it */ final HandlerRunnable hr = new HandlerRunnable(method, url, headers, params, handler); requests.put(requestId, new WeakReference<Handler>(hr)); new Thread(hr).start(); /* Return with the request id */ return requestId; }
From source file:org.apache.cxf.systest.jaxrs.JAXRSClientServerBookTest.java
@Test public void testWrongContentType() throws Exception { // can't use WebClient here because WebClient plays around with the Content-Type // (and makes sure it's syntactically correct) before sending it to the server String endpointAddress = "http://localhost:" + PORT + "/bookstore/unsupportedcontenttype"; URL url = new URL(endpointAddress); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setReadTimeout(30000); // 30 seconds tops urlConnection.setConnectTimeout(30000); // 30 second tops urlConnection.addRequestProperty("Content-Type", "MissingSeparator"); urlConnection.setRequestMethod("POST"); assertEquals(415, urlConnection.getResponseCode()); }
From source file:edu.slu.action.ObjectAction.java
private JSONObject getJWKS() throws MalformedURLException, ProtocolException, IOException { JSONObject jwksFile = new JSONObject(); String jwksLocation = "https://cubap.auth0.com/.well-known/jwks.json"; URL jwksURL = new URL(jwksLocation); BufferedReader reader = null; StringBuilder stringBuilder;// w w w . j a v a2 s . c o m HttpURLConnection connection = (HttpURLConnection) jwksURL.openConnection(); connection.setRequestMethod("GET"); connection.setReadTimeout(5 * 1000); connection.connect(); reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); stringBuilder = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { stringBuilder.append(line); } connection.disconnect(); reader.close(); jwksFile = JSONObject.fromObject(stringBuilder.toString()); return jwksFile; }
From source file:org.kymjs.kjframe.http.httpclient.HttpRequestBuilder.java
public HttpResponse execute(HashMap<String, File> files) throws HttpClientException { HttpURLConnection conn = null; UncloseableInputStream payloadStream = null; try {/*from ww w . j a va 2 s . co m*/ // if (parameters != null && !parameters.isEmpty()) { // final StringBuilder buf = new StringBuilder(256); // if (HTTP_GET.equals(method) || HTTP_HEAD.equals(method)) { // buf.append('?'); // } // // int paramIdx = 0; // for (final Map.Entry<String, String> e : parameters.entrySet()) { // if (paramIdx != 0) { // buf.append("&"); // } // final String name = e.getKey(); // final String value = e.getValue(); // buf.append(URLEncoder.encode(name, CONTENT_CHARSET)).append("=") // .append(URLEncoder.encode(value, CONTENT_CHARSET)); // ++paramIdx; // } // // if (!contentSet // && (HTTP_POST.equals(method) || HTTP_DELETE.equals(method) || HTTP_PUT.equals(method))) { // try { // content = buf.toString().getBytes(CONTENT_CHARSET); // } catch (UnsupportedEncodingException e) { // // Unlikely to happen. // throw new HttpClientException("Encoding error", e); // } // } else { // uri += buf; // } // } conn = (HttpURLConnection) new URL(uri).openConnection(); conn.setConnectTimeout(hc.getConnectTimeout()); conn.setReadTimeout(hc.getReadTimeout()); conn.setAllowUserInteraction(false); conn.setInstanceFollowRedirects(false); conn.setRequestMethod(method); conn.setUseCaches(false); conn.setDoInput(true); if (headers != null && !headers.isEmpty()) { for (final Map.Entry<String, List<String>> e : headers.entrySet()) { final List<String> values = e.getValue(); if (values != null) { final String name = e.getKey(); for (final String value : values) { conn.addRequestProperty(name, value); } } } } if (cookies != null && !cookies.isEmpty() || hc.getInMemoryCookies() != null && !hc.getInMemoryCookies().isEmpty()) { final StringBuilder cookieHeaderValue = new StringBuilder(256); prepareCookieHeader(cookies, cookieHeaderValue); prepareCookieHeader(hc.getInMemoryCookies(), cookieHeaderValue); conn.setRequestProperty("Cookie", cookieHeaderValue.toString()); } final String userAgent = hc.getUserAgent(); if (userAgent != null) { conn.setRequestProperty("User-Agent", userAgent); } conn.setRequestProperty("Connection", "keep-alive"); conn.setRequestProperty("Accept-Encoding", "gzip,deflate"); conn.setRequestProperty("Accept-Charset", CONTENT_CHARSET); conn.setRequestProperty("Content-Type", MULTIPART_FROM_DATA + ";boundary=" + BOUNDARY); if (conn instanceof HttpsURLConnection) { setupSecureConnection(hc.getContext(), (HttpsURLConnection) conn); } // ? StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : parameters.entrySet()) { sb.append(PREFIX); sb.append(BOUNDARY); sb.append(LINEND); sb.append("Content-Disposition: form-data; name=\"" + entry.getKey() + "\"" + LINEND); sb.append("Content-Type: text/plain; charset=" + CONTENT_CHARSET + LINEND); sb.append("Content-Transfer-Encoding: 8bit" + LINEND); sb.append(LINEND); sb.append(entry.getValue()); sb.append(LINEND); } DataOutputStream outStream = new DataOutputStream(conn.getOutputStream()); outStream.write(sb.toString().getBytes()); // ??? if (files != null) { for (Map.Entry<String, File> file : files.entrySet()) { StringBuilder sb1 = new StringBuilder(); sb1.append(PREFIX); sb1.append(BOUNDARY); sb1.append(LINEND); sb1.append("Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getKey() + "\"" + LINEND); sb1.append("Content-Type: application/octet-stream; charset=" + CONTENT_CHARSET + LINEND); sb1.append(LINEND); outStream.write(sb1.toString().getBytes()); InputStream is = new FileInputStream(file.getValue()); byte[] buffer = new byte[1024]; int len = 0; while ((len = is.read(buffer)) != -1) { outStream.write(buffer, 0, len); } is.close(); outStream.write(LINEND.getBytes()); } } // ? byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINEND).getBytes(); outStream.write(end_data); outStream.flush(); final int statusCode = conn.getResponseCode(); if (statusCode == -1) { throw new HttpClientException("Invalid response from " + uri); } if (!expectedStatusCodes.isEmpty() && !expectedStatusCodes.contains(statusCode)) { throw new HttpClientException( "Expected status code " + expectedStatusCodes + ", got " + statusCode); } else if (expectedStatusCodes.isEmpty() && statusCode / 100 != 2) { throw new HttpClientException("Expected status code 2xx, got " + statusCode); } final Map<String, List<String>> headerFields = conn.getHeaderFields(); final Map<String, String> inMemoryCookies = hc.getInMemoryCookies(); if (headerFields != null) { final List<String> newCookies = headerFields.get("Set-Cookie"); if (newCookies != null) { for (final String newCookie : newCookies) { final String rawCookie = newCookie.split(";", 2)[0]; final int i = rawCookie.indexOf('='); final String name = rawCookie.substring(0, i); final String value = rawCookie.substring(i + 1); inMemoryCookies.put(name, value); } } } if (isStatusCodeError(statusCode)) { // Got an error: cannot read input. payloadStream = new UncloseableInputStream(getErrorStream(conn)); } else { payloadStream = new UncloseableInputStream(getInputStream(conn)); } final HttpResponse resp = new HttpResponse(statusCode, payloadStream, headerFields == null ? NO_HEADERS : headerFields, inMemoryCookies); if (handler != null) { try { handler.onResponse(resp); } catch (HttpClientException e) { throw e; } catch (Exception e) { throw new HttpClientException("Error in response handler", e); } } else { final File temp = File.createTempFile("httpclient-req-", ".cache", hc.getContext().getCacheDir()); resp.preload(temp); temp.delete(); } return resp; } catch (SocketTimeoutException e) { if (handler != null) { try { handler.onTimeout(); return null; } catch (HttpClientException e2) { throw e2; } catch (Exception e2) { throw new HttpClientException("Error in response handler", e2); } } else { throw new HttpClientException("Response timeout from " + uri, e); } } catch (IOException e) { throw new HttpClientException("Connection failed to " + uri, e); } finally { if (conn != null) { if (payloadStream != null) { // Fully read Http response: // http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html try { while (payloadStream.read(buffer) != -1) { ; } } catch (IOException ignore) { } payloadStream.forceClose(); } conn.disconnect(); } } }
From source file:com.canappi.connector.yp.yhere.SearchView.java
public ArrayList<Element> detailsById(HashMap<String, String> requestParameters) { ArrayList<Element> data = new ArrayList<Element>(); System.setProperty("http.keepAlive", "false"); System.setProperty("javax.net.debug", "all"); // _FakeX509TrustManager.allowAllSSL(); //Protocol::: HTTP GET StringBuffer query = new StringBuffer(); HttpURLConnection connection = null; try {//from w w w .j a va 2s .co m URL url; if (requestParameters != null) { String key; query.append("http://api2.yp.com/listings/v1/details?key=5d0b448ba491c2dff5a36040a125df0a"); query.append("&"); key = "listingid"; String listingidValue = requestParameters.get(key); String listingidDefaultValue = retrieveFromUserDefaultsFor(key); if (listingidValue.length() > 0) { query.append("" + key + "=" + requestParameters.get(key)); } else { //try to find the value in the user defaults if (listingidDefaultValue != null) { query.append("" + key + "=" + retrieveFromUserDefaultsFor(key)); } } url = new URL(query.toString()); } else { url = new URL("http://api2.yp.com/listings/v1/details?key=5d0b448ba491c2dff5a36040a125df0a"); } connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(5000); connection.setReadTimeout(5000); connection.setUseCaches(false); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); int rc = connection.getResponseCode(); Log.i("Response code", String.valueOf(rc)); InputStream is; if (rc <= 400) { is = connection.getInputStream(); } else { /* error from server */ is = connection.getErrorStream(); } //XML ResultSet try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource isrc = new InputSource(); isrc.setByteStream(is); Document doc = db.parse(isrc); NodeList nodes = doc.getElementsByTagName("listingsDetails"); if (nodes.getLength() > 0) { Element list = (Element) nodes.item(0); NodeList l = list.getChildNodes(); for (int i = 0; i < l.getLength(); i++) { Node n = l.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { Element row = (Element) l.item(i); data.add(row); } } } } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } finally { connection.disconnect(); } return data; }
From source file:fur.shadowdrake.minecraft.InstallPanel.java
public boolean downloadMojangLauncher() { URL u;//from w w w . j av a2s .c o m HttpURLConnection connection; Proxy p; InputStream is; FileOutputStream fos; if (new File(config.getInstallDir(), "Minecraft.jar").isFile()) { return true; } log.println("Connecting to Mojang server..."); if (config.getHttpProxy().isEmpty()) { p = Proxy.NO_PROXY; } else { Authenticator.setDefault(new Authenticator() { @Override public PasswordAuthentication getPasswordAuthentication() { if (getRequestorType() == Authenticator.RequestorType.PROXY) { return config.getHttpProxyCredentials(); } else { return super.getPasswordAuthentication(); } } }); p = new Proxy(Proxy.Type.HTTP, new ProxyAddress(config.getHttpProxy(), 3128).getSockaddr()); } try { u = new URL("https://s3.amazonaws.com/Minecraft.Download/launcher/Minecraft.jar"); connection = (HttpURLConnection) u.openConnection(p); connection.addRequestProperty("User-agent", "Minecraft Bootloader"); connection.setUseCaches(false); connection.setDefaultUseCaches(false); connection.setConnectTimeout(10000); connection.setReadTimeout(10000); connection.connect(); log.println("Mojang server returned " + connection.getResponseMessage()); if (connection.getResponseCode() != 200) { connection.disconnect(); return false; } } catch (MalformedURLException ex) { Logger.getLogger(InstallPanel.class.getName()).log(Level.SEVERE, null, ex); return false; } catch (IOException ex) { Logger.getLogger(InstallPanel.class.getName()).log(Level.SEVERE, null, ex); log.println("Connection to Mojang server failed."); return false; } try { is = connection.getInputStream(); fos = new FileOutputStream(new File(config.getInstallDir(), "Minecraft.jar")); log.println("Downloading Minecraft.jar"); byte[] buffer = new byte[4096]; for (int n = is.read(buffer); n > 0; n = is.read(buffer)) { fos.write(buffer, 0, n); } fos.close(); is.close(); connection.disconnect(); log.println("Done."); } catch (IOException ex) { Logger.getLogger(InstallPanel.class.getName()).log(Level.SEVERE, "downloadMojangLauncher", ex); log.println("Faild to save file."); return false; } return true; }
From source file:com.canappi.connector.yp.yhere.SearchView.java
public ArrayList<Element> searchByZip(HashMap<String, String> requestParameters) { ArrayList<Element> data = new ArrayList<Element>(); System.setProperty("http.keepAlive", "false"); System.setProperty("javax.net.debug", "all"); // _FakeX509TrustManager.allowAllSSL(); //Protocol::: HTTP GET StringBuffer query = new StringBuffer(); HttpURLConnection connection = null; try {//w ww . j av a2 s. c om URL url; if (requestParameters != null) { String key; query.append( "http://api2.yp.com/listings/v1/search?format=xml&sort=distance&radius=5&listingcount=10&key=5d0b448ba491c2dff5a36040a125df0a"); query.append("&"); key = "term"; String termValue = requestParameters.get(key); String termDefaultValue = retrieveFromUserDefaultsFor(key); if (termValue.length() > 0) { query.append("" + key + "=" + requestParameters.get(key)); } else { //try to find the value in the user defaults if (termDefaultValue != null) { query.append("" + key + "=" + retrieveFromUserDefaultsFor(key)); } } key = "searchloc"; String searchlocValue = requestParameters.get(key); String searchlocDefaultValue = retrieveFromUserDefaultsFor(key); if (searchlocValue.length() > 0) { query.append("&" + key + "=" + requestParameters.get(key)); } else { //try to find the value in the user defaults if (searchlocDefaultValue != null) { query.append("&" + key + "=" + retrieveFromUserDefaultsFor(key)); } } url = new URL(query.toString()); } else { url = new URL( "http://api2.yp.com/listings/v1/search?format=xml&sort=distance&radius=5&listingcount=10&key=5d0b448ba491c2dff5a36040a125df0a"); } connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(5000); connection.setReadTimeout(5000); connection.setUseCaches(false); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setDoInput(true); connection.connect(); int rc = connection.getResponseCode(); Log.i("Response code", String.valueOf(rc)); InputStream is; if (rc <= 400) { is = connection.getInputStream(); } else { /* error from server */ is = connection.getErrorStream(); } //XML ResultSet try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource isrc = new InputSource(); isrc.setByteStream(is); Document doc = db.parse(isrc); NodeList nodes = doc.getElementsByTagName("searchListings"); if (nodes.getLength() > 0) { Element list = (Element) nodes.item(0); NodeList l = list.getChildNodes(); for (int i = 0; i < l.getLength(); i++) { Node n = l.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { Element row = (Element) l.item(i); data.add(row); } } } } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } finally { connection.disconnect(); } return data; }
From source file:wsserver.EKF1TimerSessionBean.java
private void callT2() { Runnable r2 = new Runnable() { public void run() { int badCnt2 = 0; boolean success_sql_operation = false; StringBuilder insert_sql_values_sb = new StringBuilder(); int insert_sql_cnt = 0; String requestRes = ""; try { try { cbLogsFacade.insertLog("INFO", " ? ? ekfgroup.com", "? ? ? (Timer condition worked Bad full exchange circle) ? ?? - ?? ? ??? , ?"); } catch (Exception lge) { }/* w w w .j av a 2 s .c om*/ String url2 = systemURL + "bitrix/ekflibraries/corpbus/get_json_data.php?ENTITY=1CSECT"; //try { // cbLogsFacade.insertLog("INFO", "Start load bx_1csect", "Start load bx_1csect, url="+systemURL); //} catch(Exception lge) { //} URL obj2 = new URL(url2); HttpURLConnection con2 = (HttpURLConnection) obj2.openConnection(); // optional default is GET con2.setRequestMethod("GET"); con2.setConnectTimeout(180000); con2.setReadTimeout(180000); //add request header con2.setRequestProperty("User-Agent", "Mozilla-Firefox"); int responseCode2 = con2.getResponseCode(); System.out.println("\nSending 'GET' request to URL : " + url2); System.out.println("Response Code : " + responseCode2); BufferedReader in2 = new BufferedReader(new InputStreamReader(con2.getInputStream())); String inputLine2; StringBuffer response2 = new StringBuffer(); while ((inputLine2 = in2.readLine()) != null) { response2.append(inputLine2); } in2.close(); //try { // cbLogsFacade.insertLog("INFO", "Exchange in process 8", "Exchange in process 8"); //} catch(Exception lge) { } requestRes = response2.toString(); try { cbLogsFacade.insertLog("INFO", "Complete load bx_1csect urldata", "Complete load bx_1csect urldata, url=" + url2); } catch (Exception lge) { } JsonReader jsonReader2 = Json.createReader(new StringReader(response2.toString())); bx1CSectFacade.clearBx1CSect(); JsonArray jarray2 = jsonReader2.readArray(); int crcnt2 = 0; boolean hasCrashes2 = false; String saveBxSectLog = ""; for (int i = 0; i < jarray2.size(); i++) { JsonObject jobject2 = jarray2.getJsonObject(i); Bx1CSect b1cssectObj = new Bx1CSect(); b1cssectObj.setId(-1); if (insert_sql_cnt > 0) insert_sql_values_sb.append(" ,"); insert_sql_values_sb.append("( "); try { b1cssectObj.setBxId(Tools.parseInt(jobject2.getString("ID", "-1"), -1)); } catch (Exception e) { b1cssectObj.setBxId(-1); } try { String f1cId = jobject2.getString("1C_ID", ""); if (f1cId.length() == 36) b1cssectObj.setF1cId(f1cId); else b1cssectObj.setF1cId("NULL"); } catch (Exception e) { b1cssectObj.setF1cId("NULL"); } try { b1cssectObj.setParentBxId(Tools.parseInt(jobject2.getString("PARENT_ID", "-1"), -1)); } catch (Exception e) { b1cssectObj.setParentBxId(-1); } try { String parent1cId = jobject2.getString("PARENT_1CID", "NULL"); if (parent1cId.length() == 36) b1cssectObj.setParent1cId(parent1cId); else b1cssectObj.setParent1cId("NULL"); } catch (Exception e) { b1cssectObj.setParent1cId("NULL"); } try { b1cssectObj.setName(StringEscapeUtils.unescapeHtml4(StringEscapeUtils .unescapeJson(jobject2.getString("NAME", "NULL")).replace(""", "\""))); } catch (Exception e) { b1cssectObj.setName("NULL"); } try { b1cssectObj.setPicture(StringEscapeUtils.unescapeHtml4(StringEscapeUtils .unescapeJson(jobject2.getString("PICTURE", "")).replace(""", "\""))); } catch (Exception e) { b1cssectObj.setPicture(""); } try { b1cssectObj.setMcatalog(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("MASTER_CATALOG", "")) .replace(""", "\""))); } catch (Exception e) { b1cssectObj.setMcatalog(""); } //inputLine2) try { b1cssectObj.setDescription(StringEscapeUtils.unescapeHtml4(StringEscapeUtils .unescapeJson(jobject2.getString("DESCRIPTION", "")).replace(""", "\""))); } catch (Exception e) { b1cssectObj.setDescription(""); } try { b1cssectObj.setFullDescription(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("FULL_DESCRIPTION", "")) .replace(""", "\""))); } catch (Exception e) { b1cssectObj.setFullDescription(""); } try { b1cssectObj.setTypeCompleting(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("TYPE_COMPLETING", "")) .replace(""", "\""))); } catch (Exception e) { b1cssectObj.setTypeCompleting(""); } try { b1cssectObj.setCharGabarits(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("CHAR_GABARITS", "")) .replace(""", "\""))); } catch (Exception e) { b1cssectObj.setCharGabarits(""); } try { b1cssectObj.setDocumentation(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("DOCUMENTATION", "")) .replace(""", "\""))); } catch (Exception e) { b1cssectObj.setDocumentation(""); } try { b1cssectObj.setShortDesription(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("SHORT_DESCRIPTION", "")) .replace(""", "\""))); } catch (Exception e) { b1cssectObj.setShortDesription(""); } try { b1cssectObj.setVideoDescription(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("VIDEO_DESCRIPTION", "")) .replace(""", "\""))); } catch (Exception e) { b1cssectObj.setVideoDescription(""); } insert_sql_values_sb.append(b1cssectObj.getBxId()); insert_sql_values_sb.append(",'"); insert_sql_values_sb.append(b1cssectObj.getName().replace("'", "''")); insert_sql_values_sb.append("',"); insert_sql_values_sb.append(b1cssectObj.getParentBxId()); insert_sql_values_sb.append(",'"); insert_sql_values_sb.append(b1cssectObj.getF1cId().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cssectObj.getParent1cId().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cssectObj.getFullDescription().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cssectObj.getTypeCompleting().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cssectObj.getCharGabarits().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cssectObj.getShortDesription().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cssectObj.getDocumentation().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cssectObj.getDescription().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cssectObj.getPicture().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cssectObj.getVideoDescription().replace("'", "''")); insert_sql_values_sb.append("','");// insert_sql_values_sb.append(b1cssectObj.getMcatalog().replace("'", "''")); insert_sql_values_sb.append("',"); insert_sql_values_sb .append((Tools.parseInt(jobject2.getString("COLLAPSEVC", "0"), 0) == 1 ? 1 : 0)); insert_sql_values_sb.append(",'"); try { insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4(StringEscapeUtils .unescapeJson(jobject2.getString("ADVANTS", "")).replace(""", "\""))); } catch (Exception e) { } insert_sql_values_sb.append("','"); try { insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4(StringEscapeUtils .unescapeJson(jobject2.getString("FILTER_PROPS", "")).replace(""", "\""))); } catch (Exception e) { } insert_sql_values_sb.append("','"); try { insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("DESCRIPTS_JSON", "")) .replace(""", "\"").replace("'", "''"))); } catch (Exception e) { } insert_sql_values_sb.append("','"); try { insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("GABARITS_JSON", "")) .replace(""", "\"").replace("'", "''"))); } catch (Exception e) { } insert_sql_values_sb.append("','"); try { insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("DOCS_JSON", "")) .replace(""", "\"").replace("'", "''"))); } catch (Exception e) { } insert_sql_values_sb.append("',"); try { insert_sql_values_sb.append(Tools.parseInt( StringEscapeUtils.unescapeJson(jobject2.getString("SORT_ORDER", "0")), 0)); } catch (Exception e) { } insert_sql_values_sb.append(",'"); try { insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("SEO_ALIAS_URL", "")) .replace(""", "\"").replace("'", "''"))); } catch (Exception e) { } insert_sql_values_sb.append("','"); try { insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject2.getString("SEO_TITLE", "")) .replace(""", "\"").replace("'", "''"))); } catch (Exception e) { } insert_sql_values_sb.append("','"); try { insert_sql_values_sb.append(StringEscapeUtils .unescapeHtml4(StringEscapeUtils.unescapeJson(jobject2.getString("SEO_H1", "")) .replace(""", "\"").replace("'", "''"))); } catch (Exception e) { } insert_sql_values_sb.append("')"); int try_cnt2 = 0; boolean notSucc2 = true; String err = ""; while (try_cnt2 < 10 && notSucc2) { try { //bx1CSectFacade.create(b1cssectObj); //bx1CSectFacade. crcnt2++; notSucc2 = false; } catch (Exception e) { notSucc2 = true; badCnt2++; try_cnt2++; err += "[[" + Tools.parseInt(jobject2.getString("ID", "-1"), -1) + "]]<<==!!||||||!!==>>Error of bx1CsectFacade.create " + e; } } try { if (try_cnt2 > 0) cbLogsFacade.insertLog("ERROR", "Error of bx1CSectFacade", err); } catch (Exception lge) { } hasCrashes2 = hasCrashes2 | notSucc2; insert_sql_cnt++; if (insert_sql_cnt >= 500 || i >= (jarray2.size() - 1)) { try { success_sql_operation = bx1CSectFacade .insertBx1SectMultiply(insert_sql_values_sb.toString(), insert_sql_cnt); } catch (Exception lgesq) { success_sql_operation = false; try { cbLogsFacade.insertLog("INFO", "!!!Unsuccess sending complex sql instruct to bx_1csect", "Err " + lgesq); } catch (Exception lge) { } } if (!success_sql_operation) { try { cbLogsFacade.insertLog("INFO", "!!!Unsuccess complex sql instruct to bx_1csect", "Count record to bx_1csect " + insert_sql_cnt); } catch (Exception lge) { } break; } else { //saveBxSectLog+=("Count record to bx_1cpsect "+insert_sql_cnt+". "); //try { // cbLogsFacade.insertLog("INFO", "Success complex sql instruct to bx_1csect", "Count record to bx_1cpsect "+insert_sql_cnt); //} catch(Exception lge) { //} } insert_sql_cnt = 0; insert_sql_values_sb.setLength(0); } } try { cbLogsFacade.insertLog("INFO", "Complete load bx_1csect", saveBxSectLog + " Complete load bx_1csect " + ", all=" + jarray2.size() + ",succ=" + crcnt2 + ",errcnt=" + badCnt2); } catch (Exception lge) { } if (badCnt2 <= 0 && success_sql_operation) callT3(); else exchangeInProcess = false; } catch (Exception e) { exchangeInProcess = false; try { cbLogsFacade.insertLog("ERROR", "Error of get-parse json bx_1csect", "<<==!!||||||!!==>>Error of get-parse json " + e + ",server reply[" + requestRes.substring(0, 200) + "]"); } catch (Exception lge) { } } finally { } } }; Thread t2 = new Thread(r2); t2.start(); }
From source file:wsserver.EKF1TimerSessionBean.java
private void callT3() { Runnable r3 = new Runnable() { public void run() { int badCnt3 = 0; int crcnt = 0; int allcnt = -1; boolean success_sql_operation = false; StringBuilder insert_sql_values_sb = new StringBuilder(); int insert_sql_cnt = 0; try { String url = systemURL + "bitrix/ekflibraries/corpbus/get_json_data.php?ENTITY=1CPROD"; //try { // cbLogsFacade.insertLog("INFO", "Start load bx_1cprod", "Start load bx_1cprod, url="+systemURL); //} catch(Exception lge) { //} URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); // optional default is GET con.setRequestMethod("GET"); con.setConnectTimeout(180000); con.setReadTimeout(180000); //add request header con.setRequestProperty("User-Agent", "Mozilla-Firefox"); int responseCode = con.getResponseCode(); System.out.println("\nSending 'GET' request to URL : " + url); System.out.println("Response Code : " + responseCode); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); }//from w w w .j av a 2 s. c om in.close(); try { cbLogsFacade.insertLog("INFO", "Complete load bx_1cprod urldata", "Complete load bx_1cprod urldata, url=" + systemURL); } catch (Exception lge) { } JsonReader jsonReader = Json.createReader(new StringReader(response.toString())); //int icnt = 0;//bx1CProdFacade.insertBx1ProdMultiply(); //try { // cbLogsFacade.insertLog("INFO", "Complete persist test bx_1cprod urldata ", "Complete persist test bx_1cprod urldata "+icnt); //} catch(Exception lge) { //} bx1CProdFacade.clearBx1CProd(); JsonArray jarray = jsonReader.readArray(); boolean hasCrashes = false; String saveBxDataLog = ""; for (int i = 0; i < jarray.size(); i++) { JsonObject jobject = jarray.getJsonObject(i); Bx1CProd b1cprodObj = new Bx1CProd(); b1cprodObj.setId(-1); if (insert_sql_cnt > 0) insert_sql_values_sb.append(" ,"); insert_sql_values_sb.append("( "); try { b1cprodObj.setBxId(Tools.parseInt(jobject.getString("ID", "-1"), -1)); } catch (Exception e) { b1cprodObj.setBxId(-1); } try { String f1cId = jobject.getString("1C_ID", "NULL"); if (f1cId.length() == 36) b1cprodObj.setF1cId(f1cId); else b1cprodObj.setF1cId("NULL"); } catch (Exception e) { b1cprodObj.setF1cId("NULL"); } try { b1cprodObj.setParentBxId(Tools.parseInt(jobject.getString("PARENT_ID", "-1"), -1)); } catch (Exception e) { b1cprodObj.setParentBxId(-1); } try { String parent1cId = jobject.getString("PARENT_1CID", "NULL"); if (parent1cId.length() == 36) b1cprodObj.setParent1cId(parent1cId); else b1cprodObj.setParent1cId("NULL"); } catch (Exception e) { b1cprodObj.setParent1cId("NULL"); } try { b1cprodObj.setName(StringEscapeUtils.unescapeHtml4(StringEscapeUtils .unescapeJson(jobject.getString("NAME", "NULL")).replace(""", "\""))); } catch (Exception e) { b1cprodObj.setName("NULL"); } try { b1cprodObj.setArtikul(StringEscapeUtils.unescapeHtml4( StringEscapeUtils.unescapeJson(jobject.getString("ARTICUL", "NULL")))); } catch (Exception e) { b1cprodObj.setArtikul("NULL"); } insert_sql_values_sb.append(b1cprodObj.getBxId()); insert_sql_values_sb.append(",'"); insert_sql_values_sb.append(b1cprodObj.getName().replace("'", "''")); insert_sql_values_sb.append("',"); insert_sql_values_sb.append(b1cprodObj.getParentBxId()); insert_sql_values_sb.append(",'"); insert_sql_values_sb.append(b1cprodObj.getF1cId().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cprodObj.getParent1cId().replace("'", "''")); insert_sql_values_sb.append("','"); insert_sql_values_sb.append(b1cprodObj.getArtikul().replace("'", "''")); insert_sql_values_sb.append("',"); try { b1cprodObj.setPrice(new BigDecimal(jobject.getString("PRICE", "0"))); insert_sql_values_sb.append(jobject.getString("PRICE", "0").replace(",", ".")); } catch (Exception e) { b1cprodObj.setPrice(new BigDecimal(0)); insert_sql_values_sb.append("0"); } insert_sql_values_sb.append(","); try { b1cprodObj.setAmount(new BigDecimal(jobject.getString("QUANTITY", "0"))); insert_sql_values_sb.append(jobject.getString("QUANTITY", "0").replace(",", ".")); } catch (Exception e) { b1cprodObj.setAmount(new BigDecimal(0)); insert_sql_values_sb.append("0"); } insert_sql_values_sb.append(","); try { b1cprodObj.setBprice(new BigDecimal(jobject.getString("BPRICE", "0"))); insert_sql_values_sb.append(jobject.getString("BPRICE", "0").replace(",", ".")); } catch (Exception e) { b1cprodObj.setBprice(new BigDecimal(0)); insert_sql_values_sb.append("0"); } insert_sql_values_sb.append(","); try { //b1cprodObj.setBprice(new BigDecimal(jobject.getString("SORT_ORDER", "0"))); insert_sql_values_sb.append(jobject.getString("SORT_ORDER", "0").replace(",", ".")); } catch (Exception e) { //b1cprodObj.setBprice(new BigDecimal(0)); insert_sql_values_sb.append("0"); } insert_sql_values_sb.append(",'"); try { insert_sql_values_sb.append(StringEscapeUtils .unescapeHtml4( StringEscapeUtils.unescapeJson(jobject.getString("MAIN_PICT", ""))) .replace("'", "''")); } catch (Exception e) { } insert_sql_values_sb.append("',"); try { //b1cprodObj.setBprice(new BigDecimal(jobject.getString("SORT_ORDER", "0"))); insert_sql_values_sb.append("" + jobject.getInt("PROP_CNT", 0)); } catch (Exception e) { //b1cprodObj.setBprice(new BigDecimal(0)); insert_sql_values_sb.append("0"); } insert_sql_values_sb.append(")"); int try_cnt = 0; boolean notSucc = true; String err = ""; while (try_cnt < 10 && notSucc) { try { //bx1CSectFacade. //bx1CProdFacade.create(b1cprodObj); crcnt++; notSucc = false; } catch (Exception e) { notSucc = true; badCnt3++; try_cnt++; err += "[[" + Tools.parseInt(jobject.getString("ID", "-1"), -1) + "]]<<==!!||||||!!==>>Error of bx1CProdFacade.create " + e; } } try { if (try_cnt > 0) { cbLogsFacade.insertLog("ERROR", "Error of bx1CProdFacade", err); } } catch (Exception lge) { } hasCrashes = hasCrashes | notSucc; insert_sql_cnt++; if (insert_sql_cnt >= 500 || i >= (jarray.size() - 1)) { try { success_sql_operation = bx1CProdFacade .insertBx1ProdMultiply(insert_sql_values_sb.toString(), insert_sql_cnt); } catch (Exception lgesq) { success_sql_operation = false; try { cbLogsFacade.insertLog("INFO", "!!!Unsuccess sending complex sql instruct to bx_1cprod", "Err " + lgesq); } catch (Exception lge) { } } if (!success_sql_operation) { try { cbLogsFacade.insertLog("INFO", "!!!Unsuccess complex sql instruct to bx_1cprod", "Count record to bx_1cprods " + insert_sql_cnt); } catch (Exception lge) { } break; } else { saveBxDataLog += ("Succ " + insert_sql_cnt);//complex sql instruct to bx_1cprod. "+ // "Count record to bx_1cprods "+insert_sql_cnt); //try { // cbLogsFacade.insertLog("INFO", "Success complex sql instruct to bx_1cprod", "Count record to bx_1cprods "+insert_sql_cnt); //} catch(Exception lge) { //} } insert_sql_cnt = 0; insert_sql_values_sb.setLength(0); } } try { allcnt = jarray.size(); cbLogsFacade.insertLog("INFO", "Complete load bx_1cprod", saveBxDataLog + " Complete load bx_1cprods " + ", all=" + allcnt + ",succ=" + crcnt + ",errcnt=" + badCnt3); } catch (Exception lge) { } if (badCnt3 <= 20 && (allcnt == crcnt) && success_sql_operation) { //sendCompareData(); //sendCompareSectDataDel(); //sendCompareSectDataUpd(); boolean repeat_load = true; int repeat_counter = 0; while (repeat_load && repeat_counter < 10) { repeat_counter++; String selectExchngDataLog = ""; try { if (tablesOperatingStateFacade.getEkfGrExchDataCorrupt() && false) { Thread.sleep(30000); try { cbLogsFacade.insertLog("INFO", "getEkfGrExchDataCorrupt", "Wait on 30 sec, attempt " + repeat_counter + " of 10..."); } catch (Exception lgex) { } } else { repeat_load = false; int ekfProdCount = cbLogsFacade.ekfProdCount(); int ekfProdSectCount = cbLogsFacade.ekfProdSectCount(); if (ekfProdCount >= 1000 && ekfProdCount <= 100000 && ekfProdSectCount >= 200 && ekfProdSectCount <= 10000) { if (tablesOperatingStateFacade.setEkfGrExchDataCorrupt()) { //try { // cbLogsFacade.insertLog("INFO", "Start of request cbNewPrFrom1cWpropsFacade", "Start of request cbNewPrFrom1cWpropsFacade"); //} catch(Exception lge) { } selectExchngDataLog += "Start of request cbNewPrFrom1cWpropsFacade "; npwps_ = cbNewPrFrom1cWpropsFacade.findAll(); //try { // cbLogsFacade.insertLog("INFO", "Start of request cbEkfgroupDel1csectFromBxFacade", "Complete prev, Start of request cbEkfgroupDel1csectFromBxFacade"); //} catch(Exception lge) { } selectExchngDataLog += "Complete prev, Start of request cbEkfgroupDel1csectFromBxFacade "; dswps_ = cbEkfgroupDel1csectFromBxFacade.findAll(); //try { // cbLogsFacade.insertLog("INFO", "Start of request cbEkfgroupUpd1csectToBxFacade", "Complete prev, Start of request cbEkfgroupUpd1csectToBxFacade"); //} catch(Exception lge) { } selectExchngDataLog += "Complete prev, Start of request cbEkfgroupUpd1csectToBxFacade "; uswps_ = cbEkfgroupUpd1csectToBxFacade.findAll(); //try { // cbLogsFacade.insertLog("INFO", "Start of request cbEkfgroupAdd1csectToBxFacade", "Complete prev, Start of request cbEkfgroupAdd1csectToBxFacade"); //} catch(Exception lge) { } selectExchngDataLog += "Complete prev, Start of request cbEkfgroupAdd1csectToBxFacade "; nswps_ = cbEkfgroupAdd1csectToBxFacade.findAll(); //try { // cbLogsFacade.insertLog("INFO", "Start of request cbEkfroupDelFromBxViewFacade", "Complete prev, Start of request cbEkfroupDelFromBxViewFacade"); //} catch(Exception lge) { } selectExchngDataLog += "Complete prev, Start of request cbEkfroupDelFromBxViewFacade "; dpwps_ = cbEkfroupDelFromBxViewFacade.findAll(); //try { // cbLogsFacade.insertLog("INFO", "Start of request CbEkfgroupToUpdatedBx1cFacade", "Complete prev, Start of request CbEkfgroupToUpdatedBx1cFacade"); //} catch(Exception lge) { } selectExchngDataLog += "Complete prev, Start of request CbEkfgroupToUpdatedBx1cFacade "; upwps_ = cbEkfgroupToUpdatedBx1cFacade.findAll(); try { cbLogsFacade.insertLog("INFO", "End of request CbEkfgroupToUpdatedBx1cFacade", selectExchngDataLog + " End of request CbEkfgroupToUpdatedBx1cFacade"); } catch (Exception lge) { } if (npwps_.size() == 0 && upwps_.size() == 0 && dpwps_.size() == 0) { if (cbSettingsFacade.updExchanheLastDt()) { //try { // cbLogsFacade.insertLog("INFO", "Success update exchange last datetime", // "Success update exchange last datetime"); //} catch(Exception lge) { //} } else { try { cbLogsFacade.insertLog("ERROR", "Unsuccess update exchange last datetime", "Unsuccess update exchange last datetime"); } catch (Exception lge) { } } } if (tablesOperatingStateFacade.setEkfGrExchDataUnCorrupt()) { sendCompareSectDataAdd(); } else { exchangeInProcess = false; try { cbLogsFacade.insertLog("ERROR", "Unsuccess setEkfGrExchDataCorrupt 0", "Unsuccess setEkfGrExchDataCorrupt 0"); } catch (Exception lgex) { } } } else { exchangeInProcess = false; try { cbLogsFacade.insertLog("ERROR", "Unsuccess setEkfGrExchDataCorrupt 1", "Unsuccess setEkfGrExchDataCorrupt 1"); } catch (Exception lgex) { } } } else { exchangeInProcess = false; try { cbLogsFacade.insertLog("ERROR", "Invalid data sizes, exchange stopped", "Data sizes mismatch conditions 200<=ekfProdSectCount<=10000, " + "1000<=ekfProdCount<=100000"); } catch (Exception lgex) { } } } } catch (Exception lge) { exchangeInProcess = false; repeat_load = false; try { cbLogsFacade.insertLog("ERROR", "Error of getEkfGrExchDataCorrupt or setEkfGrExchDataCorrupt or MDS data load", "Error of getEkfGrExchDataCorrupt, detail: " + selectExchngDataLog); } catch (Exception lgex) { } } } if (repeat_load) { hasLong1CWait = true; exchangeInProcess = false; } } else exchangeInProcess = false; } catch (Exception e) { exchangeInProcess = false; System.out.println("<<==!!||||||!!==>>Error of get-parse bx_1cprod json " + e); try { cbLogsFacade.insertLog("ERROR", "Error of get-parse json bx_1cprod", "<<==!!||||||!!==>>Error of get-parse json " + e); } catch (Exception lge) { } } finally { try { //tablesOperatingStateFacade.setEkfGrExchDataUnDelta(); if (tablesOperatingStateFacade.setEkfGrExchDataUnCorrupt()) { } else { try { cbLogsFacade.insertLog("ERROR", "Unsuccess setEkfGrExchDataCorrupt 0", "Unsuccess setEkfGrExchDataCorrupt 0"); } catch (Exception lgex) { } } } catch (Exception lgex) { } } } }; Thread t3 = new Thread(r3); t3.start(); }