init
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
package com.eactive.eai.rms.common.cm;
|
||||
|
||||
import com.eactive.eai.rms.common.cm.ui.CmLogDetailUI;
|
||||
import com.eactive.eai.rms.common.cm.ui.CmLogUI;
|
||||
import com.eactive.eai.rms.common.cm.ui.CmLogUISearch;
|
||||
import com.eactive.eai.rms.common.combo.ComboService;
|
||||
import com.eactive.eai.rms.common.combo.IbatisComboService;
|
||||
import com.eactive.eai.rms.common.datasource.DataSourceType;
|
||||
import com.eactive.eai.rms.common.datasource.DataSourceTypeManager;
|
||||
import com.eactive.eai.rms.common.spring.BaseController;
|
||||
import com.eactive.eai.rms.common.vo.GridResponse;
|
||||
import com.eactive.eai.rms.common.vo.JsonPageVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
//import com.eactive.eai.rms.ext.kakaocard.cm.KakaoCardCmFlagDao;
|
||||
|
||||
@Controller
|
||||
public class CmLogController extends BaseController {
|
||||
|
||||
@Autowired private ComboService comboService;
|
||||
@Autowired private CmLogService cmLogService;
|
||||
|
||||
@Autowired
|
||||
private IbatisComboService ibatisComboService;
|
||||
|
||||
@GetMapping(value = "/common/acl/cmLog/cmLog.view")
|
||||
public String view() {
|
||||
return "/common/acl/cmLog/cmLog";
|
||||
}
|
||||
|
||||
@GetMapping(value = "/common/acl/cmLog/cmLog.view", params = "cmd=DETAIL")
|
||||
public String viewDetail() {
|
||||
return "/common/acl/cmLog/cmLogDetail";
|
||||
}
|
||||
|
||||
// @PostMapping(value= "/common/acl/cmLog/cmLog.view")
|
||||
// public String viewList(HttpServletRequest request, @RequestParam(value = "cmd", required = false ) String cmd) throws Exception {
|
||||
// if (cmd == null || "LIST".equals(cmd.toUpperCase())){
|
||||
// cmd = "";
|
||||
// }else {
|
||||
// cmd = CamelCaseUtil.converCamelCase(cmd);
|
||||
// }
|
||||
// String path = request.getServletPath();
|
||||
// return path.split("[.]")[0]+cmd;
|
||||
// }
|
||||
|
||||
@PostMapping(value= "/common/acl/cmLog/cmLog.json", params = "cmd=LIST_INIT_COMBO")
|
||||
public ResponseEntity<Map<String, Object>> initCombo() throws Exception {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
|
||||
resultMap.put("ynCombo", comboService.getFromCode("YN"));
|
||||
resultMap.put("serviceTypeCombo", serviceTypeCombo());
|
||||
resultMap.put("bzwkNameCombo", ibatisComboService.selectListComboForTable("TSEAICM01", "EAIBZWKDSTCD","BZWKDSTICNAME", "", "EAIBZWKDSTCD"));
|
||||
|
||||
return ResponseEntity.ok(resultMap);
|
||||
}
|
||||
|
||||
|
||||
private List<Map<String, Object>> serviceTypeCombo() {
|
||||
List<DataSourceType> onlineDataSourceTypes = DataSourceTypeManager.getOnlineDataSourceTypes();
|
||||
List<Map<String, Object>> comboList = onlineDataSourceTypes.stream().map(d -> new HashMap<String, Object>(){{ put("CODE", d.getName()); put("NAME", d.getName()); }}).collect(Collectors.toList());
|
||||
comboList.add(new HashMap<String, Object>() {{put("CODE", "BAT"); put("NAME", "BAT");}});
|
||||
comboList.add(new HashMap<String, Object>() {{put("CODE", "BAP"); put("NAME", "BAP");}});
|
||||
return comboList;
|
||||
}
|
||||
|
||||
@PostMapping(value= "/common/acl/cmLog/cmLog.json", params = "cmd=LIST")
|
||||
public ResponseEntity<GridResponse<CmLogUI>> selectList(CmLogUISearch cmLogUISearch, Pageable pageable) throws Exception {
|
||||
|
||||
Page<CmLogUI> page = cmLogService.selectList(cmLogUISearch, pageable);
|
||||
return ResponseEntity.ok(new GridResponse<>(page));
|
||||
}
|
||||
|
||||
@PostMapping(value= "/common/acl/cmLog/cmLog.json", params = "cmd=LIST_FLAG")
|
||||
public @ResponseBody GridResponse<Object> selectListFlag(JsonPageVo pageVo, @RequestParam Map<String, String> paramMap) throws Exception {
|
||||
|
||||
// String commitId = getValueOrEmpty(paramMap.get("pop_searchDeployId"));
|
||||
// String serviceType = getValueOrEmpty(paramMap.get("pop_searchServiceType"));
|
||||
// Flag flag = StringUtils.isNotBlank(paramMap.get("pop_searchFlag")) ? Flag.valueOf(paramMap.get("pop_searchFlag")) : null;
|
||||
//
|
||||
// DataSourceContextHolder.setDataSourceType(DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.MONITORING));
|
||||
//
|
||||
// PageRequest pageable = PageRequest.of(pageVo.getPage()-1, pageVo.getRows());
|
||||
// Page<CmFlagEntity> pageableEntity = null;
|
||||
// if(flag == null) {
|
||||
// pageableEntity = cmFlagDao.findByCmFlagKeyCommitIdContainingAndCmFlagKeyServiceTypeContaining(commitId, serviceType, pageable);
|
||||
// } else {
|
||||
// pageableEntity = cmFlagDao.findByCmFlagKeyCommitIdContainingAndCmFlagKeyServiceTypeContainingAndFlag(commitId, serviceType, flag, pageable);
|
||||
// }
|
||||
|
||||
// GridResponse<CmFlagEntity> gridResponse = new GridResponse<>();
|
||||
// gridResponse.setTotal(pageableEntity.getTotalPages());
|
||||
// gridResponse.setPage(pageableEntity.getNumber()+1);
|
||||
// gridResponse.setRecords(Long.valueOf(pageableEntity.getTotalElements()).intValue());
|
||||
// gridResponse.setRows(pageableEntity.getContent());
|
||||
|
||||
// return gridResponse;
|
||||
return new GridResponse<>();
|
||||
}
|
||||
|
||||
@PostMapping(value = "/common/acl/cmLog/cmLog.json", params = "cmd=LIST_BUCKET")
|
||||
public @ResponseBody GridResponse<Map<String, Object>> retriveFiles(@RequestParam Map<String, String> paramMap) {
|
||||
|
||||
if (System.getProperty("eai.datasource.type").equals("LOCAL")) {
|
||||
GridResponse<Map<String, Object>> localTemp = new GridResponse<Map<String, Object>>() {{setRows(new ArrayList<>());}};
|
||||
return localTemp;
|
||||
} else {
|
||||
GridResponse<Map<String, Object>> bucketFileListGrid = cmLogService.bucketFileList(paramMap);
|
||||
return bucketFileListGrid;
|
||||
}
|
||||
}
|
||||
|
||||
final static Pattern pattern = Pattern.compile("[^/]+$");
|
||||
|
||||
@PostMapping(value = "/common/acl/cmLog/cmLog.json", params = "cmd=DETAIL_S3_DOWNLOAD")
|
||||
public ResponseEntity<Object> downloadFile(String objectKey) {
|
||||
|
||||
try {
|
||||
String fileName = "";
|
||||
Matcher matcher = pattern.matcher(objectKey);
|
||||
|
||||
if (matcher.find()) {
|
||||
fileName = matcher.group();
|
||||
} else {
|
||||
fileName = "errorParseFileName";
|
||||
}
|
||||
|
||||
return ResponseEntity.ok().header("Content-Disposition", "attachment; filename=" + fileName).body(cmLogService.getFileContent(objectKey));
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
logger.error(e);
|
||||
return ResponseEntity.internalServerError().contentType(new MediaType("text", "plain", StandardCharsets.UTF_8)).body(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping(value= "/common/acl/cmLog/cmLog.json", params = "cmd=DETAIL")
|
||||
public ResponseEntity<GridResponse<CmLogDetailUI>> selectDetailList(CmLogUISearch cmLogUISearch, Pageable pageable) throws Exception {
|
||||
|
||||
Page<CmLogDetailUI> page = cmLogService.selectDetailList(cmLogUISearch, pageable);
|
||||
// Map<String, Object> map = cmLogService.selectDetailList(pageVo.getStartNum(), pageVo.getEndNum(), paramMap);
|
||||
|
||||
return ResponseEntity.ok(new GridResponse<>(page));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
package com.eactive.eai.rms.common.cm;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.eactive.eai.rms.bat.loader.service.TransactionLoaderServiceImpl;
|
||||
import com.eactive.eai.rms.common.cm.mapping.CmLogDetailUIMapper;
|
||||
import com.eactive.eai.rms.common.cm.mapping.CmLogUIMapper;
|
||||
import com.eactive.eai.rms.common.cm.ui.CmLogDetailUI;
|
||||
import com.eactive.eai.rms.common.cm.ui.CmLogUI;
|
||||
import com.eactive.eai.rms.common.cm.ui.CmLogUISearch;
|
||||
import com.eactive.eai.rms.common.context.MonitoringContext;
|
||||
import com.eactive.eai.rms.common.vo.GridResponse;
|
||||
import com.eactive.eai.rms.data.entity.man.cm.CmLogDetailEntity;
|
||||
import com.eactive.eai.rms.data.entity.man.cm.CmLogDetailEntityId;
|
||||
import com.eactive.eai.rms.data.entity.man.cm.CmLogDetailEntityService;
|
||||
import com.eactive.eai.rms.data.entity.man.cm.CmLogEntity;
|
||||
import com.eactive.eai.rms.data.entity.man.cm.CmLogEntityService;
|
||||
import com.eactive.eai.rms.onl.common.util.FileWriteUtil;
|
||||
|
||||
import software.amazon.awssdk.core.ResponseBytes;
|
||||
import software.amazon.awssdk.services.s3.S3Client;
|
||||
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
|
||||
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
|
||||
import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
|
||||
import software.amazon.awssdk.services.s3.model.ListObjectsV2Response;
|
||||
import software.amazon.awssdk.services.s3.model.S3Object;
|
||||
|
||||
@Service
|
||||
@Transactional(transactionManager = "transactionManagerForEMS")
|
||||
public class CmLogService {
|
||||
|
||||
private static final Logger logger = Logger.getLogger("DYNAMIC_LOGGER");
|
||||
|
||||
public static final String DEPOLY_SUCCESS = "Y";
|
||||
public static final String DEPOLY_FAIL = "N";
|
||||
|
||||
/** The monitoring context. */
|
||||
@Autowired
|
||||
@Qualifier("monitoringContext")
|
||||
private transient MonitoringContext monitoringContext;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("batLoaderService")
|
||||
private TransactionLoaderServiceImpl loaderService;
|
||||
|
||||
// @Autowired private CmLogDao dao;
|
||||
|
||||
@Autowired private S3Client s3Client;
|
||||
|
||||
@Autowired
|
||||
private CmLogEntityService cmLogEntityService;
|
||||
|
||||
@Autowired
|
||||
private CmLogDetailEntityService cmLogDetailEntityService;
|
||||
|
||||
@Autowired
|
||||
private CmLogUIMapper cmLogUIMapper;
|
||||
|
||||
@Autowired
|
||||
private CmLogDetailUIMapper cmLogDetailUIMapper;
|
||||
|
||||
public void insertLog(CmLogEntity cmLogEntity, String path) throws Exception {
|
||||
|
||||
logger.debug("CmLogService] Insert CM log to RM37");
|
||||
|
||||
cmLogEntityService.save(cmLogEntity);
|
||||
|
||||
if ("ALL".equals(cmLogEntity.getAppl_cd())) {
|
||||
|
||||
String deployIdPath = path + cmLogEntity.getService_type() + File.separator + cmLogEntity.getDeploy_id();
|
||||
List<String> appCodesFromDirectory = getAppCodesFromDirectory(Paths.get(deployIdPath), cmLogEntity.getRollback_yn());
|
||||
|
||||
for(String appCode : appCodesFromDirectory) {
|
||||
String fullPath = path + cmLogEntity.getService_type() + File.separator + cmLogEntity.getDeploy_id() + File.separator + appCode;
|
||||
|
||||
String layoutPath = fullPath + File.separator + FileWriteUtil.LAYOUT + File.separator;
|
||||
String transformPath = fullPath + File.separator + FileWriteUtil.TRANSFORM + File.separator;
|
||||
String interfacePath = fullPath + File.separator + FileWriteUtil.INTERFACE + File.separator;
|
||||
String bapPath = fullPath + File.separator + FileWriteUtil.BAP_CM_DIR+ File.separator;
|
||||
|
||||
logger.debug("CmLogService] Insert CM detail log to RM38");
|
||||
if("MCT".equals(cmLogEntity.getService_type())) {
|
||||
detailFilesLogging(cmLogEntity.getGuid(), layoutPath, path, "^.{4}T");
|
||||
} else if("BAP".equals(cmLogEntity.getService_type())) {
|
||||
detailFilesLogging(cmLogEntity.getGuid(), bapPath, path);
|
||||
} else {
|
||||
detailFilesLogging(cmLogEntity.getGuid(), layoutPath, path);
|
||||
detailFilesLogging(cmLogEntity.getGuid(), transformPath, path);
|
||||
detailFilesLogging(cmLogEntity.getGuid(), interfacePath, path);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
String fullPath = path + cmLogEntity.getService_type() + File.separator + cmLogEntity.getDeploy_id() + File.separator + cmLogEntity.getAppl_cd();
|
||||
|
||||
String layoutPath = fullPath + File.separator + FileWriteUtil.LAYOUT + File.separator;
|
||||
String transformPath = fullPath + File.separator + FileWriteUtil.TRANSFORM + File.separator;
|
||||
String interfacePath = fullPath + File.separator + FileWriteUtil.INTERFACE + File.separator;
|
||||
String bapPath = fullPath + File.separator + FileWriteUtil.BAP_CM_DIR+ File.separator;
|
||||
|
||||
logger.debug("CmLogService] Insert CM detail log to RM38");
|
||||
if("MCT".equals(cmLogEntity.getService_type())) {
|
||||
detailFilesLogging(cmLogEntity.getGuid(), layoutPath, path, "^.{4}T");
|
||||
} else if("BAP".equals(cmLogEntity.getService_type())) {
|
||||
detailFilesLogging(cmLogEntity.getGuid(), bapPath, path);
|
||||
} else {
|
||||
detailFilesLogging(cmLogEntity.getGuid(), layoutPath, path);
|
||||
detailFilesLogging(cmLogEntity.getGuid(), transformPath, path);
|
||||
detailFilesLogging(cmLogEntity.getGuid(), interfacePath, path);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void detailFilesLogging(String guid, String path, String shouldBeDeletedOnPath) throws Exception {
|
||||
|
||||
File files = new File(path);
|
||||
|
||||
String[] fileNames = files.list();
|
||||
if(fileNames == null) {return;}
|
||||
|
||||
for(String fileName : fileNames) {
|
||||
|
||||
Path resourcePath = Paths.get(path+fileName);
|
||||
byte[] fileContentByte = Files.readAllBytes(resourcePath);
|
||||
String fileContent = new String(fileContentByte, StandardCharsets.UTF_8);
|
||||
|
||||
CmLogDetailEntity cmLogDetailEntity = new CmLogDetailEntity();
|
||||
CmLogDetailEntityId cmLogDetailEntityId = new CmLogDetailEntityId();
|
||||
|
||||
cmLogDetailEntityId.setGuid(guid);
|
||||
cmLogDetailEntityId.setResource_path(StringUtils.removeStart(path, shouldBeDeletedOnPath));
|
||||
cmLogDetailEntityId.setResource_name(fileName);
|
||||
|
||||
cmLogDetailEntity.setId(cmLogDetailEntityId);
|
||||
cmLogDetailEntity.setResource_content(fileContent);
|
||||
|
||||
cmLogDetailEntityService.save(cmLogDetailEntity);
|
||||
|
||||
// dao.insertRM38(new HashMap<String, Object>() {{
|
||||
// put("guid", guid);
|
||||
// put("path", StringUtils.removeStart(path, shouldBeDeletedOnPath));
|
||||
// put("name", fileName);
|
||||
// put("content", fileContent);
|
||||
// }});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* regExp에 match되는 fileName만 logging 합니다.
|
||||
*/
|
||||
private void detailFilesLogging(String guid, String path, String shouldBeDeletedOnPath, String regExp) throws Exception {
|
||||
|
||||
File files = new File(path);
|
||||
String[] fileNames = files.list();
|
||||
if(fileNames == null) {return;}
|
||||
|
||||
Pattern pattern = Pattern.compile(regExp);
|
||||
|
||||
for(String fileName : fileNames) {
|
||||
|
||||
Matcher matcher = pattern.matcher(fileName);
|
||||
|
||||
if(!matcher.find(0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Path resourcePath = Paths.get(path+fileName);
|
||||
byte[] fileContentByte = Files.readAllBytes(resourcePath);
|
||||
String fileContent = new String(fileContentByte, "EUC-KR");
|
||||
|
||||
CmLogDetailEntity cmLogDetailEntity = new CmLogDetailEntity();
|
||||
CmLogDetailEntityId cmLogDetailEntityId = new CmLogDetailEntityId();
|
||||
|
||||
cmLogDetailEntityId.setGuid(guid);
|
||||
cmLogDetailEntityId.setResource_path(StringUtils.removeStart(path, shouldBeDeletedOnPath));
|
||||
cmLogDetailEntityId.setResource_name(fileName);
|
||||
|
||||
cmLogDetailEntity.setId(cmLogDetailEntityId);
|
||||
cmLogDetailEntity.setResource_content(fileContent);
|
||||
|
||||
cmLogDetailEntityService.save(cmLogDetailEntity);
|
||||
|
||||
// dao.insertRM38(new HashMap<String, Object>() {{
|
||||
// put("guid", guid);
|
||||
// put("path", StringUtils.removeStart(path, shouldBeDeletedOnPath));
|
||||
// put("name", fileName);
|
||||
// put("content", fileContent);
|
||||
// }});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// @Transactional(readOnly = false, transactionManager = "transactionManager")
|
||||
public Page<CmLogUI> selectList(CmLogUISearch cmLogUISearch, Pageable pageable) throws Exception {
|
||||
|
||||
Page<CmLogEntity> tuples = cmLogEntityService.selectList(cmLogUISearch, pageable);
|
||||
|
||||
return tuples.map( tuple -> {
|
||||
// CmLog2Entity cmLog2Entity = tuple.get(QCmLog2Entity.cmLog2Entity);
|
||||
|
||||
// CmLogUI cmLogUI = cmLogUIMapper.toVoWithoutChildren(cmLog2Entity);
|
||||
CmLogUI cmLogUI = cmLogUIMapper.toVo(tuple);
|
||||
|
||||
return cmLogUI;
|
||||
});
|
||||
}
|
||||
|
||||
public Page<CmLogDetailUI> selectDetailList(CmLogUISearch cmLogUISearch, Pageable pageable) throws Exception {
|
||||
|
||||
Page<CmLogDetailEntity> tuples = cmLogDetailEntityService.selectList(cmLogUISearch, pageable);
|
||||
|
||||
|
||||
return tuples.map( tuple -> {
|
||||
CmLogDetailUI cmLogDetailUI = cmLogDetailUIMapper.toVo(tuple);
|
||||
|
||||
// cmLogDetailUI.setResource_data(cmLogDetailUI.getResource_content());
|
||||
|
||||
// DB에서 받아온 파일 데이터의 내용(RESOURCE_CONTENT)을 parseToString()으로 파싱하여 추가한다.
|
||||
String fileContent = cmLogDetailUI.getResource_content();
|
||||
|
||||
if(fileContent == null || fileContent.equals("null")) {
|
||||
fileContent = "";
|
||||
}
|
||||
|
||||
byte[] content = fileContent.getBytes();
|
||||
|
||||
InputStream is = null;
|
||||
BufferedReader br = null;
|
||||
InputStreamReader isr = null;
|
||||
try {
|
||||
is = new ByteArrayInputStream(content);
|
||||
isr = new InputStreamReader(is);
|
||||
br = new BufferedReader(isr);
|
||||
|
||||
cmLogDetailUI.setResource_data(loaderService.parseToString(br));
|
||||
} catch(Exception e) {
|
||||
logger.error("parse error : ", e);
|
||||
} finally{
|
||||
if (br != null) try{br.close();}catch(Exception e){}
|
||||
if (isr != null) try{isr.close();}catch(Exception e){}
|
||||
if (is != null) try{is.close();}catch(Exception e){}
|
||||
}
|
||||
|
||||
return cmLogDetailUI;
|
||||
});
|
||||
}
|
||||
|
||||
// public int setNullCmLogDetail(Period remain) {
|
||||
//
|
||||
// String dateTime = LocalDateTime.now()
|
||||
// .minusDays(remain.getDays())
|
||||
// .format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
//
|
||||
// return cmLogDetailEntityService.setNullCmLogDetail(dateTime);
|
||||
// }
|
||||
|
||||
// public int deleteCmLogAndDetail(Period remain) {
|
||||
//
|
||||
// String dateTime = LocalDateTime.now()
|
||||
// .minusDays(remain.getDays())
|
||||
// .format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
//
|
||||
// return dao.deleteCmLogAndDetail(new HashMap<String, Object>() {{
|
||||
// put("dateTime", dateTime);
|
||||
// }});
|
||||
// }
|
||||
|
||||
private List<String> getAppCodesFromDirectory(Path directory, String rollbackYN) {
|
||||
|
||||
List<String> appCodes = new ArrayList<>();
|
||||
|
||||
try (DirectoryStream<Path> onlyDirectory = Files.newDirectoryStream(directory, entry -> Files.isDirectory(entry));) {
|
||||
|
||||
for(Path path : onlyDirectory) {
|
||||
appCodes.add(path.getFileName().toString());
|
||||
}
|
||||
|
||||
if (appCodes.size() == 0 && rollbackYN.equals("N")) {
|
||||
throw new RuntimeException("No AppCode Directory In Folder:" + directory.toString());
|
||||
}
|
||||
|
||||
return appCodes;
|
||||
} catch (IOException e) {
|
||||
logger.error(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GridResponse<Map<String, Object>> bucketFileList(Map<String, String> paramMap) {
|
||||
|
||||
final String prefix = paramMap.get("pop_prefix");
|
||||
|
||||
GridResponse<Map<String, Object>> result = new GridResponse<>();
|
||||
List<Map<String, Object>> resultContent = new ArrayList<>();
|
||||
|
||||
try {
|
||||
|
||||
String bucketName = monitoringContext.getStringProperty(MonitoringContext.AWS_S3_CM_BUCKET_NAME);
|
||||
|
||||
ListObjectsV2Request listObjectsReqManual = ListObjectsV2Request.builder()
|
||||
.bucket(bucketName)
|
||||
.maxKeys(1000)
|
||||
.prefix(prefix)
|
||||
.build();
|
||||
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
ListObjectsV2Response listObjResponse = s3Client.listObjectsV2(listObjectsReqManual);
|
||||
|
||||
for (S3Object content : listObjResponse.contents()) {
|
||||
Map<String, Object> row = new HashMap<>();
|
||||
row.put("eTag", content.eTag());
|
||||
row.put("key", content.key());
|
||||
row.put("size", content.size());
|
||||
row.put("storageClassAsString", content.storageClassAsString());
|
||||
row.put("lastModifiedLong", content.lastModified().toEpochMilli());
|
||||
resultContent.add(row);
|
||||
}
|
||||
|
||||
if (listObjResponse.nextContinuationToken() == null) {
|
||||
done = true;
|
||||
}
|
||||
|
||||
listObjectsReqManual = ListObjectsV2Request.builder()
|
||||
.bucket(bucketName)
|
||||
.continuationToken(listObjResponse.nextContinuationToken())
|
||||
.build();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
result.setPage(1);
|
||||
result.setRecords(resultContent.size());
|
||||
result.setRows(resultContent);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public byte[] getFileContent(String objectKey) {
|
||||
String bucketName = monitoringContext.getStringProperty(MonitoringContext.AWS_S3_CM_BUCKET_NAME);
|
||||
|
||||
GetObjectRequest getObjectRequest = GetObjectRequest.builder().bucket(bucketName).key(objectKey).build();
|
||||
|
||||
ResponseBytes<GetObjectResponse> objectAsBytes = s3Client.getObjectAsBytes(getObjectRequest);
|
||||
|
||||
return objectAsBytes.asByteArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.eactive.eai.rms.common.cm.mapping;
|
||||
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
import com.eactive.eai.rms.common.cm.ui.CmLogDetailUI;
|
||||
import com.eactive.eai.rms.data.entity.man.cm.CmLogDetailEntity;
|
||||
|
||||
import org.mapstruct.*;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class)
|
||||
public abstract class CmLogDetailUIMapper implements GenericMapper<CmLogDetailUI, CmLogDetailEntity> {
|
||||
|
||||
@Override
|
||||
@Mapping(source = "id.guid", target = "guid")
|
||||
@Mapping(source = "id.resource_path", target = "resource_path")
|
||||
@Mapping(source = "id.resource_name", target = "resource_name")
|
||||
public abstract CmLogDetailUI toVo(CmLogDetailEntity entity);
|
||||
|
||||
@InheritInverseConfiguration(name = "toVo")
|
||||
@Override
|
||||
@Mapping(source = "guid", target = "id.guid")
|
||||
@Mapping(source = "resource_path", target = "id.resource_path")
|
||||
@Mapping(source = "resource_name", target = "id.resource_name")
|
||||
public abstract CmLogDetailEntity toEntity(CmLogDetailUI vo);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.eactive.eai.rms.common.cm.mapping;
|
||||
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
import com.eactive.eai.rms.common.cm.ui.CmLogUI;
|
||||
import com.eactive.eai.rms.data.entity.man.cm.CmLogEntity;
|
||||
|
||||
import org.mapstruct.*;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class)
|
||||
public abstract class CmLogUIMapper implements GenericMapper<CmLogUI, CmLogEntity> {
|
||||
|
||||
@Override
|
||||
public abstract CmLogUI toVo(CmLogEntity entity);
|
||||
|
||||
@InheritInverseConfiguration(name = "toVo")
|
||||
@Override
|
||||
public abstract CmLogEntity toEntity(CmLogUI vo);
|
||||
|
||||
@InheritConfiguration
|
||||
@Mapping(target = "cmLogDetail2Entities", ignore = true)
|
||||
public abstract CmLogUI toVoWithoutChildren(CmLogEntity entity);
|
||||
|
||||
// @InheritConfiguration
|
||||
// @BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
|
||||
// public abstract void updateEntity(CmLogUI cmLogUI, @MappingTarget CmLog2Entity cmLog2Entity);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.eactive.eai.rms.common.cm.ui;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Data
|
||||
|
||||
public class CmLogDetailUI {
|
||||
|
||||
@JsonProperty("GUID")
|
||||
@Comment("GUID")
|
||||
private String guid;
|
||||
|
||||
@JsonProperty("RESOURCE_PATH")
|
||||
@Comment("경로")
|
||||
private String resource_path;
|
||||
|
||||
@JsonProperty("RESOURCE_NAME")
|
||||
@Comment("파일명")
|
||||
private String resource_name;
|
||||
|
||||
@JsonProperty("RESOURCE_CONTENT")
|
||||
@Comment("내용")
|
||||
private String resource_content;
|
||||
|
||||
@JsonProperty("RESOURCE_DATA")
|
||||
@Comment("데이터")
|
||||
private HashMap resource_data;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.eactive.eai.rms.common.cm.ui;
|
||||
|
||||
import com.eactive.eai.rms.data.entity.man.cm.CmLogDetailEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Comment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
||||
public class CmLogUI {
|
||||
|
||||
@JsonProperty("GUID")
|
||||
@Comment("GUID")
|
||||
private String guid;
|
||||
|
||||
@JsonProperty("SERVICE_TYPE")
|
||||
@Comment("서비스타입")
|
||||
private String service_type;
|
||||
|
||||
@JsonProperty("APPL_CD")
|
||||
@Comment("어플리케이션코드")
|
||||
private String appl_cd;
|
||||
|
||||
@JsonProperty("DEPLOY_ID")
|
||||
@Comment("배포ID")
|
||||
private String deploy_id;
|
||||
|
||||
@JsonProperty("SUCCESS_YN")
|
||||
@Comment("성공여부")
|
||||
private String success_yn;
|
||||
|
||||
@JsonProperty("ROLLBACK_YN")
|
||||
@Comment("롤백여부")
|
||||
private String rollback_yn;
|
||||
|
||||
@JsonProperty("ERROR_MSG")
|
||||
@Comment("에러메시지")
|
||||
private String error_msg;
|
||||
|
||||
@JsonProperty("DEPLOY_TIME")
|
||||
@Comment("배포시각")
|
||||
private String deploy_time;
|
||||
|
||||
@JsonProperty("DEPLOY_END_TIME")
|
||||
@Comment("배포완료시각")
|
||||
private String deploy_end_time;
|
||||
|
||||
@JsonProperty("cmLogDetailAll")
|
||||
private List<CmLogDetailEntity> cmLogDetail2Entities;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.eactive.eai.rms.common.cm.ui;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CmLogUISearch {
|
||||
|
||||
private String searchDeployId;
|
||||
private String searchEndHHMM;
|
||||
private String searchEndTime;
|
||||
private String searchEndYYYYMMDD;
|
||||
private String searchResourceName;
|
||||
private String searchServiceType;
|
||||
private String searchStartHHMM;
|
||||
private String searchStartTime;
|
||||
private String searchStartYYYYMMDD;
|
||||
private String searchSuccessYn;
|
||||
private String searchResourceType;
|
||||
private String guid;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user