Browse Source

REPORT-28415 10.0连接帆软服务开关

feature/big-screen
vito 5 years ago
parent
commit
1ad716365b
  1. 10
      designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java
  2. 22
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  3. 72
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  4. 3
      designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java
  5. 2
      designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java
  6. 23
      designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java

10
designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java

@ -72,11 +72,11 @@ public class AboutPane extends JPanel {
addPhoneAndQQPane(contentPane); addPhoneAndQQPane(contentPane);
// 官网 // 官网
JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Official_Website"), CloudCenter.getInstance().acquireUrlByKind("website." + GeneralContext.getLocale(), ProductConstants.WEBSITE_URL)); JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Official_Website"), CloudCenter.getInstance().acquireConf("website." + GeneralContext.getLocale(), ProductConstants.WEBSITE_URL));
// 支持邮箱 // 支持邮箱
String defaultEmail = CloudCenter.getInstance().acquireUrlByKind("support.email", ProductConstants.SUPPORT_EMAIL); String defaultEmail = CloudCenter.getInstance().acquireConf("support.email", ProductConstants.SUPPORT_EMAIL);
JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Email"), CloudCenter.getInstance().acquireUrlByKind("support.email." + GeneralContext.getLocale(), defaultEmail)); JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Email"), CloudCenter.getInstance().acquireConf("support.email." + GeneralContext.getLocale(), defaultEmail));
contentPane.add(urlActionPane); contentPane.add(urlActionPane);
contentPane.add(emailPane); contentPane.add(emailPane);
@ -96,7 +96,7 @@ public class AboutPane extends JPanel {
if (GeneralContext.getLocale().equals(Locale.US)) { if (GeneralContext.getLocale().equals(Locale.US)) {
return; return;
} }
boxCenterAlignmentPane = new BoxCenterAligmentPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Service_Phone") + CloudCenter.getInstance().acquireUrlByKind("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE)); boxCenterAlignmentPane = new BoxCenterAligmentPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Service_Phone") + CloudCenter.getInstance().acquireConf("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE));
contentPane.add(boxCenterAlignmentPane); contentPane.add(boxCenterAlignmentPane);
// 繁体版不显示QQ // 繁体版不显示QQ
if (GeneralContext.getLocale().equals(Locale.TAIWAN)) { if (GeneralContext.getLocale().equals(Locale.TAIWAN)) {
@ -176,7 +176,7 @@ public class AboutPane extends JPanel {
private String getCopyRight() { private String getCopyRight() {
return append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_About_CopyRight"), COPYRIGHT_LABEL, return append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_About_CopyRight"), COPYRIGHT_LABEL,
ProductConstants.HISTORY, StringUtils.BLANK, CloudCenter.getInstance().acquireUrlByKind("company.name", ProductConstants.COMPANY_NAME)); ProductConstants.HISTORY, StringUtils.BLANK, CloudCenter.getInstance().acquireConf("company.name", ProductConstants.COMPANY_NAME));
} }
private String getBuildTitle() { private String getBuildTitle() {

22
designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java

@ -1,10 +1,10 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.extra.exe.callback.InstallFromDiskCallback; import com.fr.design.extra.exe.callback.InstallFromDiskCallback;
import com.fr.design.extra.exe.callback.InstallOnlineCallback; import com.fr.design.extra.exe.callback.InstallOnlineCallback;
import com.fr.design.bridge.exec.JSCallback;
import com.fr.design.extra.exe.callback.ModifyStatusCallback; import com.fr.design.extra.exe.callback.ModifyStatusCallback;
import com.fr.design.extra.exe.callback.UninstallPluginCallback; import com.fr.design.extra.exe.callback.UninstallPluginCallback;
import com.fr.design.extra.exe.callback.UpdateFromDiskCallback; import com.fr.design.extra.exe.callback.UpdateFromDiskCallback;
@ -13,6 +13,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
@ -25,9 +26,9 @@ import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.view.PluginView; import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JOptionPane; import javax.swing.*;
import javax.swing.SwingUtilities;
import java.io.File; import java.io.File;
import java.net.HttpURLConnection;
import java.util.List; import java.util.List;
@ -110,13 +111,18 @@ public class PluginOperateUtils {
public static String getRecommendPlugins() { public static String getRecommendPlugins() {
String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.feature"); String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.feature");
JSONArray resultArray = JSONArray.create(); JSONArray resultArray = JSONArray.create();
if (StringUtils.isBlank(plistUrl)) {
return resultArray.toString();
}
try { try {
HttpClient httpClient = new HttpClient(plistUrl); HttpClient httpClient = new HttpClient(plistUrl);
String result = httpClient.getResponseText(); if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
JSONArray jsonArray = new JSONArray(result); String result = httpClient.getResponseText();
resultArray = PluginUtils.filterPluginsFromVersion(jsonArray); JSONArray jsonArray = new JSONArray(result);
} catch (Exception e) { resultArray = PluginUtils.filterPluginsFromVersion(jsonArray);
FineLoggerFactory.getLogger().error(e.getMessage(), e); }
} catch (JSONException e) {
FineLoggerFactory.getLogger().info(e.getMessage(), e);
} }
return resultArray.toString(); return resultArray.toString();
} }

72
designer-base/src/main/java/com/fr/design/extra/PluginUtils.java

@ -2,6 +2,7 @@ package com.fr.design.extra;
import com.fr.base.TemplateUtils; import com.fr.base.TemplateUtils;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
@ -12,8 +13,8 @@ import com.fr.plugin.basic.version.Version;
import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.plugin.basic.version.VersionIntervalFactory;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker; import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.error.PluginBaseErrorCode; import com.fr.plugin.error.PluginBaseErrorCode;
import com.fr.plugin.error.PluginErrorCode;
import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.view.PluginView; import com.fr.plugin.view.PluginView;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
@ -21,11 +22,12 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JOptionPane; import javax.swing.*;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -46,8 +48,7 @@ public class PluginUtils {
public static PluginMarker createPluginMarker(String pluginInfo) { public static PluginMarker createPluginMarker(String pluginInfo) {
//todo 判空 //todo 判空
String[] plugin = pluginInfo.split("_"); String[] plugin = pluginInfo.split("_");
PluginMarker pluginMarker = PluginMarker.create(plugin[0], plugin[1]); return PluginMarker.create(plugin[0], plugin[1]);
return pluginMarker;
} }
public static JSONObject getLatestPluginInfo(String pluginID) throws Exception { public static JSONObject getLatestPluginInfo(String pluginID) throws Exception {
@ -90,7 +91,11 @@ public class PluginUtils {
InputStream reader = null; InputStream reader = null;
FileOutputStream writer = null; FileOutputStream writer = null;
try { try {
HttpClient httpClient = new HttpClient(getDownloadPath(id)); String downloadPath = getDownloadPath(id);
if (StringUtils.isBlank(downloadPath)) {
throw new PluginVerifyException(Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error"));
}
HttpClient httpClient = new HttpClient(downloadPath);
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
int totalSize = httpClient.getContentLength(); int totalSize = httpClient.getContentLength();
reader = httpClient.getResponseStream(); reader = httpClient.getResponseStream();
@ -108,12 +113,12 @@ public class PluginUtils {
p.process(totalBytesRead / (double) totalSize); p.process(totalBytesRead / (double) totalSize);
} }
} else { } else {
throw new com.fr.plugin.PluginVerifyException(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error")); throw new PluginVerifyException(Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error"));
} }
} catch (PluginVerifyException e) { } catch (PluginVerifyException e) {
FineJOptionPane.showMessageDialog(null, e.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); FineJOptionPane.showMessageDialog(null, e.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false; return false;
} catch (Exception e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false; return false;
} finally { } finally {
@ -122,7 +127,7 @@ public class PluginUtils {
return true; return true;
} }
private static void closeStream(InputStream reader, FileOutputStream writer){ private static void closeStream(InputStream reader, FileOutputStream writer) {
try { try {
if (null != reader) { if (null != reader) {
reader.close(); reader.close();
@ -136,18 +141,26 @@ public class PluginUtils {
} }
} }
private static String getDownloadPath(String id) throws Exception { private static String getDownloadPath(String id) {
HashMap<String, String> map = new HashMap<String, String>(); String url = CloudCenter.getInstance().acquireUrlByKind("shop.script.download");
map.put("id", id); if (StringUtils.isBlank(url)) {
HttpClient httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("shop.script.download")+ "?" + FR_VERSION + "=" + ProductConstants.VERSION); return StringUtils.EMPTY;
}
HttpClient httpClient = new HttpClient(url + "?" + FR_VERSION + "=" + ProductConstants.VERSION);
httpClient.asGet(); httpClient.asGet();
String resText = httpClient.getResponseText(); if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
JSONObject resultJSONObject = new JSONObject(resText); String resText = httpClient.getResponseText();
String scriptUrl = resultJSONObject.optString("result"); JSONObject resultJSONObject = new JSONObject(resText);
String charSet = EncodeConstants.ENCODING_UTF_8; String scriptUrl = resultJSONObject.optString("result");
scriptUrl = URLDecoder.decode(URLDecoder.decode(scriptUrl, charSet), charSet); String charSet = EncodeConstants.ENCODING_UTF_8;
try {
return scriptUrl; scriptUrl = URLDecoder.decode(URLDecoder.decode(scriptUrl, charSet), charSet);
} catch (UnsupportedEncodingException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return scriptUrl;
}
return StringUtils.EMPTY;
} }
public static boolean isPluginMatch(PluginView pluginView, String text) { public static boolean isPluginMatch(PluginView pluginView, String text) {
@ -196,7 +209,7 @@ public class PluginUtils {
} }
public static String getMessageByErrorCode(PluginBaseErrorCode errorCode) { public static String getMessageByErrorCode(PluginBaseErrorCode errorCode) {
if(errorCode == PluginErrorCode.None){ if (errorCode == PluginErrorCode.None) {
return ""; return "";
} }
@ -205,7 +218,7 @@ public class PluginUtils {
private static String getInterKeyByErrorCode(PluginBaseErrorCode errorCode) { private static String getInterKeyByErrorCode(PluginBaseErrorCode errorCode) {
return errorCode.getDescription(); return errorCode.getDescription();
} }
public static PluginMarker getInstalledPluginMarkerByID(String pluginID) { public static PluginMarker getInstalledPluginMarkerByID(String pluginID) {
@ -219,29 +232,30 @@ public class PluginUtils {
/** /**
* 在不同设计器版本下展示不同插件 * 在不同设计器版本下展示不同插件
*
* @return 插件 * @return 插件
*/ */
public static JSONArray filterPluginsFromVersion(JSONArray oriJSONArray) throws Exception{ public static JSONArray filterPluginsFromVersion(JSONArray oriJSONArray) {
JSONArray resultJSONArray = JSONArray.create(); JSONArray resultJSONArray = JSONArray.create();
for(int i = 0; i < oriJSONArray.length(); i++){ for (int i = 0; i < oriJSONArray.length(); i++) {
JSONObject jo = oriJSONArray.getJSONObject(i); JSONObject jo = oriJSONArray.getJSONObject(i);
String envVersion = jo.optString("envversion"); String envVersion = jo.optString("envversion");
if(isCompatibleCurrentEnv(envVersion)){ if (isCompatibleCurrentEnv(envVersion)) {
resultJSONArray.put(jo); resultJSONArray.put(jo);
} }
} }
return resultJSONArray; return resultJSONArray;
} }
private static boolean isCompatibleCurrentEnv(String envVersion){ private static boolean isCompatibleCurrentEnv(String envVersion) {
return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion());
} }
public static JSONArray transferStorePluginToJson(PluginContext [] pluginContexts){ public static JSONArray transferStorePluginToJson(PluginContext[] pluginContexts) {
JSONArray ja = JSONArray.create(); JSONArray ja = JSONArray.create();
try { try {
for(PluginContext pluginContext : pluginContexts){ for (PluginContext pluginContext : pluginContexts) {
JSONObject jo = JSONObject.create(); JSONObject jo = JSONObject.create();
jo.put("id", pluginContext.getID()); jo.put("id", pluginContext.getID());
jo.put("name", pluginContext.getName()); jo.put("name", pluginContext.getName());
@ -265,7 +279,7 @@ public class PluginUtils {
jo.put("switchedReason", pluginContext.getSwitchedReason()); jo.put("switchedReason", pluginContext.getSwitchedReason());
ja.put(jo); ja.put(jo);
} }
}catch (Exception e){ } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return ja; return ja;

3
designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java

@ -198,6 +198,9 @@ public class InformationCollector implements XMLReadable, XMLWriter {
} }
JSONObject content = getJSONContentAsByte(); JSONObject content = getJSONContentAsByte();
String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10"); String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10");
if (StringUtils.isBlank(url)) {
return;
}
boolean success = false; boolean success = false;
try { try {
HashMap<String, Object> para = new HashMap<>(); HashMap<String, Object> para = new HashMap<>();

2
designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java

@ -64,7 +64,7 @@ public class BBSConstants {
} }
private static String[] loadAllGuestsInfoOnline(String key, String defaultValue) { private static String[] loadAllGuestsInfoOnline(String key, String defaultValue) {
String guest = CloudCenter.getInstance().acquireUrlByKind(key, defaultValue); String guest = CloudCenter.getInstance().acquireConf(key, defaultValue);
if (StringUtils.isNotEmpty(guest)) { if (StringUtils.isNotEmpty(guest)) {
return guest.split("\\|"); return guest.split("\\|");
} }

23
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java

@ -17,6 +17,7 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -100,7 +101,10 @@ public class ErrorInfoUploader {
private void downloadSolution(File localCacheZip) { private void downloadSolution(File localCacheZip) {
try { try {
String downloadURL = CloudCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution"); String downloadURL = CloudCenter.getInstance().acquireUrlByKind("solution.download");
if (StringUtils.isBlank(downloadURL)) {
return;
}
downloadURL = String.format("%s?token=%s", downloadURL, SiteCenterToken.generateToken()); downloadURL = String.format("%s?token=%s", downloadURL, SiteCenterToken.generateToken());
InputStream in = HttpToolbox.post(downloadURL, new HashMap<String, Object>(), HttpResponseType.STREAM); InputStream in = HttpToolbox.post(downloadURL, new HashMap<String, Object>(), HttpResponseType.STREAM);
StableUtils.makesureFileExist(localCacheZip); StableUtils.makesureFileExist(localCacheZip);
@ -119,7 +123,10 @@ public class ErrorInfoUploader {
private boolean needUpdate(File localCacheZip) { private boolean needUpdate(File localCacheZip) {
if (localCacheZip.exists()) { if (localCacheZip.exists()) {
// 判断本地文件大小. // 判断本地文件大小.
String checkURL = CloudCenter.getInstance().acquireUrlByKind("solution.check", "http://cloud.fanruan.com/api/solution/cache/check"); String checkURL = CloudCenter.getInstance().acquireUrlByKind("solution.check");
if (StringUtils.isBlank(checkURL)) {
return false;
}
checkURL = String.format("%s?token=%s", checkURL, SiteCenterToken.generateToken()); checkURL = String.format("%s?token=%s", checkURL, SiteCenterToken.generateToken());
try { try {
JSONObject res = new JSONObject(HttpToolbox.get(checkURL)); JSONObject res = new JSONObject(HttpToolbox.get(checkURL));
@ -143,6 +150,9 @@ public class ErrorInfoUploader {
} }
File[] files = folder.listFiles(); File[] files = folder.listFiles();
if (files == null) {
return;
}
if (ArrayUtils.getLength(files) > MAX_ERROR_SIZE) { if (ArrayUtils.getLength(files) > MAX_ERROR_SIZE) {
CommonIOUtils.deleteFile(folder); CommonIOUtils.deleteFile(folder);
return; return;
@ -166,9 +176,12 @@ public class ErrorInfoUploader {
} }
jsonArray.put(new JSONObject(content)); jsonArray.put(new JSONObject(content));
tempFiles.add(file); tempFiles.add(file);
if( jsonArray.length() == MAX_ITEMS || count == files.length){ if (jsonArray.length() == MAX_ITEMS || count == files.length) {
String url = CloudCenter.getInstance().acquireUrlByKind("design.error"); String url = CloudCenter.getInstance().acquireUrlByKind("design.error");
if(sendErrorInfo(url, jsonArray)){ if (StringUtils.isBlank(url)) {
return;
}
if (sendErrorInfo(url, jsonArray)) {
deleteFiles(tempFiles); deleteFiles(tempFiles);
} }
jsonArray = new JSONArray(); jsonArray = new JSONArray();
@ -182,7 +195,7 @@ public class ErrorInfoUploader {
} }
private void deleteFiles(List<File> files) { private void deleteFiles(List<File> files) {
for(File file : files) { for (File file : files) {
CommonIOUtils.deleteFile(file); CommonIOUtils.deleteFile(file);
} }
} }

Loading…
Cancel
Save