use of beans.response.DelLibraryFileResponse in project MSEC by Tencent.
the class DelLibraryFile method exec.
public DelLibraryFileResponse exec(LibraryFile request) {
Logger logger = Logger.getLogger(this.getClass().getName());
DelLibraryFileResponse response = new DelLibraryFileResponse();
response.setMessage("unkown error.");
response.setStatus(100);
String result = checkIdentity();
if (!result.equals("success")) {
response.setStatus(99);
response.setMessage(result);
return response;
}
if (request.getFile_name() == null || request.getFile_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("file 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_library_file where file_name=? and first_level_service_name=? and second_level_service_name=?";
List<Object> params = new ArrayList<Object>();
params.add(request.getFile_name());
params.add(request.getFirst_level_service_name());
params.add(request.getSecond_level_service_name());
try {
int delNum = util.updateByPreparedStatement(sql, params);
String filename = LibraryFile.getLibraryFileName(request.getFirst_level_service_name(), request.getSecond_level_service_name(), request.getFile_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();
}
}
Aggregations