use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.
the class GodEyeRestService method noitifyCountQuery.
@SuppressWarnings({ "unchecked", "rawtypes" })
@POST
@Path("notify/q/count/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyCountQuery(String data, @Suspended AsyncResponse response) {
// 数据权限begin
String groups = getUserGroupsByFilter(request);
List groupList = Collections.emptyList();
boolean checkAuthor = true;
if ("NOMAPPING".equals(groups)) {
checkAuthor = false;
} else if ("ALL".equals(groups)) {
/**
* nothing
*/
} else {
String[] gs = groups.split(",");
StringBuilder sBuilder = new StringBuilder();
sBuilder.append("[");
for (String group : gs) {
sBuilder.append("{");
sBuilder.append("\"regex\":{\"appgroup\":\"" + group + "\"}");
sBuilder.append("}");
}
sBuilder.append("]");
HashMap<String, Object> or = new HashMap<String, Object>();
or.put("or", JSONHelper.toObjectArray(sBuilder.toString(), Map.class));
HashMap<String, Object> match = new HashMap<String, Object>();
match.put("match", or);
groupList = new ArrayList<HashMap<String, Object>>();
groupList.add(match);
}
if (checkAuthor) {
// mongodb .为关键字,封装时替换为#交由后台处理
data = data.replaceAll("\\.", "#");
HashMap<String, String> jsonParam = JSONHelper.toObject(data, HashMap.class);
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
// 过滤数据,只查询最近的指定数据 begin
HashMap<String, Object> sortMap = new HashMap<String, Object>();
HashMap<String, Object> sort = new HashMap<String, Object>();
sort.put("values", "time");
sort.put("sortorder", "-1");
sortMap.put("sort", sort);
list.add(sortMap);
HashMap<String, Object> requestParam = new HashMap<String, Object>();
HashMap<String, Object> firstRecord = new HashMap<String, Object>();
HashMap<String, Object> firstRecordMatch = new HashMap<String, Object>();
firstRecord.put("firstrecord", "true");
firstRecordMatch.put("match", firstRecord);
list.add(firstRecordMatch);
// 封装组合查询条件
if (jsonParam.containsKey("search")) {
String whereStr = "[{\"regex\":{\"ip\":\"searchValue\"}},{\"regex\":{\"eventid\":\"searchValue\"}},{\"regex\":{\"title\":\"searchValue\"}},{\"regex\":{\"host\":\"searchValue\"}}]";
// mongodb .为关键字,封装时替换为#交由后台处理
String inputSearchStr = jsonParam.get("search").replaceAll("\\.", "#");
whereStr = whereStr.replaceAll("searchValue", inputSearchStr);
HashMap<String, Object> or = new HashMap<String, Object>();
or.put("or", JSONHelper.toObjectArray(whereStr, Map.class));
HashMap<String, Object> match = new HashMap<String, Object>();
match.put("match", or);
list.add(match);
}
// and
if (!groupList.isEmpty()) {
list.addAll(groupList);
}
HashMap<String, Object> skipMap = new HashMap<String, Object>();
skipMap.put("skip", mongodbQueryRangeMap.get("skip"));
list.add(skipMap);
HashMap<String, Object> limitMap = new HashMap<String, Object>();
limitMap.put("limit", mongodbQueryRangeMap.get("limit"));
list.add(limitMap);
requestParam.put("count", "true");
list.add(requestParam);
// 封装http请求数据
UAVHttpMessage message = new UAVHttpMessage();
message.putRequest("mgo.sql", JSONHelper.toString(list));
message.putRequest("datastore.name", "MT_Notify");
message.putRequest("mgo.coll.name", "uav_notify");
NoitifyCountQueryCB callback = new NoitifyCountQueryCB();
callback.setResponse(response);
doHttpPost("uav.app.godeye.healthmanager.http.addr", "/hm/query", message, callback);
} else {
response.resume("{'rs':'[{\"count\":15}]'}");
}
}
use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.
the class GodEyeRestService method noitifyStrategyQuery.
@SuppressWarnings({ "unchecked" })
@POST
@Path("notify/q/stgy/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyStrategyQuery(String data, @Suspended AsyncResponse response) throws Exception {
Map<String, Object> params = JSONHelper.toObject(data, Map.class);
int pagesize = (int) params.get("pagesize");
int pageindex = (int) params.get("pageindex");
Map<String, String> strategyMap = new HashMap<String, String>();
strategyMap.put("keys", String.valueOf(params.get("inputValue")));
// 封装http请求数据
UAVHttpMessage message = new UAVHttpMessage();
message.putRequest("body", JSONHelper.toString(strategyMap));
message.setIntent("strategy.query");
NoitifyStrategyQuery callback = new NoitifyStrategyQuery();
callback.setResponse(response);
callback.setPageindex(pageindex);
callback.setPagesize(pagesize);
doHttpPost("uav.app.godeye.notify.strategy.http.addr", "/rtntf/oper", message, callback);
}
use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.
the class GodEyeRestService method queryFeedback.
@SuppressWarnings("unchecked")
@POST
@Path("/feedback/query")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void queryFeedback(String reqData, @Suspended AsyncResponse resp) {
Map<String, String> reqInfo = JSONHelper.toObject(reqData, Map.class);
Map<String, Object> where = new HashMap<String, Object>();
String userGroup = String.valueOf(request.getSession(false).getAttribute("apphub.gui.session.login.user.group"));
if (reqInfo.containsKey("checkuser") || (!"vipgroup".equals(userGroup) && !"uav_admin".equals(userGroup))) {
/**
* 不是admin用户则添加过滤
*/
Object obj = request.getSession(false).getAttribute("apphub.gui.session.login.user.id");
String userId = null == obj ? "" : String.valueOf(obj);
where.put("uid", userId);
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("where", where);
data.put("pageindex", reqInfo.get("pageindex"));
data.put("pagesize", reqInfo.get("pagesize"));
HashMap<String, Object> sort = new HashMap<String, Object>();
sort.put("values", "time");
sort.put("sortorder", "-1");
data.put("sort", sort);
Map<String, Object> mapParam = new HashMap<String, Object>();
mapParam.put("type", "query");
mapParam.put("data", data);
/**
* 打包请求数据
*/
UAVHttpMessage request = new UAVHttpMessage();
request.putRequest("mrd.data", JSONHelper.toString(mapParam));
request.putRequest("datastore.name", "AppHub.feedback");
request.putRequest("mgo.coll.name", "uav_feedback");
doHttpPost("uav.app.manage.apphubmanager.http.addr", "/ah/feedback", request, new GodEyeCB(resp));
}
use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.
the class GodEyeRestService method loadAppIPLinkList.
/**
* 应用监控:获取应用的IPLink
*
* @param data
* a json string ["UAV@http://127.0.0.1:8090/apphub","TestGroup@http://127.0.0.1:9090/testapp"]
* @param response
*/
@POST
@Path("profile/q/iplink")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void loadAppIPLinkList(String data, @Suspended AsyncResponse response) {
UAVHttpMessage message = new UAVHttpMessage();
message.setIntent("iplnk");
message.putRequest("appgpids", data);
LoadAppIPLinkListCB callback = new LoadAppIPLinkListCB();
callback.setResponse(response);
this.doHttpPost("uav.app.godeye.healthmanager.http.addr", "/hm/cache/q", message, callback);
}
use of com.creditease.agent.http.api.UAVHttpMessage in project uavstack by uavorg.
the class GodEyeRestService method noitifyStrategyRemove.
@POST
@Path("notify/del/stgy/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyStrategyRemove(String data, @Suspended AsyncResponse response) throws Exception {
// 封装http请求数据
UAVHttpMessage message = new UAVHttpMessage();
message.putRequest("body", data);
message.setIntent("strategy.remove");
NoitifyStrategyRemoveCB callback = new NoitifyStrategyRemoveCB();
callback.setResponse(response);
callback.setData(data);
doHttpPost("uav.app.godeye.notify.strategy.http.addr", "/rtntf/oper", message, callback);
}
Aggregations