Example usage for org.apache.commons.lang3 StringEscapeUtils unescapeJson

List of usage examples for org.apache.commons.lang3 StringEscapeUtils unescapeJson

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringEscapeUtils unescapeJson.

Prototype

public static final String unescapeJson(final String input) 

Source Link

Document

Unescapes any Json literals found in the String .

For example, it will turn a sequence of '\' and 'n' into a newline character, unless the '\' is preceded by another '\' .

Usage

From source file:com.manisha.allmybooksarepacked.utility.JSONUtils.java

@SuppressWarnings("unchecked")
public static <T> T JSONToObject(String json, Class<T> clazz) throws IOException {
    if (clazz == null || clazz.isAssignableFrom(String.class))
        return (T) json;
    if (StringUtils.isBlank(json))
        return null;
    return mapper.readValue(StringEscapeUtils.unescapeJson(json), clazz);
}

From source file:q4.java

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
 * response)/*  w w  w.ja  va 2 s  .  c om*/
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HTableInterface table;
    StringBuilder sb = new StringBuilder();
    sb.append(TEAM);
    table = connection.getTable(tableName);
    int m = Integer.parseInt(request.getParameter("m"));
    int n = Integer.parseInt(request.getParameter("n"));

    byte[] location = Bytes.toBytes(request.getParameter("location").hashCode());
    byte[] date = Bytes.toBytes(Integer.parseInt(request.getParameter("date").replace("-", "")));
    try {
        ArrayList<Row> batchJob = new ArrayList<>();
        for (int i = m; i <= n; i++) {
            batchJob.add(new Get(Bytes.add(location, date, Bytes.toBytes(i))));
        }
        Object[] result = table.batch(batchJob);
        for (Object r : result) {
            if (r instanceof Result) {
                if (((Result) r).value() != null) {
                    //System.out.println(new String(((Result)r).value()));
                    sb.append(StringEscapeUtils.unescapeJson(new String(((Result) r).value()))).append("\n");
                }
            }
        }
    } catch (InterruptedException ex) {
    }

    ServletOutputStream out = response.getOutputStream();
    out.write(sb.toString().getBytes());
}

From source file:com.geemvc.taglib.html.MessageTagSupport.java

@Override
public void doTag() throws JspException {
    if (locale != null && (lang != null || country != null))
        throw new JspException(
                "You can only set one of of either 'locale' or a 'language/country' combination.");

    if (lang != null && country != null)
        locale = new Locale(lang, country);

    else if (lang != null)
        locale = new Locale(lang);

    String label = null;/*from w  w  w .  j a va  2 s. c om*/

    // Handle string keys normally.
    if (key instanceof String) {
        label = messageResolver.resolve((String) key, locale, requestContext(), true);
    } else if (key.getClass().isEnum()) {
        // Attempt to resolve <enun-fqn>.<enum-value>.
        label = messageResolver.resolve(
                new StringBuilder(key.getClass().getName()).append(Char.DOT).append(key).toString(),
                requestContext(), true);

        // Attempt to resolve <enun-simple-name>.<enum-value>.
        if (label == null)
            label = messageResolver.resolve(
                    new StringBuilder(key.getClass().getSimpleName()).append(Char.DOT).append(key).toString(),
                    requestContext(), true);
    } else if (key instanceof Boolean) {
        // Attempt to resolve Boolean.true or Boolean.false.
        label = messageResolver.resolve(new StringBuilder(Boolean.class.getSimpleName()).append(Char.DOT)
                .append(String.valueOf(key).toLowerCase()).toString(), requestContext(), true);
    } else {
        throw new JspException("The type '" + key.getClass().getName()
                + "' cannot be used as a message key in MessageTagSupport. Only the types String, Boolean or enums are supported.");
    }

    if (label != null) {
        if (escapeHTML)
            label = StringEscapeUtils.escapeHtml4(label);

        if (escapeJavascript)
            label = StringEscapeUtils.escapeEcmaScript(label);

        if (escapeJson)
            label = StringEscapeUtils.escapeJson(label);

        if (unescapeHTML)
            label = StringEscapeUtils.unescapeHtml4(label);

        if (unescapeJavascript)
            label = StringEscapeUtils.unescapeEcmaScript(label);

        if (unescapeJson)
            label = StringEscapeUtils.unescapeJson(label);
    }

    if (label == null) {
        label = getBodyContent();

        if (label == null)
            label = String.format("???%s???", key);
    }

    // Deal with parameters.
    if (label != null) {
        List<Object> params = messageParameters();

        if (params != null && !params.isEmpty())
            label = MessageFormat.format(label, params.toArray());
    }

    if (!Str.isEmpty(var)) {
        jspContext.setAttribute(var, label, scope());
    } else {
        try {
            jspContext.getOut().write(label);
        } catch (IOException e) {
            throw new JspException(e);
        }
    }
}

From source file:edu.mit.scratch.ScratchCloudSession.java

public String get(final String key) throws ScratchProjectException {
    try {// w w w  . ja v  a2  s . c  o  m
        final RequestConfig globalConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.DEFAULT).build();

        final CookieStore cookieStore = new BasicCookieStore();
        final BasicClientCookie lang = new BasicClientCookie("scratchlanguage", "en");
        lang.setDomain(".scratch.mit.edu");
        lang.setPath("/");
        cookieStore.addCookie(lang);

        final CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(globalConfig)
                .setUserAgent(Scratch.USER_AGENT).setDefaultCookieStore(cookieStore).build();
        CloseableHttpResponse resp;

        final HttpUriRequest update = RequestBuilder.get()
                .setUri("https://scratch.mit.edu/varserver/" + this.getProjectID())
                .addHeader("Accept",
                        "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*//*;q=0.8")
                .addHeader("Referer", "https://scratch.mit.edu").addHeader("Origin", "https://scratch.mit.edu")
                .addHeader("Accept-Encoding", "gzip, deflate, sdch")
                .addHeader("Accept-Language", "en-US,en;q=0.8").addHeader("Content-Type", "application/json")
                .addHeader("X-Requested-With", "XMLHttpRequest").build();
        try {
            resp = httpClient.execute(update);
        } catch (final IOException e) {
            e.printStackTrace();
            throw new ScratchProjectException();
        }

        BufferedReader rd;
        try {
            rd = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
        } catch (UnsupportedOperationException | IOException e) {
            e.printStackTrace();
            throw new ScratchProjectException();
        }

        final StringBuffer result = new StringBuffer();
        String line = "";
        while ((line = rd.readLine()) != null)
            result.append(line);
        final JSONObject jsonOBJ = new JSONObject(result.toString().trim());

        final Iterator<?> keys = ((JSONArray) jsonOBJ.get("variables")).iterator();

        while (keys.hasNext()) {
            final JSONObject o = new JSONObject(StringEscapeUtils.unescapeJson("" + keys.next()));
            final String k = o.get("name") + "";

            if (k.equals(key))
                return o.get("value") + "";
        }
    } catch (final Exception e) {
        e.printStackTrace();
        throw new ScratchProjectException();
    }

    return null;
}

From source file:com.microsoft.o365_android_onenote_rest.SnippetDetailFragment.java

private void maybeDisplayResponseBody(Response response) {
    if (null != response.getBody()) {
        String body = null;/*from w w w .  j  av a2 s. com*/
        InputStream is = null;
        try {
            is = response.getBody().in();
            body = IOUtils.toString(is);
            String formattedJson = new JSONObject(body).toString(2);
            formattedJson = StringEscapeUtils.unescapeJson(formattedJson);
            mResponseBody.setText(formattedJson);
        } catch (JSONException e) {
            if (null != body) {
                // body wasn't JSON
                mResponseBody.setText(body);
            } else {
                // set the stack trace as the response body
                displayThrowable(e);
            }
        } catch (IOException e) {
            e.printStackTrace();
            displayThrowable(e);
        } finally {
            if (null != is) {
                IOUtils.closeQuietly(is);
            }
        }
    }
}

From source file:edu.mit.scratch.ScratchCloudSession.java

public List<String> getVariables() throws ScratchProjectException {
    final List<String> list = new ArrayList<>();

    try {/*from  w w w .ja v a  2 s  .c  om*/
        final RequestConfig globalConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.DEFAULT).build();

        final CookieStore cookieStore = new BasicCookieStore();
        final BasicClientCookie lang = new BasicClientCookie("scratchlanguage", "en");
        lang.setDomain(".scratch.mit.edu");
        lang.setPath("/");
        cookieStore.addCookie(lang);

        final CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(globalConfig)
                .setUserAgent(Scratch.USER_AGENT).setDefaultCookieStore(cookieStore).build();
        CloseableHttpResponse resp;

        final HttpUriRequest update = RequestBuilder.get()
                .setUri("https://scratch.mit.edu/varserver/" + this.getProjectID())
                .addHeader("Accept",
                        "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*//*;q=0.8")
                .addHeader("Referer", "https://scratch.mit.edu").addHeader("Origin", "https://scratch.mit.edu")
                .addHeader("Accept-Encoding", "gzip, deflate, sdch")
                .addHeader("Accept-Language", "en-US,en;q=0.8").addHeader("Content-Type", "application/json")
                .addHeader("X-Requested-With", "XMLHttpRequest").build();
        try {
            resp = httpClient.execute(update);
        } catch (final IOException e) {
            e.printStackTrace();
            throw new ScratchProjectException();
        }

        BufferedReader rd;
        try {
            rd = new BufferedReader(new InputStreamReader(resp.getEntity().getContent()));
        } catch (UnsupportedOperationException | IOException e) {
            e.printStackTrace();
            throw new ScratchProjectException();
        }

        final StringBuffer result = new StringBuffer();
        String line = "";
        while ((line = rd.readLine()) != null)
            result.append(line);
        final JSONObject jsonOBJ = new JSONObject(result.toString().trim());

        final Iterator<?> keys = ((JSONArray) jsonOBJ.get("variables")).iterator();

        while (keys.hasNext()) {
            final JSONObject o = new JSONObject(StringEscapeUtils.unescapeJson("" + keys.next()));
            final String k = o.get("name") + "";
            list.add(k);
        }
    } catch (final UnsupportedEncodingException e) {
        e.printStackTrace();
        throw new ScratchProjectException();
    } catch (final IOException e) {
        e.printStackTrace();
        throw new ScratchProjectException();
    }

    return list;
}

From source file:io.github.swagger2markup.internal.component.PathOperationComponent.java

private void exampleMap(MarkupDocBuilder markupDocBuilder, Map<String, Object> exampleMap,
        String operationSectionTitle, String sectionTitle, boolean beforeBreak, boolean afterBreak) {
    if (exampleMap.size() > 0) {
        if (beforeBreak)
            markupDocBuilder.pageBreak();
        buildSectionTitle(markupDocBuilder, operationSectionTitle);
        for (Map.Entry<String, Object> entry : exampleMap.entrySet()) {

            // Example title, like "Response 200" or "Request Body"
            buildExampleTitle(markupDocBuilder, sectionTitle + " " + entry.getKey());

            if (NumberUtils.isNumber(entry.getKey())) {
                // Section header is an HTTP status code (numeric)
                JsonNode rootNode = parseExample(entry.getValue());
                Iterator<Map.Entry<String, JsonNode>> fieldsIterator = rootNode.fields();

                if (!fieldsIterator.hasNext()) {
                    // workaround for "array" example
                    //TODO: print $ref'd examples correctly instead of just "array"
                    String example = stripExampleQuotes(Json.pretty(entry.getValue()));
                    example = Json.pretty(example);
                    markupDocBuilder.listingBlock(example, "json");
                }//from  www  . jav a  2  s.com
                while (fieldsIterator.hasNext()) {
                    Map.Entry<String, JsonNode> field = fieldsIterator.next();

                    if (field.getKey().equals("application/json")) {
                        String example = Json.pretty(field.getValue());
                        example = stripExampleQuotes(StringEscapeUtils.unescapeJson(example));

                        markupDocBuilder.listingBlock(example, "json");

                    } else if (field.getKey().equals("application/xml")) {

                        String example = stripExampleQuotes(field.getValue().toString());
                        example = StringEscapeUtils.unescapeJava(example);

                        //TODO: pretty print XML

                        markupDocBuilder.listingBlock(example, "xml");
                    } else {
                        String example = Json.pretty(entry.getValue());
                        markupDocBuilder.listingBlock(example, "json");
                        break; // No need to print the same example multiple times
                    }
                }
            } else if (entry.getKey().equals("path")) {
                // Path shouldn't have quotes around it
                markupDocBuilder.listingBlock(entry.getValue().toString());
            } else {
                markupDocBuilder.listingBlock(Json.pretty(entry.getValue()), "json");
            }
        }
        if (afterBreak)
            markupDocBuilder.pageBreak();
    }
}

From source file:com.hygenics.parser.getDAOTemplate.java

private BatchPreparedStatementSetter jsonBatchSetter(final ArrayList<String> jsondata,
        final ArrayList<String> keys) {
    return (new BatchPreparedStatementSetter() {

        @Override// www  .ja va 2  s. c o  m
        public int getBatchSize() {
            return jsondata.size();
        }

        @Override
        public void setValues(PreparedStatement ps, int i) throws SQLException {
            Map<String, Json> jmap = Json.read(jsondata.get(i)).asJsonMap();
            int j = 0;

            for (String k : keys) {
                if (k.toLowerCase().compareTo("table") != 0 && !k.toLowerCase().contains("narrow")) {
                    j++;
                    ps.setString(j, StringEscapeUtils.unescapeJson(jmap.get(k).asString()));
                }
            }
        }

    });

}

From source file:org.coursera.courier.grammar.ParseUtils.java

public static String extractString(String stringLiteral) {
    return StringEscapeUtils.unescapeJson(stringLiteral.substring(1, stringLiteral.length() - 1));
}

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 ww  .  j  a  v  a 2s  . com*/

                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("&quot;", "\"")));
                    } catch (Exception e) {
                        b1cssectObj.setName("NULL");
                    }

                    try {
                        b1cssectObj.setPicture(StringEscapeUtils.unescapeHtml4(StringEscapeUtils
                                .unescapeJson(jobject2.getString("PICTURE", "")).replace("&quot;", "\"")));
                    } catch (Exception e) {
                        b1cssectObj.setPicture("");
                    }

                    try {
                        b1cssectObj.setMcatalog(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("MASTER_CATALOG", ""))
                                        .replace("&quot;", "\"")));
                    } catch (Exception e) {
                        b1cssectObj.setMcatalog("");
                    }

                    //inputLine2)

                    try {
                        b1cssectObj.setDescription(StringEscapeUtils.unescapeHtml4(StringEscapeUtils
                                .unescapeJson(jobject2.getString("DESCRIPTION", "")).replace("&quot;", "\"")));
                    } catch (Exception e) {
                        b1cssectObj.setDescription("");
                    }

                    try {
                        b1cssectObj.setFullDescription(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("FULL_DESCRIPTION", ""))
                                        .replace("&quot;", "\"")));
                    } catch (Exception e) {
                        b1cssectObj.setFullDescription("");
                    }

                    try {
                        b1cssectObj.setTypeCompleting(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("TYPE_COMPLETING", ""))
                                        .replace("&quot;", "\"")));
                    } catch (Exception e) {
                        b1cssectObj.setTypeCompleting("");
                    }

                    try {
                        b1cssectObj.setCharGabarits(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("CHAR_GABARITS", ""))
                                        .replace("&quot;", "\"")));
                    } catch (Exception e) {
                        b1cssectObj.setCharGabarits("");
                    }

                    try {
                        b1cssectObj.setDocumentation(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("DOCUMENTATION", ""))
                                        .replace("&quot;", "\"")));
                    } catch (Exception e) {
                        b1cssectObj.setDocumentation("");
                    }

                    try {
                        b1cssectObj.setShortDesription(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("SHORT_DESCRIPTION", ""))
                                        .replace("&quot;", "\"")));
                    } catch (Exception e) {
                        b1cssectObj.setShortDesription("");
                    }

                    try {
                        b1cssectObj.setVideoDescription(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("VIDEO_DESCRIPTION", ""))
                                        .replace("&quot;", "\"")));
                    } 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("&quot;", "\"")));
                    } catch (Exception e) {
                    }
                    insert_sql_values_sb.append("','");
                    try {
                        insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4(StringEscapeUtils
                                .unescapeJson(jobject2.getString("FILTER_PROPS", "")).replace("&quot;", "\"")));
                    } catch (Exception e) {
                    }
                    insert_sql_values_sb.append("','");
                    try {
                        insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("DESCRIPTS_JSON", ""))
                                        .replace("&quot;", "\"").replace("'", "''")));
                    } catch (Exception e) {
                    }
                    insert_sql_values_sb.append("','");
                    try {
                        insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("GABARITS_JSON", ""))
                                        .replace("&quot;", "\"").replace("'", "''")));
                    } catch (Exception e) {
                    }
                    insert_sql_values_sb.append("','");
                    try {
                        insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("DOCS_JSON", ""))
                                        .replace("&quot;", "\"").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("&quot;", "\"").replace("'", "''")));
                    } catch (Exception e) {
                    }
                    insert_sql_values_sb.append("','");
                    try {
                        insert_sql_values_sb.append(StringEscapeUtils.unescapeHtml4(
                                StringEscapeUtils.unescapeJson(jobject2.getString("SEO_TITLE", ""))
                                        .replace("&quot;", "\"").replace("'", "''")));
                    } catch (Exception e) {
                    }
                    insert_sql_values_sb.append("','");
                    try {
                        insert_sql_values_sb.append(StringEscapeUtils
                                .unescapeHtml4(StringEscapeUtils.unescapeJson(jobject2.getString("SEO_H1", ""))
                                        .replace("&quot;", "\"").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();

}