Java Code Examples for com.alibaba.fastjson.JSONObject#getIntValue()
The following examples show how to use
com.alibaba.fastjson.JSONObject#getIntValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnsComponent.java From weixin4j with Apache License 2.0 | 6 votes |
/** * 检验授权凭证(access_token)是否有效 * * @param access_token 网页授权接口调用凭证 * @param openid 用户的唯一标识 * @return 可用返回true,否则返回false * @throws org.weixin4j.WeixinException 微信操作异常 * @since 0.1.0 */ public boolean validateAccessToken(String access_token, String openid) throws WeixinException { if (StringUtils.isEmpty(access_token)) { throw new IllegalArgumentException("access_token can't be null or empty"); } if (StringUtils.isEmpty(openid)) { throw new IllegalArgumentException("openid can't be null or empty"); } //拼接参数 String param = "?access_token=" + access_token + "&openid=" + openid; //创建请求对象 HttpsClient http = new HttpsClient(); //调用获取access_token接口 Response res = http.get("https://api.weixin.qq.com/sns/auth" + param); //根据请求结果判定,是否验证成功 JSONObject jsonObj = res.asJSONObject(); if (jsonObj != null) { if (Configuration.isDebug()) { System.out.println("validateAccessToken返回json:" + jsonObj.toString()); } return jsonObj.getIntValue("errcode") == 0; } return false; }
Example 2
Source File: JwMediaAPI.java From jeewx-api with Apache License 2.0 | 6 votes |
public static int uploadfixsource(FixSource fixSource, String accessToken) { logger.info("[CREATEMENU]", "createText param:accessToken:{},agentid:{},fixmpnews:{}", new Object[]{accessToken,fixSource}); int result = 0; // 拼装发送信息的url String url = fixsource_upload_url.replace("ACCESS_TOKEN", accessToken) ; // 将信息对象转换成json字符串 String jsonFixMpnews = JSONObject.toJSONString(fixSource); logger.info("[CREATEMENU]", "sendMessage param:jsonText:{}", new Object[]{jsonFixMpnews}); // 调用接口发送信息 JSONObject jsonObject = HttpUtil.sendPost(url, jsonFixMpnews); logger.info("[CREATEMENU]", "sendMessage response:{}", new Object[]{jsonObject.toJSONString()}); if (null != jsonObject) { int errcode = jsonObject.getIntValue("errcode"); result = errcode; } return result; }
Example 3
Source File: DoTestRuleFilterFactory.java From uavstack with Apache License 2.0 | 6 votes |
@Test public void getDefaultInstance() { String classname = "Default"; String rule = null; rule = Optional.fromNullable(rule) .or("{\"separator\":\"\t\", \"assignfields\":{\"content\":1}, \"timestamp\": 0}"); // parse filter json String filter = null; String filterregex = Optional.fromNullable(filter).or(".*"); // parse rule json JSONObject robject = JSON.parseObject(rule); String separator = Optional.fromNullable(robject.getString("separator")).or("\t"); JSONObject assignFields = Optional.fromNullable(robject.getJSONObject("assignfields")) .or(JSON.parseObject("{content:1}")); // Verify timeStamp number is available int timestampNumber = robject.getIntValue("timestamp"); LogFilterAndRule mainLogFAR = (LogFilterAndRule) ReflectionHelper.newInstance( "com.creditease.agent.feature.logagent.far." + classname + "LogFilterAndRule", new Class[] { String.class, String.class, JSONObject.class, int.class }, new Object[] { filterregex, separator, assignFields, timestampNumber }); assertNotNull(mainLogFAR); System.out.println(mainLogFAR); }
Example 4
Source File: WXAuthService.java From message_interface with MIT License | 6 votes |
private void updateAccessTokenFromWx() { if (!fetching.compareAndSet(false, true)) { return; } String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s"; url = String.format(url, Constants.WX_APP_ID, Constants.WX_APP_SECRET); try { String ret = HttpClientPool.getInstance().get(url); JSONObject json = JSONObject.parseObject(ret); accessToken = json.getString("access_token"); expireTime = System.currentTimeMillis() + json.getIntValue("expires_in"); } catch (IOException e) { logger.debug("query accessToken error: " + e); } finally { fetching.set(false); } }
Example 5
Source File: JsSdkComponent.java From weixin4j with Apache License 2.0 | 6 votes |
/** * 获取jsapi_ticket对象,每次都返回最新 * * @return 成功返回jsapi_ticket对象,失败返回NULL * @throws org.weixin4j.WeixinException 微信操作异常 */ public Ticket getJsApiTicket() throws WeixinException { //创建请求对象 HttpsClient http = new HttpsClient(); //调用获取jsapi_ticket接口 Response res = http.get("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + weixin.getToken().getAccess_token() + "&type=jsapi"); //根据请求结果判定,是否验证成功 JSONObject jsonObj = res.asJSONObject(); //成功返回如下JSON: //{"errcode":0,"errmsg":"ok","ticket":"bxLdikRXVbTPdHSM05e5u5sUoXNKd8-41ZO3MhKoyN5OfkWITDGgnr2fwJ0m9E8NYzWKVZvdVtaUgWvsdshFKA","expires_in":7200} if (jsonObj != null) { if (Configuration.isDebug()) { System.out.println("获取jsapi_ticket返回json:" + jsonObj.toString()); } Object errcode = jsonObj.get("errcode"); if (errcode != null && !errcode.toString().equals("0")) { //返回异常信息 throw new WeixinException(getCause(jsonObj.getIntValue("errcode"))); } else { return new Ticket(TicketType.JSAPI, jsonObj.getString("ticket"), jsonObj.getIntValue("expires_in")); } } return null; }
Example 6
Source File: P2PMessageActivity.java From NIM_Android_UIKit with MIT License | 6 votes |
protected void showCommandMessage(CustomNotification message) { if (!isResume) { return; } String content = message.getContent(); try { JSONObject json = JSON.parseObject(content); int id = json.getIntValue("id"); if (id == 1) { // 正在输入 ToastHelper.showToastLong(P2PMessageActivity.this, "对方正在输入..."); } else { ToastHelper.showToast(P2PMessageActivity.this, "command: " + content); } } catch (Exception ignored) { } }
Example 7
Source File: OpLogClientFactory.java From kkbinlog with Apache License 2.0 | 5 votes |
/** * 配置当前binlog位置 * * @param oplogClient * @param binaryLogConfig */ private void configOpLogStatus(OplogClient oplogClient, BinaryLogConfig binaryLogConfig) { JSONObject binLogStatus = etcdService.getBinaryLogStatus(binaryLogConfig); if (binLogStatus != null) { int seconds = binLogStatus.getIntValue("binlogFilename"); int inc = binLogStatus.getIntValue("binlogPosition"); oplogClient.setTs(new BsonTimestamp(seconds, inc)); } }
Example 8
Source File: TemplateImpl.java From tephra with MIT License | 5 votes |
private boolean failure(JSONObject object, OutputStream outputStream) throws IOException { if (object.containsKey("code") && object.getIntValue("code") > 0) { outputStream.write(object.toString().getBytes()); return true; } return false; }
Example 9
Source File: ConfigParser.java From group-signature-client with GNU General Public License v3.0 | 5 votes |
private void parseJsonStr() throws Exception { String jsonStr = read(configFile); if (jsonStr != null) { JSONObject jsonObj = JSONObject.parseObject(jsonStr); if (jsonObj != null) { if (jsonObj.containsKey("ip")) connIp = jsonObj.getString("ip"); if (jsonObj.containsKey("port")) connPort = jsonObj.getString("port"); if (jsonObj.containsKey("threadNum")) threadNum = jsonObj.getIntValue("thread_num"); } } else { throw new Exception("parse conn.json failed"); } logger.info("ip: {}, port: {}", connIp, connPort); }
Example 10
Source File: WeChatUtil.java From wechat4j with Apache License 2.0 | 5 votes |
/** * 判断是否请求成功 * @param resultStr * @throws WeChatException */ public static void isSuccess(String resultStr) throws WeChatException{ JSONObject jsonObject = JSONObject.parseObject(resultStr); Integer errCode =jsonObject.getIntValue("errcode"); if (errCode!=null && errCode!=0) { String errMsg = WeChatReturnCode.getMsg(errCode); if (errMsg.equals("")) { errMsg = jsonObject.getString("errmsg"); } throw new WeChatException("异常码:"+errCode+";异常说明:"+errMsg); } }
Example 11
Source File: GroupsComponent.java From weixin4j with Apache License 2.0 | 5 votes |
/** * 移动用户分组 * * @param openid 用户唯一标识符 * @param to_groupid 分组id * @throws org.weixin4j.WeixinException 移动用户分组异常 */ public void membersUpdate(String openid, int to_groupid) throws WeixinException { //内部业务验证 if (openid == null || openid.equals("")) { throw new IllegalStateException("openid is null!"); } if (to_groupid < 0) { throw new IllegalStateException("to_groupid can not <= 0!"); } //拼接参数 JSONObject postParam = new JSONObject(); postParam.put("openid", openid); postParam.put("to_groupid", to_groupid); //创建请求对象 HttpsClient http = new HttpsClient(); //调用获取access_token接口 Response res = http.post("https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=" + weixin.getToken().getAccess_token(), postParam); //根据请求结果判定,是否验证成功 JSONObject jsonObj = res.asJSONObject(); if (jsonObj != null) { if (Configuration.isDebug()) { System.out.println("/groups/members/update返回json:" + jsonObj.toString()); } //判断是否修改成功 //正常时返回 {"errcode": 0, "errmsg": "ok"} //错误时返回 示例:{"errcode":40013,"errmsg":"invalid appid"} int errcode = jsonObj.getIntValue("errcode"); //登录成功,设置accessToken和过期时间 if (errcode != 0) { //返回异常信息 throw new WeixinException(getCause(errcode)); } } }
Example 12
Source File: ThirdPartyLoginHelper.java From feiqu-opensource with Apache License 2.0 | 5 votes |
/** * 获取QQ用户信息 * * @param token * @param openid */ public static final ThirdPartyUser getQQUserinfo(String token, String openid) throws Exception { ThirdPartyUser user = new ThirdPartyUser(); String url = Global.getPropertiesConfig("getUserInfoURL_qq"); url = url + "?format=json&access_token=" + token + "&oauth_consumer_key=" + Global.getPropertiesConfig("app_id_qq") + "&openid=" + openid; logger.info("get qquser info url:"+url); String res = HttpUtil.get(url); logger.info("qq info:"+res); JSONObject json = JSONObject.parseObject(res); if (json.getIntValue("ret") == 0) { user.setUserName(json.getString("nickname")); String img = json.getString("figureurl_qq_2"); if (img == null || "".equals(img)) { img = json.getString("figureurl_qq_1"); } user.setAvatarUrl(img); String sex = json.getString("gender"); if ("女".equals(sex)) { user.setGender("2"); } else { user.setGender("1"); } String city = json.getString("city"); if(StringUtils.isNotBlank(city)){ user.setLocation(city); } String year = json.getString("year"); if(StringUtils.isNotBlank(year)){ user.setBirth(year); } user.setToken(token); user.setOpenid(openid); } else { throw new IllegalArgumentException(json.getString("msg")); } return user; }
Example 13
Source File: ConversationAPI.java From jeewx-api with Apache License 2.0 | 5 votes |
/** * 获取会话信息 * @param chatid 会话ID * @param accessToken TOKEN * @return */ public static Conversation getConversation(String chatid, String accessToken){ logger.info("[GETCONVERSATION]", "getConversation param:chatid:{},accessToken:{}", new Object[]{chatid,accessToken}); String url = conversation_get_url.replace("ACCESS_TOKEN", accessToken).replace("CHATID", chatid); JSONObject jsonObject = HttpUtil.sendPost(url); logger.info("[GETCONVERSATION]", "getConversation response:{}", new Object[]{jsonObject.toJSONString()}); if (null != jsonObject) { int errcode = jsonObject.getIntValue("errcode"); if(errcode==0){ Conversation conversation = JSONObject.toJavaObject(jsonObject, Conversation.class); return conversation; } } return null; }
Example 14
Source File: HttpUtil.java From ES-Fastloader with Apache License 2.0 | 4 votes |
private static String doHttp(String url, JSONObject param, String body, HttpType httpType, boolean check) { String logInfo = "url:" + url + ", param:" + param + ", body:" + body + ", type:" + httpType.getType(); if(param!=null) { StringBuilder sb = new StringBuilder(); for (String key : param.keySet()) { sb.append(key).append("=").append(param.getString(key)).append("&"); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } url = url + "?" + sb.toString(); } String result = ""; try { switch (httpType) { case GET: result = HttpUtil.get(url); break; case PUT: result = HttpUtil.putJsonEntity(url, body); break; case POST: result = HttpUtil.postJsonEntity(url, body); break; } if (StringUtil.isBlank(result)) { LogUtils.error("do http fail, get blank result, " + logInfo); return null; } if (!check) { return result; } JSONObject jsonObject = JSONObject.parseObject(result); if (jsonObject.getIntValue("code") != 0) { LogUtils.error("do http fail, code is not 0, result:" + result + ", " + logInfo); return null; } String ret = jsonObject.getString("data"); if(ret==null) { ret = ""; } return ret; } catch (Throwable t) { LogUtils.error("do http get error, result:" + result + ", " + logInfo, t); return null; } }
Example 15
Source File: SendNotification.java From rebuild with GNU General Public License v3.0 | 4 votes |
@Override public void execute(OperatingContext operatingContext) { final JSONObject content = (JSONObject) context.getActionContent(); JSONArray sendTo = content.getJSONArray("sendTo"); List<String> sendToList = new ArrayList<>(); for (Object o : sendTo) { sendToList.add((String) o); } Set<ID> toUsers = UserHelper.parseUsers(sendToList, context.getSourceRecord()); if (toUsers.isEmpty()) { return; } final int type = content.getIntValue("type"); if (type == TYPE_MAIL && !SMSender.availableMail()) { LOG.warn("Could not send because email-service is unavailable"); } else if (type == TYPE_SMS && !SMSender.availableSMS()) { LOG.warn("Could not send because sms-service is unavailable"); } // 这里等待一会,因为主事物可能未完成,如果有变量可能脏读 ThreadPool.waitFor(3000); String message = content.getString("content"); message = ContentWithFieldVars.replaceWithRecord(message, context.getSourceRecord()); // for email String subject = StringUtils.defaultIfBlank(content.getString("title"), "你有一条新通知"); for (ID user : toUsers) { if (type == TYPE_MAIL) { String emailAddr = Application.getUserStore().getUser(user).getEmail(); if (emailAddr != null) { SMSender.sendMail(emailAddr, subject, message); } } else if (type == TYPE_SMS) { String mobile = Application.getUserStore().getUser(user).getWorkphone(); if (RegexUtils.isCNMobile(mobile)) { SMSender.sendSMS(mobile, message); } } // default: TYPE_NOTIFICATION else { Message m = MessageBuilder.createMessage(user, message, context.getSourceRecord()); Application.getNotifications().send(m); } } }
Example 16
Source File: AlarmController.java From kafka-eagle with Apache License 2.0 | 4 votes |
/** Get alarmer cluster history datasets by ajax. */ @RequestMapping(value = "/alarm/history/table/ajax", method = RequestMethod.GET) public void alarmClusterHistoryAjax(HttpServletResponse response, HttpServletRequest request) { String aoData = request.getParameter("aoData"); JSONArray params = JSON.parseArray(aoData); int sEcho = 0, iDisplayStart = 0, iDisplayLength = 0; String search = ""; for (Object object : params) { JSONObject param = (JSONObject) object; if ("sEcho".equals(param.getString("name"))) { sEcho = param.getIntValue("value"); } else if ("iDisplayStart".equals(param.getString("name"))) { iDisplayStart = param.getIntValue("value"); } else if ("iDisplayLength".equals(param.getString("name"))) { iDisplayLength = param.getIntValue("value"); } else if ("sSearch".equals(param.getString("name"))) { search = param.getString("value"); } } HttpSession session = request.getSession(); String clusterAlias = session.getAttribute(KConstants.SessionAlias.CLUSTER_ALIAS).toString(); Map<String, Object> map = new HashMap<String, Object>(); map.put("cluster", clusterAlias); map.put("search", search); map.put("start", iDisplayStart); map.put("size", iDisplayLength); List<AlarmClusterInfo> alarmClusters = alertService.getAlarmClusterList(map); JSONArray aaDatas = new JSONArray(); for (AlarmClusterInfo clustersInfo : alarmClusters) { JSONObject obj = new JSONObject(); int id = clustersInfo.getId(); String server = StrUtils.convertNull(clustersInfo.getServer()); String group = StrUtils.convertNull(clustersInfo.getAlarmGroup()); obj.put("id", id); obj.put("type", clustersInfo.getType()); obj.put("value", "<a href='#" + id + "/server' name='ke_alarm_cluster_detail'>" + (server.length() > 8 ? server.substring(0, 8) + "..." : server) + "</a>"); obj.put("alarmGroup", "<a href='#" + id + "/group' name='ke_alarm_cluster_detail'>" + (group.length() > 8 ? group.substring(0, 8) + "..." : group) + "</a>"); obj.put("alarmTimes", clustersInfo.getAlarmTimes()); obj.put("alarmMaxTimes", clustersInfo.getAlarmMaxTimes()); if (clustersInfo.getAlarmLevel().equals("P0")) { obj.put("alarmLevel", "<span class='badge badge-danger'>" + clustersInfo.getAlarmLevel() + "</span>"); } else if (clustersInfo.getAlarmLevel().equals("P1")) { obj.put("alarmLevel", "<span class='badge badge-warning'>" + clustersInfo.getAlarmLevel() + "</span>"); } else if (clustersInfo.getAlarmLevel().equals("P2")) { obj.put("alarmLevel", "<span class='badge badge-info'>" + clustersInfo.getAlarmLevel() + "</span>"); } else { obj.put("alarmLevel", "<span class='badge badge-primary'>" + clustersInfo.getAlarmLevel() + "</span>"); } if (clustersInfo.getIsNormal().equals("Y")) { obj.put("alarmIsNormal", "<span class='badge badge-success'>Y</span>"); } else { obj.put("alarmIsNormal", "<span class='badge badge-danger'>N</span>"); } if (clustersInfo.getIsEnable().equals("Y")) { obj.put("alarmIsEnable", "<input type='checkbox' name='is_enable_chk' id='alarm_config_is_enable_" + id + "' checked class='chooseBtn' /><label id='is_enable_label_id' val=" + id + " name='is_enable_label' for='alarm_config_is_enable_" + id + "' class='choose-label'></label>"); } else { obj.put("alarmIsEnable", "<input type='checkbox' name='is_enable_chk' id='alarm_config_is_enable_" + id + "' class='chooseBtn' /><label id='is_enable_label_id' val=" + id + " name='is_enable_label' for='alarm_config_is_enable_" + id + "' class='choose-label'></label>"); } obj.put("created", clustersInfo.getCreated()); obj.put("modify", clustersInfo.getModify()); obj.put("operate", "<div class='btn-group btn-group-sm' role='group'><button id='ke_btn_action' class='btn btn-primary dropdown-toggle' type='button' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>Action <span class='caret'></span></button><div aria-labelledby='ke_btn_action' class='dropdown-menu dropdown-menu-right'><a class='dropdown-item' name='alarm_cluster_modify' href='#" + id + "'><i class='fas fa-edit fa-sm fa-fw mr-1'></i>Alter</a><a class='dropdown-item' href='#" + id + "' name='alarm_cluster_remove'><i class='fas fa-trash-alt fa-sm fa-fw mr-1'></i>Delete</a></div>"); aaDatas.add(obj); } JSONObject target = new JSONObject(); target.put("sEcho", sEcho); target.put("iTotalRecords", alertService.getAlarmClusterCount(map)); target.put("iTotalDisplayRecords", alertService.getAlarmClusterCount(map)); target.put("aaData", aaDatas); try { byte[] output = target.toJSONString().getBytes(); BaseController.response(output, response); } catch (Exception ex) { ex.printStackTrace(); } }
Example 17
Source File: UserStore.java From rebuild with GNU General Public License v3.0 | 4 votes |
/** * 转换成 bizz 能识别的权限定义 * * @param definition * @return * @see EntityPrivileges * @see BizzPermission */ private String converEntityPrivilegesDefinition(String definition) { JSONObject defJson = JSON.parseObject(definition); int C = defJson.getIntValue("C"); int D = defJson.getIntValue("D"); int U = defJson.getIntValue("U"); int R = defJson.getIntValue("R"); int A = defJson.getIntValue("A"); int S = defJson.getIntValue("S"); int deepP = 0; int deepL = 0; int deepD = 0; int deepG = 0; // {"A":0,"R":1,"C":4,"S":0,"D":0,"U":0} >> 1:9,2:1,3:1,4:1 if (C >= 4) { deepP += BizzPermission.CREATE.getMask(); deepL += BizzPermission.CREATE.getMask(); deepD += BizzPermission.CREATE.getMask(); deepG += BizzPermission.CREATE.getMask(); } if (D >= 1) { deepP += BizzPermission.DELETE.getMask(); } if (D >= 2) { deepL += BizzPermission.DELETE.getMask(); } if (D >= 3) { deepD += BizzPermission.DELETE.getMask(); } if (D >= 4) { deepG += BizzPermission.DELETE.getMask(); } if (U >= 1) { deepP += BizzPermission.UPDATE.getMask(); } if (U >= 2) { deepL += BizzPermission.UPDATE.getMask(); } if (U >= 3) { deepD += BizzPermission.UPDATE.getMask(); } if (U >= 4) { deepG += BizzPermission.UPDATE.getMask(); } if (R >= 1) { deepP += BizzPermission.READ.getMask(); } if (R >= 2) { deepL += BizzPermission.READ.getMask(); } if (R >= 3) { deepD += BizzPermission.READ.getMask(); } if (R >= 4) { deepG += BizzPermission.READ.getMask(); } if (A >= 1) { deepP += BizzPermission.ASSIGN.getMask(); } if (A >= 2) { deepL += BizzPermission.ASSIGN.getMask(); } if (A >= 3) { deepD += BizzPermission.ASSIGN.getMask(); } if (A >= 4) { deepG += BizzPermission.ASSIGN.getMask(); } if (S >= 1) { deepP += BizzPermission.SHARE.getMask(); } if (S >= 2) { deepL += BizzPermission.SHARE.getMask(); } if (S >= 3) { deepD += BizzPermission.SHARE.getMask(); } if (S >= 4) { deepG += BizzPermission.SHARE.getMask(); } return "1:" + deepP + ",2:" + deepL + ",3:" + deepD + ",4:" + deepG; }
Example 18
Source File: MapRule.java From xtunnel with GNU General Public License v2.0 | 4 votes |
public void init(JSONObject ho){ dstAddress=ho.getString(Constant.Key_DstAddress); dstPort=ho.getIntValue(Constant.Key_DstPort); port=ho.getIntValue(Constant.Key_Port); mapId=ho.getIntValue(Constant.Key_MapId); userId=ho.getString(Constant.Key_UserId); type=ho.getIntValue(Constant.Key_Type); mapserverId=ho.getIntValue(Constant.Key_MapServerId); domainName=ho.getString(Constant.Key_DomainName); name=ho.getString(Constant.Key_Name); domainNamePrefix=ho.getString(Constant.Key_DomainNamePrefix); if(mapserverbean==null){ mapserverbean=new MapServerBean(); mapserverbean.init(ho.getJSONObject(Constant.Key_MapServer)); } if(type==MapRule.type_single_port){ typeString=MapRule.type_string_single_port; wanAddress=mapserverbean. getDomainName()+":"+getPort(); lanAddress=getDstAddress()+":"+getDstPort(); }else if(type==MapRule.type_web){ typeString=MapRule.type_string_web; wanAddress=getWanWebAddress(this); if(mapserverbean.getWebPort()!=80){ wanAddress+=(":"+mapserverbean.getWebPort()); } lanAddress=getDstAddress(); if(getDstPort()!=80){ lanAddress+=(":"+getDstPort()); } } if(domainName!=null&&!domainName.trim().equals("")){ if(type==MapRule.type_single_port){ customAddress=domainName+":"+getPort(); }else if(type==MapRule.type_web){ customAddress=domainName; if(mapserverbean.getWebPort()!=80){ customAddress+=(":"+mapserverbean.getWebPort()); } } } }
Example 19
Source File: DeleteParseHandler.java From DataLink with Apache License 2.0 | 3 votes |
@Override public CRDResultVo parseData(JSONObject json) { CRDResultVo vo = new CRDResultVo(); vo.setOperateType(ESEnum.OperateTypeEnum.DELETE); if(json == null) { return vo; } vo.setJsonString(json.toJSONString()); //boolean found = json.getBooleanValue(FOUND_NAME); JSONObject shard = json.getJSONObject(SHARD_NAME); if(shard != null) { int failed = shard.getIntValue(FAILED_NAME); int success = shard.getIntValue(SUCCESS_NAME); if(success > 0 && failed == 0) { vo.setSuccess(true); } } vo.setIndex(json.getString(INDEX_NAME)); vo.setType(json.getString(TYPE_NAME)); vo.setId(json.getString(ID_NAME)); return vo; }
Example 20
Source File: PartUpdateParseHandler.java From DataLink with Apache License 2.0 | 3 votes |
@Override public CRDResultVo parseData(JSONObject json) { CRDResultVo vo = new CRDResultVo(); vo.setOperateType(ESEnum.OperateTypeEnum.UPDATE); if(json == null) { return vo; } vo.setJsonString(json.toJSONString()); JSONObject shard = json.getJSONObject(SHARD_NAME); int failed = shard.getIntValue(FAILED_NAME); int success = shard.getIntValue(SUCCESS_NAME); if(success > 0 && failed == 0) { vo.setSuccess(true); } vo.setIndex(json.getString(INDEX_NAME)); vo.setType(json.getString(TYPE_NAME)); vo.setId(json.getString(ID_NAME)); return vo; }