2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=========================================================
19 package org.onap.dcaegen2.collectors.datafile.configuration;
21 import com.google.gson.JsonObject;
22 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
23 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
24 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration;
25 import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration;
29 * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 9/19/18
30 * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
32 public class CloudConfigParser {
34 private final JsonObject jsonObject;
36 CloudConfigParser(JsonObject jsonObject) {
37 this.jsonObject = jsonObject;
40 DmaapPublisherConfiguration getDmaapPublisherConfig() {
41 return new ImmutableDmaapPublisherConfiguration.Builder()
42 .dmaapTopicName(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapTopicName").getAsString())
43 .dmaapUserPassword(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapUserPassword").getAsString())
44 .dmaapPortNumber(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapPortNumber").getAsInt())
45 .dmaapProtocol(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapProtocol").getAsString())
46 .dmaapContentType(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapContentType").getAsString())
47 .dmaapHostName(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapHostName").getAsString())
48 .dmaapUserName(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapUserName").getAsString())
49 .trustStorePath(jsonObject.get("dmaap.security.trustStorePath").getAsString())
50 .trustStorePasswordPath(jsonObject.get("dmaap.security.trustStorePasswordPath").getAsString())
51 .keyStorePath(jsonObject.get("dmaap.security.keyStorePath").getAsString())
52 .keyStorePasswordPath(jsonObject.get("dmaap.security.keyStorePasswordPath").getAsString())
53 .enableDmaapCertAuth(jsonObject.get("dmaap.security.enableDmaapCertAuth").getAsBoolean())
57 DmaapConsumerConfiguration getDmaapConsumerConfig() {
58 return new ImmutableDmaapConsumerConfiguration.Builder()
59 .timeoutMs(jsonObject.get("dmaap.dmaapConsumerConfiguration.timeoutMS").getAsInt())
60 .dmaapHostName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapHostName").getAsString())
61 .dmaapUserName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapUserName").getAsString())
62 .dmaapUserPassword(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapUserPassword").getAsString())
63 .dmaapTopicName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapTopicName").getAsString())
64 .dmaapPortNumber(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapPortNumber").getAsInt())
65 .dmaapContentType(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapContentType").getAsString())
66 .messageLimit(jsonObject.get("dmaap.dmaapConsumerConfiguration.messageLimit").getAsInt())
67 .dmaapProtocol(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapProtocol").getAsString())
68 .consumerId(jsonObject.get("dmaap.dmaapConsumerConfiguration.consumerId").getAsString())
69 .consumerGroup(jsonObject.get("dmaap.dmaapConsumerConfiguration.consumerGroup").getAsString())
70 .trustStorePath(jsonObject.get("dmaap.security.trustStorePath").getAsString())
71 .trustStorePasswordPath(jsonObject.get("dmaap.security.trustStorePasswordPath").getAsString())
72 .keyStorePath(jsonObject.get("dmaap.security.keyStorePath").getAsString())
73 .keyStorePasswordPath(jsonObject.get("dmaap.security.keyStorePasswordPath").getAsString())
74 .enableDmaapCertAuth(jsonObject.get("dmaap.security.enableDmaapCertAuth").getAsBoolean())
78 public FtpesConfig getFtpesConfig() {
79 return new ImmutableFtpesConfig.Builder()
80 .keyCert(jsonObject.get("dmaap.ftpesConfig.keyCert").getAsString())
81 .keyPassword(jsonObject.get("dmaap.ftpesConfig.keyPassword").getAsString())
82 .trustedCA(jsonObject.get("dmaap.ftpesConfig.trustedCA").getAsString())
83 .trustedCAPassword(jsonObject.get("dmaap.ftpesConfig.trustedCAPassword").getAsString())