/** * Handle status notifications * * @param StreamConsumer consumer The consumer object. * @param String type The status notification type. * @param JSONdn info The notification data. */ public void onStatus(StreamConsumer consumer, String type, JSONdn info) { if (type.equalsIgnoreCase("info") && info.has("progress")) { try { System.err.println(info.getStringVal("progress") + "% done"); } catch (EInvalidData e) { // Failed to get the progress string, ignore it } } else { try { System.err.println("STATUS: " + type + " " + info.getStringVal("message")); } catch (EInvalidData e1) { System.err.println("STATUS: " + type); } try { _h.reloadData(); System.err.println( "STATUS: " + _h.getStatus() + " - " + String.valueOf(_h.getProgress()) + "% done"); if (_h.getStatus().equals("succeeded")) { consumer.stop(); } } catch (EInvalidData e) { System.err.println("reloadData: EInvalidData: " + e.getMessage()); } catch (EAccessDenied e) { System.err.println("reloadData: EAccessDenied: " + e.getMessage()); } catch (EAPIError e) { System.err.println("reloadData: EAPIError: " + e.getMessage()); } } }