로깅 개선 및 EAI 배치 가상 연동 작업 완료
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.eactive.ext.kjb.common;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
public class KjbProperty {
|
||||
@Pattern(regexp = "^(https?://[^\\s/$.?#][^\\s]*)|\\s*$", message = "kjb.ums.eai_batch.url 는 유효한 URL 형식이거나 공백이어야 합니다. 예: http://example.com/api")
|
||||
private String eaiBatchUrl;
|
||||
|
||||
@NotEmpty(message = "kjb.ums.eai_batch.send_dir 는 필수값입니다.")
|
||||
@Pattern(regexp = "^(?:[a-zA-Z]:\\\\|\\\\|\\/)(?:[\\w\\-\\.]+[\\\\\\/])*[\\w\\-\\.]+$",
|
||||
message = "kjb.ums.eai_batch.send_dir 은 절대 경로여야 합니다. 예: /Data/eapim/portal/sendmail/snd 또는 C:\\Data\\eapim\\portal\\sendmail\\snd")
|
||||
private String eaiBatchSendDir;
|
||||
|
||||
@NotEmpty(message = "kjb.ums.eai_batch.backup_dir 는 필수값입니다.")
|
||||
@Pattern(regexp = "^(?:[a-zA-Z]:\\\\|\\\\|\\/)(?:[\\w\\-\\.]+[\\\\\\/])*[\\w\\-\\.]+$",
|
||||
message = "kjb.ums.eai_batch.backup_dir 은 절대 경로여야 합니다. 예: /Data/eapim/portal/sendmail/bak 또는 C:\\Data\\eapim\\portal\\sendmail\\bak")
|
||||
private String eaiBatchBackupDir;
|
||||
|
||||
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{13}$", message = "kjb.ums.eai_batch.interface_id 는 12자리 영문대소문자 및 숫자 조합이어야 합니다.")
|
||||
private String eaiBatchInterfaceId;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.eactive.ext.kjb.common;
|
||||
|
||||
import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator;
|
||||
|
||||
import javax.validation.*;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ValidationUtil {
|
||||
private static final ValidatorFactory factory;
|
||||
private static final Validator validator;
|
||||
|
||||
static {
|
||||
factory = Validation.byDefaultProvider()
|
||||
.configure()
|
||||
.messageInterpolator(new ParameterMessageInterpolator())
|
||||
.buildValidatorFactory();
|
||||
|
||||
validator = factory.getValidator();
|
||||
}
|
||||
|
||||
|
||||
private ValidationUtil() {
|
||||
}
|
||||
|
||||
|
||||
public static <T> Set<ConstraintViolation<T>> validate(T target) {
|
||||
return validator.validate(target);
|
||||
}
|
||||
|
||||
public static <T> void validateOrThrow(T target) {
|
||||
Set<ConstraintViolation<T>> violations = validate(target);
|
||||
if (!violations.isEmpty()) {
|
||||
String message = violations.stream()
|
||||
.map(v -> v.getPropertyPath() + " : " + v.getMessage())
|
||||
.collect(Collectors.joining(", "));
|
||||
throw new ConstraintViolationException("Validation failed: " + message, violations);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> String getViolationMessage(T target) {
|
||||
Set<ConstraintViolation<T>> violations = validate(target);
|
||||
if (violations.isEmpty()) return null;
|
||||
return violations.stream()
|
||||
.map(v -> v.getPropertyPath() + " : " + v.getMessage())
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user