forked from fanruan/design
Browse Source
* commit '2f9a97e2d80dc78142bb079c14b058b11a4df77b': 屏蔽回传代码 补充日志 fix 调试输出 update REPORT-21871 批量添加单元格组 合并场景 REPORT-21584 设置参数界面的设计宽度到100,所有控件还是可以正常显示 update REPORT-20769 模版数据集数据库模糊查询交互产品改进 && REPORT-14560 同步到10.0 REPORT-19945 设计器启动信息收集 REPORT-19945 设计器启动信息收集 客户端携带鉴权 回传 设计器回传 隐私策略调整 云端运维固化数据存储 REPORT-20901 10.0从前往后删掉打开的tab界面 没有改变及选中中间tab 删除不完整 && REPORT-20941 填报属性智能添加单元格组单击场景 REPORT-20303 FR中点击插件管理报错闪退 无 REPORT-16985 屏蔽新插件管理器开启选项final/10.0
Kara
5 years ago
13 changed files with 436 additions and 109 deletions
@ -0,0 +1,92 @@
|
||||
package com.fr.design.mainframe.messagecollect; |
||||
|
||||
import com.fr.concurrent.NamedThreadFactory; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.mainframe.SiteCenterToken; |
||||
import com.fr.event.Event; |
||||
import com.fr.event.EventDispatcher; |
||||
import com.fr.event.Listener; |
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.http.HttpToolbox; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.module.ModuleContext; |
||||
import com.fr.module.engine.FineModule; |
||||
import com.fr.runtime.FineRuntime; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
|
||||
/** |
||||
* 启动信息收集 |
||||
* |
||||
* @author vito |
||||
* @version 10.0 |
||||
* Created by vito on 2019/9/4 |
||||
*/ |
||||
public class StartupMessageCollector { |
||||
|
||||
private static final String XML_STARTUP_TIME = "t"; |
||||
private static final String XML_STARTUP_LOG = "startupLog"; |
||||
private static final String XML_STARTUP_Memory = "designerMemory"; |
||||
private static final String XML_STARTUP_COST = "cost"; |
||||
private static final String XML_UUID = "UUID"; |
||||
private static final String STARTUP_URL_KEY = "user.info.v10.startup"; |
||||
private static final String LOG_TYPE = "single"; |
||||
private static final int BYTE_TO_MB = 1024 * 1024; |
||||
|
||||
public static final StartupMessageCollector INSTANCE = new StartupMessageCollector(); |
||||
|
||||
private StartupMessageCollector() { |
||||
} |
||||
|
||||
public static StartupMessageCollector getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
public void recordStartupLog() { |
||||
EventDispatcher.listen(FineRuntime.ApplicationEvent.AFTER_START, new Listener<Long>() { |
||||
|
||||
@Override |
||||
public void on(Event event, Long param) { |
||||
final String url = CloudCenter.getInstance().acquireUrlByKind(STARTUP_URL_KEY); |
||||
if (StringUtils.isEmpty(url)) { |
||||
return; |
||||
} |
||||
ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("StartupMessageCollector")); |
||||
es.submit(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
FineModule root = (FineModule) ModuleContext.getRoot().getRoot(); |
||||
JSONObject profile = root.profile(); |
||||
JSONObject json = JSONObject.create() |
||||
.put(XML_UUID, DesignerEnvManager.getEnvManager().getUUID()) |
||||
.put(XML_STARTUP_TIME, FineRuntime.getAppStartTime() + FineRuntime.getStartingTime()) |
||||
.put(XML_STARTUP_COST, FineRuntime.getStartingTime()) |
||||
.put(XML_STARTUP_LOG, profile) |
||||
.put(XML_STARTUP_Memory, Runtime.getRuntime().totalMemory() / BYTE_TO_MB); |
||||
sendInfo(json, url + LOG_TYPE); |
||||
} |
||||
}); |
||||
es.shutdown(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private boolean sendInfo(JSONObject content, String url) { |
||||
boolean success = false; |
||||
try { |
||||
HashMap<String, Object> para = new HashMap<>(); |
||||
para.put("token", SiteCenterToken.generateToken()); |
||||
para.put("content", content); |
||||
String res = HttpToolbox.post(url, para); |
||||
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return success; |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.design.mainframe.messagecollect.solid; |
||||
|
||||
/** |
||||
* Created by alex sung on 2019/9/5. |
||||
*/ |
||||
public class SolidCollectConstants { |
||||
private SolidCollectConstants(){} |
||||
|
||||
/** |
||||
* 客户端请求subject |
||||
*/ |
||||
public static final String REQUEST_SUBJECT = "solid"; |
||||
|
||||
/** |
||||
* 客户端请求超时鉴权时间,默认1h失效 |
||||
*/ |
||||
public static final long TIME_OUT = 60 * 60 * 1000; |
||||
} |
@ -0,0 +1,97 @@
|
||||
package com.fr.design.mainframe.messagecollect.solid; |
||||
|
||||
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.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. |
||||
*/ |
||||
|
||||
|
||||
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"); |
||||
|
||||
private static volatile SolidCollector instance; |
||||
|
||||
public static SolidCollector getInstance() { |
||||
if (instance == null) { |
||||
synchronized (SolidCollector.class) { |
||||
if (instance == null) { |
||||
instance = new SolidCollector(); |
||||
} |
||||
} |
||||
} |
||||
return instance; |
||||
} |
||||
|
||||
/** |
||||
* 回传文件给云中心,并删除服务端本地文件 |
||||
*/ |
||||
public void sendToCloudCenterAndDeleteFile() { |
||||
if (WorkContext.getCurrent().isLocal()) { |
||||
return; |
||||
} |
||||
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 deleteUrl = WorkContext.getCurrent().getPath() + DELETE_URL; |
||||
HttpToolbox.post(deleteUrl, getParams()); |
||||
} |
||||
} |
||||
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) { |
||||
FineLoggerFactory.getLogger().warn(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取服务端固化文件内容 |
||||
* @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 Map<String, Object> getParams() { |
||||
Map<String, Object> params = new HashMap<String, Object>(); |
||||
params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT)); |
||||
return params; |
||||
} |
||||
} |
Loading…
Reference in new issue