From 394d5bddb1122e4cdf382ac76eab57fe2bf049be Mon Sep 17 00:00:00 2001 From: "alex.sung" Date: Wed, 31 Oct 2018 11:46:50 +0800 Subject: [PATCH] =?UTF-8?q?content=E9=9C=80=E8=A6=81=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/InformationCollector.java | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 00eda062de..6507620694 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -58,6 +58,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -227,11 +228,7 @@ public class InformationCollector implements XMLReadable, XMLWriter { private void sendFunctionsInfo(){ long currentTime = new Date().getTime(); ArrayList> content = null; - try { - content = getFunctionsContentAsByte(currentTime); - } catch (JSONException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } + content = getFunctionsContentAsByte(currentTime); boolean success = false; String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD); if(content.size() > 0){ @@ -246,19 +243,12 @@ public class InformationCollector implements XMLReadable, XMLWriter { } private boolean sendFunctionRecord(String url, Map record) { - HashMap para = new HashMap<>(); - para.put("token", SiteCenterToken.generateToken()); - para.put("content", new JSONObject(record).toString()); - String res = null; - try { - res = HttpToolbox.get(url, para); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } boolean success = false; try { + String recordUrl = url+"?token=" + SiteCenterToken.generateToken() + "&content="+URLEncoder.encode(new JSONObject(record).toString(), EncodeConstants.ENCODING_UTF_8); + String res = HttpToolbox.get(recordUrl); success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); - } catch (JSONException e) { + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } return success; @@ -424,14 +414,13 @@ public class InformationCollector implements XMLReadable, XMLWriter { }); } - public static ArrayList getFunctionsContentAsByte(long currentTime) throws JSONException{ + public static ArrayList getFunctionsContentAsByte(long currentTime){ ArrayList> records = new ArrayList>(); QueryCondition condition = QueryFactory.create().addRestriction( RestrictionFactory.lte(COLUMN_TIME, currentTime) ); try { DataList focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition); - focusPoints.getList(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); String bbsUserName = MarketConfig.getInstance().getBbsUsername(); String uuid = envManager.getUUID();