Search in sources :

Example 1 with DelIDLTagResponse

use of beans.response.DelIDLTagResponse in project MSEC by Tencent.

the class DelIDLTag method exec.

public DelIDLTagResponse exec(IDL request) {
    Logger logger = Logger.getLogger(this.getClass().getName());
    DelIDLTagResponse response = new DelIDLTagResponse();
    response.setMessage("unkown error.");
    response.setStatus(100);
    String result = checkIdentity();
    if (!result.equals("success")) {
        response.setStatus(99);
        response.setMessage(result);
        return response;
    }
    if (request.getTag_name() == null || request.getTag_name().equals("") || request.getSecond_level_service_name() == null || request.getSecond_level_service_name().equals("") || request.getFirst_level_service_name() == null || request.getFirst_level_service_name().equals("")) {
        response.setMessage("tag name and service name  should NOT be empty.");
        response.setStatus(100);
        return response;
    }
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        response.setMessage("DB connect failed.");
        response.setStatus(100);
        return response;
    }
    String sql = "delete from t_idl_tag where tag_name=? and first_level_service_name=? and second_level_service_name=?";
    List<Object> params = new ArrayList<Object>();
    params.add(request.getTag_name());
    params.add(request.getFirst_level_service_name());
    params.add(request.getSecond_level_service_name());
    try {
        //删除数据库记录
        int delNum = util.updateByPreparedStatement(sql, params);
        String filename = IDL.getIDLFileName(request.getFirst_level_service_name(), request.getSecond_level_service_name(), request.getTag_name());
        //删除文件
        logger.error("delte file:" + filename);
        RemoveFile(filename);
        if (delNum > 0) {
            response.setMessage("success");
            response.setDelNumber(delNum);
            response.setStatus(0);
            return response;
        } else {
            response.setMessage("delete record number is " + delNum);
            response.setDelNumber(delNum);
            response.setStatus(100);
            return response;
        }
    } catch (SQLException e) {
        response.setMessage("Delete record failed:" + e.toString());
        response.setStatus(100);
        e.printStackTrace();
        return response;
    } finally {
        util.releaseConn();
    }
}
Also used : DBUtil(ngse.org.DBUtil) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) DelIDLTagResponse(beans.response.DelIDLTagResponse) Logger(org.apache.log4j.Logger)

Aggregations

DelIDLTagResponse (beans.response.DelIDLTagResponse)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 DBUtil (ngse.org.DBUtil)1 Logger (org.apache.log4j.Logger)1