Browse Source

无jira任务,修复无网的时候报4个nul的问题

master
vito 8 years ago
parent
commit
9326872cf3
  1. 13
      designer_base/src/com/fr/design/extra/PluginHelper.java
  2. 88
      designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java
  3. 11
      designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java
  4. 37
      designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java

13
designer_base/src/com/fr/design/extra/PluginHelper.java

@ -38,6 +38,7 @@ public class PluginHelper {
//插件依赖的下载位置 //插件依赖的下载位置
public static final String DEPENDENCE_DOWNLOAD_PATH = System.getProperty("user.dir") + "/download/dependence"; public static final String DEPENDENCE_DOWNLOAD_PATH = System.getProperty("user.dir") + "/download/dependence";
public static final String TEMP_FILE = "temp.zip"; public static final String TEMP_FILE = "temp.zip";
public static final String CONNECTION_404 = "404";
/** /**
* 下载插件 * 下载插件
@ -130,7 +131,7 @@ public class PluginHelper {
//将所有未配置好的资源文件依赖准备好 //将所有未配置好的资源文件依赖准备好
private static void checkDependenceEnv(Plugin plugin) throws PluginDependenceException { private static void checkDependenceEnv(Plugin plugin) throws PluginDependenceException {
PluginDependence dependence = plugin.getDependence(); PluginDependence dependence = plugin.getDependence();
if (dependence == null){ if (dependence == null) {
return; return;
} }
@ -138,14 +139,14 @@ public class PluginHelper {
String currentID = dependence.getCurrentPluginID(); String currentID = dependence.getCurrentPluginID();
List<PluginDependenceUnit> list = dependence.getDependPlugins(); List<PluginDependenceUnit> list = dependence.getDependPlugins();
for (int i = 0;list != null && i < list.size(); i++){ for (int i = 0; list != null && i < list.size(); i++) {
PluginDependenceUnit dependenceUnit = list.get(i); PluginDependenceUnit dependenceUnit = list.get(i);
if (!dependenceUnit.checkFileEnv()){ if (!dependenceUnit.checkFileEnv()) {
needInstallDependence.add(dependenceUnit); needInstallDependence.add(dependenceUnit);
} }
} }
if (needInstallDependence.isEmpty()){ if (needInstallDependence.isEmpty()) {
return; return;
} }
@ -156,14 +157,16 @@ public class PluginHelper {
/** /**
* 构造一个下载UI * 构造一个下载UI
*
* @param currentID * @param currentID
* @param list * @param list
* @throws PluginDependenceException * @throws PluginDependenceException
*/ */
private static void installDependenceOnline(String currentID, List<PluginDependenceUnit> list) throws PluginDependenceException{ private static void installDependenceOnline(String currentID, List<PluginDependenceUnit> list) throws PluginDependenceException {
DownLoadDependenceUI ui = new DownLoadDependenceUI(currentID, list); DownLoadDependenceUI ui = new DownLoadDependenceUI(currentID, list);
ui.installOnline(); ui.installOnline();
} }
/** /**
* 从选中的压缩文件中安装插件 * 从选中的压缩文件中安装插件
* *

88
designer_base/src/com/fr/design/extra/PluginsReaderFromStore.java

@ -31,30 +31,30 @@ public class PluginsReaderFromStore {
* @return 插件信息 * @return 插件信息
*/ */
public static Plugin[] readPlugins() throws Exception { public static Plugin[] readPlugins() throws Exception {
String resText; String resText;
try {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.store"));
resText = httpClient.getResponseText();
String charSet = EncodeConstants.ENCODING_UTF_8;
resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet);
} catch (Exception e) {
throw new Exception(Inter.getLocText("FR-Designer-Plugin_PluginMarket_Coding"));
}
if (StringUtils.isNotEmpty(resText)) {
try { try {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.store")); plugins.clear();//先清空set
resText = httpClient.getResponseText(); JSONArray jsonArray = new JSONArray(resText);
String charSet = EncodeConstants.ENCODING_UTF_8; for (int i = 0, size = jsonArray.length(); i < size; i++) {
resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet); Plugin plugin = new Plugin();
} catch (Exception e) { plugin.parseJSON(jsonArray.optJSONObject(i));
throw new Exception(Inter.getLocText("FR-Designer-Plugin_PluginMarket_Coding")); if (plugin.isValidate()) {
} plugins.add(plugin);
if (StringUtils.isNotEmpty(resText)) {
try {
plugins.clear();//先清空set
JSONArray jsonArray = new JSONArray(resText);
for (int i = 0, size = jsonArray.length(); i < size; i++) {
Plugin plugin = new Plugin();
plugin.parseJSON(jsonArray.optJSONObject(i));
if (plugin.isValidate()) {
plugins.add(plugin);
}
} }
} catch (JSONException e) {
throw new Exception(Inter.getLocText("FR-Designer-Plugin_Read_Plugin_List_Error"));
} }
} catch (JSONException e) {
throw new Exception(Inter.getLocText("FR-Designer-Plugin_Read_Plugin_List_Error"));
} }
}
return plugins.toArray(new Plugin[plugins.size()]); return plugins.toArray(new Plugin[plugins.size()]);
} }
@ -65,35 +65,33 @@ public class PluginsReaderFromStore {
* @return 插件信息 * @return 插件信息
*/ */
public static Plugin[] readPluginsForUpdate() throws Exception { public static Plugin[] readPluginsForUpdate() throws Exception {
String resText; String resText = null;
String url = SiteCenter.getInstance().acquireUrlByKind("plugin.update");
if (StringUtils.isNotEmpty(url)) {
HashMap<String, String> para = new HashMap<String, String>();
para.put("plugins", PluginLoader.getLoader().pluginsToString());
//只有当前设计器的jar高于插件新版本需要的jarTime时, 才提示更新该插件.
para.put("jarTime", GeneralUtils.readBuildNO());
HttpClient httpClient = new HttpClient(url, para);
resText = httpClient.getResponseText();
String charSet = EncodeConstants.ENCODING_UTF_8;
resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet);
}
if (StringUtils.isNotEmpty(resText)) {
try { try {
HashMap<String, String> para = new HashMap<String, String>(); pluginsToUpdate.clear();
para.put("plugins", PluginLoader.getLoader().pluginsToString()); JSONArray jsonArray = new JSONArray(resText);
//只有当前设计器的jar高于插件新版本需要的jarTime时, 才提示更新该插件. for (int i = 0, size = jsonArray.length(); i < size; i++) {
para.put("jarTime", GeneralUtils.readBuildNO()); Plugin plugin = new Plugin();
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.update"), para); plugin.parseJSON(jsonArray.optJSONObject(i));
resText = httpClient.getResponseText(); if (plugin.isValidate()) {
String charSet = EncodeConstants.ENCODING_UTF_8; pluginsToUpdate.add(plugin);
resText = URLDecoder.decode(URLDecoder.decode(resText, charSet), charSet);
} catch (Exception e) {
throw new Exception(Inter.getLocText("FR-Designer-Plugin_PluginMarket_Coding"));
}
if (StringUtils.isNotEmpty(resText)) {
try {
pluginsToUpdate.clear();
JSONArray jsonArray = new JSONArray(resText);
for (int i = 0, size = jsonArray.length(); i < size; i++) {
Plugin plugin = new Plugin();
plugin.parseJSON(jsonArray.optJSONObject(i));
if (plugin.isValidate()) {
pluginsToUpdate.add(plugin);
}
} }
} catch (JSONException e) {
throw new Exception(Inter.getLocText("FR-Designer-Plugin_Read_Plugin_List_Error"));
} }
} catch (JSONException e) {
throw new Exception(Inter.getLocText("FR-Designer-Plugin_Read_Plugin_List_Error"));
} }
}
return pluginsToUpdate.toArray(new Plugin[pluginsToUpdate.size()]); return pluginsToUpdate.toArray(new Plugin[pluginsToUpdate.size()]);
} }

11
designer_base/src/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java

@ -1,5 +1,6 @@
package com.fr.design.extra.exe; package com.fr.design.extra.exe;
import com.fr.design.extra.PluginHelper;
import com.fr.design.extra.Process; import com.fr.design.extra.Process;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
@ -26,8 +27,14 @@ public class GetPluginCategoriesExecutor implements Executor {
@Override @Override
public void run(Process<String> process) { public void run(Process<String> process) {
HttpClient httpClient = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("plugin.category")); String url = SiteCenter.getInstance().acquireUrlByKind("plugin.category");
result = httpClient.getResponseText(); if (url != null) {
HttpClient httpClient = new HttpClient(url);
result = httpClient.getResponseText();
} else {
result = PluginHelper.CONNECTION_404;
}
} }
} }
}; };

37
designer_base/src/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java

@ -1,5 +1,6 @@
package com.fr.design.extra.exe; package com.fr.design.extra.exe;
import com.fr.design.extra.PluginHelper;
import com.fr.design.extra.Process; import com.fr.design.extra.Process;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
@ -38,21 +39,27 @@ public class GetPluginFromStoreExecutor implements Executor {
@Override @Override
public void run(Process<String> process) { public void run(Process<String> process) {
StringBuilder url = new StringBuilder(SiteCenter.getInstance().acquireUrlByKind("plugin.plist")); String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.plist");
if (StringUtils.isNotBlank(category)) { if (StringUtils.isNotBlank(plistUrl)) {
url.append("&cid=").append(category.split("-")[1]); StringBuilder url = new StringBuilder();
} url.append(plistUrl);
if (StringUtils.isNotBlank(seller)) { if (StringUtils.isNotBlank(category)) {
url.append("&seller=").append(seller.split("-")[1]); url.append("&cid=").append(category.split("-")[1]);
} }
if (StringUtils.isNotBlank(fee)) { if (StringUtils.isNotBlank(seller)) {
url.append("&fee=").append(fee.split("-")[1]); url.append("&seller=").append(seller.split("-")[1]);
} }
try { if (StringUtils.isNotBlank(fee)) {
HttpClient httpClient = new HttpClient(url.toString()); url.append("&fee=").append(fee.split("-")[1]);
result = httpClient.getResponseText(); }
} catch (Exception e) { try {
FRLogger.getLogger().error(e.getMessage()); HttpClient httpClient = new HttpClient(url.toString());
result = httpClient.getResponseText();
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
} else {
result = PluginHelper.CONNECTION_404;
} }
} }
} }

Loading…
Cancel
Save