|
|
|
@ -27,6 +27,7 @@ import javax.net.ssl.SSLContext;
|
|
|
|
import javax.net.ssl.TrustManager;
|
|
|
|
import javax.net.ssl.TrustManager;
|
|
|
|
import javax.net.ssl.X509TrustManager;
|
|
|
|
import javax.net.ssl.X509TrustManager;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.security.cert.X509Certificate;
|
|
|
|
import java.security.cert.X509Certificate;
|
|
|
|
@ -94,46 +95,111 @@ public class ExternalAuthController {
|
|
|
|
return ResponseEntity.ok(ApiResponse.failure(e.getMessage()));
|
|
|
|
return ResponseEntity.ok(ApiResponse.failure(e.getMessage()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Operation(
|
|
|
|
|
|
|
|
// summary = "S3 업로드 + 외부 DB 등록",
|
|
|
|
|
|
|
|
// description = "파일을 S3에 업로드하고 외부 DB에 등록합니다.",
|
|
|
|
|
|
|
|
// security = @SecurityRequirement(name = "bearerAuth") // 여기서 SecurityScheme 연결
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
// @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
|
|
|
|
// public ResponseEntity<String> uploadEdgeSW(
|
|
|
|
|
|
|
|
// @RequestParam("files") List<MultipartFile> files,
|
|
|
|
|
|
|
|
// @RequestParam("sw_id") String swId,
|
|
|
|
|
|
|
|
// @RequestParam("sw_version") String swVersion,
|
|
|
|
|
|
|
|
// @RequestParam("sw_name") String swName,
|
|
|
|
|
|
|
|
// @RequestParam("creation_datetime") String creationDatetime,
|
|
|
|
|
|
|
|
// @RequestParam("auth_id") String authId
|
|
|
|
|
|
|
|
// ) {
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// EdgeSWVO edgeSWVO = new EdgeSWVO();
|
|
|
|
|
|
|
|
// edgeSWVO.setFiles(files);
|
|
|
|
|
|
|
|
// edgeSWVO.setSw_id(swId);
|
|
|
|
|
|
|
|
// edgeSWVO.setSw_version(swVersion);
|
|
|
|
|
|
|
|
// edgeSWVO.setSw_name(swName);
|
|
|
|
|
|
|
|
// edgeSWVO.setCreation_datetime(creationDatetime);
|
|
|
|
|
|
|
|
// edgeSWVO.setAuth_id(authId);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// String result = edgeSWUploadService.uploadAndSend(edgeSWVO);
|
|
|
|
|
|
|
|
// return ResponseEntity.ok(result);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
|
|
// return ResponseEntity.internalServerError().body("업로드 실패: " + e.getMessage());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(
|
|
|
|
@Operation(
|
|
|
|
summary = "S3 업로드 + 외부 DB 등록",
|
|
|
|
summary = "외부 DB 등록 + 파일 업로드",
|
|
|
|
description = "파일을 S3에 업로드하고 외부 DB에 등록합니다.",
|
|
|
|
description = "S3 업로드된 파일 정보를 외부 DB에 등록합니다. 파일도 함께 업로드 가능",
|
|
|
|
security = @SecurityRequirement(name = "bearerAuth") // 여기서 SecurityScheme 연결
|
|
|
|
security = @SecurityRequirement(name = "bearerAuth")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
@PostMapping(value = "/register-with-file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
|
|
|
public ResponseEntity<String> uploadEdgeSW(
|
|
|
|
public ResponseEntity<String> registerWithFile(
|
|
|
|
@RequestParam("files") List<MultipartFile> files,
|
|
|
|
|
|
|
|
@RequestParam("sw_id") String swId,
|
|
|
|
@RequestParam("sw_id") String swId,
|
|
|
|
@RequestParam("sw_version") String swVersion,
|
|
|
|
@RequestParam("sw_version") int swVersion,
|
|
|
|
@RequestParam("sw_name") String swName,
|
|
|
|
@RequestParam("sw_name") String swName,
|
|
|
|
@RequestParam("creation_datetime") String creationDatetime,
|
|
|
|
@RequestParam("auth_id") String authId,
|
|
|
|
@RequestParam("auth_id") String authId
|
|
|
|
|
|
|
|
|
|
|
|
@RequestParam
|
|
|
|
|
|
|
|
@Schema(description = "엣지 패키지 정보", example = "14", required = true)
|
|
|
|
|
|
|
|
Integer edPkgSerial,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestParam
|
|
|
|
|
|
|
|
@Schema(description = "압축여부(0:단일,1:묶음)", example = "1", required = true)
|
|
|
|
|
|
|
|
Integer archiveType,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestParam
|
|
|
|
|
|
|
|
@Schema(description = "비밀글 여부 (true/false)", example = "false", required = true)
|
|
|
|
|
|
|
|
String secretAt,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestParam
|
|
|
|
|
|
|
|
@Schema(description = "설치 위치", example = "/etc/test/", required = true)
|
|
|
|
|
|
|
|
String downloadLocation,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestParam("user_id")
|
|
|
|
|
|
|
|
@Schema(description = "사용자 ID", example = "admin", required = true) String userId,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestParam("creation_datetime")
|
|
|
|
|
|
|
|
@Schema(
|
|
|
|
|
|
|
|
description = "생성 일시 (ISO-8601 형식, UTC)",
|
|
|
|
|
|
|
|
example = "2025-10-20T11:46:49.848Z",
|
|
|
|
|
|
|
|
required = true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
String creationDatetime,
|
|
|
|
|
|
|
|
@RequestPart(value = "file", required = false) MultipartFile file
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
// VO 생성
|
|
|
|
EdgeSWVO edgeSWVO = new EdgeSWVO();
|
|
|
|
EdgeSWVO edgeSWVO = new EdgeSWVO();
|
|
|
|
edgeSWVO.setFiles(files);
|
|
|
|
|
|
|
|
edgeSWVO.setSw_id(swId);
|
|
|
|
edgeSWVO.setSw_id(swId);
|
|
|
|
edgeSWVO.setSw_version(swVersion);
|
|
|
|
edgeSWVO.setSw_version(swVersion);
|
|
|
|
edgeSWVO.setSw_name(swName);
|
|
|
|
edgeSWVO.setSw_name(swName);
|
|
|
|
edgeSWVO.setCreation_datetime(creationDatetime);
|
|
|
|
|
|
|
|
edgeSWVO.setAuth_id(authId);
|
|
|
|
edgeSWVO.setAuth_id(authId);
|
|
|
|
|
|
|
|
edgeSWVO.setUser_id(userId);
|
|
|
|
|
|
|
|
edgeSWVO.setCreation_datetime(creationDatetime);
|
|
|
|
|
|
|
|
edgeSWVO.setEd_pkg_serial(edPkgSerial);
|
|
|
|
|
|
|
|
edgeSWVO.setArchive_type(archiveType);
|
|
|
|
|
|
|
|
edgeSWVO.setDownload_location(downloadLocation);
|
|
|
|
|
|
|
|
|
|
|
|
String result = edgeSWUploadService.uploadAndSend(edgeSWVO);
|
|
|
|
|
|
|
|
return ResponseEntity.ok(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
return ResponseEntity.internalServerError().body("업로드 실패: " + e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "외부 DB 등록", description = "S3 업로드된 파일 정보를 외부 DB에 등록합니다.",
|
|
|
|
edgeSWVO.setSecret_at(secretAt);
|
|
|
|
security = @SecurityRequirement(name = "bearerAuth"))
|
|
|
|
|
|
|
|
@PostMapping("/register")
|
|
|
|
|
|
|
|
public ResponseEntity<String> registerMetadata(
|
|
|
|
// 파일이 있으면 S3 업로드
|
|
|
|
@RequestBody EdgeSWVO edgeSWVO
|
|
|
|
if (file != null && !file.isEmpty()) {
|
|
|
|
) {
|
|
|
|
edgeSWUploadService.uploadFilesToS3Only(edgeSWVO, file);
|
|
|
|
try {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DB 등록 (파일 업로드 성공 후)
|
|
|
|
String result = edgeSWUploadService.registerMetadata(edgeSWVO);
|
|
|
|
String result = edgeSWUploadService.registerMetadata(edgeSWVO);
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(result);
|
|
|
|
return ResponseEntity.ok(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (IOException ioe) {
|
|
|
|
|
|
|
|
log.error("S3 파일 업로드 실패", ioe);
|
|
|
|
|
|
|
|
return ResponseEntity.internalServerError().body("파일 업로드 실패: " + ioe.getMessage());
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("DB 등록 실패", e);
|
|
|
|
log.error("DB 등록 실패", e);
|
|
|
|
return ResponseEntity.internalServerError().body("DB 등록 실패: " + e.getMessage());
|
|
|
|
return ResponseEntity.internalServerError().body("DB 등록 실패: " + e.getMessage());
|
|
|
|
|