Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-api-handlers / mso-api-handler-common / src / main / java / org / onap / so / 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.onap.so.apihandler.common;
22
23
24
25 import org.apache.http.impl.client.DefaultHttpClient;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.core.env.Environment;
28 import org.springframework.stereotype.Component;
29
30 @Component
31 public class RequestClientFactory {
32
33     @Autowired
34     private Environment env;
35
36     // based on URI, returns BPEL, CamundaTask or Camunda client
37     public RequestClient getRequestClient(String orchestrationURI) throws IllegalStateException {
38         RequestClient retClient;
39
40         String url;
41         if (orchestrationURI.contains(CommonConstants.TASK_SEARCH_STR)) {
42             url = env.getProperty(CommonConstants.CAMUNDA_URL) + orchestrationURI;
43             retClient = new CamundaTaskClient();
44         } else {
45             url = env.getProperty(CommonConstants.CAMUNDA_URL) + orchestrationURI;
46             retClient = new CamundaClient();
47         }
48         retClient.setClient(new DefaultHttpClient());
49         retClient.setProps(env);
50         retClient.setUrl(url);
51         return retClient;
52
53     }
54
55     public Environment getEnv() {
56         return env;
57     }
58
59     public void setEnv(Environment env) {
60         this.env = env;
61     }
62
63
64
65 }