diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index be7c5fd93..24e1d37cd 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -43,10 +43,10 @@ jobs: uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. diff --git a/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/DataExtractor.java b/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/DataExtractor.java index cf6dd37e2..ddaa08a8f 100644 --- a/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/DataExtractor.java +++ b/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/DataExtractor.java @@ -1,8 +1,33 @@ +/* + * Copyright 2020 Aiven Oy + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.aiven.kafka.connect.common.config.extractors; import org.apache.kafka.connect.sink.SinkRecord; +/** + * Extracts data from a {@link SinkRecord}. The actual data extracted is implementation specific + */ public interface DataExtractor { + /** + * Extracts data from a {@link SinkRecord}. + * + * @param record the record to extract data from + * @return the extracted data + */ Object extractDataFrom(final SinkRecord record); } diff --git a/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/HeaderValueExtractor.java b/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/HeaderValueExtractor.java index 9e954fdb9..ad703985b 100644 --- a/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/HeaderValueExtractor.java +++ b/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/HeaderValueExtractor.java @@ -1,11 +1,37 @@ +/* + * Copyright 2020 Aiven Oy + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.aiven.kafka.connect.common.config.extractors; import org.apache.kafka.connect.header.Header; import org.apache.kafka.connect.sink.SinkRecord; +/** + * A DataExtractor that extracts the value of a header from a SinkRecord + * If there are multiple headers with the same ane, then the last occurrence will be used + * If the header does not exist, then the extraction will yield null + */ public class HeaderValueExtractor implements DataExtractor { private final String headerKey; + /** + * Create a new HeaderValueExtractor + * + * @param headerKey the key of the header to extract. + */ public HeaderValueExtractor(final String headerKey) { this.headerKey = headerKey; } diff --git a/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/SimpleValuePath.java b/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/SimpleValuePath.java index 8ded6ddbe..d2375a83a 100644 --- a/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/SimpleValuePath.java +++ b/commons/src/main/java/io/aiven/kafka/connect/common/config/extractors/SimpleValuePath.java @@ -26,6 +26,22 @@ import java.util.Map; import java.util.regex.Pattern; +/* + * Copyright 2020 Aiven Oy + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + public final class SimpleValuePath implements DataExtractor { private final String[] terms;