From 816b00638cf8c871318655b6ab0bff47f4e120cf Mon Sep 17 00:00:00 2001 From: Hades Date: Wed, 15 May 2019 18:21:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-16567=20=E6=B7=BB=E5=8A=A0=E5=8F=B0?= =?UTF-8?q?=E7=89=88=E6=95=99=E5=AD=A6=E8=A7=86=E9=A2=91=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/actions/community/VideoAction.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java index 8e9fd5b32e..1c441a83f7 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java @@ -27,8 +27,10 @@ public class VideoAction extends UpdateAction public void actionPerformed(ActionEvent arg0) { String url; - if (GeneralContext.getLocale().equals(Locale.US)) { + if (Locale.US.equals(GeneralContext.getLocale())) { url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); + } else if (Locale.TAIWAN.equals(GeneralContext.getLocale())) { + url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.tw"); } else { url = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); } From 7939232a2ccf1dfa5412042e7a9f38d717612268 Mon Sep 17 00:00:00 2001 From: Hades Date: Fri, 24 May 2019 17:03:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-17422=20&&=20REPORT-17460=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8D=87=E7=BA=A7=20=E6=9C=89jar=E5=8C=85?= =?UTF-8?q?=E6=B2=A1=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../update/ui/dialog/UpdateMainDialog.java | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index ad6c4b33f1..e59cc09fff 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -22,6 +22,7 @@ import com.fr.design.update.ui.widget.UpdateInfoTableCellRender; import com.fr.design.update.ui.widget.UpdateInfoTableModel; import com.fr.design.update.ui.widget.UpdateInfoTextAreaCellRender; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.DateUtils; import com.fr.general.GeneralContext; @@ -29,6 +30,7 @@ import com.fr.general.GeneralUtils; import com.fr.general.IOUtils; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; +import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; @@ -37,6 +39,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.third.org.apache.commons.codec.digest.DigestUtils; import com.fr.workspace.WorkContext; import com.sun.java.swing.plaf.motif.MotifProgressBarUI; @@ -371,9 +374,7 @@ public class UpdateMainDialog extends UIDialog { new SwingWorker() { @Override protected JSONObject doInBackground() throws Exception { - HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("jar10.update")); - hc.setTimeout(UpdateConstants.CONNECTION_TIMEOUT); - return new JSONObject(hc.getResponseText()); + return new JSONObject(HttpToolbox.get(CloudCenter.getInstance().acquireUrlByKind("jar10.update"))); } @Override @@ -620,8 +621,11 @@ public class UpdateMainDialog extends UIDialog { long downloadSize = jo.optLong("size"); if (ComparatorUtils.equals(category, "server")) { File currentJAR = new File(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, downloadName)); - if (currentJAR.exists() && ComparatorUtils.equals(currentJAR.length(), downloadSize)) { - //假如大小一样的jar包就不要下载了 + String currentMD5 = getCurrentJarMD5(currentJAR); + String downloadMD5 = jo.optString("md5"); + boolean exist = currentJAR.exists() && ComparatorUtils.equals(currentJAR.length(), downloadSize) && ComparatorUtils.equals(currentMD5, downloadMD5); + if (exist) { + // 如果jar包存在且MD5值和大小与oss上的一致 不下载 continue; } } @@ -630,6 +634,31 @@ public class UpdateMainDialog extends UIDialog { } } + /** + * 获取当前jar的md5 + * @param currentJAR + * @return + */ + private String getCurrentJarMD5(File currentJAR) { + String md5 = StringUtils.EMPTY; + FileInputStream input = null; + try { + input = new FileInputStream(currentJAR); + md5 = DigestUtils.md5Hex(input); + } catch (Exception ignore) { + + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + return md5; + } + /** * jar包更新按钮监听器 */ From 3b4ef22c272c62f2ba3e95b74e63e1283009244f Mon Sep 17 00:00:00 2001 From: Hades Date: Fri, 24 May 2019 17:05:52 +0800 Subject: [PATCH 3/3] update --- .../java/com/fr/design/actions/community/VideoAction.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java index 1c441a83f7..8e9fd5b32e 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java @@ -27,10 +27,8 @@ public class VideoAction extends UpdateAction public void actionPerformed(ActionEvent arg0) { String url; - if (Locale.US.equals(GeneralContext.getLocale())) { + if (GeneralContext.getLocale().equals(Locale.US)) { url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); - } else if (Locale.TAIWAN.equals(GeneralContext.getLocale())) { - url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.tw"); } else { url = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); }