Refine search
protected JobDataMap createJobDataMap(String parameters) { JobDataMap map = new JobDataMap(); if (!StringUtils.isEmpty(parameters)) { JSONArray jsonArray = JSON.parseArray(parameters); for (int i = 0; i < jsonArray.size(); i++) { JSONObject o = jsonArray.getJSONObject(i); map.put(o.getString("key"), o.get("value")); } } return map; }
@RequestMapping("/getAllListeners") public JSONObject getAllListeners(HttpServletRequest request, HttpServletResponse response) { JSONObject result = new JSONObject(); List<RaftListener> listeners = RaftCore.getListeners(); JSONArray listenerArray = new JSONArray(); for (RaftListener listener : listeners) { if (listener instanceof VirtualClusterDomain) { listenerArray.add(((VirtualClusterDomain) listener).getName()); } } result.put("listeners", listenerArray); return result; }
@Override public AuthenticationBuilder json(String json) { JSONObject jsonObject = JSON.parseObject(json); user(jsonObject.getObject("user", SimpleUser.class)); role(jsonObject.getJSONArray("roles").toJSONString()); permission(jsonObject.getJSONArray("permissions").toJSONString()); return this; }
private String[] getArray(String key) { JSONArray jsonArray = this.jsonConfig.getJSONArray(key); String[] result = new String[jsonArray.size()]; for (int i = 0, len = jsonArray.size(); i < len; i++) { result[i] = jsonArray.getString(i); } return result; }
@RequestMapping("/list") @ResponseBody public String list(@ModelAttribute MchInfo mchInfo, Integer pageIndex, Integer pageSize) { PageModel pageModel = new PageModel(); int count = mchInfoService.count(mchInfo); if(count <= 0) return JSON.toJSONString(pageModel); List<MchInfo> mchInfoList = mchInfoService.getMchInfoList((pageIndex-1)*pageSize, pageSize, mchInfo); if(!CollectionUtils.isEmpty(mchInfoList)) { JSONArray array = new JSONArray(); for(MchInfo mi : mchInfoList) { JSONObject object = (JSONObject) JSONObject.toJSON(mi); object.put("createTime", DateUtil.date2Str(mi.getCreateTime())); array.add(object); } pageModel.setList(array); } pageModel.setCount(count); pageModel.setMsg("ok"); pageModel.setRel(true); return JSON.toJSONString(pageModel); }
@Override public AuthenticationBuilder permission(String permissionJson) { JSONArray jsonArray = JSON.parseArray(permissionJson); List<Permission> permissions = new ArrayList<>(); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); SimplePermission permission = new SimplePermission(); permission.setId(jsonObject.getString("id")); permission.setName(jsonObject.getString("name")); JSONArray actions = jsonObject.getJSONArray("actions"); if (actions != null) { permission.setActions(new HashSet<>(actions.toJavaList(String.class))); } JSONArray dataAccess = jsonObject.getJSONArray("dataAccesses"); if (null != dataAccess) { permission.setDataAccesses(dataAccess.stream().map(JSONObject.class::cast) .map(dataJson -> dataBuilderFactory.create().fromJson(dataJson.toJSONString()).build()) .filter(Objects::nonNull) .collect(Collectors.toSet())); } permissions.add(permission); } authentication.setPermissions(permissions); return this; }
/** * 拉取消息 * * @param callback 获取消息后的回调 */ private void pollMessage(MessageCallback callback) { LOGGER.debug("开始接收消息"); JSONObject r = new JSONObject(); r.put("ptwebqq", ptwebqq); r.put("clientid", Client_ID); r.put("psessionid", psessionid); r.put("key", ""); Response<String> response = post(ApiURL.POLL_MESSAGE, r); JSONArray array = getJsonArrayResult(response); for (int i = 0; array != null && i < array.size(); i++) { JSONObject message = array.getJSONObject(i); String type = message.getString("poll_type"); if ("message".equals(type)) { callback.onMessage(new Message(message.getJSONObject("value"))); } else if ("group_message".equals(type)) { callback.onGroupMessage(new GroupMessage(message.getJSONObject("value"))); } else if ("discu_message".equals(type)) { callback.onDiscussMessage(new DiscussMessage(message.getJSONObject("value"))); } } }
@Override public CandidateDimension parse(DimensionContext context, String jsonConfig) { JSONArray jsonArray; if (jsonConfig.startsWith("[")) { jsonArray = JSON.parseArray(jsonConfig); } else { JSONObject jsonObject = JSON.parseObject(jsonConfig); jsonArray = new JSONArray(); jsonArray.add(jsonObject); } return parse(context, jsonArray); } }
/** * 获得最近会话列表 * * @return */ public List<Recent> getRecentList() { LOGGER.debug("开始获取最近会话列表"); JSONObject r = new JSONObject(); r.put("vfwebqq", vfwebqq); r.put("clientid", Client_ID); r.put("psessionid", ""); Response<String> response = post(ApiURL.GET_RECENT_LIST, r); return JSON.parseArray(getJsonArrayResult(response).toJSONString(), Recent.class); }
@Override public List<Episode> parseEpisodes(String videoUrl) { List<Episode> episodes = new ArrayList<>(); Document document = JsoupUtils.getDocWithPhone(videoUrl); Matcher matcher = Pattern.compile("([0-9]{5,})\\.html").matcher(document.html()); if (matcher.find()) { String vid = matcher.group(1); String videosAPI = String.format(LETV_VIDEOS, vid); String data = JsoupUtils.getDocWithPhone(videosAPI).body().text(); JSONObject jsonObject = JSONObject.parseObject(data); JSONArray array = jsonObject.getJSONObject("data").getJSONObject("episode").getJSONArray("videolist"); if (array.size() > 1) { for (int i = array.size() - 1; i >= 0; i--) { JSONObject object = array.getJSONObject(i); Episode episode = new Episode(); Integer index = object.getInteger("episode"); if (index < 10) { episode.setIndex("0" + index); } else { episode.setIndex("" + index); } episode.setValue(object.getString("url")); episodes.add(episode); } } } return episodes; }
/** * 初始化视频信息 */ private void initVideo(Video video, JSONObject json) { JSONObject videoJson = json.getJSONObject("vl").getJSONArray("vi").getJSONObject(0); int random = RandomUtils.nextInt(3); String url = videoJson.getJSONObject("ul").getJSONArray("ui").getJSONObject(random).getString("url"); String vkey = videoJson.getString("fvkey"); String fn = videoJson.getString("fn"); String file = fn.replace("mp4", "1.mp4"); String title = videoJson.getString("ti"); String firstPlayUrl = playUrl(url, file, vkey); String size = videoJson.getJSONObject("cl").getString("fc"); video.setPlayUrl(firstPlayUrl); video.setImage(""); video.setTitle(title); video.setType("qq"); video.setOther(size); }
@Override protected <T> T parseResponse(String resultStr, Class<T> responseCls) throws TaskException { try { JSONArray jsonArray = JSONArray.parseArray(resultStr); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); if (jsonObject.containsKey("card_group")) { JSONArray card_group = jsonObject.getJSONArray("card_group"); for (int j = 0; j < card_group.size(); j++) { try { JSONObject card = card_group.getJSONObject(j); comment.setId(card.getString("id")); comment.setText(Html.fromHtml(card.getString("text")).toString()); comment.setCreated_at(card.getString("created_at"));
JSONArray resultList = new JSONArray(); JSONObject resultJson = new JSONObject(); resultJson.put("topic", topicName); resultJson.put("idealStateMeta", idealStateForTopic); resultList.add(resultJson); idealState.append(new StringRepresentation(resultList.toJSONString())); resultList = new JSONArray(); for (String server : stateMap.keySet()) { if (!externalViewPartitionToServerMappingJson.containsKey(partition)) { externalViewPartitionToServerMappingJson.put(partition, new JSONArray()); externalViewPartitionToServerMappingJson.getJSONArray(partition).add(server); for (String server : stateMap.keySet()) { if (!idealStatePartitionToServerMappingJson.containsKey(partition)) { idealStatePartitionToServerMappingJson.put(partition, new JSONArray()); idealStatePartitionToServerMappingJson.getJSONArray(partition).add(server); if (!serverToPartitionMapping.containsKey(server)) { serverToPartitionMapping.put(server, new ArrayList<String>()); serverToPartitionMappingJson.put(server, new JSONArray()); serverToNumPartitionsMappingJson.put(server, 0); serverToPartitionMappingJson.getJSONArray(server).add(partition);
protected Set<Correlation> buildCorrelations(String correlations) { if (StringUtils.isEmpty(correlations)) { return new LinkedHashSet<>(); } JSONArray correlationsConfig = JSON.parseArray(correlations); Set<Correlation> correlations1 = new LinkedHashSet<>(); for (int i = 0; i < correlationsConfig.size(); i++) { JSONObject single = correlationsConfig.getJSONObject(i); String target = single.getString("target"); String alias = single.getString("alias"); String condition = single.getString("condition"); Objects.requireNonNull(target); Objects.requireNonNull(condition); Correlation correlation = new Correlation(target, alias, condition); correlation.setJoin(Correlation.JOIN.valueOf(String.valueOf(single.getOrDefault("join", "LEFT")).toUpperCase())); JSONObject properties = single.getJSONObject("properties"); if (properties != null) { properties.forEach(correlation::setProperty); } correlations1.add(correlation); } return correlations1; }
private JSONArray buildRequestLimitData(Set<String> namespaceSet) { JSONArray array = new JSONArray(); for (String namespace : namespaceSet) { array.add(new JSONObject() .fluentPut("namespace", namespace) .fluentPut("currentQps", GlobalRequestLimiter.getCurrentQps(namespace)) .fluentPut("maxAllowedQps", GlobalRequestLimiter.getMaxAllowedQps(namespace)) ); } return array; } }
public void updatedDom2(String namespaceId, String domName, String serverIP) { Message msg = synchronizer.get(serverIP, UtilsAndCommons.assembleFullServiceName(namespaceId, domName)); JSONObject dom = JSON.parseObject(msg.getData()); JSONArray ipList = dom.getJSONArray("ips"); Map<String, String> ipsMap = new HashMap<>(ipList.size()); for (int i = 0; i < ipList.size(); i++) { String ip = ipList.getString(i); String[] strings = ip.split("_"); ipsMap.put(strings[0], strings[1]);
/** * 获得讨论组的详细信息 * * @param discussId 讨论组id * @return */ public DiscussInfo getDiscussInfo(long discussId) { LOGGER.debug("开始获取讨论组资料"); Response<String> response = get(ApiURL.GET_DISCUSS_INFO, discussId, vfwebqq, psessionid); JSONObject result = getJsonObjectResult(response); DiscussInfo discussInfo = result.getObject("info", DiscussInfo.class); //获得讨论组成员信息 Map<Long, DiscussUser> discussUserMap = new HashMap<>(); JSONArray minfo = result.getJSONArray("mem_info"); for (int i = 0; minfo != null && i < minfo.size(); i++) { DiscussUser discussUser = minfo.getObject(i, DiscussUser.class); discussUserMap.put(discussUser.getUin(), discussUser); discussInfo.addUser(discussUser); } JSONArray stats = result.getJSONArray("mem_status"); for (int i = 0; stats != null && i < stats.size(); i++) { JSONObject item = stats.getJSONObject(i); DiscussUser discussUser = discussUserMap.get(item.getLongValue("uin")); discussUser.setClientType(item.getIntValue("client_type")); discussUser.setStatus(item.getString("status")); } return discussInfo; }
private static Map<Long, Friend> parseFriendMap(JSONObject result) { Map<Long, Friend> friendMap = new HashMap<>(); JSONArray info = result.getJSONArray("info"); for (int i = 0; info != null && i < info.size(); i++) { JSONObject item = info.getJSONObject(i); Friend friend = new Friend(); friend.setUserId(item.getLongValue("uin")); friend.setNickname(item.getString("nick")); friendMap.put(friend.getUserId(), friend); } JSONArray marknames = result.getJSONArray("marknames"); for (int i = 0; marknames != null && i < marknames.size(); i++) { JSONObject item = marknames.getJSONObject(i); friendMap.get(item.getLongValue("uin")).setMarkname(item.getString("markname")); } JSONArray vipinfo = result.getJSONArray("vipinfo"); for (int i = 0; vipinfo != null && i < vipinfo.size(); i++) { JSONObject item = vipinfo.getJSONObject(i); Friend friend = friendMap.get(item.getLongValue("u")); friend.setVip(item.getIntValue("is_vip") == 1); friend.setVipLevel(item.getIntValue("vip_level")); } return friendMap; }