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