changes
This commit is contained in:
@@ -6,7 +6,8 @@ import com.cfdeployer.service.CfCliService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -16,12 +17,13 @@ import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/cf")
|
||||
@RequiredArgsConstructor
|
||||
public class CfDeployController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CfDeployController.class);
|
||||
|
||||
private final CfCliService cfCliService;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.cfdeployer.exception;
|
||||
|
||||
import com.cfdeployer.model.CfDeployResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.FieldError;
|
||||
@@ -14,10 +15,11 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseEntity<CfDeployResponse> handleValidationExceptions(MethodArgumentNotValidException ex) {
|
||||
log.error("Validation error occurred", ex);
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.cfdeployer.service;
|
||||
import com.cfdeployer.model.CfDeployRequest;
|
||||
import com.cfdeployer.model.CfDeployResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -18,16 +18,18 @@ import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CfCliService {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CfCliService.class);
|
||||
|
||||
@Value("${cf.cli.timeout:600}")
|
||||
private long timeout;
|
||||
|
||||
@@ -206,7 +208,15 @@ public class CfCliService {
|
||||
|
||||
private void cleanupTempDirectory(Path tempDir) {
|
||||
try {
|
||||
FileUtils.deleteDirectory(tempDir.toFile());
|
||||
Files.walk(tempDir)
|
||||
.sorted(Comparator.reverseOrder())
|
||||
.forEach(path -> {
|
||||
try {
|
||||
Files.delete(path);
|
||||
} catch (IOException e) {
|
||||
log.warn("Failed to delete file: {}", path, e);
|
||||
}
|
||||
});
|
||||
log.debug("Cleaned up temporary directory: {}", tempDir);
|
||||
} catch (IOException e) {
|
||||
log.warn("Failed to clean up temporary directory: {}", tempDir, e);
|
||||
|
||||
20
src/main/resources/application.properties
Normal file
20
src/main/resources/application.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
# Server Configuration
|
||||
server.port=8080
|
||||
|
||||
# Application Name
|
||||
spring.application.name=cf-deployer
|
||||
|
||||
# Multipart Configuration
|
||||
spring.servlet.multipart.max-file-size=500MB
|
||||
spring.servlet.multipart.max-request-size=500MB
|
||||
spring.servlet.multipart.enabled=true
|
||||
|
||||
# Cloud Foundry CLI Configuration
|
||||
cf.cli.timeout=600
|
||||
cf.cli.path=
|
||||
|
||||
# Logging Configuration
|
||||
logging.level.root=INFO
|
||||
logging.level.com.cfdeployer=DEBUG
|
||||
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %msg%n
|
||||
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
|
||||
@@ -1,24 +0,0 @@
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: cf-deployer
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 500MB
|
||||
max-request-size: 500MB
|
||||
enabled: true
|
||||
|
||||
cf:
|
||||
cli:
|
||||
timeout: 600
|
||||
path:
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: INFO
|
||||
com.cfdeployer: DEBUG
|
||||
pattern:
|
||||
console: "%d{yyyy-MM-dd HH:mm:ss} - %msg%n"
|
||||
file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
|
||||
Reference in New Issue
Block a user