public boolean preloadCurrencies() { try { logger.log(Level.INFO, "Preloading currencies"); ServerLoader loader = new ServerLoader(); ServerLoader.Response r = loader.read("CurrenciesAPI", "getAll"); if (r.getStatus().equals(ServerLoader.Response.STATUS_OK)) { JSONArray a = r.getArrayContent(); List<CurrencyInfo> currencies = new ArrayList<CurrencyInfo>(); for (int i = 0; i < a.length(); i++) { JSONObject o = a.getJSONObject(i); CurrencyInfo currency = new CurrencyInfo(o); currencies.add(currency); } CurrenciesCache.refreshCurrencies(currencies); return true; } else { return false; } } catch (Exception e) { e.printStackTrace(); return false; } }
public CurrencyInfo getMainCurrency() throws BasicException { return CurrenciesCache.getMainCurrency(); }
public CurrencyInfo getCurrency(int currencyId) throws BasicException { return CurrenciesCache.getCurrency(currencyId); }
public final List<CurrencyInfo> getCurrenciesList() throws BasicException { return CurrenciesCache.getCurrencies(); }