summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/dcae/ApplicationSettings.java176
-rw-r--r--src/main/java/org/onap/dcae/CLIUtils.java60
-rw-r--r--src/main/java/org/onap/dcae/commonFunction/CommonStartup.java107
-rw-r--r--src/main/java/org/onap/dcae/commonFunction/EventProcessor.java37
-rw-r--r--src/main/java/org/onap/dcae/commonFunction/event/publishing/DMaaPConfigurationParser.java3
-rw-r--r--src/main/java/org/onap/dcae/restapi/RestfulCollectorServlet.java9
-rw-r--r--src/main/java/org/onap/dcae/restapi/endpoints/EventReceipt.java6
7 files changed, 289 insertions, 109 deletions
diff --git a/src/main/java/org/onap/dcae/ApplicationSettings.java b/src/main/java/org/onap/dcae/ApplicationSettings.java
new file mode 100644
index 00000000..0ebd1e90
--- /dev/null
+++ b/src/main/java/org/onap/dcae/ApplicationSettings.java
@@ -0,0 +1,176 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Nokia. All rights reserved.s
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcae;
+
+import com.att.nsa.drumlin.till.nv.impl.nvReadableStack;
+import com.att.nsa.drumlin.till.nv.impl.nvReadableTable;
+import com.att.nsa.drumlin.till.nv.rrNvReadable;
+import com.google.common.annotations.VisibleForTesting;
+import io.vavr.Function1;
+import io.vavr.collection.HashMap;
+import io.vavr.collection.Map;
+import org.apache.commons.configuration.ConfigurationConverter;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.nio.file.Paths;
+
+/**
+ * Abstraction over application configuration.
+ * Its job is to provide easily discoverable (by method names lookup) and type safe access to configuration properties.
+ */
+public class ApplicationSettings {
+
+ private static final Logger inlog = LoggerFactory.getLogger(ApplicationSettings.class);
+ private static final String COLLECTOR_PROPERTIES = "etc/collector.properties";
+ private final PropertiesConfiguration properties = new PropertiesConfiguration();
+
+ public ApplicationSettings(String[] args, Function1<String[], Map<String, String>> argsParser) {
+ properties.setDelimiterParsingDisabled(true);
+ Map<String, String> parsedArgs = argsParser.apply(args);
+ loadProperties(Paths.get(new File(COLLECTOR_PROPERTIES).getAbsolutePath()).toString());
+ loadCommandLineProperties(parsedArgs);
+ parsedArgs.filterKeys(k -> !k.equals("c")).forEach(this::updateProperty);
+ }
+
+ private void loadCommandLineProperties(Map<String, String> parsedArgs) {
+ parsedArgs.get("c").forEach(e -> {
+ properties.clear();
+ loadProperties(e);
+ });
+ }
+
+ private void loadProperties(String property){
+ try {
+ properties.load(property);
+ } catch (ConfigurationException ex) {
+ inlog.error("Cannot load properties cause:", ex);
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public String validAuthorizationCredentials() {
+ return properties.getString("header.authlist", null);
+ }
+
+ public int maximumAllowedQueuedEvents() {
+ return properties.getInt("collector.inputQueue.maxPending", 1024 * 4);
+ }
+
+ public boolean jsonSchemaValidationEnabled() {
+ return properties.getInt("collector.schema.checkflag", -1) > 0;
+ }
+
+ public boolean authorizationEnabled() {
+ return properties.getInt("header.authflag", 0) > 0;
+ }
+
+ public JSONObject jsonSchema() {
+ return new JSONObject(
+ properties.getString("collector.schema.file", "{\"v5\":\"./etc/CommonEventFormat_28.3.json\"}"));
+ }
+
+ public int httpPort() {
+ return properties.getInt("collector.service.port", 8080);
+ }
+
+ public int httpsPort() {
+ return properties.getInt("collector.service.secure.port", 8443);
+ }
+
+ public boolean httpsEnabled() {
+ return httpsPort() > 0;
+ }
+
+ public boolean eventTransformingEnabled() {
+ return properties.getInt("event.transform.flag", 1) > 0;
+ }
+
+ public String keystorePasswordFileLocation() {
+ return properties.getString("collector.keystore.passwordfile", "./etc/passwordfile");
+ }
+
+ public String keystoreFileLocation() {
+ return properties.getString("collector.keystore.file.location", "../etc/keystore");
+ }
+
+ public String keystoreAlias() {
+ return properties.getString("collector.keystore.alias", "tomcat");
+ }
+
+ public String exceptionConfigFileLocation() {
+ return properties.getString("exceptionConfig", null);
+ }
+
+ public String cambriaConfigurationFileLocation() {
+ return properties.getString("collector.dmaapfile", "./etc/DmaapConfig.json");
+ }
+
+ public Map<String, String[]> dMaaPStreamsMapping() {
+ String streamIdsProperty = properties.getString("collector.dmaap.streamid", null);
+ if (streamIdsProperty == null) {
+ return HashMap.empty();
+ } else {
+ return convertDMaaPStreamsPropertyToMap(streamIdsProperty);
+ }
+ }
+
+ /*
+ * Kept back here for backward compatibility.
+ * RestfulCollectorServlet upon its initialization requires options to be represented
+ * as object represented by rrNvReadable interface, so we define a a handy transformation function here.
+ */
+ public rrNvReadable torrNvReadable() {
+ final nvReadableStack settings = new nvReadableStack();
+ settings.push(new nvReadableTable(ConfigurationConverter.getProperties(properties)));
+ return settings;
+ }
+
+ private Map<String, String[]> convertDMaaPStreamsPropertyToMap(String streamIdsProperty) {
+ java.util.HashMap<String, String[]> domainToStreamIdsMapping = new java.util.HashMap<>();
+ String[] topics = streamIdsProperty.split("\\|");
+ for (String t : topics) {
+ String domain = t.split("=")[0];
+ String[] streamIds = t.split("=")[1].split(",");
+ domainToStreamIdsMapping.put(domain, streamIds);
+ }
+ return HashMap.ofAll(domainToStreamIdsMapping);
+ }
+
+ private void updateProperty(String key, String value) {
+ if (properties.containsKey(key)) {
+ properties.setProperty(key, value);
+ } else {
+ properties.addProperty(key, value);
+ }
+ }
+
+ @VisibleForTesting
+ String getStringDirectly(String key) {
+ return properties.getString(key);
+ }
+}
+
diff --git a/src/main/java/org/onap/dcae/CLIUtils.java b/src/main/java/org/onap/dcae/CLIUtils.java
new file mode 100644
index 00000000..6450d2e5
--- /dev/null
+++ b/src/main/java/org/onap/dcae/CLIUtils.java
@@ -0,0 +1,60 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcae;
+
+import java.util.HashMap;
+
+/**
+ * CLIUtils extracted from nsaServerLibrary this implementation will be removed once we switch to different API library
+ */
+public class CLIUtils {
+
+ public static io.vavr.collection.HashMap<String, String> processCmdLine (String[] args) {
+ final HashMap<String,String> map = new HashMap<String,String> ();
+
+ String lastKey = null;
+ for ( String arg : args )
+ {
+ if ( arg.startsWith ( "-" ) )
+ {
+ if ( lastKey != null )
+ {
+ map.put ( lastKey.substring(1), "" );
+ }
+ lastKey = arg;
+ }
+ else
+ {
+ if ( lastKey != null )
+ {
+ map.put ( lastKey.substring(1), arg );
+ }
+ lastKey = null;
+ }
+ }
+ if ( lastKey != null )
+ {
+ map.put ( lastKey.substring(1), "" );
+ }
+ return io.vavr.collection.HashMap.ofAll(map);
+ }
+}
diff --git a/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java b/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java
index 3469531e..36713aa4 100644
--- a/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java
+++ b/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java
@@ -23,14 +23,8 @@ package org.onap.dcae.commonFunction;
import com.att.nsa.apiServer.ApiServer;
import com.att.nsa.apiServer.ApiServerConnector;
import com.att.nsa.apiServer.endpoints.NsaBaseEndpoint;
-import com.att.nsa.cmdLine.NsaCommandLineUtil;
-import com.att.nsa.drumlin.service.framework.DrumlinServlet;
-import com.att.nsa.drumlin.till.nv.impl.nvPropertiesFile;
-import com.att.nsa.drumlin.till.nv.impl.nvReadableStack;
-import com.att.nsa.drumlin.till.nv.impl.nvReadableTable;
import com.att.nsa.drumlin.till.nv.rrNvReadable;
import com.att.nsa.drumlin.till.nv.rrNvReadable.loadException;
-import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.JsonLoader;
@@ -39,99 +33,75 @@ import com.github.fge.jsonschema.core.report.ProcessingMessage;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchema;
import com.github.fge.jsonschema.main.JsonSchemaFactory;
-import java.io.IOException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
import org.apache.catalina.LifecycleException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.onap.dcae.ApplicationSettings;
+import org.onap.dcae.CLIUtils;
import org.onap.dcae.commonFunction.event.publishing.DMaaPConfigurationParser;
import org.onap.dcae.commonFunction.event.publishing.EventPublisher;
import org.onap.dcae.restapi.RestfulCollectorServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+
public class CommonStartup extends NsaBaseEndpoint implements Runnable {
- private static final String KCONFIG = "c";
- private static final String KSETTING_PORT = "collector.service.port";
- private static final int KDEFAULT_PORT = 8080;
- private static final String KSETTING_SECUREPORT = "collector.service.secure.port";
- private static final int KDEFAULT_SECUREPORT = -1;
- private static final String KSETTING_KEYSTOREPASSFILE = "collector.keystore.passwordfile";
- private static final String KDEFAULT_KEYSTOREPASSFILE = "../etc/passwordfile";
- private static final String KSETTING_KEYSTOREFILE = "collector.keystore.file.location";
- private static final String KDEFAULT_KEYSTOREFILE = "../etc/keystore";
- private static final String KSETTING_KEYALIAS = "collector.keystore.alias";
- private static final String KDEFAULT_KEYALIAS = "tomcat";
- private static final String KSETTING_DMAAPCONFIGS = "collector.dmaapfile";
- private static final String[] KDEFAULT_DMAAPCONFIGS = new String[]{"/etc/DmaapConfig.json"};
- private static final String KSETTING_SCHEMAVALIDATOR = "collector.schema.checkflag";
- private static final int KDEFAULT_SCHEMAVALIDATOR = -1;
- private static final String KSETTING_SCHEMAFILE = "collector.schema.file";
- private static final String KDEFAULT_SCHEMAFILE = "{\"v5\":\"./etc/CommonEventFormat_28.3.json\"}";
- private static final String KSETTING_DMAAPSTREAMID = "collector.dmaap.streamid";
- private static final String KSETTING_AUTHFLAG = "header.authflag";
- private static final int KDEFAULT_AUTHFLAG = 0;
- private static final String KSETTING_EVENTTRANSFORMFLAG = "event.transform.flag";
- private static final int KDEFAULT_EVENTTRANSFORMFLAG = 1;
private static final Logger metriclog = LoggerFactory.getLogger("com.att.ecomp.metrics");
public static final Logger inlog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.input");
static final Logger oplog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.output");
public static final Logger eplog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.error");
- public static final String KSETTING_AUTHLIST = "header.authlist";
- static final int KDEFAULT_MAXQUEUEDEVENTS = 1024 * 4;
- public static int schemaValidatorflag = -1;
- public static int authflag = 1;
- static int eventTransformFlag = 1;
+ static int maxQueueEvent = 1024 * 4;
+ public static boolean schemaValidatorflag = false;
+ public static boolean authflag = false;
+ static boolean eventTransformFlag = true;
public static JSONObject schemaFileJson;
static String cambriaConfigFile;
- public static String streamID;
+ public static io.vavr.collection.Map<String , String [] > streamID;
static LinkedBlockingQueue<JSONObject> fProcessingInputQueue;
private static ApiServer fTomcatServer = null;
private static final Logger log = LoggerFactory.getLogger(CommonStartup.class);
- private CommonStartup(rrNvReadable settings) throws loadException, IOException, rrNvReadable.missingReqdSetting {
+ private CommonStartup(ApplicationSettings settings) throws loadException, IOException, rrNvReadable.missingReqdSetting {
final List<ApiServerConnector> connectors = new LinkedList<>();
- if (settings.getInt(KSETTING_PORT, KDEFAULT_PORT) > 0) {
- connectors.add(new ApiServerConnector.Builder(settings.getInt(KSETTING_PORT, KDEFAULT_PORT)).secure(false)
- .build());
+ if (!settings.authorizationEnabled()) {
+ connectors.add(new ApiServerConnector.Builder(settings.httpPort()).secure(false).build());
}
- final int securePort = settings.getInt(KSETTING_SECUREPORT, KDEFAULT_SECUREPORT);
- final String keystoreFile = settings.getString(KSETTING_KEYSTOREFILE, KDEFAULT_KEYSTOREFILE);
- final String keystorePasswordFile = settings.getString(KSETTING_KEYSTOREPASSFILE, KDEFAULT_KEYSTOREPASSFILE);
- final String keyAlias = settings.getString(KSETTING_KEYALIAS, KDEFAULT_KEYALIAS);
+ final int securePort = settings.httpsPort();
+ final String keystoreFile = settings.keystoreFileLocation();
+ final String keystorePasswordFile = settings.keystorePasswordFileLocation();
+ final String keyAlias = settings.keystoreAlias();
- if (securePort > 0) {
+ if (settings.authorizationEnabled()) {
String keystorePassword = readFile(keystorePasswordFile);
connectors.add(new ApiServerConnector.Builder(securePort).secure(true)
- .keystorePassword(keystorePassword).keystoreFile(keystoreFile).keyAlias(keyAlias).build());
+ .keystorePassword(keystorePassword).keystoreFile(keystoreFile).keyAlias(keyAlias).build());
}
- schemaValidatorflag = settings.getInt(KSETTING_SCHEMAVALIDATOR, KDEFAULT_SCHEMAVALIDATOR);
- if (schemaValidatorflag > 0) {
- String schemaFile = settings.getString(KSETTING_SCHEMAFILE, KDEFAULT_SCHEMAFILE);
- schemaFileJson = new JSONObject(schemaFile);
+ schemaValidatorflag = settings.jsonSchemaValidationEnabled();
+ maxQueueEvent = settings.maximumAllowedQueuedEvents();
+ if (schemaValidatorflag) {
+ schemaFileJson = settings.jsonSchema();
}
- authflag = settings.getInt(CommonStartup.KSETTING_AUTHFLAG, CommonStartup.KDEFAULT_AUTHFLAG);
- String[] currentConfigFile = settings.getStrings(KSETTING_DMAAPCONFIGS, KDEFAULT_DMAAPCONFIGS);
- cambriaConfigFile = currentConfigFile[0];
- streamID = settings.getString(KSETTING_DMAAPSTREAMID, null);
- eventTransformFlag = settings.getInt(KSETTING_EVENTTRANSFORMFLAG, KDEFAULT_EVENTTRANSFORMFLAG);
+ authflag = settings.authorizationEnabled();
+ cambriaConfigFile = settings.cambriaConfigurationFileLocation();
+ streamID = settings.dMaaPStreamsMapping();
+ eventTransformFlag = settings.eventTransformingEnabled();
fTomcatServer = new ApiServer.Builder(connectors, new RestfulCollectorServlet(settings)).encodeSlashes(true)
.name("collector").build();
@@ -139,19 +109,12 @@ public class CommonStartup extends NsaBaseEndpoint implements Runnable {
public static void main(String[] args) {
try {
- final Map<String, String> argMap = NsaCommandLineUtil.processCmdLine(args, true);
- final String config = NsaCommandLineUtil.getSetting(argMap, KCONFIG, "collector.properties");
- final URL settingStream = DrumlinServlet.findStream(config, CommonStartup.class);
-
- final nvReadableStack settings = new nvReadableStack();
- settings.push(new nvPropertiesFile(settingStream));
- settings.push(new nvReadableTable(argMap));
- fProcessingInputQueue = new LinkedBlockingQueue<>(CommonStartup.KDEFAULT_MAXQUEUEDEVENTS);
+ fProcessingInputQueue = new LinkedBlockingQueue<>(CommonStartup.maxQueueEvent);
VESLogger.setUpEcompLogging();
- CommonStartup cs = new CommonStartup(settings);
+ CommonStartup cs = new CommonStartup(new ApplicationSettings(args, CLIUtils::processCmdLine));
Thread commonStartupThread = new Thread(cs);
commonStartupThread.start();
diff --git a/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java b/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java
index 9d6ad360..a57ea3f0 100644
--- a/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java
+++ b/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,6 @@ import com.att.nsa.logging.LoggingContext;
import com.att.nsa.logging.log4j.EcompFields;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
-import java.util.Map;
import org.json.JSONObject;
import org.onap.dcae.commonFunction.event.publishing.EventPublisher;
import org.slf4j.Logger;
@@ -40,38 +39,25 @@ import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
-
+import java.util.Map;
class EventProcessor implements Runnable {
private static final Logger log = LoggerFactory.getLogger(EventProcessor.class);
private static final String EVENT_LITERAL = "event";
private static final String COMMON_EVENT_HEADER = "commonEventHeader";
- static final Type EVENT_LIST_TYPE = new TypeToken<List<Event>>() {
- }.getType();
+ static final Type EVENT_LIST_TYPE = new TypeToken<List<Event>>() {}.getType();
private final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MM dd yyyy hh:mm:ss z");
- static Map<String, String[]> streamidHash = new HashMap<>();
- public JSONObject event;
+ static Map<String, String[]> streamidHash = new HashMap<>();
+ public JSONObject event;
private EventPublisher eventPublisher;
public EventProcessor(EventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
- streamidHash = parseStreamIdToStreamHashMapping(CommonStartup.streamID);
- }
-
- private Map<String, String[]> parseStreamIdToStreamHashMapping(String streamId) {
- Map<String, String[]> streamidHash = new HashMap<>();
- String[] list = streamId.split("\\|");
- for (String aList : list) {
- String domain = aList.split("=")[0];
- String[] streamIdList = aList.substring(aList.indexOf('=') + 1).split(",");
- streamidHash.put(domain, streamIdList);
- }
- return streamidHash;
+ streamidHash = CommonStartup.streamID.toJavaMap();
}
-
@Override
public void run() {
try {
@@ -101,14 +87,13 @@ class EventProcessor implements Runnable {
log.error("EventProcessor InterruptedException" + e.getMessage());
Thread.currentThread().interrupt();
}
-
}
public void overrideEvent() {
// Set collector timestamp in event payload before publish
addCurrentTimeToEvent(event);
- if (CommonStartup.eventTransformFlag == 1) {
+ if (CommonStartup.eventTransformFlag) {
// read the mapping json file
try (FileReader fr = new FileReader("./etc/eventTransform.json")) {
log.info("parse eventTransform.json");
@@ -118,13 +103,11 @@ class EventProcessor implements Runnable {
log.error("Couldn't find file ./etc/eventTransform.json" + e.toString());
}
}
- // Remove VESversion from event. This field is for internal use and must
- // be removed after use.
+ // Remove VESversion from event. This field is for internal use and must be removed after use.
if (event.has("VESversion"))
event.remove("VESversion");
log.debug("Modified event:" + event);
-
}
private void sendEventsToStreams(String[] streamIdList) {
@@ -132,7 +115,6 @@ class EventProcessor implements Runnable {
log.info("Invoking publisher for streamId:" + aStreamIdList);
this.overrideEvent();
eventPublisher.sendEvent(event, aStreamIdList);
-
}
}
@@ -145,7 +127,6 @@ class EventProcessor implements Runnable {
}
void parseEventsJson(List<Event> eventsTransform, ConfigProcessorAdapter configProcessorAdapter) {
-
// load VESProcessors class at runtime
for (Event eventTransform : eventsTransform) {
JSONObject filterObj = new JSONObject(eventTransform.filter.toString());
diff --git a/src/main/java/org/onap/dcae/commonFunction/event/publishing/DMaaPConfigurationParser.java b/src/main/java/org/onap/dcae/commonFunction/event/publishing/DMaaPConfigurationParser.java
index bef14448..5865b12c 100644
--- a/src/main/java/org/onap/dcae/commonFunction/event/publishing/DMaaPConfigurationParser.java
+++ b/src/main/java/org/onap/dcae/commonFunction/event/publishing/DMaaPConfigurationParser.java
@@ -59,8 +59,7 @@ public final class DMaaPConfigurationParser {
private static Try<Map<String, PublisherConfig>> toConfigMap(AnyNode config) {
return Try(() -> usesLegacyFormat(config) ? parseLegacyFormat(config) : parseNewFormat(config))
- .mapFailure(enhanceError(
- f("Parsing DMaaP configuration: '%s' failed, probably it is in unexpected format", config)));
+ .mapFailure(enhanceError(f("Parsing DMaaP configuration: '%s' failed, probably it is in unexpected format", config)));
}
private static boolean usesLegacyFormat(AnyNode dMaaPConfig) {
diff --git a/src/main/java/org/onap/dcae/restapi/RestfulCollectorServlet.java b/src/main/java/org/onap/dcae/restapi/RestfulCollectorServlet.java
index 0d9df155..e5a29e9f 100644
--- a/src/main/java/org/onap/dcae/restapi/RestfulCollectorServlet.java
+++ b/src/main/java/org/onap/dcae/restapi/RestfulCollectorServlet.java
@@ -27,6 +27,7 @@ import java.net.URL;
import javax.servlet.ServletException;
import org.apache.tomcat.util.codec.binary.Base64;
+import org.onap.dcae.ApplicationSettings;
import org.onap.dcae.commonFunction.CommonStartup;
import org.onap.dcae.commonFunction.VESLogger;
import org.slf4j.Logger;
@@ -53,10 +54,10 @@ public class RestfulCollectorServlet extends CommonServlet
private static String authCredentialsList;
- public RestfulCollectorServlet ( rrNvReadable settings ) throws loadException, missingReqdSetting
+ public RestfulCollectorServlet ( ApplicationSettings settings ) throws loadException, missingReqdSetting
{
- super ( settings, "collector", false );
- authCredentialsList = settings.getString(CommonStartup.KSETTING_AUTHLIST, null);
+ super ( settings.torrNvReadable(), "collector", false );
+ authCredentialsList = settings.validAuthorizationCredentials();
}
@@ -91,7 +92,7 @@ public class RestfulCollectorServlet extends CommonServlet
final DrumlinPlayishRoutingFileSource drs = new DrumlinPlayishRoutingFileSource ( routes );
drr.addRouteSource ( drs );
- if (CommonStartup.authflag > 0) {
+ if (CommonStartup.authflag) {
NsaAuthenticator<NsaSimpleApiKey> NsaAuth;
NsaAuth = createAuthenticator(authCredentialsList);
diff --git a/src/main/java/org/onap/dcae/restapi/endpoints/EventReceipt.java b/src/main/java/org/onap/dcae/restapi/endpoints/EventReceipt.java
index d028a957..d60e2a11 100644
--- a/src/main/java/org/onap/dcae/restapi/endpoints/EventReceipt.java
+++ b/src/main/java/org/onap/dcae/restapi/endpoints/EventReceipt.java
@@ -100,7 +100,7 @@ public class EventReceipt extends NsaBaseEndpoint {
}
try {
- if (CommonStartup.authflag == 1) {
+ if (CommonStartup.authflag) {
userId = getUser (ctx);
retkey = NsaBaseEndpoint.getAuthenticatedUser(ctx);
}
@@ -160,8 +160,8 @@ public class EventReceipt extends NsaBaseEndpoint {
JSONArray jsonArrayMod = new JSONArray();
JSONObject event;
FileReader fr;
- if (retkey != null || CommonStartup.authflag == 0) {
- if (CommonStartup.schemaValidatorflag > 0) {
+ if (retkey != null || !CommonStartup.authflag) {
+ if (CommonStartup.schemaValidatorflag) {
if ((arrayFlag == 1) && (jsonObject.has("eventList") && (!jsonObject.has("event")))
|| ((arrayFlag == 0) && (!jsonObject.has("eventList") && (jsonObject.has("event"))))) {
fr = new FileReader(schemaFileVersion(vesVersion));