diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index c00f8bb44f..3d23b31621 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -445,14 +445,13 @@ public class HistoryTemplateListCache implements CallbackEvent { int size = historyList.size(); for (int i = 0; i < size; i++) { JTemplate template = historyList.get(i); + // 判断刷新逻辑比较耗时,且可能出现插件安装后误判导致不刷新 + // 插件安装/启用场景比较少,因此插件安装/启用后每次均进行刷新 FILE file = template.getEditingFILE(); - boolean needReload = context == null || needReloadTemplate(context, template); - if (needReload) { - FILE stashFile = template.templateToStashFile(); - if (stashFile != null) { - FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName()); - template.refreshResource(stashFile); - } + FILE stashFile = template.templateToStashFile(); + if (stashFile != null) { + FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName()); + template.refreshResource(stashFile); } } FineLoggerFactory.getLogger().info("Plugin env change reload all template ended"); @@ -474,28 +473,6 @@ public class HistoryTemplateListCache implements CallbackEvent { _reloadAllEditingTemplate(null); } - private boolean needReloadTemplate(PluginContext context, JTemplate template) { - BaseBook baseBook = template.getTarget(); - if (baseBook != null) { - String name = template.getEditingFILE().getName(); - String pluginId = context.getID(); - long start = System.currentTimeMillis(); - Set set = ClassHelper.getClassLoadersByFilter(baseBook, ClassFilter.getInstance()); - FineLoggerFactory.getLogger().info("{} find plugin classloader spend: {} ms", name, (System.currentTimeMillis() - start)); - if (set != null) { - for (ClassLoader classLoader : set) { - if (ComparatorUtils.equals(pluginId, PluginManager.detectLeakingPlugin(classLoader))) { - return true; - } - } - } else { - // set为null说明 检测classloader 这里返回true直接刷新 兜底行为 - return true; - } - } - return false; - } - public void replaceCurrentEditingTemplate(JTemplate jt) { int index = contains(this.editingTemplate); this.editingTemplate = jt; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineCloudConstants.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineCloudConstants.java new file mode 100644 index 0000000000..537984470c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineCloudConstants.java @@ -0,0 +1,191 @@ +package com.fr.design.mainframe.alphafine; + +import com.fr.design.i18n.Toolkit; +import com.fr.general.CloudCenter; +import com.fr.json.JSONArray; + +import java.util.HashMap; +import java.util.Map; + +/** + * 需要从云端获取的常量单独放一起 + * 每次获取的时候都去加载一次 + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/28 + */ +public class AlphaFineCloudConstants { + + + private static final String PLUGIN_SEARCH_API = "plugin.searchAPI"; + private static final String AF_PLUGIN_INFO = "af.pluginInfo"; + private static final String AF_REUSE_INFO = "af.reuseInfo"; + private static final String AF_DOC_VIEW = "af.doc_view"; + private static final String AF_DOC_SEARCH = "af.doc_search"; + private static final String AF_DOC_INFO = "af.doc_info"; + private static final String AF_PLUGIN_IMAGE = "af.plugin_image"; + private static final String AF_RECORD = "af.record"; + private static final String AF_CLOUD_SEARCH = "af.cloud_search"; + private static final String AF_SIMILAR_SEARCH = "af.similar_search"; + private static final String AF_ADVICE_SEARCH = "af.advice_search"; + private static final String AF_HOT_SEARCH = "af.hot_search"; + private static final String AF_GO_FORUM = "af.go_fourm"; + private static final String AF_GO_WEB = "af.go_web"; + private static final String AF_PREVIEW = "af.preview"; + private static final String AF_CID_NEW = "af.cid.new"; + private static final String AF_CID_USER_GROUP_INFO = "af.cid.user.group.info"; + private static final String AF_HELP_QUICK_START = "af.help.quick.start"; + private static final String AF_HELP_REPORT_LEARNING_PATH = "af.help.report.learning.path"; + private static final String AF_HELP_PARAM_LEARNING_PATH = "af.help.param.learning.path"; + private static final String AF_HELP_FILL_LEARNING_PATH = "af.help.fill.learning.path"; + private static final String AF_HELP_API_SUMMARY = "af.help.api.summary"; + private static final String AF_HELP_MONTHLY_DOCUMENT = "af.help.monthly.document"; + private static final String AF_RECOMMEND = "af.recommend"; + + private static final String LINK_NAME = "name"; + private static final String LINK_URL = "link"; + + /** + * 插件搜索api + */ + public static String getPluginSearchUrl() { + return CloudCenter.getInstance().acquireUrlByKind(PLUGIN_SEARCH_API); + } + + /** + * 插件信息api + */ + public static String getPluginUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_PLUGIN_INFO); + } + + /** + * 获取组件信息api + */ + public static String getReuseUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_REUSE_INFO); + } + + /** + * 获取帮助文档url + */ + public static String getDocumentDocUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_VIEW); + } + + /** + * 获取文档搜索api + */ + public static String getDocumentSearchUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_SEARCH); + } + + /** + * 文档信息api + */ + public static String getDocumentInformationUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_INFO); + } + + /** + * 插件图标api + */ + public static String getPluginImageUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_PLUGIN_IMAGE); + } + + /** + * 获取云端接口,用于上传alphafine搜索记录 + */ + public static String getCloudServerUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_RECORD); + } + + /** + * 获取搜索api,输入搜索词,返回fr的相关功能 + */ + public static String getSearchApi() { + return CloudCenter.getInstance().acquireUrlByKind(AF_CLOUD_SEARCH); + } + + /** + * 获取模糊搜索api前缀,输入搜索词,返回alphaFine相关内容,插件,文档,功能等 + */ + public static String getSimilarSearchUrlPrefix() { + return CloudCenter.getInstance().acquireUrlByKind(AF_SIMILAR_SEARCH); + } + + /** + * 补全建议搜索结果 api,与AF_SIMILAR_SEARCH接口类似,但是返回的信息更全 + */ + public static String getComplementAdviceSearchUrlPrefix() { + return CloudCenter.getInstance().acquireUrlByKind(AF_ADVICE_SEARCH); + } + + /** + * 获取热门问题 + */ + public static String getAlphaHotSearch() { + return CloudCenter.getInstance().acquireUrlByKind(AF_HOT_SEARCH); + } + + /** + * 跳转论坛api + */ + public static String getAlphaGoToForum() { + return CloudCenter.getInstance().acquireUrlByKind(AF_GO_FORUM); + } + + /** + * 推荐搜索api,输入搜索词,返回猜你想搜的内容(html格式) + */ + public static String getAlphaGoToWeb() { + return CloudCenter.getInstance().acquireUrlByKind(AF_GO_WEB); + } + + /** + * 帆软智能客服页面url + */ + public static String getAlphaPreview() { + return CloudCenter.getInstance().acquireUrlByKind(AF_PREVIEW); + } + + /** + * cid系统的产品动态api + */ + public static String getAlphaCid() { + return CloudCenter.getInstance().acquireUrlByKind(AF_CID_NEW); + } + + /** + * cid系统的用户组信息api + */ + public static String getAlphaCidUserGroupInfo() { + return CloudCenter.getInstance().acquireUrlByKind(AF_CID_USER_GROUP_INFO); + } + + /** + * 获取默认推荐的帮助文档 + */ + public static String getAlphaHelpRecommend() { + String[][] links = new String[][]{ + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Quick_Start"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_QUICK_START)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Report_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_REPORT_LEARNING_PATH)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Parameter_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_PARAM_LEARNING_PATH)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Fill_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_FILL_LEARNING_PATH)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Api_Summary"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_API_SUMMARY)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Monthly_Document"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_MONTHLY_DOCUMENT)} + }; + JSONArray jsonArray = new JSONArray(); + for (String[] link : links) { + Map map = new HashMap<>(); + map.put(LINK_NAME, link[0]); + map.put(LINK_URL, link[1]); + jsonArray.put(map); + } + + return CloudCenter.getInstance().acquireUrlByKind(AF_RECOMMEND, jsonArray.toString()); + } +} + diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java index 935d2d0e35..0fffe30b2d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java @@ -4,7 +4,6 @@ import com.fr.base.extension.FileExtension; import com.fr.base.svg.IconUtils; import com.fr.design.i18n.Toolkit; import com.fr.design.utils.DesignUtils; -import com.fr.general.CloudCenter; import com.fr.general.IOUtils; import javax.swing.Icon; @@ -113,25 +112,6 @@ public class AlphaFineConstants { public static final String ALPHA_HOT_IMAGE_NAME = "alphafine_hot"; - public static final String PLUGIN_SEARCH_URL = CloudCenter.getInstance().acquireUrlByKind("plugin.searchAPI"); - - public static final String PLUGIN_URL = CloudCenter.getInstance().acquireUrlByKind("af.pluginInfo"); - - public static final String REUSE_URL = CloudCenter.getInstance().acquireUrlByKind("af.reuseInfo"); - - - public static final String DOCUMENT_DOC_URL = CloudCenter.getInstance().acquireUrlByKind("af.doc_view"); - - public static final String DOCUMENT_SEARCH_URL = CloudCenter.getInstance().acquireUrlByKind("af.doc_search"); - - public static final String DOCUMENT_INFORMATION_URL = CloudCenter.getInstance().acquireUrlByKind("af.doc_info"); - - public static final String PLUGIN_IMAGE_URL = CloudCenter.getInstance().acquireUrlByKind("af.plugin_image"); - - public static final String CLOUD_SERVER_URL = CloudCenter.getInstance().acquireUrlByKind("af.record"); - - public static final String SEARCH_API = CloudCenter.getInstance().acquireUrlByKind("af.cloud_search"); - public static final String SPECIAL_CHARACTER_REGEX = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】';:”“’。,、?]"; public static final String BOTTOM_REGEX_FIRST = "
([\\s\\S]*?)class=\"jiaoyes\">YES
"; @@ -144,36 +124,8 @@ public class AlphaFineConstants { public static final String ALPHA_ROBOT_SEARCH_TOKEN = "K8dl0Np6l0gs"; - public static final String SIMILAR_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.similar_search"); - - public static final String COMPLEMENT_ADVICE_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.advice_search"); - - public static final String ALPHA_HOT_SEARCH = CloudCenter.getInstance().acquireUrlByKind("af.hot_search"); - - public static final String ALPHA_GO_TO_FORUM = CloudCenter.getInstance().acquireUrlByKind("af.go_fourm"); - - public static final String ALPHA_GO_TO_WEB = CloudCenter.getInstance().acquireUrlByKind("af.go_web"); - - public static final String ALPHA_PREVIEW = CloudCenter.getInstance().acquireUrlByKind("af.preview"); - - public static final String ALPHA_CID = CloudCenter.getInstance().acquireUrlByKind("af.cid.new"); - - public static final String ALPHA_CID_USER_GROUP_INFO = CloudCenter.getInstance().acquireUrlByKind("af.cid.user.group.info"); - public static final String SEARCH_BY_ID = "?id="; - private static final String QUICK_START_URL = CloudCenter.getInstance().acquireUrlByKind("af.help.quick.start"); - private static final String REPORT_LEARNING_PATH = CloudCenter.getInstance().acquireUrlByKind("af.help.report.learning.path"); - private static final String PARAMETER_LEARNING_PATH = CloudCenter.getInstance().acquireUrlByKind("af.help.param.learning.path"); - private static final String FILL_LEARNING_PATH = CloudCenter.getInstance().acquireUrlByKind("af.help.fill.learning.path"); - private static final String API_SUMMARY = CloudCenter.getInstance().acquireUrlByKind("af.help.api.summary"); - private static final String MONTHLY_DOCUMENT = CloudCenter.getInstance().acquireUrlByKind("af.help.monthly.document"); - - - private static final String DEFAULT_RECOMMEND = "[ { \"name\":\"快速入门指南\", \"link\":\"" + QUICK_START_URL + "\" }, { \"name\":\"报表应用学习路径\", \"link\":\"" + REPORT_LEARNING_PATH + "\" }, { \"name\":\"参数应用学习路径\", \"link\":\"" + PARAMETER_LEARNING_PATH + "\" }, { \"name\":\"填报学习路径\", \"link\":\"" + FILL_LEARNING_PATH + "\" }, { \"name\":\"API接口汇总\", \"link\":\"" + API_SUMMARY + "\" }, { \"name\":\"文档月刊\", \"link\":\"" + MONTHLY_DOCUMENT + "\" } ]"; - - public static final String ALPHA_HELP_RECOMMEND = CloudCenter.getInstance().acquireUrlByKind("af.recommend", DEFAULT_RECOMMEND); - public static final String JAVASCRIPT_PREFIX = "javascript:SendJava"; public static final String CHINESE_CHARACTERS = "[\\u4e00-\\u9fa5]"; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java index 503a4f413d..800c3f71d5 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.alphafine.cell.model; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.json.JSONException; import com.fr.json.JSONObject; @@ -48,7 +48,7 @@ public class BottomModel extends AlphaCellModel { @Override public void doAction() { try { - Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_GO_TO_FORUM)); + Desktop.getDesktop().browse(new URI(AlphaFineCloudConstants.getAlphaGoToForum())); } catch (IOException | URISyntaxException e) { FineLoggerFactory.getLogger().error(e.getMessage()); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java index 7456daffce..a61f5d9579 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/DocumentModel.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.alphafine.cell.model; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; @@ -26,8 +26,8 @@ public class DocumentModel extends AlphaCellModel { public DocumentModel(String name, String content, int documentId) { super(name, content, CellType.DOCUMENT); this.documentId = documentId; - this.informationUrl = AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentId; - this.documentUrl = AlphaFineConstants.DOCUMENT_DOC_URL + documentId + ".html"; + this.informationUrl = AlphaFineCloudConstants.getDocumentInformationUrl() + documentId; + this.documentUrl = AlphaFineCloudConstants.getDocumentDocUrl() + documentId + ".html"; } public DocumentModel(String name, String content, int documentId, int searchCount) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java index 570538cad1..84ee2e30f9 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/PluginModel.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.cell.model; import com.fr.design.extra.WebViewDlgHelper; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.json.JSONObject; import com.fr.stable.StringUtils; @@ -36,9 +36,9 @@ public class PluginModel extends AlphaCellModel { this.price = price; this.pluginId = pluginId; if (getType() == CellType.PLUGIN) { - this.informationUrl = AlphaFineConstants.PLUGIN_URL + id; + this.informationUrl = AlphaFineCloudConstants.getPluginUrl() + id; } else { - this.informationUrl = AlphaFineConstants.REUSE_URL + id; + this.informationUrl = AlphaFineCloudConstants.getReuseUrl() + id; } } @@ -102,7 +102,15 @@ public class PluginModel extends AlphaCellModel { if (StringUtils.isBlank(this.pluginId) || !WorkContext.getCurrent().isLocal()) { return; } - WebViewDlgHelper.createPluginDialog(getName()); + openPluginStore(getName()); + } + + /** + * 打开插件商城 + * 方便埋点 + */ + private void openPluginStore(String name) { + WebViewDlgHelper.createPluginDialog(name); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java index d504b9d859..80f610f4eb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.alphafine.cell.model; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.general.http.HttpToolbox; @@ -46,7 +47,7 @@ public class RobotModel extends AlphaCellModel { public static String getContent(String titleStr) { String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + titleStr); - String url = AlphaFineConstants.ALPHA_GO_TO_WEB + titleStr + "&token=" + token; + String url = AlphaFineCloudConstants.getAlphaGoToWeb() + titleStr + "&token=" + token; try { String result = HttpToolbox.get(url); @@ -83,7 +84,7 @@ public class RobotModel extends AlphaCellModel { @Override public void doAction() { try { - Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + URLEncoder.encode(super.getName(), EncodeConstants.ENCODING_UTF_8))); + Desktop.getDesktop().browse(new URI(AlphaFineCloudConstants.getAlphaPreview() + URLEncoder.encode(super.getName(), EncodeConstants.ENCODING_UTF_8))); } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage()); } catch (URISyntaxException e) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 4a55d973f0..e1b4dcbd19 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -7,6 +7,7 @@ import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; @@ -968,7 +969,7 @@ public class AlphaFineDialog extends UIDialog { String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); para.put("token", CodeUtils.md5Encode(date, StringUtils.EMPTY, "MD5")); para.put("content", object.toString()); - HttpClient httpClient = new HttpClient(AlphaFineConstants.CLOUD_SERVER_URL, para, true); + HttpClient httpClient = new HttpClient(AlphaFineCloudConstants.getCloudServerUrl(), para, true); httpClient.asGet(); if (!httpClient.isServerAlive()) { FineLoggerFactory.getLogger().error("Failed to sent data to server!"); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java index 66a300280c..5d984dca39 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java @@ -920,11 +920,12 @@ public class AlphaFineFrame extends JFrame { if (StringUtils.isEmpty(text)) { return; } - searchLoadingPane = new SearchLoadingPane(); + initSearchLoadingPane(); SearchTextBean searchTextBean = new SearchTextBean(text, segmentationResult); this.productNewsSearchWorkerManager.doSearch(searchTextBean); this.documentWorkerManager.doSearch(searchTextBean); this.pluginSearchWorkerManager.doSearch(searchTextBean); + this.templateResourceSearchWorkerManager.doSearch(searchTextBean); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java index 961d490e58..b793cf52c9 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java @@ -3,7 +3,7 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.DesignUtils; @@ -98,7 +98,7 @@ public class HelpDocumentNoResultPane extends JPanel { private Map generateMap() { - JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, AlphaFineConstants.ALPHA_HELP_RECOMMEND); + JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, AlphaFineCloudConstants.getAlphaHelpRecommend()); Map linkMap = new LinkedHashMap<>(); for (int i = 0, len = jsonArray.size(); i < len; i++) { JSONObject json = jsonArray.getJSONObject(i); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java index 3dc4a44b2a..ebfdd99c4c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.dialog.link.MessageWithLink; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.DesignUtils; @@ -32,7 +33,7 @@ public class NoResultWithLinkPane extends NoResultPane { String[] para1 = title.split(TAG_A_START); String[] para2 = para1[1].split(TAG_A_END); - MessageWithLink messageWithLink = new MessageWithLink(para1[0], para2[0], AlphaFineConstants.ALPHA_GO_TO_FORUM, para2[1], Color.WHITE, DesignUtils.getDefaultGUIFont().applySize(14), AlphaFineConstants.MEDIUM_GRAY) { + MessageWithLink messageWithLink = new MessageWithLink(para1[0], para2[0], AlphaFineCloudConstants.getAlphaGoToForum(), para2[1], Color.WHITE, DesignUtils.getDefaultGUIFont().applySize(14), AlphaFineConstants.MEDIUM_GRAY) { @Override protected void initListener(String link) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java index f6a9f70767..6732e2205e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextarea.UITextArea; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.RobotModel; @@ -60,7 +61,7 @@ public class RobotPreviewPane extends JPanel { .replaceAll("\\('", StringUtils.EMPTY) .replaceAll("'\\)", StringUtils.EMPTY); try { - Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + URLEncoder.encode(s, EncodeConstants.ENCODING_UTF_8))); + Desktop.getDesktop().browse(new URI(AlphaFineCloudConstants.getAlphaPreview() + URLEncoder.encode(s, EncodeConstants.ENCODING_UTF_8))); } catch (IOException | URISyntaxException e1) { FineLoggerFactory.getLogger().error(e1.getMessage()); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java index 9aff9f92b9..c62f98fce7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.alphafine.search.helper; +import com.fr.base.login.ClientHelper; import com.fr.design.DesignerEnvManager; import com.fr.design.extra.PluginConstants; import com.fr.design.mainframe.alphafine.download.FineMarketDownloadManager; @@ -12,6 +13,7 @@ import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.market.key.FineMarketPublicKeyHolder; import com.fr.security.SecurityToolbox; +import com.fr.stable.EncodeConstants; import com.fr.stable.StableUtils; import com.fr.third.org.apache.http.HttpEntity; import com.fr.third.org.apache.http.HttpException; @@ -56,6 +58,7 @@ public class FineMarketClientHelper { private static final String CERTIFICATE_PUBLIC_KEY = FineMarketPublicKeyHolder.getInstance().getDefaultKey(); public static final String FINE_MARKET_TEMPLATE_INFO = CloudCenter.getInstance().acquireUrlByKind("market.template.info"); public static final String FINE_MARKET_TEMPLATE_URL = CloudCenter.getInstance().acquireUrlByKind("market.template.url"); + public static final String VERSION = "&version=10.0"; public static final String FILE_DOWNLOAD = "file/download/"; public static final String PACKAGE_DOWNLOAD = "package/download/"; public static final String TEMPLATES_PARENT_PACKAGE = "parent/"; @@ -278,8 +281,12 @@ public class FineMarketClientHelper { } } + + /** + * 通过名字搜索模板信息 + */ public @Nullable JSONArray getTemplateInfoByName(String name) throws IOException { - String url = FINE_MARKET_TEMPLATE_INFO + NAME_SEARCH + name; + String url = FINE_MARKET_TEMPLATE_INFO + NAME_SEARCH + ClientHelper.urlEncode(name, EncodeConstants.ENCODING_UTF_8) + VERSION; String jsonString = HttpToolbox.get(url); JSONObject jsonObject = new JSONObject(jsonString); String responseState = (String) jsonObject.get(RESPONSE_STATE); @@ -334,7 +341,7 @@ public class FineMarketClientHelper { * */ private void initTags() throws IOException { tags = new HashMap<>(); - String url = FINE_MARKET_TEMPLATE_INFO + TEMPLATES_TAGS; + String url = FINE_MARKET_TEMPLATE_INFO + ClientHelper.urlEncode(TEMPLATES_TAGS, EncodeConstants.ENCODING_UTF_8); String jsonString = HttpToolbox.get(url); JSONObject jsonObject = new JSONObject(jsonString); String responseState = (String) jsonObject.get(RESPONSE_STATE); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java index aa3690cb68..55c153f364 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java @@ -1,14 +1,18 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; +import com.fr.base.login.ClientHelper; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.general.http.HttpToolbox; import com.fr.log.FineLoggerFactory; +import com.fr.stable.EncodeConstants; import com.fr.third.org.apache.commons.codec.digest.DigestUtils; + /** * @author alex.sung created on 2018/7/23. */ @@ -39,8 +43,9 @@ public class ComplementAdviceManager { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { SearchResult searchResult = new SearchResult(); for (int j = 0; j < searchText.length; j++) { - String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]); - String url = AlphaFineConstants.COMPLEMENT_ADVICE_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token; + String msg = ClientHelper.urlEncode(searchText[j], EncodeConstants.ENCODING_UTF_8); + String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + msg); + String url = AlphaFineCloudConstants.getComplementAdviceSearchUrlPrefix() + "msg=" + msg + "&token=" + ClientHelper.urlEncode(token, EncodeConstants.ENCODING_UTF_8); try { String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java index 3ea1f2db2f..9ef4c7c3df 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; @@ -69,7 +70,7 @@ public class DocumentSearchManager implements AlphaFineSearchProvider { searchResult = new SearchResult(); for (int j = 0; j < searchText.length; j++) { long start = System.currentTimeMillis(); - String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText[j]; + String url = AlphaFineCloudConstants.getDocumentSearchUrl() + searchText[j]; try { String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java index 749a0a611f..0e29a44c63 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.RobotModel; @@ -11,7 +11,6 @@ import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONFactory; import com.fr.json.JSONObject; -import com.fr.json.JSONUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; @@ -76,7 +75,7 @@ public class HotIssuesManager { public String[][] getHotIssues() { try { - String result = HttpToolbox.get(AlphaFineConstants.ALPHA_HOT_SEARCH); + String result = HttpToolbox.get(AlphaFineCloudConstants.getAlphaHotSearch()); JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, result); if(jsonArray != null){ for (int i = 0; i < HOT_ITEM_NUM; i++) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 56f7078b41..ea4f359370 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; @@ -15,7 +16,6 @@ import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.basic.version.Version; -import com.fr.plugin.basic.version.VersionIntervalType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; @@ -60,7 +60,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { int searchCount = object.optInt("searchCount"); String imageUrl = null; try { - imageUrl = isFromCloud ? AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8") : object.optString("pic"); + imageUrl = isFromCloud ? AlphaFineCloudConstants.getPluginImageUrl() + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineCloudConstants.getPluginImageUrl().length()), "utf8") : object.optString("pic"); } catch (UnsupportedEncodingException e) { FineLoggerFactory.getLogger().error("plugin icon error: " + e.getMessage()); } @@ -112,7 +112,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { for (int j = 0; j < searchText.length; j++) { try { String encodedKey = URLEncoder.encode(searchText[j], EncodeConstants.ENCODING_UTF_8); - String url = AlphaFineConstants.PLUGIN_SEARCH_URL + "?keyword=" + encodedKey; + String url = AlphaFineCloudConstants.getPluginSearchUrl() + "?keyword=" + encodedKey; String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); JSONObject jsonObject = new JSONObject(result); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java index 97b705fc10..1ee765c5a6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.model.ProductNews; @@ -81,7 +82,7 @@ public class ProductNewsSearchManager { public List getProductNewsList() throws Exception { productNewsList = new ArrayList<>(); idSet = new HashSet<>(); - String jsonStr = HttpToolbox.get(AlphaFineConstants.ALPHA_CID); + String jsonStr = HttpToolbox.get(AlphaFineCloudConstants.getAlphaCid()); AlphaFineHelper.checkCancel(); JSONObject cidJSON = JSONFactory.createJSON(JSON.OBJECT, jsonStr); JSONArray jsonArray = cidJSON.getJSONArray("data"); @@ -149,7 +150,7 @@ public class ProductNewsSearchManager { * 根据用户组id,查询用户组信息(改用户组中的所有设计器id) * */ private Set searchUserGroupInfo(String userGroupId) { - String url = AlphaFineConstants.ALPHA_CID_USER_GROUP_INFO + AlphaFineConstants.SEARCH_BY_ID + userGroupId; + String url = AlphaFineCloudConstants.getAlphaCidUserGroupInfo() + AlphaFineConstants.SEARCH_BY_ID + userGroupId; Set idSet = new HashSet<>(); try { String jsonStr = HttpToolbox.get(url); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java index ce0d987767..11dc5424f9 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; @@ -59,7 +60,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { for (int j = 0; j < searchText.length; j++) { searchText[j] = searchText[j].replaceAll(StringUtils.BLANK, StringUtils.EMPTY); try { - String url = AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText[j]); + String url = AlphaFineCloudConstants.getSearchApi() + CodeUtils.cjkEncode(searchText[j]); String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); JSONObject jsonObject = new JSONObject(result); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java index f353573b49..0689d24ea8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java @@ -1,6 +1,8 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; +import com.fr.base.login.ClientHelper; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; @@ -12,6 +14,7 @@ import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; +import com.fr.stable.EncodeConstants; import com.fr.third.org.apache.commons.codec.digest.DigestUtils; /** @@ -46,8 +49,9 @@ public class SimilarSearchManager implements AlphaFineSearchProvider { } SearchResult allModelList = new SearchResult(); for (int j = 0; j < searchText.length; j++) { - String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]); - String url = AlphaFineConstants.SIMILAR_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token; + String msg = ClientHelper.urlEncode(searchText[j], EncodeConstants.ENCODING_UTF_8); + String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + msg); + String url = AlphaFineCloudConstants.getSimilarSearchUrlPrefix() + "msg=" + msg + "&token=" + ClientHelper.urlEncode(token, EncodeConstants.ENCODING_UTF_8); try { String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java index 5d32b85bbd..8de69db5c0 100644 --- a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.alphafine.cell.model; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.json.JSONException; import com.fr.json.JSONObject; @@ -14,8 +14,8 @@ public class ModelTest { Assert.assertEquals("name", documentModel.getName()); Assert.assertEquals("content", documentModel.getContent()); Assert.assertEquals(1, documentModel.getDocumentId()); - Assert.assertEquals(AlphaFineConstants.DOCUMENT_DOC_URL + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl()); - Assert.assertEquals(AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentModel.getDocumentId(), documentModel.getInformationUrl()); + Assert.assertEquals(AlphaFineCloudConstants.getDocumentDocUrl() + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl()); + Assert.assertEquals(AlphaFineCloudConstants.getDocumentInformationUrl() + documentModel.getDocumentId(), documentModel.getInformationUrl()); Assert.assertEquals(documentModel.getStoreInformation(), documentModel.getInformationUrl()); Assert.assertEquals(CellType.DOCUMENT, documentModel.getType()); Assert.assertEquals(true, documentModel.hasAction());