X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=aai-rest%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Frestclient%2FAAIRestClient.java;h=393c66329f6654700deefb837e4ba1e7144a77da;hb=b7ad55e5d91527b259cb9189237b3f01915c31f8;hp=652f399a41aa61a76e719a1617106f27530282a0;hpb=703072969c51068d6a7aadf7131a545eabab87cd;p=aai%2Faai-common.git diff --git a/aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java b/aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java index 652f399a..393c6632 100644 --- a/aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java +++ b/aai-rest/src/main/java/org/onap/aai/restclient/AAIRestClient.java @@ -17,72 +17,77 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.aai.restclient; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import java.util.Collections; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Conditional; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.util.MultiValueMap; -import java.util.Collections; -import java.util.Map; - -@Component(value=ClientType.AAI) -public class AAIRestClient extends TwoWaySSLRestClient{ - - private static EELFLogger logger = EELFManager.getInstance().getLogger(AAIRestClient.class); - - @Value("${aai.base.url}") - private String baseUrl; - - @Value("${aai.ssl.key-store}") - private String keystorePath; - - @Value("${aai.ssl.trust-store}") - private String truststorePath; - - @Value("${aai.ssl.key-store-password}") - private String keystorePassword; - - @Value("${aai.ssl.trust-store-password}") - private String truststorePassword; - - @Override - public String getBaseUrl() { - return baseUrl; - } - - @Override - protected String getKeystorePath() { - return keystorePath; - } - - @Override - protected String getTruststorePath() { - return truststorePath; - } - - @Override - protected char[] getKeystorePassword() { - return keystorePassword.toCharArray(); - } - - @Override - protected char[] getTruststorePassword() { - return truststorePassword.toCharArray(); - } - - @Override - public MultiValueMap getHeaders(Map headers) { - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - httpHeaders.setContentType(MediaType.APPLICATION_JSON); - httpHeaders.add("Real-Time", "true"); - headers.forEach(httpHeaders::add); - return httpHeaders; - } +@Component(value = ClientType.AAI) +@ConditionalOnExpression("${aai-rest-client.enabled:false}") +public class AAIRestClient extends TwoWaySSLRestClient { + + private static Logger logger = LoggerFactory.getLogger(AAIRestClient.class); + + @Value("${aai.base.url}") + private String baseUrl; + + @Value("${aai.ssl.key-store}") + private String keystorePath; + + @Value("${aai.ssl.trust-store}") + private String truststorePath; + + @Value("${aai.ssl.key-store-password}") + private String keystorePassword; + + @Value("${aai.ssl.trust-store-password}") + private String truststorePassword; + + @Override + public String getBaseUrl() { + return baseUrl; + } + + @Override + protected String getKeystorePath() { + return keystorePath; + } + + @Override + protected String getTruststorePath() { + return truststorePath; + } + + @Override + protected char[] getKeystorePassword() { + return keystorePassword.toCharArray(); + } + + @Override + protected char[] getTruststorePassword() { + return truststorePassword.toCharArray(); + } + + @Override + public MultiValueMap getHeaders(Map headers) { + HttpHeaders httpHeaders = new HttpHeaders(); + httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + httpHeaders.setContentType(MediaType.APPLICATION_JSON); + httpHeaders.add("Real-Time", "true"); + headers.forEach(httpHeaders::add); + return httpHeaders; + } }