From 39393f87ce3e649026b5c6d5d4bd5babb902f039 Mon Sep 17 00:00:00 2001 From: Lanlan Date: Fri, 13 Mar 2020 16:36:26 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-27914=20https=E8=BF=9C=E7=A8=8B=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=EF=BC=8C=E6=B2=A1=E6=9C=89=E8=A7=A6=E5=8F=91=E5=9B=BA?= =?UTF-8?q?=E5=8C=96=E5=9F=8B=E7=82=B9=E5=9B=9E=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../messagecollect/solid/SolidCollector.java | 77 +++++++++++-------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java index 68cc882a92..d090b9e8f1 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java +++ b/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 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 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 params = new HashMap(); - 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() { + @Override + public String callHandler(RPCInvokerExceptionInfo info) { + FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException()); + return StringUtils.EMPTY; + } + }).feedBackTask(StringUtils.EMPTY); } - private Map getParams() { - Map params = new HashMap(); - params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT)); - return params; + /** + * 删除服务端固化文件 + */ + private void deleteSolidFile() throws Exception { + WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler() { + @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() { + @Override + public Void callHandler(RPCInvokerExceptionInfo info) { + FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException()); + return null; + } + }).unlockSolidFile(); } }