06c9e0b2e1d47a0bcf64420aca97a9ee34a0ad4a
[aai/router-core.git] / src / main / java / org / onap / aai / rest / RestClientEndpoint.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.aai.rest;
22
23 import org.apache.camel.Consumer;
24 import org.apache.camel.Processor;
25 import org.apache.camel.Producer;
26 import org.apache.camel.impl.DefaultEndpoint;
27 import org.apache.camel.spi.Metadata;
28 import org.apache.camel.spi.UriEndpoint;
29 import org.apache.camel.spi.UriParam;
30 import org.apache.camel.spi.UriPath;
31
32 import java.util.Map;
33
34
35 /**
36  * Represents a RestClient endpoint.
37  */
38 @UriEndpoint(scheme = "ecomp-rest", syntax = "ecomp-rest:op",
39     consumerClass = RestClientConsumer.class, label = "RestClient2", title = "")
40 public class RestClientEndpoint extends DefaultEndpoint {
41
42   public static final String CONTEXT_PARAM_CLIENT_CERT = "ecomp-client-cert";
43   public static final String CONTEXT_PARAM_KEYSTORE = "ecomp-keystore";
44   public static final String CONTEXT_PARAM_KEYSTORE_PWD = "ecomp-keystore-password";
45
46   public static final String IN_HEADER_URL = "ecomp-url";
47
48   public static final String OUT_HEADER_RESPONSE_CODE = "ecomp-response-code";
49   public static final String OUT_HEADER_RESPONSE_MSG = "ecomp-response-message";
50
51   @UriPath
52   @Metadata(required = "true")
53   private String op;
54
55   @UriParam
56   private String ecompClientCert;
57
58   @UriParam
59   private String ecompKeystore;
60
61   @UriParam
62   private String ecompKeystorePassword;
63
64
65   public RestClientEndpoint() {}
66
67   public RestClientEndpoint(String uri, RestClientComponent component) {
68     super(uri, component);
69   }
70
71   public RestClientEndpoint(String endpointUri) {
72     super(endpointUri);
73   }
74
75   @Override
76   protected void setProperties(Object bean, Map<String, Object> parameters) throws Exception {
77     super.setProperties(bean, parameters);
78   }
79
80   public Producer createProducer() throws Exception {
81     return new RestClientProducer(this);
82   }
83   @Override
84   public Consumer createConsumer(Processor processor) throws Exception {
85     return new RestClientConsumer(this, processor);
86   }
87   @Override
88   public boolean isSingleton() {
89     return true;
90   }
91
92   public String getOp() {
93     return op;
94   }
95
96   public void setOp(String op) {
97     this.op = op;
98   }
99
100   public String getEcompClientCert() {
101     return ecompClientCert;
102   }
103
104   public void setEcompClientCert(String ecompClientCert) {
105     this.ecompClientCert = ecompClientCert;
106   }
107
108   public String getEcompKeystore() {
109     return ecompKeystore;
110   }
111
112   public void setEcompKeystore(String ecompKeystore) {
113     this.ecompKeystore = ecompKeystore;
114   }
115
116   public String getEcompKeystorePassword() {
117     return ecompKeystorePassword;
118   }
119
120   public void setEcompKeystorePassword(String ecompKeystorePassword) {
121     this.ecompKeystorePassword = ecompKeystorePassword;
122   }
123 }