update to current version
all initial features implemented tbd: etrack front
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.release11.klaus.model.constraints;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@Target({ ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Constraint(validatedBy = HttpCodeValidation.class )
|
||||
public @interface HttpCode {
|
||||
String message() default "must be a valid http code";
|
||||
|
||||
Class<?>[] groups() default { };
|
||||
Class<? extends Payload>[] payload() default { };
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.release11.klaus.model.constraints;
|
||||
|
||||
import com.release11.klaus.repository.MockedResponseRepository;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class HttpCodeValidation implements ConstraintValidator<HttpCode, Integer> {
|
||||
private Set<Integer> allowedValues;
|
||||
|
||||
@Override
|
||||
public void initialize(HttpCode targetEnum) {
|
||||
allowedValues = Stream.of(HttpStatus.values())
|
||||
.map(HttpStatus::value)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Integer integer, ConstraintValidatorContext context) {
|
||||
return allowedValues.contains(integer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.release11.klaus.repository;
|
||||
|
||||
import com.release11.klaus.utilis.BusinessKey;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface LogsRepository {
|
||||
String getLogsByBusinessKeys(List<BusinessKey> businessKeys, ZonedDateTime zonedDateTime);
|
||||
}
|
||||
16
src/main/java/com/release11/klaus/utilis/BusinessKey.java
Normal file
16
src/main/java/com/release11/klaus/utilis/BusinessKey.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.release11.klaus.utilis;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public enum BusinessKey {
|
||||
INTERFACE_NAME("interfaceName"),
|
||||
CLIENT_UUID("clientUUID"),
|
||||
MESSAGE_ID("messageId");
|
||||
|
||||
private final String phrase;
|
||||
|
||||
public String getReasonPhrase() {
|
||||
return this.phrase;
|
||||
}
|
||||
}
|
||||
18
src/main/java/com/release11/klaus/utilis/TrackingClient.java
Normal file
18
src/main/java/com/release11/klaus/utilis/TrackingClient.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.release11.klaus.utilis;
|
||||
|
||||
import org.slf4j.MDC;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class TrackingClient {
|
||||
|
||||
private TrackingClient(){};
|
||||
|
||||
public static void setBusinessKeys(Map<BusinessKey, String> businessKeysMap){
|
||||
for (Map.Entry<BusinessKey, String> entry : businessKeysMap.entrySet()) {
|
||||
MDC.put(entry.getKey().getReasonPhrase(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user