use of com.serotonin.m2m2.module.ModuleNotificationListener in project ma-core-public by infiniteautomation.
the class ModulesDwr method upgradesAvailable.
/**
* How many upgrades are available
* @return
* @throws Exception
*/
public static int upgradesAvailable() throws Exception {
JsonValue jsonResponse = getAvailableUpgrades();
if (jsonResponse instanceof JsonString)
throw new Exception("Mango Store Response Error: " + jsonResponse.toString());
JsonObject root = jsonResponse.toJsonObject();
int size = root.getJsonArray("upgrades").size();
if (size > 0) {
// Notify the listeners
JsonValue jsonUpgrades = root.get("upgrades");
JsonArray jsonUpgradesArray = jsonUpgrades.toJsonArray();
for (JsonValue v : jsonUpgradesArray) {
for (ModuleNotificationListener l : listeners) l.moduleUpgradeAvailable(v.getJsonValue("name").toString(), v.getJsonValue("version").toString());
}
JsonValue jsonInstalls = root.get("newInstalls");
JsonArray jsonInstallsArray = jsonInstalls.toJsonArray();
for (JsonValue v : jsonInstallsArray) {
for (ModuleNotificationListener l : listeners) l.newModuleAvailable(v.getJsonValue("name").toString(), v.getJsonValue("version").toString());
}
}
return size;
}
Aggregations