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;
24 import java.util.Properties;
26 import org.apache.http.impl.client.DefaultHttpClient;
28 import org.openecomp.mso.properties.MsoJavaProperties;
30 public class RequestClientFactory {
32 //based on URI, returns BPEL, CamundaTask or Camunda client
33 public static RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
34 RequestClient retClient;
36 throw new IllegalStateException("properties is null");
39 if(orchestrationURI.contains(CommonConstants.BPEL_SEARCH_STR)){
40 url = props.getProperty(CommonConstants.BPEL_URL,null) + orchestrationURI;
41 retClient= new BPELRestClient();
43 }else if(orchestrationURI.contains(CommonConstants.TASK_SEARCH_STR)){
44 url = props.getProperty(CommonConstants.CAMUNDA_URL,null) + orchestrationURI;
45 retClient = new CamundaTaskClient();
48 url = props.getProperty(CommonConstants.CAMUNDA_URL,null) + orchestrationURI;
49 retClient = new CamundaClient();
51 retClient.setClient(new DefaultHttpClient());
52 retClient.setProps(props);
53 retClient.setUrl(url);