io.streamthoughts.jikkou.kafka.validation.NoDuplicatePrincipalRoleValidation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jikkou-provider-kafka Show documentation
Show all versions of jikkou-provider-kafka Show documentation
Integration between Apache Kafka and Jikkou
The newest version!
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) The original authors
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.streamthoughts.jikkou.kafka.validation;
import io.streamthoughts.jikkou.core.annotation.Enabled;
import io.streamthoughts.jikkou.core.annotation.SupportedResource;
import io.streamthoughts.jikkou.core.exceptions.DuplicateMetadataNameException;
import io.streamthoughts.jikkou.core.exceptions.ValidationException;
import io.streamthoughts.jikkou.core.models.DefaultResourceListObject;
import io.streamthoughts.jikkou.core.validation.Validation;
import io.streamthoughts.jikkou.core.validation.ValidationError;
import io.streamthoughts.jikkou.core.validation.ValidationResult;
import io.streamthoughts.jikkou.kafka.models.V1KafkaPrincipalRole;
import java.util.List;
import org.jetbrains.annotations.NotNull;
@Enabled
@SupportedResource(type = V1KafkaPrincipalRole.class)
public class NoDuplicatePrincipalRoleValidation implements Validation {
/**
* {@inheritDoc}
*/
@Override
public ValidationResult validate(@NotNull List resources) throws ValidationException {
DefaultResourceListObject list = new DefaultResourceListObject<>(resources);
try {
list.verifyNoDuplicateMetadataName();
return ValidationResult.success();
} catch (DuplicateMetadataNameException e) {
return ValidationResult.failure(new ValidationError(
getName(),
"Duplicate V1KafkaPrincipalRole for metadata.name: " + e.duplicates())
);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy