use of com.varsql.core.exception.VarsqlRuntimeException in project varsql by varsqlinfo.
the class SQLManager method setSQLMapper.
public void setSQLMapper(ConnectionInfo connInfo, Object obj) {
try {
if (!(obj instanceof ConnectionFactory || obj instanceof SQLManager)) {
logger.error("SQLManager setSQLMapper access denied object {}", obj);
throw new VarsqlRuntimeException(VarsqlAppCode.EC_DB_POOL, "SQLManager setSQLMapper access denied object " + obj);
}
SqlSessionFactory sqlSessionFactory = sqlSessionFactory(connInfo).getObject();
try (Connection connChk = sqlSessionFactory.openSession().getConnection()) {
JdbcUtils.close(connChk);
}
sqlSessionFactoryMap.put(connInfo.getConnid(), sqlSessionFactory);
sqlSessionMap.put(connInfo.getConnid(), new SqlSessionTemplate(sqlSessionFactory));
} catch (Exception e) {
logger.error("connection info : {} ", VartechReflectionUtils.reflectionToString(connInfo));
logger.error("SQLManager :{} ", e.getMessage(), e);
throw new ConnectionException("getSqlSession IOException " + e.getMessage(), e);
}
}
use of com.varsql.core.exception.VarsqlRuntimeException in project varsql by varsqlinfo.
the class FileUploadService method uploadFiles.
public List<FileInfoEntity> uploadFiles(UploadFileType fileType, List<MultipartFile> files, String fileContId, String contGroupId, String fieldName, boolean addExtensionSuffix, boolean fileInfoSaveFlag) {
List<FileInfoEntity> fileInfos = new ArrayList<FileInfoEntity>();
files.forEach(file -> {
if (!(file.getSize() <= 0 && "blob".equals(file.getOriginalFilename()))) {
try {
FileInfoEntity fileInfo = saveFile(fileType, file, fileContId, addExtensionSuffix);
fileInfo.setFileContId(fileContId);
fileInfo.setFileFieldName(fieldName);
fileInfo.setContGroupId(contGroupId);
fileInfos.add(fileInfo);
} catch (IllegalStateException | IOException e) {
logger.error("file upload exception : {}", e.getMessage(), e);
throw new VarsqlRuntimeException(VarsqlAppCode.COMM_FILE_UPLOAD_ERROR, "file upload error", e);
}
}
});
if (fileInfoSaveFlag) {
fileInfoEntityRepository.saveAll(fileInfos);
}
return fileInfos;
}
use of com.varsql.core.exception.VarsqlRuntimeException in project varsql by varsqlinfo.
the class SQLTemplateFactory method sqlRender.
/**
* @Method Name : sqlRender
* @Method 설명 : query render
* @작성일 : 2018. 6. 12.
* @작성자 : ytkim
* @변경이력 :
* @param dbVender
* @param templateId
* @param param
* @return
*/
public String sqlRender(DBType dbType, SQLTemplateEnum code, Map param) {
String dbVender = dbType.getDbVenderName();
String templateId = code.getTemplateId();
Template template = getDDLTemplate(dbVender, templateId);
if (template == null) {
throw new VarsqlRuntimeException(VarsqlAppCode.EC_TEMPLATE_CONFIGURATION, new StringBuilder().append("sqlRender template ").append("dbVender : [").append(dbVender).append("] templateId : [").append(templateId).append("] template : [").append(template).append("]").toString());
}
try {
return template.apply(param);
} catch (IOException e) {
logger.error("sqlRender IOException : {} ", e.getMessage(), e);
}
return "";
}
use of com.varsql.core.exception.VarsqlRuntimeException in project varsql by varsqlinfo.
the class DriverProvierMgmtServiceImpl method uploadDriverFiles.
private List<DBTypeDriverFileEntity> uploadDriverFiles(List<MultipartFile> files, String fileContId) {
final UploadFileType fileType = UploadFileType.JDBC_DIRVER;
List<DBTypeDriverFileEntity> fileInfos = new ArrayList<DBTypeDriverFileEntity>();
files.forEach(file -> {
if (!(file.getSize() <= 0 && "blob".equals(file.getOriginalFilename()))) {
try {
String filePath = FileServiceUtils.getSaveRelativePath(fileType, fileContId);
// 파일 원본명
String fileName = FileUtils.normalize(file.getOriginalFilename());
// 파일 확장자 구하기
String extension = FileUtils.extension(fileName);
String fileId = VartechUtils.generateUUID();
if (fileType.isOrginFileName()) {
filePath = FileUtils.pathConcat(filePath, fileName);
} else {
filePath = FileUtils.pathConcat(filePath, String.format("%s.%s", fileId, extension));
}
Path createFilePath = FileServiceUtils.getPath(filePath);
file.transferTo(createFilePath);
fileInfos.add(DBTypeDriverFileEntity.builder().fileDiv(fileType.getDiv()).fileId(fileId).fileName(fileName).fileSize(file.getSize()).fileExt(extension).fileContId(fileContId).filePath(filePath).build());
} catch (IllegalStateException | IOException e) {
logger.error("file upload exception : {}", e.getMessage(), e);
throw new VarsqlRuntimeException(VarsqlAppCode.COMM_FILE_UPLOAD_ERROR, "file upload error", e);
}
}
});
dbTypeDriverFileEntityRepository.saveAll(fileInfos);
return fileInfos;
}
Aggregations