Browse Source

REPORT-2354 将平台的插件管理和设计器的插件管理统一起来

master
kerry 8 years ago
parent
commit
e384ed0732
  1. 93
      designer_base/src/com/fr/design/extra/PluginOperateUtils.java
  2. 2
      designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java

93
designer_base/src/com/fr/design/extra/PluginOperateUtils.java

@ -18,6 +18,7 @@ import com.fr.plugin.manage.bbs.BBSUserInfo;
import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils;
import com.fr.third.v2.org.apache.poi.util.StringUtil;
import java.io.File;
import java.util.List;
@ -132,39 +133,81 @@ public class PluginOperateUtils {
@Override
public void run() {
// String plistUrl = SiteCenter.getInstance().acquireUrlByKind("plugin.plist");
String plistUrl = "http://shop.finereport.com/shopServer?pg=plist";
String plistUrl = "http://shop.finereport.com/plugins" + "?";
boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee);
if (getRecommend){
plistUrl = "http://shop.finereport.com/ShopServer?pg=feature";
if (getRecommend) {
getRecommendPlugins(jsCallback);
return;
}
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());
String result = httpClient.getResponseText();
jsCallback.execute(result);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
} else {
String result = PluginConstants.CONNECTION_404;
jsCallback.execute(result);
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");
jsCallback.execute(resultArr.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){
String plistUrl = "http://shop.finereport.com/ShopServer?pg=feature";
try {
HttpClient httpClient = new HttpClient(plistUrl.toString());
String result = httpClient.getResponseText();
jsCallback.execute(result);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
}
public static void dealParams(StringBuilder url, String category, String seller, String fee){
if (StringUtils.isNotBlank(category)) {
url.append("cid=").append(category.split("-")[1]);
} else {
url.append("cid=").append("");
}
if (StringUtils.isNotBlank(seller)) {
switch (seller.split("-")[1]) {
case "finereport":
url.append("&seller=").append(1);
break;
case "developer":
url.append("&seller=").append(2);
break;
default:
url.append("&seller=").append("");
}
}
if (StringUtils.isNotBlank(fee)) {
switch (fee.split("-")[1]) {
case "free":
url.append("&fee=").append(1);
break;
case "charge":
url.append("&fee=").append(2);
break;
default:
url.append("&fee=").append("");
}
}
}
public static void getPluginCategories(JSCallback jsCallback) {
new Thread(new Runnable() {
@Override

2
designer_base/src/com/fr/design/extra/exe/callback/JSCallback.java

@ -80,7 +80,7 @@ public class JSCallback<T> extends Task<T> {
*/
private String filterHtmlTag(String origin, String tag) {
String matter1 = "<" + tag;
String matter2 = "</" + tag + ">";
String matter2 = tag + ">";
int a = origin.indexOf(matter1);
int b = origin.indexOf(matter2);
while (a != -1 && b != -1) {

Loading…
Cancel
Save