From 70a122e166ff2bd4406340fe3d6118496bc81b7d Mon Sep 17 00:00:00 2001 From: ytvnr Date: Thu, 7 Mar 2024 15:25:27 +0100 Subject: [PATCH] refactor: remove VertxProxyOptionsUtils and gravitee-node dependency BREAKING CHANGE: Remove VertxProxyOptionsUtils, please use the one from gravitee-node from version 5.9.0 https://gravitee.atlassian.net/browse/APIM-3800 --- pom.xml | 14 ++-- .../common/util/VertxProxyOptionsUtils.java | 81 ------------------- 2 files changed, 7 insertions(+), 88 deletions(-) delete mode 100644 src/main/java/io/gravitee/common/util/VertxProxyOptionsUtils.java diff --git a/pom.xml b/pom.xml index d737f95..484ddd9 100644 --- a/pom.xml +++ b/pom.xml @@ -35,11 +35,11 @@ 6.0.4 - 2.0.0 3.1.4 1.69 9.15.2 2.3.31 + 3.5.0 @@ -58,15 +58,15 @@ - io.gravitee.node - gravitee-node-api - ${gravitee-node.version} - provided + org.slf4j + slf4j-api - org.slf4j - slf4j-api + io.gravitee.gateway + gravitee-gateway-api + ${gravitee-gateway-api.version} + provided diff --git a/src/main/java/io/gravitee/common/util/VertxProxyOptionsUtils.java b/src/main/java/io/gravitee/common/util/VertxProxyOptionsUtils.java deleted file mode 100644 index 1956e3b..0000000 --- a/src/main/java/io/gravitee/common/util/VertxProxyOptionsUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright © 2015 The Gravitee team (http://gravitee.io) - * - * 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.gravitee.common.util; - -import io.gravitee.node.api.configuration.Configuration; -import io.vertx.core.http.HttpClientOptions; -import io.vertx.core.net.ProxyOptions; -import io.vertx.core.net.ProxyType; -import java.util.Objects; - -/** - * @author GraviteeSource Team - */ -public class VertxProxyOptionsUtils { - - static final String PROXY_HOST_PROPERTY = "system.proxy.host"; - static final String PROXY_PORT_PROPERTY = "system.proxy.port"; - static final String PROXY_TYPE_PROPERTY = "system.proxy.type"; - static final String PROXY_USERNAME_PROPERTY = "system.proxy.username"; - static final String PROXY_PASSWORD_PROPERTY = "system.proxy.password"; - - public static void setSystemProxy(HttpClientOptions options, Configuration configuration) { - options.setProxyOptions(buildProxyOptions(configuration)); - } - - public static ProxyOptions buildProxyOptions(Configuration configuration) { - final ProxyOptions proxyOptions = new ProxyOptions(); - final StringBuilder errorMessageBuilder = new StringBuilder(); - - try { - proxyOptions.setHost(configuration.getProperty(PROXY_HOST_PROPERTY)); - } catch (Exception e) { - appendErrorMessage(errorMessageBuilder, PROXY_HOST_PROPERTY, e); - } - - try { - proxyOptions.setPort(parseProxyPort(configuration.getProperty(PROXY_PORT_PROPERTY))); - } catch (Exception e) { - appendErrorMessage(errorMessageBuilder, PROXY_PORT_PROPERTY, e); - } - - try { - proxyOptions.setType(ProxyType.valueOf(configuration.getProperty(PROXY_TYPE_PROPERTY))); - } catch (Exception e) { - appendErrorMessage(errorMessageBuilder, PROXY_TYPE_PROPERTY, e); - } - - proxyOptions.setUsername(configuration.getProperty(PROXY_USERNAME_PROPERTY)); - proxyOptions.setPassword(configuration.getProperty(PROXY_PASSWORD_PROPERTY)); - - if (errorMessageBuilder.length() > 0) { - throw new IllegalStateException(errorMessageBuilder.toString()); - } - - return proxyOptions; - } - - private static int parseProxyPort(String proxyPortPropertyValue) { - return Integer.parseInt(Objects.requireNonNull(proxyPortPropertyValue, "Proxy port may not be null")); - } - - private static void appendErrorMessage(StringBuilder messageBuilder, String property, Exception e) { - if (messageBuilder.length() > 0) { - messageBuilder.append(", "); - } - messageBuilder.append(property).append(": ").append(e.getMessage()); - } -}