2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.dmaap.dbcapi.server;
22 import static com.att.eelf.configuration.Configuration.MDC_ALERT_SEVERITY;
23 import static com.att.eelf.configuration.Configuration.MDC_INSTANCE_UUID;
24 import static com.att.eelf.configuration.Configuration.MDC_SERVER_FQDN;
25 import static com.att.eelf.configuration.Configuration.MDC_SERVER_IP_ADDRESS;
26 import static com.att.eelf.configuration.Configuration.MDC_SERVICE_INSTANCE_ID;
27 import static com.att.eelf.configuration.Configuration.MDC_TARGET_ENTITY;
29 import java.net.InetAddress;
30 import java.util.Properties;
31 import java.util.UUID;
32 import org.onap.dmaap.dbcapi.authentication.ApiPerms;
33 import org.onap.dmaap.dbcapi.authentication.ApiPolicy;
34 import org.onap.dmaap.dbcapi.database.DatabaseClass;
35 import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
36 import org.onap.dmaap.dbcapi.model.Dmaap;
37 import org.onap.dmaap.dbcapi.util.DmaapConfig;
38 import org.onap.dmaap.dbcapi.util.Singleton;
41 public class Main extends BaseLoggingClass {
43 private static String provFQDN;
44 public static String getProvFQDN() {
47 public void setProvFQDN(String provFQDN) {
48 Main.provFQDN = provFQDN;
52 public static void main(String[] args) {
60 MDC.put(MDC_SERVICE_INSTANCE_ID, "");
62 MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
63 MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
64 } catch (Exception e) {
65 errorLogger.error("Error while getting hostname or address", e);
67 MDC.put(MDC_INSTANCE_UUID, UUID.randomUUID().toString());
68 MDC.put(MDC_ALERT_SEVERITY, "0");
69 MDC.put(MDC_TARGET_ENTITY, "DCAE");
71 appLogger.info("Started.");
72 Properties parameters = DmaapConfig.getConfig();
73 setProvFQDN( parameters.getProperty("ProvFQDN", "ProvFQDN.notset.com"));
75 // for fresh installs, we may come up with no dmaap name so need to have a way for Controller to talk to us
76 Singleton<Dmaap> dmaapholder = DatabaseClass.getDmaap();
77 String name = dmaapholder.get().getDmaapName();
78 ApiPolicy apiPolicy = new ApiPolicy();
79 if ( apiPolicy.isPermissionClassSet() && (name == null || name.isEmpty())) {
80 ApiPerms p = new ApiPerms();
85 new JettyServer(parameters);
86 } catch (Exception e) {
87 errorLogger.error("Unable to start Jetty " + DmaapConfig.getConfigFileName(), e);