Search in sources :

Example 1 with ReleasePlan

use of beans.request.ReleasePlan in project MSEC by Tencent.

the class ReleaseOnlySharedobject method doRelease.

private ReleaseStepsGOResponse doRelease(ReleasePlan request) {
    ReleaseStepsGOResponse response = new ReleaseStepsGOResponse();
    //把计划保存到session里
    HttpSession session = getHttpRequest().getSession();
    ReleasePlan plan = (ReleasePlan) session.getAttribute("plan");
    if (plan == null) {
        response.setMessage("can NOT find the session, it maybe timeout.");
        response.setStatus(100);
        return response;
    }
    //System.out.println("plan id in session:"+plan.getPlan_id());
    if (request.getSharedobject_tag() == null || request.getSharedobject_tag().length() < 1) {
        response.setMessage("idl tag is empty!");
        response.setStatus(100);
        return response;
    }
    plan.setSharedobject_tag(request.getSharedobject_tag());
    plan.setMemo(request.getMemo());
    //check if saved
    ReleasePlan plan2 = (ReleasePlan) session.getAttribute("plan");
    //System.out.println("so tag:"+plan2.getSharedobject_tag());
    // Commit Plan
    String commitResult = CommitPlan(plan2);
    if (commitResult == null || !commitResult.equals("success")) {
        response.setMessage("commit failed:" + (commitResult == null ? "" : commitResult));
        response.setStatus(100);
        return response;
    }
    response.setPlanDetail(plan2);
    response.setMessage("success");
    response.setStatus(0);
    return response;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ReleaseStepsGOResponse(beans.response.ReleaseStepsGOResponse) ReleasePlan(beans.request.ReleasePlan)

Example 2 with ReleasePlan

use of beans.request.ReleasePlan in project MSEC by Tencent.

the class ReleaseStepsGO method doStep5.

private ReleaseStepsGOResponse doStep5(ReleasePlan request) {
    ReleaseStepsGOResponse response = new ReleaseStepsGOResponse();
    //把计划保存到session里
    HttpSession session = getHttpRequest().getSession();
    ReleasePlan plan = (ReleasePlan) session.getAttribute("plan");
    if (plan == null) {
        response.setMessage("can NOT find the session, it maybe timeout.");
        response.setStatus(100);
        return response;
    }
    //System.out.println("plan id in session:"+plan.getPlan_id());
    if (request.getSharedobject_tag() == null || request.getSharedobject_tag().length() < 1) {
        response.setMessage("idl tag is empty!");
        response.setStatus(100);
        return response;
    }
    plan.setSharedobject_tag(request.getSharedobject_tag());
    plan.setMemo(request.getMemo());
    //跳过第三步:选择IDL文件版本,所以在这里设置一下
    plan.setIdl_tag("");
    //check if saved
    ReleasePlan plan2 = (ReleasePlan) session.getAttribute("plan");
    //System.out.println("so tag:"+plan2.getSharedobject_tag());
    // Commit Plan
    String commitResult = CommitPlan(plan2);
    if (commitResult == null || !commitResult.equals("success")) {
        response.setMessage("commit failed:" + (commitResult == null ? "" : commitResult));
        response.setStatus(100);
        return response;
    }
    response.setPlanDetail(plan2);
    response.setMessage("success");
    response.setStatus(0);
    return response;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ReleaseStepsGOResponse(beans.response.ReleaseStepsGOResponse) ReleasePlan(beans.request.ReleasePlan)

Example 3 with ReleasePlan

use of beans.request.ReleasePlan in project MSEC by Tencent.

the class ReleaseStepsGO method doStep3.

private ReleaseStepsGOResponse doStep3(ReleasePlan request) {
    ReleaseStepsGOResponse response = new ReleaseStepsGOResponse();
    //把计划保存到session里
    HttpSession session = getHttpRequest().getSession();
    ReleasePlan plan = (ReleasePlan) session.getAttribute("plan");
    if (plan == null) {
        response.setMessage("can NOT find the session, it maybe timeout.");
        response.setStatus(100);
        return response;
    }
    //System.out.println("plan id in session:" + plan.getPlan_id());
    if (request.getIdl_tag() == null || request.getIdl_tag().length() < 1) {
        response.setMessage("idl tag is empty!");
        response.setStatus(100);
        return response;
    }
    plan.setIdl_tag(request.getIdl_tag());
    //check if saved
    ReleasePlan plan2 = (ReleasePlan) session.getAttribute("plan");
    //System.out.println("idl tag:" + plan2.getIdl_tag());
    response.setMessage("success");
    response.setStatus(0);
    return response;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ReleaseStepsGOResponse(beans.response.ReleaseStepsGOResponse) ReleasePlan(beans.request.ReleasePlan)

Example 4 with ReleasePlan

use of beans.request.ReleasePlan in project MSEC by Tencent.

the class QueryReleasePlan method exec.

public QueryReleasePlanResponse exec(ReleasePlan request) {
    QueryReleasePlanResponse resp = new QueryReleasePlanResponse();
    String result = checkIdentity();
    if (!result.equals("success")) {
        resp.setStatus(99);
        resp.setMessage(result);
        return resp;
    }
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        resp.setStatus(100);
        resp.setMessage("db connect failed!");
        return resp;
    }
    List<ReleasePlan> planList;
    String sql = "select plan_id, first_level_service_name,second_level_service_name," + "config_tag,idl_tag, sharedobject_tag, status,memo,backend_task_status from t_release_plan ";
    List<Object> params = new ArrayList<Object>();
    boolean hasWhere = false;
    if (request.getPlan_id() != null && request.getPlan_id().length() > 0) {
        sql += " where plan_id like ? ";
        params.add(request.getPlan_id());
        hasWhere = true;
    }
    String flsn = request.getFirst_level_service_name();
    String slsn = request.getSecond_level_service_name();
    if (flsn != null && flsn.length() > 0 && slsn != null && slsn.length() > 0) {
        if (hasWhere) {
            sql = sql + " and first_level_service_name=? and second_level_service_name=? ";
        } else {
            sql = sql + " where first_level_service_name=? and second_level_service_name=? ";
        }
        hasWhere = true;
        params.add(flsn);
        params.add(slsn);
    }
    sql = sql + " order by plan_id desc";
    try {
        planList = util.findMoreRefResult(sql, params, ReleasePlan.class);
    } catch (Exception e) {
        resp.setStatus(100);
        resp.setMessage("db query exception!");
        e.printStackTrace();
        return resp;
    } finally {
        util.releaseConn();
    }
    resp.setPlan_list((ArrayList<ReleasePlan>) planList);
    resp.setMessage("success");
    resp.setStatus(0);
    return resp;
}
Also used : DBUtil(ngse.org.DBUtil) QueryReleasePlanResponse(beans.response.QueryReleasePlanResponse) ArrayList(java.util.ArrayList) ReleasePlan(beans.request.ReleasePlan)

Example 5 with ReleasePlan

use of beans.request.ReleasePlan in project MSEC by Tencent.

the class QueryReleasePlanDetail method exec.

public QueryReleasePlanDetailResponse exec(ReleasePlan request) {
    QueryReleasePlanDetailResponse resp = new QueryReleasePlanDetailResponse();
    String result = checkIdentity();
    if (!result.equals("success")) {
        resp.setStatus(99);
        resp.setMessage(result);
        return resp;
    }
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        resp.setStatus(100);
        resp.setMessage("db connect failed!");
        return resp;
    }
    List<ReleasePlan> planList;
    try {
        String sql = "select plan_id, first_level_service_name,second_level_service_name," + "config_tag,idl_tag, sharedobject_tag, status,memo,backend_task_status " + "from t_release_plan where plan_id=?";
        List<Object> params = new ArrayList<Object>();
        params.add(request.getPlan_id());
        planList = util.findMoreRefResult(sql, params, ReleasePlan.class);
        if (planList.size() != 1) {
            resp.setStatus(100);
            resp.setMessage("Plan does NOT exist.");
            return resp;
        }
        resp.setDetail(planList.get(0));
        ReleasePlan detail = resp.getDetail();
        sql = "select dest_ip_list from t_release_plan where plan_id=?";
        params = new ArrayList<Object>();
        params.add(request.getPlan_id());
        Map<String, Object> res = util.findSimpleResult(sql, params);
        if (res.get("dest_ip_list") == null) {
            resp.setStatus(100);
            resp.setMessage("query dest ip list failed.");
            return resp;
        }
        String dest_ip_list = (String) (res.get("dest_ip_list"));
        ObjectMapper objectMapper = new ObjectMapper();
        Object o = objectMapper.readValue(dest_ip_list, new ArrayList<IPPortPair>().getClass());
        detail.setDest_ip_list((ArrayList<IPPortPair>) o);
    } catch (Exception e) {
        resp.setStatus(100);
        resp.setMessage("db query exception!");
        e.printStackTrace();
        return resp;
    } finally {
        util.releaseConn();
    }
    resp.setMessage("success");
    resp.setStatus(0);
    return resp;
}
Also used : ArrayList(java.util.ArrayList) QueryReleasePlanDetailResponse(beans.response.QueryReleasePlanDetailResponse) ReleasePlan(beans.request.ReleasePlan) DBUtil(ngse.org.DBUtil) IPPortPair(beans.request.IPPortPair) JSONObject(org.json.JSONObject) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Aggregations

ReleasePlan (beans.request.ReleasePlan)8 ReleaseStepsGOResponse (beans.response.ReleaseStepsGOResponse)6 HttpSession (javax.servlet.http.HttpSession)6 ArrayList (java.util.ArrayList)2 DBUtil (ngse.org.DBUtil)2 IPPortPair (beans.request.IPPortPair)1 QueryReleasePlanDetailResponse (beans.response.QueryReleasePlanDetailResponse)1 QueryReleasePlanResponse (beans.response.QueryReleasePlanResponse)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 JSONObject (org.json.JSONObject)1