BobK wroteCouple of questions:
1) are you still testing in AwareIM v8.1?
2) what TypeUtils methods are you trying to execute?
I have installed on production server.
private double getRate (IEntity exchangeRate, String apiKey, IExecutionEngine engine)
throws Exception
{
DateHolder dh = (DateHolder) exchangeRate.getAttributeValue(MyUtils2016.EXCHANGE_RATE_DATE_ATTR);
if (dh == null)
throw new Exception ("Unable to extract rate date");
ObjectReference [] or = exchangeRate.getReferences(MyUtils2016.EXCHANGE_RATE_CURRENCY_TO_ATTR);
if (or == null || or.length == 0)
throw new Exception ("Unable to extract currency from exchange rate object");
IEntity currency = engine.getEntity(this, or[0].m_objectName, new Long (or [0].m_objectId));
if (currency == null)
throw new Exception ("Unable to get currency instance");
String code = (String) currency.getAttributeValue(WeblikeUtils2016.CURRENCY_CODE_ATTR);
if (code == null)
throw new Exception ("Unable to extract currency code");
if (code.equalsIgnoreCase("USD"))
return 1.0;
String dateStr = [b]TypeUtils.toString[/b](dh, new SimpleDateFormat("yyyy-MM-dd"));
String reply = MyUtils2016.getURLContents(MyUtils2016.EXCHANGE_URL + code.toLowerCase() + "?date=" + dateStr, apiKey);
System.out.println ("Service returned the following exchange string: " + reply);
if (reply == null)
throw new Exception ("No reply returned from service provider");
JSONParser parser = new JSONParser();
JSONObject jo = (JSONObject) parser.parse (reply);
String rate = (String) jo.get("rate");
if (rate == null)
throw new Exception ("NO rate returned in the reply");
rate = rate.replace(",", ".");
return Double.parseDouble(rate);
}
}