e39a9ca705835aa2a435a96d20379c36a7eb188d
[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.Category;
24 import org.apache.camel.Consumer;
25 import org.apache.camel.Processor;
26 import org.apache.camel.Producer;
27 import org.apache.camel.support.DefaultEndpoint;
28 import org.apache.camel.spi.Metadata;
29 import org.apache.camel.spi.UriEndpoint;
30 import org.apache.camel.spi.UriParam;
31 import org.apache.camel.spi.UriPath;
32
33 import java.util.Map;
34
35
36 @UriEndpoint(scheme = "ecomp-rest", syntax = "ecomp-rest:op",
37     consumerClass = RestClientConsumer.class, label = "RestClient2", title = "ecomp-rest",
38     firstVersion = "1.0.0", category = {Category.CORE})
39 public class RestClientEndpoint extends DefaultEndpoint {
40
41   public static final String CONTEXT_PARAM_CLIENT_CERT = "ecomp-client-cert";
42   public static final String CONTEXT_PARAM_KEYSTORE = "ecomp-keystore";
43   public static final String CONTEXT_PARAM_KEYSTORE_PWD = "ecomp-keystore-password";
44
45   public static final String IN_HEADER_URL = "ecomp-url";
46
47   public static final String OUT_HEADER_RESPONSE_CODE = "ecomp-response-code";
48   public static final String OUT_HEADER_RESPONSE_MSG = "ecomp-response-message";
49
50   @UriPath(description = "op")
51   @Metadata(required = true)
52   private String op;
53   @UriParam(description = "ecomp client cert")
54   private String ecompClientCert;
55   @UriParam(description = "ecomp key store")
56   private String ecompKeystore;
57   @UriParam(description = "ecomp key store passwd")
58   private String ecompKeystorePassword;
59
60   public RestClientEndpoint() {}
61
62   public RestClientEndpoint(String uri, RestClientComponent component) {
63     super(uri, component);
64   }
65
66   @Override
67   public void setProperties(Object bean, Map<String, Object> parameters) {
68     super.setProperties(bean, parameters);
69   }
70
71   public Producer createProducer() throws Exception {
72     return new RestClientProducer(this);
73   }
74   @Override
75   public Consumer createConsumer(Processor processor) throws Exception {
76     return new RestClientConsumer(this, processor);
77   }
78   @Override
79   public boolean isSingleton() {
80     return true;
81   }
82
83   public String getOp() {
84     return op;
85   }
86
87   public void setOp(String op) {
88     this.op = op;
89   }
90
91   public String getEcompClientCert() {
92     return ecompClientCert;
93   }
94
95   public void setEcompClientCert(String ecompClientCert) {
96     this.ecompClientCert = ecompClientCert;
97   }
98
99   public String getEcompKeystore() {
100     return ecompKeystore;
101   }
102
103   public void setEcompKeystore(String ecompKeystore) {
104     this.ecompKeystore = ecompKeystore;
105   }
106
107   public String getEcompKeystorePassword() {
108     return ecompKeystorePassword;
109   }
110
111   public void setEcompKeystorePassword(String ecompKeystorePassword) {
112     this.ecompKeystorePassword = ecompKeystorePassword;
113   }
114 }