RED-2246: updated platform-commons-dependency

This commit is contained in:
Dominique Eiflaender 2021-10-07 16:19:29 +02:00 committed by aoezyetimoglu
commit de9f41cde6
4 changed files with 13 additions and 1 deletions

View File

@ -27,7 +27,7 @@
<dependency> <dependency>
<groupId>com.iqser.red</groupId> <groupId>com.iqser.red</groupId>
<artifactId>platform-commons-dependency</artifactId> <artifactId>platform-commons-dependency</artifactId>
<version>1.6.0</version> <version>1.7.0</version>
<scope>import</scope> <scope>import</scope>
<type>pom</type> <type>pom</type>
</dependency> </dependency>

View File

@ -1,14 +1,18 @@
package com.iqser.red.service.search.v1.server.client; package com.iqser.red.service.search.v1.server.client;
import com.iqser.red.service.search.v1.server.settings.ElasticsearchSettings; import com.iqser.red.service.search.v1.server.settings.ElasticsearchSettings;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.experimental.Delegate; import lombok.experimental.Delegate;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.http.Header;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope; import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider; import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.message.BasicHeader;
import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
@ -16,6 +20,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
import java.io.IOException; import java.io.IOException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -46,6 +51,11 @@ public class ElasticsearchClient {
.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(ABSURD_HIGH_TIMEOUT) .setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(ABSURD_HIGH_TIMEOUT)
.setSocketTimeout(ABSURD_HIGH_TIMEOUT)); .setSocketTimeout(ABSURD_HIGH_TIMEOUT));
if (settings.getApiKeyAuth() != null) {
var defaultHeaders = new Header[]{new BasicHeader("Authorization", "ApiKey " + settings.getApiKeyAuth())};
builder.setDefaultHeaders(defaultHeaders);
}
if (settings.getUsername() != null && !settings.getUsername().isEmpty()) { if (settings.getUsername() != null && !settings.getUsername().isEmpty()) {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getUsername(), settings credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getUsername(), settings

View File

@ -20,6 +20,7 @@ public class ElasticsearchSettings {
private int port = 9300; private int port = 9300;
private String scheme = "http"; private String scheme = "http";
private String apiKeyAuth;
private String username; private String username;

View File

@ -39,6 +39,7 @@ elasticsearch:
scheme: ${elasticsearch.cluster.scheme:http} scheme: ${elasticsearch.cluster.scheme:http}
username: ${elasticsearch.cluster.username} username: ${elasticsearch.cluster.username}
password: ${elasticsearch.cluster.password} password: ${elasticsearch.cluster.password}
apiKeyAuth: ${elasticsearch.cluster.apikey}
storage: storage:
signer-type: 'AWSS3V4SignerType' signer-type: 'AWSS3V4SignerType'