Browse Source

Merge pull request #1491 in DESIGN/design from ~LANLAN/design:release/10.0 to release/10.0

* commit '890fa881aab6461aff8c0e771a63051754a43de8':
  REPORT-27914 https远程连接,没有触发固化埋点回传
feature/big-screen
Lanlan 5 years ago
parent
commit
330d5b3b77
  1. 77
      designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java

77
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java

@ -1,22 +1,18 @@
package com.fr.design.mainframe.messagecollect.solid;
import com.fr.analysis.cloud.solid.SolidRecordExecutor;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.security.JwtUtils;
import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.stable.CommonUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.REQUEST_SUBJECT;
import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.TIME_OUT;
/**
* 设计器固化信息回传类
* Created by alex sung on 2019/8/22.
@ -24,9 +20,6 @@ import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants
public class SolidCollector {
private static final String CONTENT_URL = "/v10/collect/solid";
private static final String DELETE_URL = "/v10/collect/solid/delete";
private static final String UNLOCK_URL = "/v10/collect/solid/unlock";
private static final String ATTR_CIPHER_TEXT = "cipherText";
private static final String ATTR_SIGNATURE = "signature";
private static final String SOLID_UPLOAD_URL = CloudCenter.getInstance().acquireUrlByKind("design.solid");
@ -53,27 +46,22 @@ public class SolidCollector {
}
FineLoggerFactory.getLogger().info("start to get solid content from server...");
try {
String content = requestContent();
if (StringUtils.isNotEmpty(content)) {
String cipherText = JSONFactory.createJSON(JSON.OBJECT, content).optString("data");
if(StringUtils.isNotEmpty(cipherText)){
Map<String, Object> params = new HashMap<>();
params.put(ATTR_CIPHER_TEXT, cipherText);
params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature()));
HttpToolbox.post(SOLID_UPLOAD_URL, params);
String cipherText = requestContent();
if (StringUtils.isNotEmpty(cipherText)) {
Map<String, Object> params = new HashMap<>();
params.put(ATTR_CIPHER_TEXT, cipherText);
params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature()));
HttpToolbox.post(SOLID_UPLOAD_URL, params);
String deleteUrl = WorkContext.getCurrent().getPath() + DELETE_URL;
HttpToolbox.post(deleteUrl, getParams());
}
deleteSolidFile();
}
FineLoggerFactory.getLogger().info("send solid content to cloud center success.");
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage(), e);
} finally {
String unlockUrl = WorkContext.getCurrent().getPath() + UNLOCK_URL;
try {
HttpToolbox.post(unlockUrl, getParams());
} catch (IOException e) {
unlockSolidFile();
} catch (Exception e) {
FineLoggerFactory.getLogger().warn(e.getMessage(), e);
}
}
@ -81,17 +69,42 @@ public class SolidCollector {
/**
* 获取服务端固化文件内容
*
* @return 回传内容
*/
public String requestContent() throws Exception {
Map<String, String> params = new HashMap<String, String>();
params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT));
return HttpToolbox.get(WorkContext.getCurrent().getPath() + CONTENT_URL, params);
private String requestContent() throws Exception {
return WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler<String>() {
@Override
public String callHandler(RPCInvokerExceptionInfo info) {
FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException());
return StringUtils.EMPTY;
}
}).feedBackTask(StringUtils.EMPTY);
}
private Map<String, Object> getParams() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT));
return params;
/**
* 删除服务端固化文件
*/
private void deleteSolidFile() throws Exception {
WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler<Void>() {
@Override
public Void callHandler(RPCInvokerExceptionInfo info) {
FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException());
return null;
}
}).deleteSolidFile();
}
/**
* unlock
*/
private void unlockSolidFile() throws Exception {
WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler<Void>() {
@Override
public Void callHandler(RPCInvokerExceptionInfo info) {
FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException());
return null;
}
}).unlockSolidFile();
}
}

Loading…
Cancel
Save