org.eclipse.ditto.wot.api.config.InternalDynamicTmValidationConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ditto-wot-api Show documentation
Show all versions of ditto-wot-api Show documentation
Eclipse Ditto is a framework for creating and managing digital twins in the IoT.
The newest version!
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.ditto.wot.api.config;
import java.util.AbstractMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.eclipse.ditto.wot.validation.ValidationContext;
import com.typesafe.config.Config;
/**
* Internal helper in order to dynamically apply WoT ThingModel validation/enforcement configuration based on the
* {@link ValidationContext} for individual API requests.
*/
final class InternalDynamicTmValidationConfiguration {
private static final String CONFIG_KEY_VALIDATION_CONTEXT = "validation-context";
private static final String CONFIG_KEY_DITTO_HEADERS_PATTERNS = "ditto-headers-patterns";
private static final String CONFIG_KEY_THING_DEFINITION_PATTERNS = "thing-definition-patterns";
private static final String CONFIG_KEY_FEATURE_DEFINITION_PATTERNS = "feature-definition-patterns";
private static final String CONFIG_KEY_CONFIG_OVERRIDES = "config-overrides";
private final DynamicValidationContextConfiguration dynamicValidationContextConfiguration;
private final Config configOverrides;
InternalDynamicTmValidationConfiguration(final Config config) {
final Config validationContext = config.getConfig(CONFIG_KEY_VALIDATION_CONTEXT);
final List