changes
This commit is contained in:
@@ -4,7 +4,8 @@
|
|||||||
"Bash(.gradlew.bat build:*)",
|
"Bash(.gradlew.bat build:*)",
|
||||||
"Bash(echo:*)",
|
"Bash(echo:*)",
|
||||||
"Bash(gradle wrapper:*)",
|
"Bash(gradle wrapper:*)",
|
||||||
"Bash(./gradlew build:*)"
|
"Bash(./gradlew build:*)",
|
||||||
|
"Bash(./gradlew clean build:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ plugins {
|
|||||||
|
|
||||||
group = 'com.cfdeployer'
|
group = 'com.cfdeployer'
|
||||||
version = '1.0.0'
|
version = '1.0.0'
|
||||||
sourceCompatibility = '17'
|
sourceCompatibility = '21'
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
compileOnly {
|
compileOnly {
|
||||||
@@ -21,7 +21,6 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||||
implementation 'commons-io:commons-io:2.15.1'
|
|
||||||
|
|
||||||
compileOnly 'org.projectlombok:lombok'
|
compileOnly 'org.projectlombok:lombok'
|
||||||
annotationProcessor 'org.projectlombok:lombok'
|
annotationProcessor 'org.projectlombok:lombok'
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import com.cfdeployer.service.CfCliService;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.RequiredArgsConstructor;
|
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.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
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.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/cf")
|
@RequestMapping("/api/cf")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CfDeployController {
|
public class CfDeployController {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CfDeployController.class);
|
||||||
|
|
||||||
private final CfCliService cfCliService;
|
private final CfCliService cfCliService;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.cfdeployer.exception;
|
package com.cfdeployer.exception;
|
||||||
|
|
||||||
import com.cfdeployer.model.CfDeployResponse;
|
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.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.FieldError;
|
import org.springframework.validation.FieldError;
|
||||||
@@ -14,10 +15,11 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
public class GlobalExceptionHandler {
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||||
|
|
||||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||||
public ResponseEntity<CfDeployResponse> handleValidationExceptions(MethodArgumentNotValidException ex) {
|
public ResponseEntity<CfDeployResponse> handleValidationExceptions(MethodArgumentNotValidException ex) {
|
||||||
log.error("Validation error occurred", ex);
|
log.error("Validation error occurred", ex);
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.cfdeployer.service;
|
|||||||
import com.cfdeployer.model.CfDeployRequest;
|
import com.cfdeployer.model.CfDeployRequest;
|
||||||
import com.cfdeployer.model.CfDeployResponse;
|
import com.cfdeployer.model.CfDeployResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.slf4j.Logger;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -18,16 +18,18 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.nio.file.attribute.PosixFilePermission;
|
import java.nio.file.attribute.PosixFilePermission;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CfCliService {
|
public class CfCliService {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CfCliService.class);
|
||||||
|
|
||||||
@Value("${cf.cli.timeout:600}")
|
@Value("${cf.cli.timeout:600}")
|
||||||
private long timeout;
|
private long timeout;
|
||||||
|
|
||||||
@@ -206,7 +208,15 @@ public class CfCliService {
|
|||||||
|
|
||||||
private void cleanupTempDirectory(Path tempDir) {
|
private void cleanupTempDirectory(Path tempDir) {
|
||||||
try {
|
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);
|
log.debug("Cleaned up temporary directory: {}", tempDir);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warn("Failed to clean up temporary directory: {}", tempDir, 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