diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 76118da..2166b88 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -18,7 +18,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: 'temurin' - uses: gradle/wrapper-validation-action@v1 # Only for a merge into this repo - not a fork, and just for the main branch diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f2bd2d5..b0f6104 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '11' + java-version: '17' - uses: gradle/wrapper-validation-action@v1 - name: Build with Gradle & Release artifacts uses: gradle/gradle-build-action@v2 diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index b63fa06..a316f01 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -16,7 +16,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: 'temurin' - uses: gradle/wrapper-validation-action@v1 - name: Build diff --git a/build.gradle b/build.gradle index d34f7e2..48d2731 100644 --- a/build.gradle +++ b/build.gradle @@ -5,11 +5,27 @@ plugins { id 'java-library' - id "com.github.johnrengelman.shadow" version "7.1.2" + id "com.github.johnrengelman.shadow" version "8.1.0" id 'idea' id 'maven-publish' + // Checks for unnecessary dependencies + id 'com.autonomousapps.dependency-analysis' version "1.19.0" + // helps resolve log implementation clashes + id 'dev.jacomet.logging-capabilities' version "0.11.0" + // This plugin helps resolve jakarta/javax dev.jacomet.logging-capabilities + id 'org.gradlex.java-ecosystem-capabilities' version "1.1" } +// Mostly java, so default to this for now +apply plugin: 'java' +apply plugin: 'java-library' +apply plugin: 'jacoco' +apply plugin: 'org.gradlex.java-ecosystem-capabilities' +// temp disabled due to k/wrapp +// apply plugin: 'dev.jacomet.logging-capabilities' +// As we've migrated from maven - we'll assume all submodules publish directly to maven +apply plugin: 'maven-publish' + if (System.getenv("CI")) { apply plugin: 'signing' } @@ -17,7 +33,6 @@ if (System.getenv("CI")) { repositories { mavenCentral() maven { url("https://oss.sonatype.org/content/repositories/snapshots") } - mavenLocal() // note - this may pick up modified classes from ~/.m2 } // ensures we pick up the very latest snapshots when built @@ -28,43 +43,37 @@ configurations.all { group = 'org.odpi.egeria' version = '1.0-SNAPSHOT' - -ext.name = 'Strimzi topic integration connector' +ext.name = 'strimzi-topic-integration-connector' description = 'Strimzi topic integration connector for Egeria' ext { - egeriaversion = '3.10' - slf4jVersion = '1.7.36' - jacksonVersion = '2.13.3' - jupiterVersion = '5.9.0' - httpclientVersion = '4.5.13' + egeriaVersion = '4.1' + httpClient5Version = '5.2.1' } -dependencies { - - // Only used for build - already present in server chassis at runtime - compileOnly "org.odpi.egeria:audit-log-framework:${egeriaversion}" - compileOnly "org.odpi.egeria:data-manager-api:${egeriaversion}" - // TODO: this is a dependency on an optional connector. validate, document as needed, consider packaging impact - compileOnly "org.odpi.egeria:kafka-open-metadata-topic-connector:${egeriaversion}" - compileOnly "org.odpi.egeria:open-connector-framework:${egeriaversion}" - compileOnly "org.odpi.egeria:repository-services-apis:${egeriaversion}" - compileOnly "org.odpi.egeria:repository-services:${egeriaversion}" - compileOnly "org.odpi.egeria:topic-integrator-api:${egeriaversion}" - - // Needed for build and run - implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}" - implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}" - implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" - implementation "org.apache.httpcomponents:httpclient:${httpclientVersion}" - implementation "org.slf4j:slf4j-api:${slf4jVersion}" +dependencies { + implementation platform("org.odpi.egeria:egeria:${egeriaVersion}") + + implementation "org.odpi.egeria:open-connector-framework" + implementation "org.odpi.egeria:repository-services-apis" + implementation "org.odpi.egeria:data-manager-api" + implementation "org.odpi.egeria:open-integration-framework" + implementation "org.odpi.egeria:topic-integrator-api" + implementation "org.odpi.egeria:audit-log-framework" + implementation "com.fasterxml.jackson.core:jackson-annotations" + implementation "com.fasterxml.jackson.core:jackson-core" + implementation "com.fasterxml.jackson.core:jackson-databind" + implementation "org.apache.httpcomponents.client5:httpclient5:${httpClient5Version}" + + compileOnly "org.springframework:spring-web" + compileOnly "org.apache.commons:commons-lang3" // Only needed to compile test code - testCompileOnly "org.junit.jupiter:junit-jupiter-api:${jupiterVersion}" - testImplementation "org.odpi.egeria:topic-integrator-api:${egeriaversion}" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}" - - // TODO: Refactor above with custom configurations if cleaner + testCompileOnly "org.junit.jupiter:junit-jupiter-api" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine" + testImplementation "org.mockito:mockito-junit-jupiter" + testImplementation "org.odpi.egeria:connector-configuration-factory" + testImplementation "org.odpi.egeria:fvt-utilities" } @@ -84,8 +93,8 @@ test { // Maven Central (technically sonatype oss) requires we distribute source and javadoc java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 withJavadocJar() withSourcesJar() } @@ -93,8 +102,8 @@ java { // More Java language settings tasks.withType(JavaCompile) { options.encoding = 'UTF-8' - sourceCompatibility = "11" - targetCompatibility = "11" + sourceCompatibility = "17" + targetCompatibility = "17" options.incremental = true options.fork = true options.failOnError = true diff --git a/gradle.properties b/gradle.properties index 6a97c8b..36231cf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ org.gradle.parallel=true # Caching org.gradle.caching=true -# Watch filesystem for changes. Disable if memory constrained +# Watch fileystem - disable - too many files swamps OS org.gradle.vfs.watch=true # Default logging output diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e708b1c..ccebba7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 070cb70..98c925c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/gradlew b/gradlew index 4f906e0..79a61d4 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,105 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index ac1b06f..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle index 2859ec0..1664fe0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,17 +1,2 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * Copyright Contributors to the ODPi Egeria project. - */ - -// This HAS to be the first block of the file -pluginManagement { - plugins { - - id 'gradle-aggregate-javadocs-plugin' version '3.0.1' - // For reference we use these, but they are internal so no version spec needed - //id 'java' version - //id 'maven-publish' version - } -} rootProject.name = 'egeria-connector-integration-topic-strimzi' diff --git a/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/StrimziMonitorIntegrationConnector.java b/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/StrimziMonitorIntegrationConnector.java index 62a6e11..535267f 100644 --- a/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/StrimziMonitorIntegrationConnector.java +++ b/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/StrimziMonitorIntegrationConnector.java @@ -7,24 +7,24 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.TrustStrategy; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.io.HttpClientConnectionManager; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.core5.ssl.SSLContexts; +import org.apache.hc.core5.ssl.TrustStrategy; import org.odpi.openmetadata.accessservices.datamanager.metadataelements.TopicElement; import org.odpi.openmetadata.accessservices.datamanager.properties.TemplateProperties; import org.odpi.openmetadata.accessservices.datamanager.properties.TopicProperties; import org.odpi.openmetadata.adapters.connectors.integration.strimzi.ffdc.StrimziIntegrationConnectorAuditCode; import org.odpi.openmetadata.adapters.connectors.integration.strimzi.ffdc.StrimziIntegrationConnectorErrorCode; import org.odpi.openmetadata.frameworks.auditlog.messagesets.AuditLogMessageDefinition; +import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition; import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; -import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException; -import org.odpi.openmetadata.frameworks.connectors.ffdc.PropertyServerException; -import org.odpi.openmetadata.frameworks.connectors.ffdc.UserNotAuthorizedException; import org.odpi.openmetadata.frameworks.connectors.properties.EndpointProperties; import org.odpi.openmetadata.integrationservices.topic.connector.TopicIntegratorConnector; import org.odpi.openmetadata.integrationservices.topic.connector.TopicIntegratorContext; -import org.odpi.openmetadata.frameworks.auditlog.messagesets.ExceptionMessageDefinition; import org.springframework.http.*; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @@ -38,8 +38,6 @@ import java.security.cert.X509Certificate; import java.util.*; -import static org.odpi.openmetadata.adapters.connectors.integration.strimzi.StrimziMonitorIntegrationProvider.DESCRIPTION_ANNOTATION_FIELD; - /** * StrimziMonitorIntegrationConnector catalogues active topics in a Strimzi broker. @@ -389,36 +387,27 @@ boolean updateRequired(TopicProperties strimziTopicProperties, TopicElement cata return doUpdate; } - private void deleteFromContext(String methodName, String cataloguedTopicName, String cataloguedEgeriaTopicGUID) throws InvalidParameterException, UserNotAuthorizedException, PropertyServerException { - myContext.removeTopic(cataloguedEgeriaTopicGUID, cataloguedTopicName); - - if (auditLog != null) { - auditLog.logMessage(methodName, - StrimziIntegrationConnectorAuditCode.TOPIC_DELETED.getMessageDefinition(connectorName, - cataloguedTopicName, - cataloguedEgeriaTopicGUID)); - } - } - - - public RestTemplate restTemplate() - throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { + public RestTemplate restTemplate() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true; - SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom() + SSLContext sslContext = SSLContexts.custom() .loadTrustMaterial(null, acceptingTrustStrategy) .build(); - SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext); + SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext); + + HttpClientConnectionManager httpClientConnectionManager = PoolingHttpClientConnectionManagerBuilder + .create() + .setSSLSocketFactory(sslConnectionSocketFactory) + .build(); CloseableHttpClient httpClient = HttpClients.custom() - .setSSLSocketFactory(csf) + .setConnectionManager(httpClientConnectionManager) .build(); HttpComponentsClientHttpRequestFactory requestFactory = - new HttpComponentsClientHttpRequestFactory(); + new HttpComponentsClientHttpRequestFactory(httpClient); - requestFactory.setHttpClient(httpClient); return new RestTemplate(requestFactory); } diff --git a/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/ffdc/StrimziIntegrationConnectorAuditCode.java b/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/ffdc/StrimziIntegrationConnectorAuditCode.java index c69fc50..3dffa48 100644 --- a/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/ffdc/StrimziIntegrationConnectorAuditCode.java +++ b/src/main/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/ffdc/StrimziIntegrationConnectorAuditCode.java @@ -9,7 +9,7 @@ /** * The StrimziIntegrationConnectorAuditCode is used to define the message content for the OMRS Audit Log. - * + *

* The 5 fields in the enum are: *

*/ -public enum StrimziIntegrationConnectorAuditCode implements AuditLogMessageSet -{ +public enum StrimziIntegrationConnectorAuditCode implements AuditLogMessageSet { CONNECTOR_CONFIGURATION("STRIMZI-INTEGRATION-CONNECTOR-0001", - OMRSAuditLogRecordSeverity.INFO, - "The {0} integration connector has been initialized to monitor event broker at URL {1} with templateQualifiedName={2}", - "The connector is designed to monitor changes to the topics managed by the event broker. " + - "If the templateQualifiedName is set, it identifies a template entity to use.", - "No specific action is required. This message is to confirm the configuration for the integration connector."), + OMRSAuditLogRecordSeverity.INFO, + "The {0} integration connector has been initialized to monitor event broker at URL {1} with templateQualifiedName={2}", + "The connector is designed to monitor changes to the topics managed by the event broker. " + + "If the templateQualifiedName is set, it identifies a template entity to use.", + "No specific action is required. This message is to confirm the configuration for the integration connector."), BAD_CONFIGURATION("STRIMZI-INTEGRATION-CONNECTOR-0002", - OMRSAuditLogRecordSeverity.EXCEPTION, - "The {0} integration connector encountered an {1} exception when event broker at URL {1} during the {3} method. The exception message included was {4}", - "The exception is passed back to the Topic Integrator OMIS in the integration daemon that is hosting " + - "this connector to enable it to perform error handling. More messages are likely to follow describing the " + - "error handling that was performed. These can help to determine how to recover from this error", - "This message contains the exception that was the original cause of the problem. Use the information from the " + - "exception stack trace to determine why the connector is not able to access the event broker and resolve that issue. " + - "Use the messages that where subsequently logged during the error handling to discover how to restart the " + - "connector in the integration daemon once the original cause of the error has been corrected."), + OMRSAuditLogRecordSeverity.EXCEPTION, + "The {0} integration connector encountered an {1} exception when event broker at URL {1} during the {3} method. The exception message included was {4}", + "The exception is passed back to the Topic Integrator OMIS in the integration daemon that is hosting " + + "this connector to enable it to perform error handling. More messages are likely to follow describing the " + + "error handling that was performed. These can help to determine how to recover from this error", + "This message contains the exception that was the original cause of the problem. Use the information from the " + + "exception stack trace to determine why the connector is not able to access the event broker and resolve that issue. " + + "Use the messages that where subsequently logged during the error handling to discover how to restart the " + + "connector in the integration daemon once the original cause of the error has been corrected."), UNABLE_TO_RETRIEVE_TOPICS("STRIMZI-INTEGRATION-CONNECTOR-0003", - OMRSAuditLogRecordSeverity.EXCEPTION, - "The {0} integration connector received an unexpected {2} exception when retrieving topics from event broker at {1}. The error message was {3}", - "The exception is returned to the integration daemon that is hosting this connector to enable it to perform error handling.", - "Use the message in the nested exception to determine the root cause of the error. Once this is " + - "resolved, follow the instructions in the messages produced by the integration daemon to restart this connector."), + OMRSAuditLogRecordSeverity.EXCEPTION, + "The {0} integration connector received an unexpected {2} exception when retrieving topics from event broker at {1}. The error message was {3}", + "The exception is returned to the integration daemon that is hosting this connector to enable it to perform error handling.", + "Use the message in the nested exception to determine the root cause of the error. Once this is " + + "resolved, follow the instructions in the messages produced by the integration daemon to restart this connector."), RETRIEVED_TOPICS("STRIMZI-INTEGRATION-CONNECTOR-0004", - OMRSAuditLogRecordSeverity.INFO, - "The {0} integration connector has retrieved {2} topics from {1}", - "The connector will maintain these topics as assets.", - "No action is required unless there are errors that follow indicating that the topics can not be maintained."), + OMRSAuditLogRecordSeverity.INFO, + "The {0} integration connector has retrieved {2} topics from {1}", + "The connector will maintain these topics as assets.", + "No action is required unless there are errors that follow indicating that the topics can not be maintained."), CONNECTOR_STOPPING("STRIMZI-INTEGRATION-CONNECTOR-0009", - OMRSAuditLogRecordSeverity.INFO, - "The {0} integration connector has stopped its topic monitoring and is shutting down", - "The connector is disconnecting.", - "No action is required unless there are errors that follow indicating that there were problems shutting down."), + OMRSAuditLogRecordSeverity.INFO, + "The {0} integration connector has stopped its topic monitoring and is shutting down", + "The connector is disconnecting.", + "No action is required unless there are errors that follow indicating that there were problems shutting down."), BAD_TOPIC_ELEMENT("STRIMZI-INTEGRATION-CONNECTOR-0013", - OMRSAuditLogRecordSeverity.ERROR, - "The {0} integration connector retrieved an incomplete Topic asset: {1}", - "The metadata element for the topic that was retrieved from the open metadata repositories has missing " + - "information. This is likely to be a logic error in the Topic Integrator OMIS or Data Manager OMAS.", - "Look for errors in the audit logs for the integration daemon where the connector and Topic Integrator OMIS are " + - "running and the metadata server where the Data Manager OMAS is running. Collect these diagnostics and " + - "ask the Egeria community for help to determine why the Topic element is incomplete."), + OMRSAuditLogRecordSeverity.ERROR, + "The {0} integration connector retrieved an incomplete Topic asset: {1}", + "The metadata element for the topic that was retrieved from the open metadata repositories has missing " + + "information. This is likely to be a logic error in the Topic Integrator OMIS or Data Manager OMAS.", + "Look for errors in the audit logs for the integration daemon where the connector and Topic Integrator OMIS are " + + "running and the metadata server where the Data Manager OMAS is running. Collect these diagnostics and " + + "ask the Egeria community for help to determine why the Topic element is incomplete."), UNEXPECTED_EXC_TOPIC_UPDATE("STRIMZI-INTEGRATION-CONNECTOR-0014", - OMRSAuditLogRecordSeverity.EXCEPTION, - "An unexpected {0} exception was returned to the {1} integration connector when it tried to update the " + - "Topic in the metadata repositories for topic {2}. The error message was {3}", - "The exception is logged and the integration connector continues to synchronize metadata. " + - "This topic is not catalogued at this time but may succeed later.", - "Use the message in the unexpected exception to determine the root cause of the error and fix it."), + OMRSAuditLogRecordSeverity.EXCEPTION, + "An unexpected {0} exception was returned to the {1} integration connector when it tried to update the " + + "Topic in the metadata repositories for topic {2}. The error message was {3}", + "The exception is logged and the integration connector continues to synchronize metadata. " + + "This topic is not catalogued at this time but may succeed later.", + "Use the message in the unexpected exception to determine the root cause of the error and fix it."), MISSING_TEMPLATE("STRIMZI-INTEGRATION-CONNECTOR-0015", - OMRSAuditLogRecordSeverity.ERROR, - "The {0} integration connector is unable to retrieve the Topic template with qualified name: {1}", - "The metadata element for the template is not found in the open metadata repositories. " + - "The template name was configured for the connector. This means that topics should be catalogued " + - "using the template. Since the template is missing, topics are not being catalogued.", - "Create the template in the metadata repository. The connector will catalog the topics during " + - "its next periodic refresh or you can force it to refresh immediately by calling the refresh" + - "operation on the integration daemon."), + OMRSAuditLogRecordSeverity.ERROR, + "The {0} integration connector is unable to retrieve the Topic template with qualified name: {1}", + "The metadata element for the template is not found in the open metadata repositories. " + + "The template name was configured for the connector. This means that topics should be catalogued " + + "using the template. Since the template is missing, topics are not being catalogued.", + "Create the template in the metadata repository. The connector will catalog the topics during " + + "its next periodic refresh or you can force it to refresh immediately by calling the refresh" + + "operation on the integration daemon."), TOPIC_CREATED("STRIMZI-INTEGRATION-CONNECTOR-0016", - OMRSAuditLogRecordSeverity.INFO, - "The {0} integration connector created the Topic {1} ({2}) for a new real-world topic", - "The connector created the Topic as part of its monitoring of the topics in the event broker.", - "No action is required. This message is to record the reason why the Topic was created."), + OMRSAuditLogRecordSeverity.INFO, + "The {0} integration connector created the Topic {1} ({2}) for a new real-world topic", + "The connector created the Topic as part of its monitoring of the topics in the event broker.", + "No action is required. This message is to record the reason why the Topic was created."), TOPIC_CREATED_FROM_TEMPLATE("STRIMZI-INTEGRATION-CONNECTOR-0017", - OMRSAuditLogRecordSeverity.INFO, - "The {0} integration connector created the Topic {1} ({2}) for a new real-world topic using template {3} ({4})", - "The connector created the Topic as part of its monitoring of the topics in the event broker. " + - "The template provides details of additional metadata that should also be attached to the new Topic element. " + - "It was specified in the templateQualifiedName configuration property of the connector.", - "No action is required. This message is to record the reason why the Topic was created with the template."), + OMRSAuditLogRecordSeverity.INFO, + "The {0} integration connector created the Topic {1} ({2}) for a new real-world topic using template {3} ({4})", + "The connector created the Topic as part of its monitoring of the topics in the event broker. " + + "The template provides details of additional metadata that should also be attached to the new Topic element. " + + "It was specified in the templateQualifiedName configuration property of the connector.", + "No action is required. This message is to record the reason why the Topic was created with the template."), TOPIC_UPDATED("STRIMZI-INTEGRATION-CONNECTOR-0018", - OMRSAuditLogRecordSeverity.INFO, - "The {0} integration connector has updated the Topic {1} ({2}) because the real-world topic changed", - "The connector updated the Topic as part of its monitoring of the topics in the event broker.", - "No action is required. This message is to record the reason why the Topic was updated."), + OMRSAuditLogRecordSeverity.INFO, + "The {0} integration connector has updated the Topic {1} ({2}) because the real-world topic changed", + "The connector updated the Topic as part of its monitoring of the topics in the event broker.", + "No action is required. This message is to record the reason why the Topic was updated."), TOPIC_DELETED("STRIMZI-INTEGRATION-CONNECTOR-0019", - OMRSAuditLogRecordSeverity.INFO, - "The {0} integration connector has deleted the Topic {1} ({2}) because the real-world topic is no longer defined in the event broker", - "The connector removed the Topic as part of its monitoring of the topics in the event broker.", - "No action is required. This message is to record the reason why the Topic was removed."), + OMRSAuditLogRecordSeverity.INFO, + "The {0} integration connector has deleted the Topic {1} ({2}) because the real-world topic is no longer defined in the event broker", + "The connector removed the Topic as part of its monitoring of the topics in the event broker.", + "No action is required. This message is to record the reason why the Topic was removed."), NO_CONNECTION_PROPERTIES("STRIMZI-INTEGRATION-CONNECTOR-0020", - OMRSAuditLogRecordSeverity.ERROR, - "The {0} integration connector has been initialized to monitor event broker at URL {1} but there is no configuration properties supplied", - "The connector is designed to monitor changes to the topics managed by the event broker. " + - "If the templateQualifiedName is set, it identifies a template entity to use.", - "No specific action is required. This message is to confirm the configuration for the integration connector."), + OMRSAuditLogRecordSeverity.ERROR, + "The {0} integration connector has been initialized to monitor event broker at URL {1} but there is no configuration properties supplied", + "The connector is designed to monitor changes to the topics managed by the event broker. " + + "If the templateQualifiedName is set, it identifies a template entity to use.", + "No specific action is required. This message is to confirm the configuration for the integration connector."), REFRESH_CALLED("STRIMZI-INTEGRATION-CONNECTOR-0021", - OMRSAuditLogRecordSeverity.INFO, - "The {0} integration connector refresh has been called", - "This is normal behaviour for a polling integration connector", - "No specific action is required. This message is to inform that polling is occurring."), + OMRSAuditLogRecordSeverity.INFO, + "The {0} integration connector refresh has been called", + "This is normal behaviour for a polling integration connector", + "No specific action is required. This message is to inform that polling is occurring."), ; - private String logMessageId; - private OMRSAuditLogRecordSeverity severity; - private String logMessage; - private String systemAction; - private String userAction; + private final String logMessageId; + private final OMRSAuditLogRecordSeverity severity; + private final String logMessage; + private final String systemAction; + private final String userAction; /** * The constructor for StrimziIntegrationConnectorAuditCode expects to be passed one of the enumeration rows defined in * StrimziIntegrationConnectorAuditCode above. For example: - * - * StrimziIntegrationConnectorAuditCode auditCode = StrimziIntegrationConnectorAuditCode.SERVER_NOT_AVAILABLE; - * + *

+ * StrimziIntegrationConnectorAuditCode auditCode = StrimziIntegrationConnectorAuditCode.SERVER_NOT_AVAILABLE; + *

* This will expand out to the 4 parameters shown below. * - * @param messageId - unique Id for the message - * @param severity - severity of the message - * @param message - text for the message + * @param messageId - unique Id for the message + * @param severity - severity of the message + * @param message - text for the message * @param systemAction - description of the action taken by the system when the condition happened - * @param userAction - instructions for resolving the situation, if any + * @param userAction - instructions for resolving the situation, if any */ - StrimziIntegrationConnectorAuditCode(String messageId, - OMRSAuditLogRecordSeverity severity, - String message, - String systemAction, - String userAction) - { + StrimziIntegrationConnectorAuditCode(String messageId, + OMRSAuditLogRecordSeverity severity, + String message, + String systemAction, + String userAction) { this.logMessageId = messageId; this.severity = severity; this.logMessage = message; @@ -168,13 +166,12 @@ public enum StrimziIntegrationConnectorAuditCode implements AuditLogMessageSet * @return message definition object. */ @Override - public AuditLogMessageDefinition getMessageDefinition() - { + public AuditLogMessageDefinition getMessageDefinition() { return new AuditLogMessageDefinition(logMessageId, - severity, - logMessage, - systemAction, - userAction); + severity, + logMessage, + systemAction, + userAction); } @@ -185,13 +182,12 @@ public AuditLogMessageDefinition getMessageDefinition() * @return message definition object. */ @Override - public AuditLogMessageDefinition getMessageDefinition(String ...params) - { + public AuditLogMessageDefinition getMessageDefinition(String... params) { AuditLogMessageDefinition messageDefinition = new AuditLogMessageDefinition(logMessageId, - severity, - logMessage, - systemAction, - userAction); + severity, + logMessage, + systemAction, + userAction); messageDefinition.setMessageParameters(params); return messageDefinition; } @@ -203,8 +199,7 @@ public AuditLogMessageDefinition getMessageDefinition(String ...params) * @return string of property names and values for this enum */ @Override - public String toString() - { + public String toString() { return "StrimziIntegrationConnectorAuditCode{" + "logMessageId='" + logMessageId + '\'' + ", severity=" + severity + diff --git a/src/test/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/StrimziMonitorIntegrationConnectorTest.java b/src/test/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/StrimziMonitorIntegrationConnectorTest.java index 305783e..112e2a4 100644 --- a/src/test/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/StrimziMonitorIntegrationConnectorTest.java +++ b/src/test/java/org/odpi/openmetadata/adapters/connectors/integration/strimzi/StrimziMonitorIntegrationConnectorTest.java @@ -4,11 +4,10 @@ package org.odpi.openmetadata.adapters.connectors.integration.strimzi; import org.junit.jupiter.api.Test; -import org.odpi.openmetadata.accessservices.datamanager.metadataelements.ElementHeader; import org.odpi.openmetadata.accessservices.datamanager.metadataelements.TopicElement; import org.odpi.openmetadata.accessservices.datamanager.properties.TopicProperties; import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException; -import org.odpi.openmetadata.frameworks.connectors.properties.ConnectionProperties; +import org.odpi.openmetadata.frameworks.connectors.properties.beans.ElementHeader; import java.io.IOException; import java.nio.file.Files;