Browse Source

content需要编码

research/10.0
alex.sung 6 years ago
parent
commit
394d5bddb1
  1. 23
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

23
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.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -227,11 +228,7 @@ public class InformationCollector implements XMLReadable, XMLWriter {
private void sendFunctionsInfo(){ private void sendFunctionsInfo(){
long currentTime = new Date().getTime(); long currentTime = new Date().getTime();
ArrayList<Map<String, Object>> content = null; ArrayList<Map<String, Object>> content = null;
try { content = getFunctionsContentAsByte(currentTime);
content = getFunctionsContentAsByte(currentTime);
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
boolean success = false; boolean success = false;
String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD); String url = CloudCenter.getInstance().acquireUrlByKind(TABLE_FUNCTION_RECORD);
if(content.size() > 0){ if(content.size() > 0){
@ -246,19 +243,12 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} }
private boolean sendFunctionRecord(String url, Map<String,Object> record) { private boolean sendFunctionRecord(String url, Map<String,Object> record) {
HashMap<String, String> 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; boolean success = false;
try { 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"); success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");
} catch (JSONException e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return success; 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<Map<String,Object>> records = new ArrayList<Map<String,Object>>(); ArrayList<Map<String,Object>> records = new ArrayList<Map<String,Object>>();
QueryCondition condition = QueryFactory.create().addRestriction( QueryCondition condition = QueryFactory.create().addRestriction(
RestrictionFactory.lte(COLUMN_TIME, currentTime) RestrictionFactory.lte(COLUMN_TIME, currentTime)
); );
try { try {
DataList<FocusPoint> focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition); DataList<FocusPoint> focusPoints = MetricRegistry.getMetric().find(FocusPoint.class,condition);
focusPoints.getList();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
String bbsUserName = MarketConfig.getInstance().getBbsUsername(); String bbsUserName = MarketConfig.getInstance().getBbsUsername();
String uuid = envManager.getUUID(); String uuid = envManager.getUUID();

Loading…
Cancel
Save