X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fmodelloader%2Frestclient%2FAaiRestClient.java;h=a2a4c5bdfee41d436d6fd76aa630a7e669997a5d;hb=270656abb1ed24930b2f9e57f5bef659494f5e8e;hp=7d2ab09c5fcd2d4e4b2dfeab790fe2540d0530e0;hpb=7b1f813441f94261f43ec4f5bb0944ad2570fbdf;p=aai%2Fmodel-loader.git diff --git a/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java b/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java index 7d2ab09..a2a4c5b 100644 --- a/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java +++ b/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java @@ -1,27 +1,26 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 European Software Marketing Ltd. + * ================================================================================ * 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 + * 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. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.restclient; import com.sun.jersey.core.util.MultivaluedMapImpl; // NOSONAR -// import edu.emory.mathcs.backport.java.util.Collections; import java.io.IOException; import java.io.StringReader; import java.net.URI; @@ -91,7 +90,7 @@ public class AaiRestClient { * @return operation result */ public OperationResult putResource(String url, String payload, String transId, MediaType mediaType) { - logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload); + logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload); return setupClient().put(url, payload, buildHeaders(transId), mediaType, mediaType); } @@ -106,7 +105,7 @@ public class AaiRestClient { * @return ClientResponse */ public OperationResult postResource(String url, String payload, String transId, MediaType mediaType) { - logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload); + logger.info(ModelLoaderMsgs.AAI_REST_REQUEST_PAYLOAD, payload); return setupClient().post(url, payload, buildHeaders(transId), mediaType, mediaType); } @@ -134,7 +133,7 @@ public class AaiRestClient { public OperationResult getAndDeleteResource(String url, String transId) { // First, GET the model OperationResult getResponse = getResource(url, transId, MediaType.APPLICATION_XML_TYPE); - if ((getResponse == null) || (getResponse.getResultCode() != Response.Status.OK.getStatusCode())) { + if (getResponse == null || getResponse.getResultCode() != Response.Status.OK.getStatusCode()) { return getResponse; } @@ -152,7 +151,7 @@ public class AaiRestClient { public boolean useBasicAuth() { - return (config.getAaiAuthenticationUser() != null) && (config.getAaiAuthenticationPassword() != null); + return config.getAaiAuthenticationUser() != null && config.getAaiAuthenticationPassword() != null; } private RestClient setupClient() { @@ -162,7 +161,9 @@ public class AaiRestClient { restClient.validateServerHostname(false) .validateServerCertChain(false) .clientCertFile(config.getAaiKeyStorePath()) - .clientCertPassword(config.getAaiKeyStorePassword()); + .clientCertPassword(config.getAaiKeyStorePassword()) + .connectTimeoutMs(120000) + .readTimeoutMs(120000); // @formatter:on if (useBasicAuth()) { @@ -180,7 +181,6 @@ public class AaiRestClient { * @param transId * @return map of headers */ - @SuppressWarnings("unchecked") private Map> buildHeaders(String transId) { MultivaluedMap headers = new MultivaluedMapImpl(); headers.put(HEADER_TRANS_ID, Collections.singletonList(transId));