/** * @param mapProcessing * @param surl * @throws Exception */ protected static void processQueueAsync(String sURL, String sData, Map mapProcessing) throws Exception { URL url; url = new URL(sURL); String s; byte[] bytes = downloadURL(url, sData); s = new String(bytes, "UTF8"); Map mapAllReplies = JSONUtils.decodeJSON(s); List listReplies = MapUtils.getMapList(mapAllReplies, "replies", null); if (mapAllReplies == null || listReplies == null || listReplies.isEmpty()) { debug( "Error while sending message(s) to Platform: reply: " + s + "\nurl: " + sURL + "\nPostData: " + sData); for (Iterator iter = mapProcessing.keySet().iterator(); iter.hasNext(); ) { PlatformMessage message = (PlatformMessage) iter.next(); PlatformMessengerListener l = (PlatformMessengerListener) mapProcessing.get(message); if (l != null) { try { HashMap map = new HashMap(); map.put("text", "result was " + s); l.replyReceived(message, REPLY_EXCEPTION, map); } catch (Throwable e2) { debug( "Error while sending replyReceived" + "\nurl: " + sURL + "\nPostData: " + sData, e2); } } } return; } Map<Long, Map> mapOrder = new HashMap<Long, Map>(); for (Object reply : listReplies) { if (reply instanceof Map) { mapOrder.put(MapUtils.getMapLong((Map) reply, "seq-id", -1), (Map) reply); } } for (Iterator iter = mapProcessing.keySet().iterator(); iter.hasNext(); ) { PlatformMessage message = (PlatformMessage) iter.next(); PlatformMessengerListener l = (PlatformMessengerListener) mapProcessing.get(message); if (l == null) { continue; } Map mapReply = mapOrder.get(new Long(message.getSequenceNo())); if (mapReply == null) { debug("No reply for " + message.toShortString()); } String replyType = MapUtils.getMapString(mapReply, "type", "payload"); Map payload; if (replyType.equalsIgnoreCase("payload")) { payload = MapUtils.getMapMap(mapReply, "payload", Collections.EMPTY_MAP); } else { payload = new HashMap(); payload.put("message", MapUtils.getMapString(mapReply, "message", "?")); } if (mapReply != null) { String reply = JSONUtils.encodeToJSON(payload); debug( "Got a reply for " + message.toShortString() + "\n\t" + reply.substring(0, Math.min(8192, reply.length()))); } try { l.replyReceived(message, replyType, payload); } catch (Exception e2) { debug("Error while sending replyReceived", e2); } } }
public ClientStatsOverall(Map loadMap) { if (loadMap == null) { return; } count = MapUtils.getMapLong(loadMap, "count", 0); }