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 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 {
PluginDependence dependence = plugin.getDependence();
if (dependence == null){
if (dependence == null) {
return;
}
@ -138,14 +139,14 @@ public class PluginHelper {
String currentID = dependence.getCurrentPluginID();
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);
if (!dependenceUnit.checkFileEnv()){
if (!dependenceUnit.checkFileEnv()) {
needInstallDependence.add(dependenceUnit);
}
}
if (needInstallDependence.isEmpty()){
if (needInstallDependence.isEmpty()) {
return;
}
@ -156,14 +157,16 @@ public class PluginHelper {
/**
* 构造一个下载UI
*
* @param currentID
* @param list
* @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);
ui.installOnline();
}
/**
* 从选中的压缩文件中安装插件
*

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

@ -31,30 +31,30 @@ public class PluginsReaderFromStore {
* @return 插件信息
*/
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 {
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 {
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);
}
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()]);
}
@ -65,35 +65,33 @@ public class PluginsReaderFromStore {
* @return 插件信息
*/
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 {
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(SiteCenter.getInstance().acquireUrlByKind("plugin.update"), para);
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 {
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);
}
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()]);
}

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

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