forked from fanruan/design
Browse Source
* commit '2edd2ae67002b8754ff9a6709bcb1846e9769405': (21 commits) 换一个扩展性更好的方式 rt REPORT-19557 ToolbarItemProvider接口需要支持表单报表块 取消屏蔽 屏蔽回传代码 补充日志 fix 调试输出 update REPORT-21871 批量添加单元格组 合并场景 REPORT-21584 设置参数界面的设计宽度到100,所有控件还是可以正常显示 update REPORT-20769 模版数据集数据库模糊查询交互产品改进 && REPORT-14560 同步到10.0 REPORT-19945 设计器启动信息收集 REPORT-19945 设计器启动信息收集 客户端携带鉴权 回传 设计器回传 隐私策略调整 云端运维固化数据存储 无 ...bugfix/10.0
16 changed files with 552 additions and 115 deletions
@ -0,0 +1,70 @@ |
|||||||
|
package com.fr.design; |
||||||
|
|
||||||
|
import com.fr.config.dao.DaoContext; |
||||||
|
import com.fr.config.dao.impl.LocalClassHelperDao; |
||||||
|
import com.fr.config.dao.impl.LocalEntityDao; |
||||||
|
import com.fr.config.dao.impl.LocalXmlEntityDao; |
||||||
|
import com.fr.design.fun.ToolbarItemProvider; |
||||||
|
import com.fr.design.gui.core.WidgetOption; |
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.design.mainframe.JVirtualTemplate; |
||||||
|
import com.fr.general.ModuleContext; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.report.restriction.CellCountRestriction; |
||||||
|
import com.fr.report.restriction.ReportRestrictionScene; |
||||||
|
import com.fr.restriction.Restrictions; |
||||||
|
import com.fr.stable.Filter; |
||||||
|
import com.fr.stable.module.Module; |
||||||
|
import junit.framework.TestCase; |
||||||
|
import org.easymock.EasyMock; |
||||||
|
import org.junit.Assert; |
||||||
|
|
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author zack |
||||||
|
* @version 10.0 |
||||||
|
* Created by zack on 2019/9/17 |
||||||
|
*/ |
||||||
|
public class ExtraDesignClassManagerTest extends TestCase { |
||||||
|
@Override |
||||||
|
protected void setUp() throws Exception { |
||||||
|
DaoContext.setEntityDao(new LocalEntityDao()); |
||||||
|
DaoContext.setClassHelperDao(new LocalClassHelperDao()); |
||||||
|
DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); |
||||||
|
ModuleContext.startModule(Module.PAGE_MODULE); |
||||||
|
Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction()); |
||||||
|
} |
||||||
|
|
||||||
|
public void testGetWebOption() { |
||||||
|
try { |
||||||
|
final JTemplate jTemplate = new JVirtualTemplate(null); |
||||||
|
ToolbarItemProvider item = EasyMock.mock(ToolbarItemProvider.class); |
||||||
|
ToolbarItemProvider item1 = EasyMock.mock(ToolbarItemProvider.class); |
||||||
|
EasyMock.expect(item.accept(jTemplate)).andReturn(false).anyTimes(); |
||||||
|
EasyMock.expect(item.classForWidget()).andReturn(null).anyTimes(); |
||||||
|
EasyMock.expect(item.iconPathForWidget()).andReturn("").anyTimes(); |
||||||
|
EasyMock.expect(item.nameForWidget()).andReturn("1").anyTimes(); |
||||||
|
EasyMock.expect(item1.accept(jTemplate)).andReturn(true).anyTimes(); |
||||||
|
EasyMock.expect(item1.classForWidget()).andReturn(null).anyTimes(); |
||||||
|
EasyMock.expect(item1.iconPathForWidget()).andReturn("").anyTimes(); |
||||||
|
EasyMock.expect(item1.nameForWidget()).andReturn("2").anyTimes(); |
||||||
|
EasyMock.replay(item); |
||||||
|
EasyMock.replay(item1); |
||||||
|
|
||||||
|
Set<ToolbarItemProvider> set = new HashSet<>(); |
||||||
|
set.add(item); |
||||||
|
set.add(item1); |
||||||
|
WidgetOption[] widgetOptions = ExtraDesignClassManager.getInstance().getWebWidgetOptions(set, new Filter<ToolbarItemProvider>() { |
||||||
|
@Override |
||||||
|
public boolean accept(ToolbarItemProvider toolbarItemProvider) { |
||||||
|
return toolbarItemProvider.accept(jTemplate); |
||||||
|
} |
||||||
|
}); |
||||||
|
Assert.assertEquals(1, widgetOptions.length); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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