use of beans.dbaccess.LibraryFile in project MSEC by Tencent.
the class DelLibraryFile method deleteAll.
public static String deleteAll(String flsn, String slsn) {
DBUtil util = new DBUtil();
if (util.getConnection() == null) {
return "DB connect failed.";
}
try {
String sql = "select file_name from t_library_file where first_level_service_name=? and second_level_service_name=?";
List<Object> params = new ArrayList<Object>();
params.add(flsn);
params.add(slsn);
ArrayList<LibraryFile> result = util.findMoreRefResult(sql, params, LibraryFile.class);
for (int i = 0; i < result.size(); i++) {
String file_name = result.get(i).getFile_name();
sql = "delete from t_library_file where file_name=? and first_level_service_name=? and second_level_service_name=?";
params = new ArrayList<Object>();
params.add(file_name);
params.add(flsn);
params.add(slsn);
//删除数据库记录
int delNum = util.updateByPreparedStatement(sql, params);
String filename = LibraryFile.getLibraryFileName(flsn, slsn, file_name);
RemoveFile(filename);
}
return "success";
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
} finally {
util.releaseConn();
}
}
use of beans.dbaccess.LibraryFile in project MSEC by Tencent.
the class PackDevFile method getLibraryFilesFromDB.
private ArrayList<LibraryFile> getLibraryFilesFromDB(String flsn, String slsn) {
Logger logger = Logger.getLogger(PackDevFile.class);
DBUtil util = new DBUtil();
if (util.getConnection() == null) {
return null;
}
try {
String sql = "select file_name from t_library_file where first_level_service_name=? and second_level_service_name=?";
List<Object> params = new ArrayList<Object>();
params.add(flsn);
params.add(slsn);
ArrayList<LibraryFile> ret = util.findMoreRefResult(sql, params, LibraryFile.class);
logger.info("get library files from db, file number:" + ret.size());
return ret;
} catch (Exception e) {
e.printStackTrace();
logger.error(e.toString());
return null;
} finally {
util.releaseConn();
}
}
use of beans.dbaccess.LibraryFile in project MSEC by Tencent.
the class PackDevFile method copyLibraryFile.
private void copyLibraryFile(String baseDir) throws Exception {
Logger logger = Logger.getLogger(PackDevFile.class);
ArrayList<LibraryFile> libraryFiles = getLibraryFilesFromDB(pack.getFirst_level_service_name(), pack.getSecond_level_service_name());
for (int i = 0; i < libraryFiles.size(); i++) {
String destFile = baseDir + "/lib/" + libraryFiles.get(i).getFile_name();
String srcFile = LibraryFile.getLibraryFileName(pack.getFirst_level_service_name(), pack.getSecond_level_service_name(), libraryFiles.get(i).getFile_name());
if (copyFile(new File(srcFile), new File(destFile))) {
logger.info("copy file successfully." + srcFile + " " + destFile);
continue;
} else {
logger.error("failed to copy file:" + srcFile + " " + destFile);
throw new Exception("failed to copy file:" + srcFile + " " + destFile);
}
}
}
use of beans.dbaccess.LibraryFile in project MSEC by Tencent.
the class PackReleaseFile method getLibraryFilesFromDB.
private ArrayList<LibraryFile> getLibraryFilesFromDB(String flsn, String slsn) {
Logger logger = Logger.getLogger(PackReleaseFile.class);
DBUtil util = new DBUtil();
if (util.getConnection() == null) {
return null;
}
try {
String sql = "select file_name from t_library_file where first_level_service_name=? and second_level_service_name=?";
List<Object> params = new ArrayList<Object>();
params.add(flsn);
params.add(slsn);
ArrayList<LibraryFile> ret = util.findMoreRefResult(sql, params, LibraryFile.class);
logger.info("get library file list:" + ret.size());
return ret;
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
return null;
} finally {
util.releaseConn();
}
}
use of beans.dbaccess.LibraryFile in project MSEC by Tencent.
the class PackReleaseFile method copyLibraryFile.
private void copyLibraryFile(String baseDir) throws Exception {
Logger logger = Logger.getLogger(PackReleaseFile.class);
ArrayList<LibraryFile> libraryFiles = getLibraryFilesFromDB(plan.getFirst_level_service_name(), plan.getSecond_level_service_name());
if (libraryFiles == null) {
throw new Exception("getLibraryFilesFromDB() failed");
}
for (int i = 0; i < libraryFiles.size(); i++) {
String destFile = baseDir + "/bin/lib/" + libraryFiles.get(i).getFile_name();
String srcFile = LibraryFile.getLibraryFileName(plan.getFirst_level_service_name(), plan.getSecond_level_service_name(), libraryFiles.get(i).getFile_name());
if (!copyFile(new File(srcFile), new File(destFile))) {
throw new Exception("failed to copy file:" + srcFile + " " + destFile);
}
}
}
Aggregations