2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.apihandler.common;
23 import java.io.IOException;
24 import java.security.GeneralSecurityException;
26 import org.apache.http.HttpResponse;
27 import org.apache.http.client.HttpClient;
28 import org.openecomp.mso.logger.MsoLogger;
29 import org.openecomp.mso.properties.MsoJavaProperties;
30 import org.openecomp.mso.utils.CryptoUtils;
32 public abstract class RequestClient {
33 private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
34 protected MsoJavaProperties props;
36 protected HttpClient client;
39 public RequestClient(int type){
43 public void setProps(MsoJavaProperties props) {
47 public void setUrl(String url) {
51 public String getUrl() {
59 public HttpClient getClient() {
63 public void setClient(HttpClient client) {
67 public abstract HttpResponse post(String request, String requestId, String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws IOException;
69 public abstract HttpResponse post(String request) throws IOException;
71 public abstract HttpResponse post(RequestClientParamater params) throws IOException;
73 public abstract HttpResponse get() throws IOException;
75 protected String getEncryptedPropValue (String prop, String defaultValue, String encryptionKey) {
77 return CryptoUtils.decrypt(prop, encryptionKey);
79 catch (GeneralSecurityException e) {
80 msoLogger.debug("Security exception", e);