feat: align DDS with common permission and vector flow
This commit is contained in:
@@ -5,6 +5,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.bind.ConstructorBinding;
|
||||
|
||||
@ConfigurationProperties(prefix = "dds")
|
||||
public record DdsProperties(
|
||||
@@ -12,6 +13,7 @@ public record DdsProperties(
|
||||
Duration queryTimeout,
|
||||
String pgObject,
|
||||
String myObject,
|
||||
String vectorObject,
|
||||
Map<String, User> users
|
||||
) {
|
||||
|
||||
@@ -19,11 +21,13 @@ public record DdsProperties(
|
||||
"[A-Za-z][A-Za-z0-9_$#]*(\\.[A-Za-z][A-Za-z0-9_$#]*)*"
|
||||
);
|
||||
|
||||
@ConstructorBinding
|
||||
public DdsProperties {
|
||||
dbUrl = dbUrl == null ? "" : dbUrl.trim();
|
||||
queryTimeout = queryTimeout == null ? Duration.ofSeconds(10) : queryTimeout;
|
||||
pgObject = normalizeObject(pgObject, "ADMIN.V_DDS_CUSTOMERS_PG");
|
||||
myObject = normalizeObject(myObject, "ADMIN.V_DDS_CUSTOMERS_MY");
|
||||
vectorObject = normalizeObject(vectorObject, "ADMIN.CB_DDS_VECTOR_SEARCH_DOCUMENTS");
|
||||
var normalizedUsers = new LinkedHashMap<String, User>();
|
||||
if (users != null) {
|
||||
users.forEach((key, value) -> {
|
||||
@@ -35,6 +39,22 @@ public record DdsProperties(
|
||||
users = Map.copyOf(normalizedUsers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility constructor for small unit tests and older local configs.
|
||||
* The DDS vector view has a safe default and can still be overridden by
|
||||
* {@code DDS_BACKOFFICE_VECTOR_OBJECT}.
|
||||
*/
|
||||
public DdsProperties(
|
||||
String dbUrl,
|
||||
Duration queryTimeout,
|
||||
String pgObject,
|
||||
String myObject,
|
||||
Map<String, User> users
|
||||
) {
|
||||
this(dbUrl, queryTimeout, pgObject, myObject,
|
||||
"ADMIN.CB_DDS_VECTOR_SEARCH_DOCUMENTS", users);
|
||||
}
|
||||
|
||||
public String objectFor(String sourceKey) {
|
||||
if ("PG".equalsIgnoreCase(sourceKey)) {
|
||||
return pgObject;
|
||||
|
||||
Reference in New Issue
Block a user