use of com.biglybt.pifimpl.update.sf.SFPluginDetailsException in project BiglyBT by BiglySoftware.
the class SFPluginDetailsLoaderImpl method loadPluginList.
protected void loadPluginList() throws SFPluginDetailsException {
try {
String page_url_to_use = addEPIDS(page_url);
URL original_url = new URL(page_url_to_use);
URL url = original_url;
Proxy proxy = null;
PluginProxy plugin_proxy = null;
boolean tried_proxy = false;
boolean ok = false;
if (COConfigurationManager.getBooleanParameter("update.anonymous")) {
tried_proxy = true;
plugin_proxy = AEProxyFactory.getPluginProxy("loading plugin details", url);
if (plugin_proxy == null) {
throw (new SFPluginDetailsException("Proxy not available"));
} else {
url = plugin_proxy.getURL();
proxy = plugin_proxy.getProxy();
}
}
try {
while (true) {
try {
ResourceDownloader dl = rd_factory.create(url, proxy);
if (plugin_proxy != null) {
dl.setProperty("URL_HOST", plugin_proxy.getURLHostRewrite());
}
dl = rd_factory.getRetryDownloader(dl, 5);
dl.addListener(this);
Properties details = new Properties();
InputStream is = dl.download();
details.load(is);
is.close();
Iterator it = details.keySet().iterator();
while (it.hasNext()) {
String plugin_id = (String) it.next();
String data = (String) details.get(plugin_id);
int pos = 0;
List bits = new ArrayList();
while (pos < data.length()) {
int p1 = data.indexOf(';', pos);
if (p1 == -1) {
bits.add(data.substring(pos).trim());
break;
} else {
bits.add(data.substring(pos, p1).trim());
pos = p1 + 1;
}
}
if (bits.size() < 3) {
Logger.log(new LogEvent(LOGID, LogEvent.LT_ERROR, "SF loadPluginList failed for plugin '" + plugin_id + "'. Details array is " + bits.size() + " (3 min)"));
} else {
String version = (String) bits.get(0);
String cvs_version = (String) bits.get(1);
String name = (String) bits.get(2);
String category = "";
if (bits.size() > 3) {
category = (String) bits.get(3);
}
plugin_ids.add(plugin_id);
plugin_map.put(plugin_id.toLowerCase(MessageText.LOCALE_ENGLISH), new SFPluginDetailsImpl(this, plugin_id, version, cvs_version, name, category));
}
}
ok = true;
break;
} catch (Throwable e) {
if (!tried_proxy) {
tried_proxy = true;
plugin_proxy = AEProxyFactory.getPluginProxy("loading plugin details", url);
if (plugin_proxy == null) {
throw (e);
} else {
url = plugin_proxy.getURL();
proxy = plugin_proxy.getProxy();
}
} else {
throw (e);
}
}
}
} finally {
if (plugin_proxy != null) {
plugin_proxy.setOK(ok);
}
}
plugin_ids_loaded = true;
plugin_ids_loaded_at = SystemTime.getCurrentTime();
} catch (Throwable e) {
Debug.printStackTrace(e);
throw (new SFPluginDetailsException("Plugin list load failed", e));
}
}
use of com.biglybt.pifimpl.update.sf.SFPluginDetailsException in project BiglyBT by BiglySoftware.
the class SFPluginDetailsLoaderImpl method getPluginDetails.
@Override
public SFPluginDetails getPluginDetails(String name) throws SFPluginDetailsException {
try {
this_mon.enter();
// make sure details are loaded
getPluginIDs();
SFPluginDetails details = (SFPluginDetails) plugin_map.get(name.toLowerCase(MessageText.LOCALE_ENGLISH));
if (details == null) {
throw (new SFPluginDetailsException("Plugin '" + name + "' not found"));
}
return (details);
} finally {
this_mon.exit();
}
}
use of com.biglybt.pifimpl.update.sf.SFPluginDetailsException in project BiglyBT by BiglySoftware.
the class PluginInstallerImpl method getStandardPlugins.
@Override
public StandardPlugin[] getStandardPlugins() throws PluginException {
try {
SFPluginDetailsLoader loader = SFPluginDetailsLoaderFactory.getSingleton();
SFPluginDetails[] details = loader.getPluginDetails();
List res = new ArrayList();
for (int i = 0; i < details.length; i++) {
SFPluginDetails detail = details[i];
String name = detail.getId();
String version = "";
if (Constants.isCVSVersion()) {
version = detail.getCVSVersion();
}
if (version == null || version.length() == 0 || !Character.isDigit(version.charAt(0))) {
version = detail.getVersion();
} else {
// if cvs version and non-cvs version are the same then show the
// non-cvs version
String non_cvs_version = detail.getVersion();
if (version.equals(non_cvs_version + "_CVS")) {
version = non_cvs_version;
}
}
if (name.startsWith("azplatform") || name.equals("azupdater")) {
// skip built in ones we don't want to let user install directly
// not the cleanest of fixes, but it'll do for the moment
} else if (version == null || version.length() == 0 || !Character.isDigit(version.charAt(0))) {
// dodgy version
} else if (detail.getCategory().equalsIgnoreCase("hidden")) {
// not public
} else {
res.add(new StandardPluginImpl(this, details[i], version));
}
}
StandardPlugin[] res_a = new StandardPlugin[res.size()];
res.toArray(res_a);
return (res_a);
} catch (SFPluginDetailsException e) {
throw (new PluginException("Failed to load standard plugin details", e));
}
}
use of com.biglybt.pifimpl.update.sf.SFPluginDetailsException in project BiglyBT by BiglySoftware.
the class PluginInstallerImpl method getStandardPlugin.
@Override
public StandardPlugin getStandardPlugin(String id) throws PluginException {
try {
SFPluginDetailsLoader loader = SFPluginDetailsLoaderFactory.getSingleton();
SFPluginDetails[] details = loader.getPluginDetails();
for (int i = 0; i < details.length; i++) {
SFPluginDetails detail = details[i];
String name = detail.getId();
if (name.equalsIgnoreCase(id)) {
String version = "";
if (Constants.isCVSVersion()) {
version = detail.getCVSVersion();
}
if (version == null || version.length() == 0 || !Character.isDigit(version.charAt(0))) {
version = detail.getVersion();
} else {
// if cvs version and non-cvs version are the same then show the
// non-cvs version
String non_cvs_version = detail.getVersion();
if (version.equals(non_cvs_version + "_CVS")) {
version = non_cvs_version;
}
}
if (name.startsWith("azplatform") || name.equals("azupdater")) {
// skip built in ones we don't want to let user install directly
// not the cleanest of fixes, but it'll do for the moment
} else if (version == null || version.length() == 0 || !Character.isDigit(version.charAt(0))) {
// dodgy version
} else {
return (new StandardPluginImpl(this, details[i], version));
}
}
}
return (null);
} catch (SFPluginDetailsException e) {
throw (new PluginException("Failed to load standard plugin details", e));
}
}
use of com.biglybt.pifimpl.update.sf.SFPluginDetailsException in project BiglyBT by BiglySoftware.
the class SFPluginDetailsLoaderImpl method loadPluginDetails.
protected void loadPluginDetails(SFPluginDetailsImpl details) throws SFPluginDetailsException {
try {
String page_url_to_use = site_prefix + "update/pluginlist3.php?plugin=" + UrlUtils.encode(details.getId()) + "&" + base_url_params;
page_url_to_use = addEPIDS(page_url_to_use);
try {
PluginInterface defPI = PluginInitializer.getDefaultInterface();
PluginInterface pi = defPI == null ? null : defPI.getPluginManager().getPluginInterfaceByID(details.getId(), false);
if (pi != null) {
String existing_version = pi.getPluginVersion();
if (existing_version != null) {
page_url_to_use += "&ver_" + details.getId() + "=" + UrlUtils.encode(existing_version);
}
}
} catch (Throwable e) {
Debug.out(e);
}
URL original_url = new URL(page_url_to_use);
URL url = original_url;
Proxy proxy = null;
PluginProxy plugin_proxy = null;
boolean tried_proxy = false;
boolean ok = false;
if (COConfigurationManager.getBooleanParameter("update.anonymous")) {
tried_proxy = true;
plugin_proxy = AEProxyFactory.getPluginProxy("loading plugin details", url);
if (plugin_proxy == null) {
throw (new SFPluginDetailsException("Proxy not available"));
} else {
url = plugin_proxy.getURL();
proxy = plugin_proxy.getProxy();
}
}
try {
while (true) {
try {
ResourceDownloader p_dl = rd_factory.create(url, proxy);
if (proxy != null) {
p_dl.setProperty("URL_HOST", original_url.getHost());
}
p_dl = rd_factory.getRetryDownloader(p_dl, 5);
p_dl.addListener(this);
InputStream is = p_dl.download();
try {
if (!processPluginStream(details, is)) {
throw (new SFPluginDetailsException("Plugin details load fails for '" + details.getId() + "': data not found"));
}
ok = true;
break;
} finally {
is.close();
}
} catch (Throwable e) {
if (!tried_proxy) {
tried_proxy = true;
plugin_proxy = AEProxyFactory.getPluginProxy("loading plugin details", url);
if (plugin_proxy == null) {
throw (e);
} else {
url = plugin_proxy.getURL();
proxy = plugin_proxy.getProxy();
}
} else {
throw (e);
}
}
}
} finally {
if (plugin_proxy != null) {
plugin_proxy.setOK(ok);
}
}
} catch (Throwable e) {
Debug.printStackTrace(e);
throw (new SFPluginDetailsException("Plugin details load fails", e));
}
}
Aggregations