Merge "Reorder modifiers"
[so.git] / mso-api-handlers / mso-api-handler-common / src / main / java / org / openecomp / mso / apihandler / common / RequestClientFactory.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.mso.apihandler.common;
22
23
24 import org.apache.http.impl.client.DefaultHttpClient;
25
26 import org.openecomp.mso.properties.MsoJavaProperties;
27
28 public class RequestClientFactory {
29
30     private RequestClientFactory() {
31     }
32
33         //based on URI, returns BPEL, CamundaTask or Camunda client
34         public static RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
35                 RequestClient retClient;
36                 if(props ==null){
37                         throw new IllegalStateException("properties is null");
38                 }
39                 String url;
40                 if(orchestrationURI.contains(CommonConstants.BPEL_SEARCH_STR)){
41                         url = props.getProperty(CommonConstants.BPEL_URL,null) + orchestrationURI;
42                         retClient= new BPELRestClient();
43                         
44                 }else if(orchestrationURI.contains(CommonConstants.TASK_SEARCH_STR)){
45                         url = props.getProperty(CommonConstants.CAMUNDA_URL,null) + orchestrationURI;
46                         retClient = new CamundaTaskClient();
47                 }
48                 else{
49                         url = props.getProperty(CommonConstants.CAMUNDA_URL,null) + orchestrationURI;
50                         retClient = new CamundaClient();
51                 }
52                 retClient.setClient(new DefaultHttpClient());
53                 retClient.setProps(props);
54                 retClient.setUrl(url);
55                 return retClient;
56                 
57         }
58         
59
60
61 }