Search in sources :

Example 1 with BASE64DecoderUrl

use of com.creditease.uav.helpers.url.BASE64DecoderUrl in project uavstack by uavorg.

the class GodEyeRestService method noitifyView.

@POST
@Path("notify/view/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyView(String data, @Suspended AsyncResponse response) throws Exception {
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    @SuppressWarnings("unchecked") Map<String, String> jsonParam = JSONHelper.toObject(data, Map.class);
    String url = jsonParam.get("url");
    String time;
    if ("link".equals(jsonParam.get("type"))) {
        byte[] d = new BASE64DecoderUrl().decodeBuffer(url);
        url = new String(d, "utf-8");
        time = url.substring(url.lastIndexOf("&") + 1);
    } else {
        String timeStr = url.substring(url.lastIndexOf("&") + 1);
        time = String.valueOf(simpleDateFormat.parse(timeStr).getTime());
    }
    String ntfkey = url.substring(0, url.lastIndexOf("&"));
    String loginUser = "";
    HttpSession session = request.getSession(false);
    if (null != session) {
        loginUser = String.valueOf(session.getAttribute("apphub.gui.session.login.user.id"));
    }
    String log = "loginUser=[" + loginUser + "],type=[" + jsonParam.get("type") + "],ntfkey=[" + ntfkey + "],time=[" + time + "]";
    if (!"".equals(ntfkey) && !"undefined".equals(ntfkey)) {
        UAVHttpMessage message = new UAVHttpMessage();
        message.putRequest("ncevent", ntfkey);
        message.putRequest("time", time);
        NoitifyViewCB callback = new NoitifyViewCB();
        callback.setResponse(response);
        callback.setLog(log);
        doHttpPost("uav.app.godeye.notify.view.http.addr", "/nc/update", message, callback);
    }
}
Also used : BASE64DecoderUrl(com.creditease.uav.helpers.url.BASE64DecoderUrl) HttpSession(javax.servlet.http.HttpSession) UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) SimpleDateFormat(java.text.SimpleDateFormat) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 2 with BASE64DecoderUrl

use of com.creditease.uav.helpers.url.BASE64DecoderUrl in project uavstack by uavorg.

the class GodEyeRestService method noitifyDescQuery.

/**
 * 先获取第一条预警信息,条件:time,ntfkey 获取当前查看时间:如果有则取其时间范围内数据,没有则取time以后所有数据
 *
 * @param data
 * @param response
 * @throws Exception
 */
@SuppressWarnings("unchecked")
@POST
@Path("notify/q/desc/hm")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public void noitifyDescQuery(String data, @Suspended AsyncResponse response) throws Exception {
    final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    Map<String, String> jsonParam = JSONHelper.toObject(data, Map.class);
    String url = jsonParam.get("url");
    Long time;
    if ("link".equals(jsonParam.get("type"))) {
        byte[] d = new BASE64DecoderUrl().decodeBuffer(url);
        url = new String(d, "utf-8");
        time = Long.valueOf(url.substring(url.lastIndexOf("&") + 1));
    } else {
        String timeStr = url.substring(url.lastIndexOf("&") + 1);
        time = simpleDateFormat.parse(timeStr).getTime();
    }
    final String ntfkey = url.substring(0, url.lastIndexOf("&"));
    HashMap<String, Object> requestWhere = new HashMap<String, Object>();
    requestWhere.put("ntfkey", ntfkey);
    requestWhere.put("firstrecord", "true");
    requestWhere.put("time", time);
    HashMap<String, Object> requestParam = new HashMap<String, Object>();
    requestParam.put("where", requestWhere);
    HashMap<String, Object> sort = new HashMap<String, Object>();
    sort.put("values", "time");
    sort.put("sortorder", "-1");
    requestParam.put("sort", sort);
    // 封装http请求数据
    UAVHttpMessage message = new UAVHttpMessage();
    message.putRequest("mgo.sql", JSONHelper.toString(requestParam));
    message.putRequest("datastore.name", "MT_Notify");
    message.putRequest("mgo.coll.name", "uav_notify");
    NoitifyDescQueryCB callback = new NoitifyDescQueryCB();
    callback.setResponse(response);
    callback.setNtfkey(ntfkey);
    callback.setTime(time);
    doHttpPost("uav.app.godeye.healthmanager.http.addr", "/hm/query", message, callback);
}
Also used : BASE64DecoderUrl(com.creditease.uav.helpers.url.BASE64DecoderUrl) HashMap(java.util.HashMap) UAVHttpMessage(com.creditease.agent.http.api.UAVHttpMessage) SimpleDateFormat(java.text.SimpleDateFormat) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

UAVHttpMessage (com.creditease.agent.http.api.UAVHttpMessage)2 BASE64DecoderUrl (com.creditease.uav.helpers.url.BASE64DecoderUrl)2 SimpleDateFormat (java.text.SimpleDateFormat)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 HashMap (java.util.HashMap)1 HttpSession (javax.servlet.http.HttpSession)1