From 8077974e74816321f4badaa78eba7fa2cd259a76 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 6 Nov 2017 13:54:12 +0800 Subject: [PATCH 1/5] =?UTF-8?q?REPORT-5357=20=E6=8F=92=E4=BB=B6=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=B8=AD=E7=9A=84=E4=BB=A3=E7=A0=81=E8=B4=A8=E9=87=8F?= =?UTF-8?q?=EF=BC=88=E5=85=B3=E4=BA=8E=E4=BD=BF=E7=94=A8Executor=E5=92=8C?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=B1=A0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/extra/PluginOperateUtils.java | 148 +++--------------- .../src/com/fr/design/extra/PluginTask.java | 20 ++- .../com/fr/design/extra/PluginWebBridge.java | 42 +++-- .../exe/GetPluginCategoriesExecutor.java | 42 +++++ .../extra/exe/GetPluginFromStoreExecutor.java | 75 +++++++++ .../extra/exe/ReadUpdateOnlineExecutor.java | 51 ++++++ .../extra/exe/SearchOnlineExecutor.java | 59 +++++++ .../extra/exe/getPluginPrefixExecutor.java | 35 +++++ 8 files changed, 328 insertions(+), 144 deletions(-) create mode 100644 designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java create mode 100644 designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java create mode 100644 designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java create mode 100644 designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java create mode 100644 designer_base/src/com/fr/design/extra/exe/getPluginPrefixExecutor.java diff --git a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java index 7fe4101d3f..960212a26f 100644 --- a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java +++ b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java @@ -2,7 +2,13 @@ package com.fr.design.extra; import com.fr.base.ConfigManager; import com.fr.base.FRContext; -import com.fr.design.extra.exe.callback.*; +import com.fr.design.extra.exe.callback.InstallFromDiskCallback; +import com.fr.design.extra.exe.callback.InstallOnlineCallback; +import com.fr.design.extra.exe.callback.JSCallback; +import com.fr.design.extra.exe.callback.ModifyStatusCallback; +import com.fr.design.extra.exe.callback.UninstallPluginCallback; +import com.fr.design.extra.exe.callback.UpdateFromDiskCallback; +import com.fr.design.extra.exe.callback.UpdateOnlineCallback; import com.fr.design.gui.ilable.UILabel; import com.fr.general.FRLogger; import com.fr.general.Inter; @@ -20,7 +26,8 @@ import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import java.io.File; import java.util.List; @@ -81,17 +88,17 @@ public class PluginOperateUtils { } public static void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSCallback jsCallback) { - + SwingUtilities.invokeLater(new Runnable() { - + @Override public void run() { int rv = JOptionPane.showConfirmDialog( - null, - Inter.getLocText("FR-Plugin_Delete_Confirmed"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE + null, + Inter.getLocText("FR-Plugin_Delete_Confirmed"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE ); if (rv == JOptionPane.OK_OPTION) { PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); @@ -101,104 +108,18 @@ public class PluginOperateUtils { }); } - public static void readUpdateOnline(final JSCallback jsCallback) { - - new Thread(new Runnable() { - @Override - public void run() { - try { - List plugins = PluginsReaderFromStore.readPluginsForUpdate(); - JSONArray jsonArray = new JSONArray(); - for (PluginView plugin : plugins) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("pluginid", plugin.getID()); - jsonArray.put(jsonObject); - } - String result = jsonArray.toString(); - jsCallback.execute(result); - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - } - } - }).start(); - - - } - - public static void searchPlugin(final String keyword, final JSCallback jsCallback) { - - new Thread(new Runnable() { - @Override - public void run() { - try { - if (StringUtils.isBlank(keyword)) { - getRecommendPlugins(jsCallback); - return; - } - HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("shop.plugin.store") + "&keyword=" + keyword); - httpClient.asGet(); - String result = httpClient.getResponseText(); - JSONObject jsonObject = new JSONObject(result); - JSONArray jsonArray = jsonObject.getJSONArray("result"); - JSONArray resultJSONArray = PluginUtils.filterPluginsFromVersion(jsonArray); - jsCallback.execute(resultJSONArray.toString()); - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - } - } - }).start(); - - } - - public static void getPluginFromStore(final String category, final String seller, final String fee, final JSCallback jsCallback) { - - new Thread(new Runnable() { - @Override - public void run() { - String plistUrl = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.plist") + "?"; - boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee); - if (getRecommend) { - getRecommendPlugins(jsCallback); - return; - } - - if (StringUtils.isNotBlank(plistUrl)) { - StringBuilder url = new StringBuilder(); - url.append(plistUrl); - dealParams(url, category, seller, fee); - try { - HttpClient httpClient = new HttpClient(url.toString()); - httpClient.asGet(); - String result = httpClient.getResponseText(); - JSONObject resultJSONObject = new JSONObject(result); - JSONArray resultArr = resultJSONObject.getJSONArray("result"); - JSONArray resultJSONArray = PluginUtils.filterPluginsFromVersion(resultArr); - jsCallback.execute(resultJSONArray.toString()); - } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); - } - } else { - String result = PluginConstants.CONNECTION_404; - jsCallback.execute(result); - } - } - - }).start(); - - } - - public static void getRecommendPlugins(JSCallback jsCallback) { + public static String getRecommendPlugins() { String plistUrl = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.feature"); + JSONArray resultArray = JSONArray.create(); try { HttpClient httpClient = new HttpClient(plistUrl.toString()); String result = httpClient.getResponseText(); JSONArray jsonArray = new JSONArray(result); - JSONArray resultJSONArray = PluginUtils.filterPluginsFromVersion(jsonArray); - jsCallback.execute(resultJSONArray.toString()); + resultArray = PluginUtils.filterPluginsFromVersion(jsonArray); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } - + return resultArray.toString(); } public static void dealParams(StringBuilder url, String category, String seller, String fee) { @@ -233,35 +154,6 @@ public class PluginOperateUtils { } } - public static void getPluginCategories(final JSCallback jsCallback) { - - new Thread(new Runnable() { - @Override - public void run() { - String result; - String url = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.category"); - if (url != null) { - HttpClient httpClient = new HttpClient(url); - result = httpClient.getResponseText(); - } else { - result = PluginConstants.CONNECTION_404; - } - jsCallback.execute(result); - } - }).start(); - } - - public static void getPluginPrefix(final JSCallback jsCallback) { - - new Thread(new Runnable() { - @Override - public void run() { - String result = SiteCenter.getInstance().acquireUrlByKind("plugin.url.prefix"); - jsCallback.execute(result); - } - }).start(); - } - public static void getLoginInfo(JSCallback jsCallback, UILabel uiLabel) { String username = ConfigManager.getProviderInstance().getBbsUsername(); if (StringUtils.isEmpty(username)) { diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index e2c87a46e1..78521f4dab 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -9,6 +9,9 @@ import javafx.concurrent.Task; import javafx.scene.web.WebEngine; import netscape.javascript.JSObject; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /** * 插件安装,卸载,更新等任务 * @@ -77,8 +80,23 @@ public class PluginTask extends Task { */ private String trimText(String old) { if (StringUtils.isNotBlank(old)) { - return old.replaceAll("\n", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'"); + String b = filterHtmlTag(old); + return b.replaceAll("\\\\n", "").replaceAll("\\\\t", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'").replaceAll("\\\\\\\\", "\\\\\\\\\\\\"); } return StringUtils.EMPTY; } + + /** + * 进行html标签过滤 + * @param origin 原始字符串 + * @return 处理之后的字符串 + */ + private String filterHtmlTag(String origin) { + String regEx_html = "<[^>]+>"; + Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE); + Matcher m_html = p_html.matcher(origin); + origin = m_html.replaceAll(""); + return origin; + } + } diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 438deb9145..919db379e0 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -5,8 +5,13 @@ import com.fr.base.FRContext; import com.fr.design.RestartHelper; import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.dialog.UIDialog; +import com.fr.design.extra.exe.GetPluginCategoriesExecutor; +import com.fr.design.extra.exe.GetPluginFromStoreExecutor; import com.fr.design.extra.exe.PluginLoginExecutor; +import com.fr.design.extra.exe.ReadUpdateOnlineExecutor; +import com.fr.design.extra.exe.SearchOnlineExecutor; import com.fr.design.extra.exe.callback.JSCallback; +import com.fr.design.extra.exe.getPluginPrefixExecutor; import com.fr.design.gui.ilable.UILabel; import com.fr.general.FRLogger; import com.fr.general.Inter; @@ -23,14 +28,20 @@ import javafx.scene.web.WebEngine; import javafx.stage.FileChooser; import javafx.stage.Stage; import netscape.javascript.JSObject; - -import javax.swing.*; -import java.awt.*; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; +import java.awt.Desktop; import java.io.File; import java.io.IOException; import java.net.URI; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * 开放给Web组件的接口,用于安装,卸载,更新以及更改插件可用状态 @@ -48,6 +59,7 @@ public class PluginWebBridge { private UILabel uiLabel; + private ExecutorService threadPoolExecutor = Executors.newSingleThreadExecutor(); /** * 动作枚举 @@ -222,8 +234,8 @@ public class PluginWebBridge { * 已安装插件检查更新 */ public void readUpdateOnline(final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); - PluginOperateUtils.readUpdateOnline(jsCallback); + Task task = new PluginTask<>(webEngine, callback, new ReadUpdateOnlineExecutor()); + threadPoolExecutor.submit(task); } /** @@ -306,8 +318,8 @@ public class PluginWebBridge { * @param keyword 关键字 */ public void searchPlugin(String keyword, final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); - PluginOperateUtils.searchPlugin(keyword, jsCallback); + Task task = new PluginTask<>(webEngine, callback, new SearchOnlineExecutor(keyword)); + threadPoolExecutor.submit(task); } /** @@ -319,14 +331,14 @@ public class PluginWebBridge { * @param callback 回调函数 */ public void getPluginFromStore(String category, String seller, String fee, final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); - PluginOperateUtils.getPluginFromStore(category, seller, fee, jsCallback); + Task task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(category, seller, fee)); + threadPoolExecutor.submit(task); } public void getPluginPrefix(final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); - PluginOperateUtils.getPluginPrefix(jsCallback); + Task task = new PluginTask<>(webEngine, callback, new getPluginPrefixExecutor()); + threadPoolExecutor.submit(task); } @@ -336,8 +348,8 @@ public class PluginWebBridge { * @param callback 回调函数 */ public void getPluginCategories(final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); - PluginOperateUtils.getPluginCategories(jsCallback); + Task task = new PluginTask<>(webEngine, callback, new GetPluginCategoriesExecutor()); + threadPoolExecutor.submit(task); } /** @@ -502,7 +514,7 @@ public class PluginWebBridge { */ public void defaultLogin(String username, String password, final JSObject callback) { Task task = new PluginTask<>(webEngine, callback, new PluginLoginExecutor(username, password)); - new Thread(task).start(); + threadPoolExecutor.submit(task); } /** diff --git a/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java new file mode 100644 index 0000000000..f517d0b65a --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java @@ -0,0 +1,42 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.PluginConstants; +import com.fr.design.extra.Process; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; + +/** + * Created by vito on 16/5/16. + */ +public class GetPluginCategoriesExecutor implements Executor { + private String result = "[]"; + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return null; + } + + @Override + public void run(Process process) { + String url = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.category"); + if (url != null) { + HttpClient httpClient = new HttpClient(url); + result = httpClient.getResponseText(); + } else { + result = PluginConstants.CONNECTION_404; + } + + } + } + }; + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java new file mode 100644 index 0000000000..123c3ceed3 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java @@ -0,0 +1,75 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.PluginConstants; +import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.PluginUtils; +import com.fr.design.extra.Process; +import com.fr.general.FRLogger; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.stable.StringUtils; + +/** + * Created by vito on 16/4/18. + * 获取插件分类信息 + */ +public class GetPluginFromStoreExecutor implements Executor { + private String result = "[]"; + private String category; + private String seller; + private String fee; + + public GetPluginFromStoreExecutor(String category, String seller, String fee) { + this.category = category; + this.seller = seller; + this.fee = fee; + } + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return StringUtils.EMPTY; + } + + @Override + public void run(Process process) { + String plistUrl = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.plist") + "?"; + boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee); + if (getRecommend) { + result = PluginOperateUtils.getRecommendPlugins(); + return; + } + + if (StringUtils.isNotBlank(plistUrl)) { + StringBuilder url = new StringBuilder(); + url.append(plistUrl); + PluginOperateUtils.dealParams(url, category, seller, fee); + try { + HttpClient httpClient = new HttpClient(url.toString()); + httpClient.asGet(); + String responseText = httpClient.getResponseText(); + JSONObject resultJSONObject = new JSONObject(responseText); + JSONArray resultArr = resultJSONObject.getJSONArray("result"); + JSONArray resultJSONArray = PluginUtils.filterPluginsFromVersion(resultArr); + result = resultJSONArray.toString(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } else { + result = PluginConstants.CONNECTION_404; + } + } + } + }; + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java new file mode 100644 index 0000000000..303d8aee7b --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java @@ -0,0 +1,51 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.PluginsReaderFromStore; +import com.fr.design.extra.Process; +import com.fr.general.FRLogger; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.plugin.view.PluginView; +import com.fr.stable.StringUtils; + +import java.util.List; + +/** + * Created by vito on 16/4/19. + */ +public class ReadUpdateOnlineExecutor implements Executor { + private String result = StringUtils.EMPTY; + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return StringUtils.EMPTY; + } + + @Override + public void run(Process process) { + try { + List plugins = PluginsReaderFromStore.readPluginsForUpdate(); + JSONArray jsonArray = new JSONArray(); + for (PluginView plugin : plugins) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("pluginid", plugin.getID()); + jsonArray.put(jsonObject); + } + result = jsonArray.toString(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + } + }; + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java b/designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java new file mode 100644 index 0000000000..c46dd5d4e2 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/SearchOnlineExecutor.java @@ -0,0 +1,59 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.PluginOperateUtils; +import com.fr.design.extra.PluginUtils; +import com.fr.design.extra.Process; +import com.fr.general.FRLogger; +import com.fr.general.SiteCenter; +import com.fr.general.http.HttpClient; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.stable.StringUtils; + +/** + * Created by vito on 16/4/18. + */ +public class SearchOnlineExecutor implements Executor { + private String result = StringUtils.EMPTY; + private String keyword; + + public SearchOnlineExecutor(String keyword) { + this.keyword = keyword; + } + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return StringUtils.EMPTY; + } + + @Override + public void run(Process process) { + try { + if (StringUtils.isBlank(keyword)) { + result = PluginOperateUtils.getRecommendPlugins(); + return; + } + HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("shop.plugin.store") + "&keyword=" + keyword); + httpClient.asGet(); + String responseText = httpClient.getResponseText(); + JSONObject jsonObject = new JSONObject(responseText); + JSONArray jsonArray = jsonObject.getJSONArray("result"); + JSONArray resultJSONArray = PluginUtils.filterPluginsFromVersion(jsonArray); + result = resultJSONArray.toString(); + } catch (Exception e) { + FRLogger.getLogger().error(e.getMessage()); + } + } + } + }; + } +} diff --git a/designer_base/src/com/fr/design/extra/exe/getPluginPrefixExecutor.java b/designer_base/src/com/fr/design/extra/exe/getPluginPrefixExecutor.java new file mode 100644 index 0000000000..b40b9fdff1 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/getPluginPrefixExecutor.java @@ -0,0 +1,35 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.Process; +import com.fr.general.SiteCenter; +import com.fr.stable.StringUtils; + +/** + * Created by kerry on 2017/11/3. + */ +public class getPluginPrefixExecutor implements Executor { + private String result = StringUtils.EMPTY; + + @Override + public String getTaskFinishMessage() { + return result; + } + + @Override + public Command[] getCommands() { + return new Command[]{ + new Command() { + @Override + public String getExecuteMessage() { + return null; + } + + @Override + public void run(Process process) { + result = SiteCenter.getInstance().acquireUrlByKind("plugin.url.prefix"); + } + } + }; + } +} + From d21223a98cbc3779494bf882b6d7927e423ad80c Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 6 Nov 2017 14:14:00 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginTask.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index 78521f4dab..b3cedd98a9 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -92,10 +92,10 @@ public class PluginTask extends Task { * @return 处理之后的字符串 */ private String filterHtmlTag(String origin) { - String regEx_html = "<[^>]+>"; - Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE); - Matcher m_html = p_html.matcher(origin); - origin = m_html.replaceAll(""); + String regHtml = "<[^>]+>"; + Pattern patternHtml = Pattern.compile(regHtml, Pattern.CASE_INSENSITIVE); + Matcher matchHtml = patternHtml.matcher(origin); + origin = matchHtml.replaceAll(""); return origin; } From 63a5a3f6ebcc02a092e9c1110a3e8c44c1bd8533 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 6 Nov 2017 14:14:54 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/extra/exe/callback/JSCallback.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java index c246ebfa8f..ee7a5b1c2d 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java @@ -74,14 +74,12 @@ public class JSCallback { * @return 处理之后的字符串 */ private String filterHtmlTag(String origin) { - String regEx_html = "<[^>]+>"; - Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE); - Matcher m_html = p_html.matcher(origin); - origin = m_html.replaceAll(""); + String regHtml = "<[^>]+>"; + Pattern patternHtml = Pattern.compile(regHtml, Pattern.CASE_INSENSITIVE); + Matcher matchHtml = patternHtml.matcher(origin); + origin = matchHtml.replaceAll(""); return origin; } - - } From 07e4900daf45110a199e39ea7ece1dc2db66fa53 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 6 Nov 2017 14:33:24 +0800 Subject: [PATCH 4/5] =?UTF-8?q?PMD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/extra/PluginOperateUtils.java | 19 +++++++++---------- .../src/com/fr/design/extra/PluginTask.java | 2 +- .../com/fr/design/extra/PluginWebBridge.java | 6 +++--- ...utor.java => GetPluginPrefixExecutor.java} | 2 +- .../design/extra/exe/callback/JSCallback.java | 4 ++-- 5 files changed, 16 insertions(+), 17 deletions(-) rename designer_base/src/com/fr/design/extra/exe/{getPluginPrefixExecutor.java => GetPluginPrefixExecutor.java} (93%) diff --git a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java index 960212a26f..5ce0852c8e 100644 --- a/designer_base/src/com/fr/design/extra/PluginOperateUtils.java +++ b/designer_base/src/com/fr/design/extra/PluginOperateUtils.java @@ -112,7 +112,7 @@ public class PluginOperateUtils { String plistUrl = SiteCenter.getInstance().acquireUrlByKind("shop.plugin.feature"); JSONArray resultArray = JSONArray.create(); try { - HttpClient httpClient = new HttpClient(plistUrl.toString()); + HttpClient httpClient = new HttpClient(plistUrl); String result = httpClient.getResponseText(); JSONArray jsonArray = new JSONArray(result); resultArray = PluginUtils.filterPluginsFromVersion(jsonArray); @@ -126,7 +126,7 @@ public class PluginOperateUtils { if (StringUtils.isNotBlank(category)) { url.append("cid=").append(category.split("-")[1]); } else { - url.append("cid=").append(""); + url.append("cid=").append(StringUtils.EMPTY); } if (StringUtils.isNotBlank(seller)) { switch (seller.split("-")[1]) { @@ -137,7 +137,7 @@ public class PluginOperateUtils { url.append("&seller=").append(2); break; default: - url.append("&seller=").append(""); + url.append("&seller=").append(StringUtils.EMPTY); } } if (StringUtils.isNotBlank(fee)) { @@ -149,7 +149,7 @@ public class PluginOperateUtils { url.append("&fee=").append(2); break; default: - url.append("&fee=").append(""); + url.append("&fee=").append(StringUtils.EMPTY); } } } @@ -157,11 +157,11 @@ public class PluginOperateUtils { public static void getLoginInfo(JSCallback jsCallback, UILabel uiLabel) { String username = ConfigManager.getProviderInstance().getBbsUsername(); if (StringUtils.isEmpty(username)) { - jsCallback.execute(""); + jsCallback.execute(StringUtils.EMPTY); uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); } else { uiLabel.setText(username); - String result = username; + String result = username; jsCallback.execute(result); } } @@ -177,11 +177,11 @@ public class PluginOperateUtils { StringBuilder pluginInfo = new StringBuilder(); List pluginTaskResults = result.asList(); for (PluginTaskResult pluginTaskResult : pluginTaskResults) { - if(pluginInfo.length() != 0){ + if (pluginInfo.length() != 0) { pluginInfo.append("\n"); } PluginTask pluginTask = pluginTaskResult.getCurrentTask(); - if(pluginTask == null){ + if (pluginTask == null) { pluginInfo.append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode())); continue; } @@ -189,7 +189,7 @@ public class PluginOperateUtils { PluginContext pluginContext = PluginManager.getContext(pluginMarker); if (pluginContext != null) { pluginInfo.append(pluginContext.getName()).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode())); - }else{ + } else { pluginInfo.append(pluginMarker.getPluginID()).append(PluginUtils.getMessageByErrorCode(pluginTaskResult.errorCode())); } } @@ -197,5 +197,4 @@ public class PluginOperateUtils { } - } diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index b3cedd98a9..1afe542bba 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -95,7 +95,7 @@ public class PluginTask extends Task { String regHtml = "<[^>]+>"; Pattern patternHtml = Pattern.compile(regHtml, Pattern.CASE_INSENSITIVE); Matcher matchHtml = patternHtml.matcher(origin); - origin = matchHtml.replaceAll(""); + origin = matchHtml.replaceAll(StringUtils.EMPTY); return origin; } diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 919db379e0..8f40280b1f 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -11,7 +11,7 @@ import com.fr.design.extra.exe.PluginLoginExecutor; import com.fr.design.extra.exe.ReadUpdateOnlineExecutor; import com.fr.design.extra.exe.SearchOnlineExecutor; import com.fr.design.extra.exe.callback.JSCallback; -import com.fr.design.extra.exe.getPluginPrefixExecutor; +import com.fr.design.extra.exe.GetPluginPrefixExecutor; import com.fr.design.gui.ilable.UILabel; import com.fr.general.FRLogger; import com.fr.general.Inter; @@ -337,7 +337,7 @@ public class PluginWebBridge { public void getPluginPrefix(final JSObject callback) { - Task task = new PluginTask<>(webEngine, callback, new getPluginPrefixExecutor()); + Task task = new PluginTask<>(webEngine, callback, new GetPluginPrefixExecutor()); threadPoolExecutor.submit(task); } @@ -549,7 +549,7 @@ public class PluginWebBridge { * 初始化设计器部分 */ public void initExtraDiff(final JSObject callback) { - + //todo 初始化设计器其他部分 } /** diff --git a/designer_base/src/com/fr/design/extra/exe/getPluginPrefixExecutor.java b/designer_base/src/com/fr/design/extra/exe/GetPluginPrefixExecutor.java similarity index 93% rename from designer_base/src/com/fr/design/extra/exe/getPluginPrefixExecutor.java rename to designer_base/src/com/fr/design/extra/exe/GetPluginPrefixExecutor.java index b40b9fdff1..31b4e2d3f4 100644 --- a/designer_base/src/com/fr/design/extra/exe/getPluginPrefixExecutor.java +++ b/designer_base/src/com/fr/design/extra/exe/GetPluginPrefixExecutor.java @@ -7,7 +7,7 @@ import com.fr.stable.StringUtils; /** * Created by kerry on 2017/11/3. */ -public class getPluginPrefixExecutor implements Executor { +public class GetPluginPrefixExecutor implements Executor { private String result = StringUtils.EMPTY; @Override diff --git a/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java index ee7a5b1c2d..d01446ee01 100644 --- a/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java +++ b/designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java @@ -63,7 +63,7 @@ public class JSCallback { private String trimText(String old) { if (StringUtils.isNotBlank(old)) { String b = filterHtmlTag(old); - return b.replaceAll("\\\\n", "").replaceAll("\\\\t", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'").replaceAll("\\\\\\\\", "\\\\\\\\\\\\"); + return b.replaceAll("\\\\n", StringUtils.EMPTY).replaceAll("\\\\t", StringUtils.EMPTY).replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'").replaceAll("\\\\\\\\", "\\\\\\\\\\\\"); } return StringUtils.EMPTY; } @@ -77,7 +77,7 @@ public class JSCallback { String regHtml = "<[^>]+>"; Pattern patternHtml = Pattern.compile(regHtml, Pattern.CASE_INSENSITIVE); Matcher matchHtml = patternHtml.matcher(origin); - origin = matchHtml.replaceAll(""); + origin = matchHtml.replaceAll(StringUtils.EMPTY); return origin; } From 5510686ed5e6c7301127590012efca2792cfb3e4 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 6 Nov 2017 16:44:47 +0800 Subject: [PATCH 5/5] =?UTF-8?q?PMD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/PluginTask.java b/designer_base/src/com/fr/design/extra/PluginTask.java index 1afe542bba..f91001cc7e 100644 --- a/designer_base/src/com/fr/design/extra/PluginTask.java +++ b/designer_base/src/com/fr/design/extra/PluginTask.java @@ -81,7 +81,7 @@ public class PluginTask extends Task { private String trimText(String old) { if (StringUtils.isNotBlank(old)) { String b = filterHtmlTag(old); - return b.replaceAll("\\\\n", "").replaceAll("\\\\t", "").replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'").replaceAll("\\\\\\\\", "\\\\\\\\\\\\"); + return b.replaceAll("\\\\n", StringUtils.EMPTY).replaceAll("\\\\t", StringUtils.EMPTY).replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'").replaceAll("\\\\\\\\", "\\\\\\\\\\\\"); } return StringUtils.EMPTY; }