summaryrefslogtreecommitdiffstats
path: root/appc-event-listener
diff options
context:
space:
mode:
Diffstat (limited to 'appc-event-listener')
-rw-r--r--appc-event-listener/appc-event-listener-bundle/pom.xml50
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/AppcEventListenerActivator.java12
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/ListenerImpl.java128
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/ProviderOperations.java296
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/WorkerImpl.java79
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/Action.java55
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/CommonMessage.java181
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/IncomingMessage.java140
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/OutgoingMessage.java150
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/Status.java74
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/conv/Converter.java45
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/ListenerImpl.java9
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/WorkerImpl.java22
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/model/DmaapMessage.java39
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/operation/ProviderOperations.java14
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/ListenerProperties.java37
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/impl/ListenerImpl.java (renamed from appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/impl/ListenerImpl.java)5
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/impl/ProviderOperations.java (renamed from appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/impl/ProviderOperations.java)4
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/impl/WorkerImpl.java (renamed from appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/impl/WorkerImpl.java)6
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/Action.java (renamed from appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/Action.java)2
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/CommonMessage.java (renamed from appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/CommonMessage.java)2
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/IncomingMessage.java (renamed from appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/IncomingMessage.java)2
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/OutgoingMessage.java (renamed from appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/OutgoingMessage.java)2
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/Status.java (renamed from appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/Status.java)2
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/impl/EventHandlerImpl.java112
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestListenerImpl.java43
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestProviderOperations.java122
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestWorker.java72
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/model/TestMessages.java151
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL1607/model/TestEnums.java59
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM/TestConverter.java2
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestListenerProperties.java18
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestEnums.java (renamed from appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/model/TestEnums.java)10
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestMessages.java (renamed from appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL1607/model/TestMessages.java)12
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestEventHandler.java5
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestListener.java2
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessage.txt24
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessagedemo.txt (renamed from appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessage1607.txt)0
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessage.txt14
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessagedemo.txt (renamed from appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessage1607.txt)0
-rw-r--r--appc-event-listener/appc-event-listener-bundle/src/test/resources/org/openecomp/appc/default.properties2
-rw-r--r--appc-event-listener/appc-event-listener-features/src/main/resources/features.xml3
-rw-r--r--appc-event-listener/pom.xml2
43 files changed, 229 insertions, 1780 deletions
diff --git a/appc-event-listener/appc-event-listener-bundle/pom.xml b/appc-event-listener/appc-event-listener-bundle/pom.xml
index 7b2285ad2..52dccf043 100644
--- a/appc-event-listener/appc-event-listener-bundle/pom.xml
+++ b/appc-event-listener/appc-event-listener-bundle/pom.xml
@@ -32,6 +32,19 @@
<groupId>org.openecomp.appc</groupId>
<artifactId>appc-dmaap-adapter-bundle</artifactId>
<version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-message-adapter-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-message-adapter-factory</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
</dependency>
<!--
<dependency>
@@ -58,6 +71,12 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.2</version>
+ <scope>compile</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
@@ -78,28 +97,15 @@
<Bundle-SymbolicName>org.openecomp.appc.listener</Bundle-SymbolicName>
<Bundle-Activator>org.openecomp.appc.listener.AppcEventListenerActivator</Bundle-Activator>
<Export-Package>org.openecomp.appc.listener</Export-Package>
- <Import-Package>
- !com.datastax.*,
- !com.ibm.icu.text,
- !com.jcraft.jzlib,
- !groovy.lang,
- !javax.jms,
- !net.sf.ehcache,
- !net.spy.memcached,
- !org.apache.commons.lang3,
- !org.apache.log,
- !org.apache.log4j.*,
- !org.apache.zookeeper.*,
- !org.jasypt.*,
- !org.codehaus.commons.compiler,
- !org.codehaus.groovy.*,
- !org.codehaus.jackson.*,
- !org.codehaus.jackson.map.*,
- !org.codehaus.janino,
- !org.I0Itec.*,
- !com.sun.faces.*,
- *;resolution:=optional</Import-Package>
- <Embed-Dependency>*;scope=compile|runtime;artifactId=!appc-metric-bundle|sli-common|org.eclipse.osgi|slf4j-api|jcl-over-slf4j|mysql-connector-java|xml-apis|pax-*</Embed-Dependency>
+ <Import-Package>org.openecomp.appc.adapter.message.*,org.openecomp.appc.adapter.factory.*,org.openecomp.appc.adapter.messaging.*
+ org.openecomp.appc.exceptions, org.openecomp.appc.util,
+ com.att.eelf.configuration, com.att.eelf.i18n,
+ *;resolution:=optional
+ </Import-Package>
+ <Embed-Dependency>
+ jasypt,commons-lang,commons-lang3,appc-common,
+ logback-core,logback-classic,eelf-core,commons-logging;scope=compile|runtime;inline=false
+ </Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/AppcEventListenerActivator.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/AppcEventListenerActivator.java
index b5f0af598..e9e4bd936 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/AppcEventListenerActivator.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/AppcEventListenerActivator.java
@@ -117,11 +117,13 @@ public class AppcEventListenerActivator implements BundleActivator {
Properties props = configuration.getProperties();
Set<ListenerProperties> listeners = new HashSet<ListenerProperties>();
-
- // Configure App-C 1607 Closed Loop Listener
- ListenerProperties cl1607Props = new ListenerProperties("appc.ClosedLoop1607", props);
- cl1607Props.setListenerClass(org.openecomp.appc.listener.CL1607.impl.ListenerImpl.class);
- listeners.add(cl1607Props);
+
+ // Configure event listener for the demo use case
+ ListenerProperties demoProps = new ListenerProperties("appc.demo", props);
+ demoProps.setListenerClass(org.openecomp.appc.listener.demo.impl.ListenerImpl.class);
+ listeners.add(demoProps);
+
+ // ===========================================================================
adapter = new ControllerImpl(listeners);
if (ctx != null && registration == null) {
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/ListenerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/ListenerImpl.java
deleted file mode 100644
index 3f0f8a112..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/ListenerImpl.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.impl;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-import java.util.concurrent.RejectedExecutionException;
-
-import org.openecomp.appc.listener.AbstractListener;
-import org.openecomp.appc.listener.ListenerProperties;
-import org.openecomp.appc.listener.CL.model.IncomingMessage;
-import org.openecomp.appc.listener.CL.model.Status;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.att.eelf.i18n.EELFResourceManager;
-
-public class ListenerImpl extends AbstractListener {
-
- private final EELFLogger LOG = EELFManager.getInstance().getLogger(ListenerImpl.class);
-
- private long startTime = 0;
-
- public ListenerImpl(ListenerProperties props) {
- super(props);
- String url = props.getProperty("provider.url");
- LOG.info("DMaaP Provider Endpoint: " + url);
- ProviderOperations.setUrl(url);
-
- // Set Basic Auth
- String user = props.getProperty("provider.user");
- String pass = props.getProperty("provider.pass");
- ProviderOperations.setAuthentication(user, pass);
- }
-
- @Override
- public void run() {
- // Some vars for benchmarking
- startTime = System.currentTimeMillis();
-
- LOG.info("Running DMaaP Listener");
-
- while (run.get()) {
- // Only update if the queue is low. otherwise we read in more
- // messages than we need
- try {
- if (executor.getQueue().size() <= QUEUED_MIN) {
- LOG.debug("DMaaP queue running low. Querying for more jobs");
- List<IncomingMessage> messages = dmaap.getIncomingEvents(IncomingMessage.class, QUEUED_MAX);
- LOG.debug(String.format("Read %d messages from dmaap", messages.size()));
- for (IncomingMessage incoming : messages) {
- // Acknowledge that we read the event
- LOG.info("Acknowledging Message: " + incoming.getId());
- dmaap.postStatus(incoming.toOutgoing(Status.PENDING, null).toString());
- }
- for (IncomingMessage incoming : messages) {
- // Add to pool if still running
- if (run.get()) {
- LOG.info(String.format("Adding DMaaP message to pool queue [%s]", incoming.getId()));
- if (incoming.isValid()) {
- try {
- executor.execute(new WorkerImpl(incoming, dmaap));
- } catch (RejectedExecutionException rejectEx) {
- LOG.error("Task Rejected: ", rejectEx);
- }
- } else {
- // Badly formed message
- LOG.error("Message was not valid. Rejecting");
- }
- } else {
- LOG.info("Run stopped. Orphaning Message: " + incoming.getId());
- }
- }
- }
- } catch (Exception e) {
- LOG.error("Exception " + e.getClass().getSimpleName() + " caught in DMaaP listener");
- LOG.error(EELFResourceManager.format(e));
- LOG.error("DMaaP Listener logging and ignoring the exception, continue...");
- }
- }
-
- LOG.info("Stopping DMaaP Listener thread");
-
- // We've told the listener to stop
- // TODO - Should we:
- // 1) Put a message back on the queue indicating that APP-C never got to
- // the message
- // or
- // 2) Let downstream figure it out after timeout between PENDING and
- // ACTIVE messages
- }
-
- @Override
- public String getBenchmark() {
- long time = System.currentTimeMillis();
- DateFormat df = new SimpleDateFormat("HH:mm:ss");
- df.setTimeZone(TimeZone.getTimeZone("UTC"));
- String runningTime = df.format(new Date(time - startTime));
-
- String out = String.format("Running for %s and completed %d jobs using %d threads.", runningTime,
- executor.getCompletedTaskCount(), executor.getPoolSize());
- LOG.info("***BENCHMARK*** " + out);
- return out;
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/ProviderOperations.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/ProviderOperations.java
deleted file mode 100644
index 7a53bcdd9..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/ProviderOperations.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.impl;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.Socket;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.io.IOUtils;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.scheme.PlainSocketFactory;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpProtocolParams;
-import org.apache.http.protocol.HTTP;
-import org.json.JSONObject;
-import org.openecomp.appc.exceptions.APPCException;
-import org.openecomp.appc.listener.CL.model.IncomingMessage;
-import org.openecomp.appc.listener.util.Mapper;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-public class ProviderOperations {
-
- private static final EELFLogger LOG = EELFManager.getInstance().getLogger(ProviderOperations.class);
-
- private static URL url;
-
- private static String basic_auth;
-
- //@formatter:off
- @SuppressWarnings("nls")
- private final static String TEMPLATE = "{\"input\": {\"common-request-header\": {\"service-request-id\": \"%s\"},\"vnf-resource\": {\"vm-id\": \"%s\"%s}}}";
- //@formatter:on
-
- /**
- * Calls the AppcProvider to run a topology directed graph
- *
- * @param msg
- * The incoming message to be run
- * @return True if the result is success. Never returns false and throws an exception instead.
- * @throws UnsupportedEncodingException
- * @throws Exception
- * if there was a failure processing the request. The exception message is the failure reason.
- */
- @SuppressWarnings("nls")
- public static boolean topologyDG(IncomingMessage msg) throws APPCException {
- if (msg == null) {
- throw new APPCException("Provided message was null");
- }
-
- HttpPost post = null;
- try {
- // Concatenate the "action" on the end of the URL
- String path = url.getPath() + ":" + msg.getAction().getValue().toLowerCase();
- URL serviceUrl = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);
-
- post = new HttpPost(serviceUrl.toExternalForm());
- post.setHeader("Content-Type", "application/json");
- post.setHeader("Accept", "application/json");
-
- // Set Auth
- if (basic_auth != null) {
- post.setHeader("Authorization", "Basic " + basic_auth);
- }
-
- String body = buildReqest(msg.getId(), msg.getUrl(), msg.getIdentityUrl());
-
-
- LOG.info(String.format("DMaaP ACTION PATH : %s", path));
- LOG.info(String.format("DMaaP ACTION BODY : %s", body));
-
- StringEntity entity = new StringEntity(body);
- entity.setContentType("application/json");
- post.setEntity(new StringEntity(body));
- } catch (UnsupportedEncodingException | MalformedURLException e) {
- throw new APPCException(e);
- }
-
- HttpClient client = getHttpClient();
-
- int httpCode = 0;
- String respBody = null;
- try {
- HttpResponse response = client.execute(post);
- httpCode = response.getStatusLine().getStatusCode();
- respBody = IOUtils.toString(response.getEntity().getContent());
- } catch (IOException e) {
- throw new APPCException(e);
- }
-
- if (httpCode >= 200 && httpCode < 300 && respBody != null) {
- JSONObject json;
- try {
- json = Mapper.toJsonObject(respBody);
- } catch (Exception e) {
- LOG.error("Error processing response from provider. Could not map response to json", e);
- throw new APPCException("APPC has an unknown RPC error");
- }
- boolean success;
- String reason;
- try {
- JSONObject header = json.getJSONObject("output").getJSONObject("common-response-header");
- success = header.getBoolean("success");
- reason = header.getString("reason");
- } catch (Exception e) {
- LOG.error("Unknown error prcoessing failed response from provider. Json not in expected format", e);
- throw new APPCException("APPC has an unknown RPC error");
- }
- if (success) {
- return true;
- }
- String reasonStr = reason == null ? "Unknown" : reason;
- LOG.warn(String.format("Topology Operation [%s] failed. Reason: %s", msg.getId(), reasonStr));
- throw new APPCException(reasonStr);
-
- }
- throw new APPCException(String.format("Unexpected response from endpoint: [%d] - %s ", httpCode, respBody));
- }
-
- /**
- * Updates the static var URL and returns the value;
- *
- * @return The new value of URL
- */
- public static String getUrl() {
- return url.toExternalForm();
- }
-
- public static void setUrl(String newUrl) {
- try {
- url = new URL(newUrl);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Sets the basic authentication header for the given user and password. If either entry is null then set basic auth
- * to null
- *
- * @param user
- * The user with optional domain name
- * @param password
- * The password for the user
- * @return The new value of the basic auth string that will be used in the request headers
- */
- public static String setAuthentication(String user, String password) {
- if (user != null && password != null) {
- String authStr = user + ":" + password;
- basic_auth = new String(Base64.encodeBase64(authStr.getBytes()));
- } else {
- basic_auth = null;
- }
- return basic_auth;
- }
-
- /**
- * Builds the request body for a topology operation
- *
- * @param id
- * The request id
- * @param action
- * The action in lowercase
- * @param url
- * The vm's url
- * @return A String containing the request body
- */
- private static String buildReqest(String id, String url, String ident) {
- String extraVmResource = "";
- if (ident != null) {
- extraVmResource = String.format(", \"identity-url\": \"%s\"", ident);
- }
- return String.format(TEMPLATE, id, url, extraVmResource);
- }
-
- @SuppressWarnings("deprecation")
- private static HttpClient getHttpClient() throws APPCException {
- HttpClient client;
- if (url.getProtocol().equals("https")) {
- try {
- KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
- trustStore.load(null, null);
- MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
- sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
-
- HttpParams params = new BasicHttpParams();
- HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
- HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
-
- SchemeRegistry registry = new SchemeRegistry();
- registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
- registry.register(new Scheme("https", sf, 443));
- registry.register(new Scheme("https", sf, 8443));
- registry.register(new Scheme("http", sf, 8181));
-
- ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
- client = new DefaultHttpClient(ccm, params);
- } catch (Exception e) {
- client = new DefaultHttpClient();
- }
- } else if (url.getProtocol().equals("http")) {
- client = new DefaultHttpClient();
- } else {
- throw new APPCException(
- "The provider.topology.url property is invalid. The url did not start with http[s]");
- }
- return client;
- }
-
- @SuppressWarnings("deprecation")
- public static class MySSLSocketFactory extends SSLSocketFactory {
- private SSLContext sslContext = SSLContext.getInstance("TLS");
-
- public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException,
- KeyStoreException, UnrecoverableKeyException {
- super(truststore);
-
- TrustManager tm = new X509TrustManager() {
- @Override
- public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- }
-
- @Override
- public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
- }
-
- @Override
- public X509Certificate[] getAcceptedIssuers() {
- return null;
- }
- };
-
- sslContext.init(null, new TrustManager[] {
- tm
- }, null);
- }
-
- @Override
- public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
- throws IOException, UnknownHostException {
- return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
- }
-
- @Override
- public Socket createSocket() throws IOException {
- return sslContext.getSocketFactory().createSocket();
- }
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/WorkerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/WorkerImpl.java
deleted file mode 100644
index 1eb13f736..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/impl/WorkerImpl.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.impl;
-
-import org.openecomp.appc.exceptions.APPCException;
-import org.openecomp.appc.listener.EventHandler;
-import org.openecomp.appc.listener.CL.model.IncomingMessage;
-import org.openecomp.appc.listener.CL.model.Status;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-public class WorkerImpl implements Runnable {
-
- private final EELFLogger LOG = EELFManager.getInstance().getLogger(WorkerImpl.class);
-
- // Should have all of the data we need for processing
- private IncomingMessage event;
-
- // So we can post messages from inside the worker.
- private EventHandler dmaap;
-
- public WorkerImpl(IncomingMessage message, EventHandler dmaap) {
- this.event = message;
- this.dmaap = dmaap;
- }
-
- @Override
- public void run() {
- LOG.debug(String.format("Started working on %s", event.getId()));
- dmaap.postStatus(event.toOutgoing(Status.ACTIVE, null));
- // Run the dg in a try catch to handle all exceptions and update the
- // message at the end
- try {
- if (doDG(event)) {
- dmaap.postStatus(event.toOutgoing(Status.SUCCESS, null));
- LOG.debug(String.format("Event %s finished successfully", event.getId()));
- } else {
- // Should never happen. Exception with message should be thrown instead.
- LOG.error(String.format(
- "We somehow returned false from doDG() instead of throwing exception. Incoming event [%s]",
- event.toJson().toString()));
- dmaap.postStatus(event.toOutgoing(Status.FAILURE));
- }
-
- } catch (Exception e) {
- // Unknown exception from DG method. Fail and pass the exception
- // along
- String msg = "Exception: " + e.getMessage();
- LOG.warn(String.format("Event %s finished with failure. %s", event.getId(), msg));
- dmaap.postStatus(event.toOutgoing(Status.FAILURE, msg));
- }
-
- LOG.debug("Done working on " + event.getId());
- }
-
- private boolean doDG(IncomingMessage msg) throws APPCException {
- return ProviderOperations.topologyDG(msg);
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/Action.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/Action.java
deleted file mode 100644
index a8fe8035b..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/Action.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.model;
-
-public enum Action {
- Restart("Restart"), Rebuild("Rebuild"), Migrate("Migrate"), Evacuate("Evacuate");
-
- /**
- * Converts the string to an Action
- *
- * @param value
- * The string to try and convert. Is case insensitive
- * @return The action matching the string or null if no match was found.
- */
- public static Action toAction(String value) {
- if (value != null) {
- for (Action e : values()) {
- if (e.getValue().toUpperCase().equals(value.toUpperCase())) {
- return e;
- }
- }
- }
-
- return null;
- }
-
- private String value;
-
- private Action(String valueToUse) {
- value = valueToUse;
- }
-
- public final String getValue() {
- return value;
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/CommonMessage.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/CommonMessage.java
deleted file mode 100644
index 76a112618..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/CommonMessage.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.model;
-
-import java.io.Serializable;
-
-import org.json.JSONObject;
-import org.openecomp.appc.listener.util.Mapper;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
-
-/**
- * This class holds attributes that are common to DMaaP messages both coming in from DCAE and being sent out by APPC
- *
- */
-@JsonSerialize(include = Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class CommonMessage implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /*
- * The unique id of the event as of 1602
- */
- @JsonProperty("eventID")
- private String id;
-
- /*
- * The time that the request was sent out.
- */
- @JsonProperty("requestTime")
- private String requestTime;
-
- /*
- * The originator of the event
- */
- @JsonProperty("requestClient")
- private String requestClient;
-
- /*
- * The system that sent the message
- */
- @JsonProperty("from")
- private String fromSystem;
-
- /*
- * The actual trap message
- */
- @JsonProperty("message")
- private String message;
-
- /*
- * The vm name associated with the event
- */
- @JsonProperty("VMName")
- private String vmName;
-
- /*
- * The policy name on the incoming event
- */
- @JsonProperty("policyName")
- private String policyName;
-
- /*
- * The policy version on the incoming event
- */
- @JsonProperty("policyVersion")
- private String policyVersion;
-
- @JsonIgnore
- private long startTime = System.currentTimeMillis();
-
- /*
- * Getters and Setters
- */
-
- public String getId() {
- return id;
- }
-
- public String getRequestTime() {
- return requestTime;
- }
-
- public String getRequestClient() {
- return requestClient;
- }
-
- public String getFromSystem() {
- return fromSystem;
- }
-
- public String getMessage() {
- return message;
- }
-
- public String getPolicyName() {
- return policyName;
- }
-
- public String getPolicyVersion() {
- return policyVersion;
- }
-
- public String getVmName() {
- return vmName;
- }
-
- public long getStartTime() {
- return startTime;
- }
-
- public void setId(String eventId) {
- id = eventId;
- }
-
- public void setRequestTime(String requestTime) {
- this.requestTime = requestTime;
- }
-
- public void setRequestClient(String requestClient) {
- this.requestClient = requestClient;
- }
-
- public void setFromSystem(String fromSystem) {
- this.fromSystem = fromSystem;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public void setPolicyName(String name) {
- policyName = name;
- }
-
- public void setPolicyVersion(String version) {
- policyVersion = version;
- }
-
- public void setVmName(String vmName) {
- this.vmName = vmName;
- }
-
- public void setStartTime(long startTime) {
- this.startTime = startTime;
- }
-
- /**
- * Convenience method to return a json representation of this object.
- *
- * @return The json representation of this object
- */
- public JSONObject toJson() {
- return Mapper.toJsonObject(this);
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/IncomingMessage.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/IncomingMessage.java
deleted file mode 100644
index 60d1d004b..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/IncomingMessage.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.model;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
-
-/**
- * This class reperesnts a message coming in from DCAE.
- *
- */
-@JsonSerialize(include = Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class IncomingMessage extends CommonMessage {
-
- private static final long serialVersionUID = 1L;
-
- /*
- * The action being requested. Its presence signals that it is an incoming message and it is not present on outgoing
- * messages
- */
- @JsonProperty("request")
- private String request;
-
- /*
- * The url for the server used for auth. http://<compute>:<port>/<tenentId>/server/<serverID>
- */
- @JsonProperty("VServerSelfLink")
- private String Url;
-
- /*
- * The tenant Id in OpenStack that the server belongs to
- */
- @JsonProperty("TenantID")
- private String TenantId;
-
- /*
- * The VM's UUID in
- */
- @JsonProperty("VMID")
- private String VmId;
-
- @JsonProperty("Identity")
- private String identityUrl;
-
- public String getRequest() {
- return request;
- }
-
- @JsonIgnore
- public Action getAction() {
- return Action.toAction(request);
- }
-
- public String getUrl() {
- return Url;
- }
-
- public String getTenantId() {
- return TenantId;
- }
-
- public String getVmId() {
- return VmId;
- }
-
- public String getIdentityUrl() {
- return identityUrl;
- }
-
- public void setUrl(String Url) {
- this.Url = Url;
- }
-
- public void setTenantId(String TenantId) {
- this.TenantId = TenantId;
- }
-
- public void setVmId(String VmId) {
- this.VmId = VmId;
- }
-
- public void setRequest(String request) {
- this.request = request;
- }
-
- public void setIdentityUrl(String identityUrl) {
- this.identityUrl = identityUrl;
- }
-
- @Override
- public String toString() {
- String time = getRequestTime() != null ? getRequestTime() : "N/A";
- // String req = request != null ? request : "N/A";
- return String.format("[%s - %s]", time, getId());
- }
-
- public String toOutgoing(Status status) {
- return toOutgoing(status, getMessage());
- }
-
- public String toOutgoing(Status status, String msg) {
- OutgoingMessage out = new OutgoingMessage(this);
- out.setResponse(status);
- out.setMessage(msg);
- return out.toResponse().toString();
- }
-
- /**
- * Determines if this message should be parsed parsed. Will eventually check that the message is well formed, has
- * all required fields, and had not exceeded any timing restrictions.
- *
- * @return True if the message should be parsed. False otherwise
- */
- public boolean isValid() {
- return true;
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/OutgoingMessage.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/OutgoingMessage.java
deleted file mode 100644
index fa8560ed2..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/OutgoingMessage.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.model;
-
-import java.net.InetAddress;
-import java.security.SecureRandom;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.json.JSONObject;
-import org.openecomp.appc.listener.util.Mapper;
-import org.openecomp.appc.util.Time;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
-
-/**
- * This class represents a message being sent out to DMaaP by APPC to update listeners on the status of a request
- *
- */
-@JsonSerialize(include = Inclusion.NON_NULL)
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class OutgoingMessage extends CommonMessage {
-
- private static final long serialVersionUID = -5447940920271469613L;
-
- @JsonProperty("response")
- private Status response;
-
- @JsonProperty("responseTime")
- private String responseTime;
-
- @JsonProperty("originalRequest")
- private String originalRequest;
-
- public OutgoingMessage() {
-
- }
-
- public OutgoingMessage(IncomingMessage msg) {
- setId(msg.getId());
- setOriginalRequest(msg.getRequest());
- setRequestClient(msg.getRequestClient());
- setRequestTime(msg.getRequestTime());
- setVmName(msg.getVmName());
- setFromSystem(generateFrom());
- setResponse(Status.PENDING);
- setPolicyName(msg.getPolicyName());
- setPolicyVersion(msg.getPolicyVersion());
- setStartTime(msg.getStartTime());
- }
-
- @JsonProperty("duration")
- public long getDuration() {
- return System.currentTimeMillis() - getStartTime();
- }
-
- public Status getResponse() {
- return response;
- }
-
- public String getResponseTime() {
- return responseTime;
- }
-
- public String getOriginalRequest() {
- return originalRequest;
- }
-
- @JsonIgnore
- public void setResponse(Status response) {
- this.response = response;
- }
-
- public void setResponse(String responseString) {
- this.response = Status.valueOf(responseString);
- }
-
- public void setResponseTime(String responseTime) {
- this.responseTime = responseTime;
- }
-
- public void setOriginalRequest(String originalRequest) {
- this.originalRequest = originalRequest;
- }
-
- public void updateResponseTime() {
- SecureRandom rand = new SecureRandom();
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss.SSS");
- df.setTimeZone(TimeZone.getTimeZone("UTC"));
- String date = df.format(new Date(Time.utcTime()));
- this.responseTime = String.format("%s%03d", date, rand.nextInt(1000));
- }
-
- public String generateFrom() {
- String name;
- try {
- InetAddress iAddress = InetAddress.getLocalHost();
- name = iAddress.getCanonicalHostName();
- } catch (Exception e) {
- // Could not get anything from the InetAddress
- name = "UnknownHost";
- }
- return "appc@" + name;
- }
-
- public JSONObject toResponse() {
- updateResponseTime();
- JSONObject json = Mapper.toJsonObject(this);
-
- if (!json.has("message")) {
- // If there is no message, parrot the status (response field)
- // TODO - Can this be removed for 1602 making message truely optional?
- json.put("message", this.getResponse().toString());
- }
-
- // Removed duplication of status from message for 1602
- // json.put("message", String.format("%s: %s", request, json.get("message")));
-
- return json;
- }
-
- @Override
- public String toString() {
- return String.format("%s - %s", getId(), getResponse());
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/Status.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/Status.java
deleted file mode 100644
index d8e8b5c64..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL/model/Status.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.model;
-
-public enum Status {
- /*
- * APP-C acknowledges that it has read the event off of the wire. This is the initial status of an OutgoingEvent
- */
- PENDING("PENDING"),
-
- /*
- * APP-C has started processing the event
- */
- ACTIVE("ACTIVE"),
-
- /*
- * APP-C has finished processing the event without errors
- */
- SUCCESS("SUCCESS"),
-
- /*
- * APP-C has finished processing the event with errors
- */
- FAILURE("FAILURE");
-
- /**
- * Converts the string to an Status
- *
- * @param value
- * The string to try and convert. Is case insensitive
- * @return The status matching the string or null if no match was found.
- */
- public static Status toStatus(String value) {
- if (value != null) {
- for (Status e : values()) {
- if (e.getValue().toUpperCase().equals(value.toUpperCase())) {
- return e;
- }
- }
- }
-
- return null;
- }
-
- private String value;
-
- private Status(String valueToUse) {
- value = valueToUse;
- }
-
- public final String getValue() {
- return value;
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/conv/Converter.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/conv/Converter.java
index 021dfefc8..29e0fc723 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/conv/Converter.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/conv/Converter.java
@@ -30,14 +30,15 @@ import org.openecomp.appc.listener.LCM.model.DmaapMessage;
import org.openecomp.appc.listener.LCM.model.DmaapOutgoingMessage;
import org.openecomp.appc.listener.util.Mapper;
-
public class Converter {
-
-
- public static DmaapOutgoingMessage convJsonNodeToDmaapOutgoingMessage(JsonNode inObj, String rpcName) {
- DmaapOutgoingMessage outObj = new DmaapOutgoingMessage();
+
+ public static DmaapOutgoingMessage convJsonNodeToDmaapOutgoingMessage(DmaapMessage event, JsonNode inObj) {
+ DmaapOutgoingMessage outObj = new DmaapOutgoingMessage();
outObj.setBody(inObj);
- outObj.setRpcName(rpcName);
+ outObj.setRpcName(event.getRpcName());
+ outObj.setVersion(event.getVersion());
+ outObj.setType("response");
+ outObj.setCorrelationID(event.getCorrelationID());
return outObj;
}
@@ -50,13 +51,16 @@ public class Converter {
}
- public static DmaapOutgoingMessage buildDmaapOutgoingMessageWithUnexpectedError(JsonNode dmaapInputBody, String rpcName,Exception inputException) {
- DmaapOutgoingMessage dmaapOutgoingMessage = null;
+ public static DmaapOutgoingMessage buildDmaapOutgoingMessageWithUnexpectedError(DmaapMessage event,Exception inputException) {
+ DmaapOutgoingMessage dmaapOutgoingMessage = null;
String errMsg = StringUtils.isEmpty(inputException.getMessage())? inputException.toString() : inputException.getMessage();
- JSONObject commonHeaderJsonObject = Mapper.toJsonObject(dmaapInputBody.get("input").get("common-header"));
+ JSONObject commonHeaderJsonObject = Mapper.toJsonObject(event.getBody().get("input").get("common-header"));
JSONObject jsonObjectOutput = new JSONObject().accumulate("common-header", commonHeaderJsonObject).accumulate("status", new JSONObject().accumulate("code",200).accumulate("value",errMsg));
dmaapOutgoingMessage = new DmaapOutgoingMessage();
- dmaapOutgoingMessage.setRpcName(rpcName);
+ dmaapOutgoingMessage.setRpcName(event.getRpcName());
+ dmaapOutgoingMessage.setCorrelationID(event.getCorrelationID());
+ dmaapOutgoingMessage.setType("error");
+ dmaapOutgoingMessage.setVersion(event.getVersion());
JSONObject jsonObjectBody = new JSONObject().accumulate("output",jsonObjectOutput);
JsonNode jsonNodeBody = Mapper.toJsonNodeFromJsonString(jsonObjectBody.toString());
dmaapOutgoingMessage.setBody(jsonNodeBody);
@@ -64,12 +68,10 @@ public class Converter {
}
public static String extractRequestIdWithSubId(JsonNode dmaapBody) {
- String requestId;
//TODO: null pointer exception if dmaapBody is null, check if null or ensure is not null before calling
JsonNode commonHeaderJsonNode = dmaapBody.get("input").get("common-header");
- requestId = commonHeaderJsonNode.get("request-id").asText();
- requestId = requestId != null ? requestId : "";
- String subRequestId = commonHeaderJsonNode.get("sub-request-id").asText();
+ String requestId = getValue(commonHeaderJsonNode,"request-id","");
+ String subRequestId = getValue(commonHeaderJsonNode,"sub-request-id","");
if(!StringUtils.isEmpty(subRequestId)){
requestId = requestId +"-"+subRequestId;
}
@@ -82,4 +84,19 @@ public class Converter {
return statusCode;
}
+ private static String getValue(JsonNode jsonNode,String name,String defaultValue){
+ if(jsonNode == null){
+ return defaultValue;
+ }
+ JsonNode childJsonNode = jsonNode.get(name);
+ if(childJsonNode == null){
+ return defaultValue;
+ }
+ String value = childJsonNode.asText();
+ if(value == null){
+ return defaultValue;
+ }
+ return value;
+ }
+
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/ListenerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/ListenerImpl.java
index dd877e98a..408e97a13 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/ListenerImpl.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/ListenerImpl.java
@@ -46,17 +46,20 @@ public class ListenerImpl extends AbstractListener {
private long startTime = 0;
+ private final ProviderOperations providerOperations;
+
public ListenerImpl(ListenerProperties props) {
super(props);
String url = props.getProperty("provider.url");
LOG.info("DMaaP Provider Endpoint: " + url);
- ProviderOperations.setUrl(url);
+ providerOperations = new ProviderOperations();
+ providerOperations.setUrl(url);
// Set Basic Auth
String user = props.getProperty("provider.user");
String pass = props.getProperty("provider.pass");
- ProviderOperations.setAuthentication(user, pass);
+ providerOperations.setAuthentication(user, pass);
}
@Override
@@ -91,7 +94,7 @@ public class ListenerImpl extends AbstractListener {
if (isValid(incoming)) {
LOG.info(String.format("Adding DMaaP message to pool queue [%s]", requestIdWithSubId));
try {
- executor.execute(new WorkerImpl(incoming.getRpcName(),incoming.getBody(), dmaap));
+ executor.execute(new WorkerImpl(incoming, dmaap, providerOperations));
} catch (RejectedExecutionException rejectEx) {
LOG.error("Task Rejected: ", rejectEx);
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/WorkerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/WorkerImpl.java
index af8334ee4..41a77c7fc 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/WorkerImpl.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/impl/WorkerImpl.java
@@ -24,6 +24,7 @@ package org.openecomp.appc.listener.LCM.impl;
import org.openecomp.appc.exceptions.APPCException;
import org.openecomp.appc.listener.EventHandler;
import org.openecomp.appc.listener.LCM.conv.Converter;
+import org.openecomp.appc.listener.LCM.model.DmaapMessage;
import org.openecomp.appc.listener.LCM.model.DmaapOutgoingMessage;
import org.openecomp.appc.listener.LCM.operation.ProviderOperations;
@@ -38,28 +39,31 @@ public class WorkerImpl implements Runnable {
private final EELFLogger LOG = EELFManager.getInstance().getLogger(WorkerImpl.class);
// Should have all of the data we need for processing
- private JsonNode event;
+ private DmaapMessage event;
// So we can post messages from inside the worker.
private EventHandler dmaap;
- private String rpcName;
- public WorkerImpl(String rpcName,JsonNode message, EventHandler dmaap) {
- this.rpcName = rpcName;
+ //so we know were to post the messages
+ private final ProviderOperations providerOperations;
+
+
+ public WorkerImpl(DmaapMessage message, EventHandler dmaap, ProviderOperations providerOperations) {
this.event = message;
this.dmaap = dmaap;
+ this.providerOperations = providerOperations;
}
@Override
public void run() {
- String requestIdWithSubId = extractRequestIdWithSubId(event);
+ String requestIdWithSubId = extractRequestIdWithSubId(event.getBody());
LOG.debug(String.format("Started working on %s", requestIdWithSubId));
// Run the dg in a try catch to handle all exceptions and update the
// message at the end
try {
- JsonNode outputJsonNode = doDG(rpcName, event);
- DmaapOutgoingMessage dmaapOutgoingMessage= Converter.convJsonNodeToDmaapOutgoingMessage(outputJsonNode,rpcName);
+ JsonNode outputJsonNode = doDG(event.getRpcName(), event.getBody());
+ DmaapOutgoingMessage dmaapOutgoingMessage= Converter.convJsonNodeToDmaapOutgoingMessage(event, outputJsonNode);
postMessageToDMaaP(dmaapOutgoingMessage,requestIdWithSubId);
Integer statusCode = extractStatusCode(dmaapOutgoingMessage.getBody());
if (ProviderOperations.isSucceeded(statusCode)) {
@@ -73,7 +77,7 @@ public class WorkerImpl implements Runnable {
// along
String msg = "Exception: " + e.getMessage();
LOG.error(String.format("Event %s finished with failure. %s", requestIdWithSubId, msg));
- DmaapOutgoingMessage dmaapOutgoingMessage= Converter.buildDmaapOutgoingMessageWithUnexpectedError(event,rpcName,e);
+ DmaapOutgoingMessage dmaapOutgoingMessage= Converter.buildDmaapOutgoingMessageWithUnexpectedError(event, e);
postMessageToDMaaP(dmaapOutgoingMessage,requestIdWithSubId);
}
@@ -115,6 +119,6 @@ public class WorkerImpl implements Runnable {
}
private JsonNode doDG(String rpcName, JsonNode msg) throws APPCException {
- return ProviderOperations.topologyDG(rpcName,msg);
+ return providerOperations.topologyDG(rpcName,msg);
}
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/model/DmaapMessage.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/model/DmaapMessage.java
index 56099cb7e..95453ad9c 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/model/DmaapMessage.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/model/DmaapMessage.java
@@ -31,6 +31,15 @@ import com.fasterxml.jackson.databind.JsonNode;
@JsonIgnoreProperties(ignoreUnknown = true)
public class DmaapMessage{
+ @JsonProperty("version")
+ private String version;
+
+ @JsonProperty("type")
+ private String type;
+
+ @JsonProperty("correlation-id")
+ private String correlationID;
+
@JsonProperty("cambria.partition")
private String cambriaPartition;
@@ -43,6 +52,30 @@ public class DmaapMessage{
public DmaapMessage() {
}
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getCorrelationID() {
+ return correlationID;
+ }
+
+ public void setCorrelationID(String correlationID) {
+ this.correlationID = correlationID;
+ }
+
public String getCambriaPartition() {
return cambriaPartition;
}
@@ -70,10 +103,14 @@ public class DmaapMessage{
@Override
public String toString() {
return "DmaapMessage{" +
- "cambriaPartition='" + cambriaPartition + '\'' +
+ "version='" + version + '\'' +
+ ", type='" + type + '\'' +
+ ", correlationId='" + correlationID + '\'' +
+ ", cambriaPartition='" + cambriaPartition + '\'' +
", rpcName='" + rpcName + '\'' +
", body=" + body +
'}';
}
+
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/operation/ProviderOperations.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/operation/ProviderOperations.java
index f5672a575..32118d4e8 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/operation/ProviderOperations.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/LCM/operation/ProviderOperations.java
@@ -65,8 +65,8 @@ public class ProviderOperations {
private static final EELFLogger LOG = EELFManager.getInstance().getLogger(ProviderOperations.class);
- private static URL url;
- private static String basic_auth;
+ private URL url;
+ private String basic_auth;
private static ProviderOperationRequestFormatter requestFormatter = new GenericProviderOperationRequestFormatter();
@@ -79,7 +79,7 @@ public class ProviderOperations {
* @throws Exception if there was a failure processing the request. The exception message is the failure reason.
*/
@SuppressWarnings("nls")
- public static JsonNode topologyDG(String rpcName, JsonNode msg) throws APPCException {
+ public JsonNode topologyDG(String rpcName, JsonNode msg) throws APPCException {
if (msg == null) {
throw new APPCException("Provided message was null");
}
@@ -146,11 +146,11 @@ public class ProviderOperations {
*
* @return The new value of URL
*/
- public static String getUrl() {
+ public String getUrl() {
return url.toExternalForm();
}
- public static void setUrl(String newUrl) {
+ public void setUrl(String newUrl) {
try {
url = new URL(newUrl);
} catch (MalformedURLException e) {
@@ -166,7 +166,7 @@ public class ProviderOperations {
* @param password The password for the user
* @return The new value of the basic auth string that will be used in the request headers
*/
- public static String setAuthentication(String user, String password) {
+ public String setAuthentication(String user, String password) {
if (user != null && password != null) {
String authStr = user + ":" + password;
basic_auth = new String(Base64.encodeBase64(authStr.getBytes()));
@@ -177,7 +177,7 @@ public class ProviderOperations {
}
@SuppressWarnings("deprecation")
- private static HttpClient getHttpClient() throws APPCException {
+ private HttpClient getHttpClient() throws APPCException {
HttpClient client;
if (url.getProtocol().equals("https")) {
try {
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/ListenerProperties.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/ListenerProperties.java
index c6c374eb0..2ff76b311 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/ListenerProperties.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/ListenerProperties.java
@@ -156,43 +156,6 @@ public class ListenerProperties {
return String.format("%s", prefix);
}
- /**
- * The message service types that are available. Choices are DMaaP and DMaaP.
- *
- * @since Apr 25, 2016
- * @version $Id$
- */
- public enum MessageService {
- DMaaP("dmaap");
-
- private String val;
-
- private MessageService(String val) {
- this.val = val;
- }
-
- public String getValue() {
- return val;
- }
-
- /**
- * Tries to match a string to a MessageService. If no match is found, returns the default (DMaaP)
- *
- * @param input
- * the string to try and match
- * @return A MessasgeService
- */
- public static MessageService parse(String input) {
- if (input != null) {
- for (MessageService ms : MessageService.values()) {
- if (ms.getValue().equals(input.toLowerCase())) {
- return ms;
- }
- }
- }
- return MessageService.DMaaP; // Default
- }
- }
/**
* Set of common properties that will be used by most systems. Primarily relating to DMaaP and ThreadPools
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/impl/ListenerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/impl/ListenerImpl.java
index 5d3b741ff..04fbe6982 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/impl/ListenerImpl.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/impl/ListenerImpl.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL1607.impl;
+package org.openecomp.appc.listener.demo.impl;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -30,8 +30,7 @@ import java.util.concurrent.RejectedExecutionException;
import org.openecomp.appc.listener.AbstractListener;
import org.openecomp.appc.listener.ListenerProperties;
-import org.openecomp.appc.listener.CL1607.model.IncomingMessage;
-import org.openecomp.appc.listener.CL1607.model.Status;
+import org.openecomp.appc.listener.demo.model.IncomingMessage;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/impl/ProviderOperations.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/impl/ProviderOperations.java
index c300df154..23a6f41ae 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/impl/ProviderOperations.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/impl/ProviderOperations.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL1607.impl;
+package org.openecomp.appc.listener.demo.impl;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -59,7 +59,7 @@ import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HTTP;
import org.json.JSONObject;
import org.openecomp.appc.exceptions.APPCException;
-import org.openecomp.appc.listener.CL1607.model.IncomingMessage;
+import org.openecomp.appc.listener.demo.model.IncomingMessage;
import org.openecomp.appc.listener.util.Mapper;
import com.att.eelf.configuration.EELFLogger;
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/impl/WorkerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/impl/WorkerImpl.java
index 52bcd2f5e..69db9cd3f 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/impl/WorkerImpl.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/impl/WorkerImpl.java
@@ -19,12 +19,12 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL1607.impl;
+package org.openecomp.appc.listener.demo.impl;
import org.openecomp.appc.exceptions.APPCException;
import org.openecomp.appc.listener.EventHandler;
-import org.openecomp.appc.listener.CL1607.model.IncomingMessage;
-import org.openecomp.appc.listener.CL1607.model.Status;
+import org.openecomp.appc.listener.demo.model.IncomingMessage;
+import org.openecomp.appc.listener.demo.model.Status;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/Action.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/Action.java
index 9e7e923be..413be61aa 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/Action.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/Action.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL1607.model;
+package org.openecomp.appc.listener.demo.model;
public enum Action {
Restart("Restart"), Rebuild("Rebuild"), Migrate("Migrate"), Evacuate("Evacuate"), Snapshot("Snapshot"),modifyconfig("ModifyConfig");
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/CommonMessage.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/CommonMessage.java
index 80a78095b..aa056d3a7 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/CommonMessage.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/CommonMessage.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL1607.model;
+package org.openecomp.appc.listener.demo.model;
import java.io.Serializable;
import java.util.Collection;
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/IncomingMessage.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/IncomingMessage.java
index 62d4d1b7d..6a345ea82 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/IncomingMessage.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/IncomingMessage.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL1607.model;
+package org.openecomp.appc.listener.demo.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/OutgoingMessage.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/OutgoingMessage.java
index 7b766212d..24b40c78e 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/OutgoingMessage.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/OutgoingMessage.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL1607.model;
+package org.openecomp.appc.listener.demo.model;
import java.net.InetAddress;
import java.security.SecureRandom;
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/Status.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/Status.java
index f7ec8febd..3cf2c5991 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/CL1607/model/Status.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/demo/model/Status.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL1607.model;
+package org.openecomp.appc.listener.demo.model;
public enum Status {
/*
diff --git a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/impl/EventHandlerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/impl/EventHandlerImpl.java
index 590afbe8b..ee9f30ea7 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/impl/EventHandlerImpl.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/main/java/org/openecomp/appc/listener/impl/EventHandlerImpl.java
@@ -20,29 +20,25 @@
*/
package org.openecomp.appc.listener.impl;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.openecomp.appc.adapter.dmaap.Consumer;
-import org.openecomp.appc.adapter.dmaap.DmaapConsumer;
-import org.openecomp.appc.adapter.dmaap.DmaapProducer;
-import org.openecomp.appc.adapter.dmaap.Producer;
-import org.openecomp.appc.adapter.dmaap.DmaapConsumer;
-import org.openecomp.appc.adapter.dmaap.DmaapProducer;
+import org.openecomp.appc.adapter.factory.DmaapMessageAdapterFactoryImpl;
+import org.openecomp.appc.adapter.factory.MessageService;
+import org.openecomp.appc.adapter.message.Consumer;
+import org.openecomp.appc.adapter.message.MessageAdapterFactory;
+import org.openecomp.appc.adapter.message.Producer;
import org.openecomp.appc.listener.EventHandler;
import org.openecomp.appc.listener.ListenerProperties;
-import org.openecomp.appc.listener.ListenerProperties.MessageService;
import org.openecomp.appc.listener.util.Mapper;
import org.openecomp.appc.logging.LoggingConstants;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
import org.slf4j.MDC;
+import java.util.*;
+
/**
* This class is a wrapper for the DMaaP client provided in appc-dmaap-adapter. Its aim is to ensure that only well formed
* messages are sent and received on DMaaP.
@@ -154,7 +150,16 @@ public class EventHandlerImpl implements EventHandler {
LOG.info("Getting Consumer...");
reader = getConsumer();
}
- for (String item : reader.fetch(READ_TIMEOUT * 1000, limit)) {
+
+ List<String> items = null;
+ try{
+ items = reader.fetch(READ_TIMEOUT * 1000, limit);
+ }catch(Error r){
+ LOG.error("EvenHandlerImpl.getIncomingEvents",r);
+ }
+
+
+ for (String item : items) {
out.add(item);
}
LOG.info(String.format("Read %d messages from %s as %s/%s.", out.size(), readTopic, clientName, clientId));
@@ -198,13 +203,25 @@ public class EventHandlerImpl implements EventHandler {
LOG.error(
"*****We will be writing and reading to the same topic without a filter. This will cause an infinite loop.*****");
}
- Consumer out;
- out = new DmaapConsumer(pool, readTopic, clientName, clientId, filter_json, apiKey, apiSecret);
- for (String url : pool) {
- if (url.contains("3905") || url.contains("https")) {
- out.useHttps(true);
- break;
- }
+
+ Consumer out=null;
+ BundleContext ctx = FrameworkUtil.getBundle(EventHandlerImpl.class).getBundleContext();
+ if (ctx != null) {
+ ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName());
+ if (svcRef != null) {
+ try{
+ out = ((MessageAdapterFactory) ctx.getService(svcRef)).createConsumer(pool, readTopic, clientName, clientId, filter_json, apiKey, apiSecret);
+ }catch(Error e){
+ //TODO:create eelf message
+ LOG.error("EvenHandlerImp.getConsumer calling MessageAdapterFactor.createConsumer",e);
+ }
+ for (String url : pool) {
+ if (url.contains("3905") || url.contains("https")) {
+ out.useHttps(true);
+ break;
+ }
+ }
+ }
}
return out;
}
@@ -217,18 +234,19 @@ public class EventHandlerImpl implements EventHandler {
protected Producer getProducer() {
LOG.debug(String.format("Getting Producer: %s %s", pool, readTopic));
- Producer out;
- out = new DmaapProducer(pool,writeTopics);
-
- if (apiKey != null && apiSecret != null) {
- out.updateCredentials(apiKey, apiSecret);
- }
-
- for (String url : pool) {
- if (url.contains("3905") || url.contains("https")) {
- out.useHttps(true);
- break;
- }
+ Producer out = null;
+ BundleContext ctx = FrameworkUtil.getBundle(EventHandlerImpl.class).getBundleContext();
+ if (ctx != null) {
+ ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName());
+ if (svcRef != null) {
+ out = ((MessageAdapterFactory) ctx.getService(svcRef)).createProducer(pool, writeTopics,apiKey, apiSecret);
+ for (String url : pool) {
+ if (url.contains("3905") || url.contains("https")) {
+ out.useHttps(true);
+ break;
+ }
+ }
+ }
}
return out;
}
@@ -236,23 +254,11 @@ public class EventHandlerImpl implements EventHandler {
@Override
public void closeClients() {
LOG.debug("Closing Consumer and Producer DMaaP clients");
- switch (messageService) {
- case DMaaP:
- if (reader != null) {
- ((DmaapConsumer) reader).close();
- }
- if (producer != null) {
- ((DmaapProducer) producer).close();
- }
- break;
- default:
- // close DMaaP clients
- if (reader != null) {
- ((DmaapConsumer) reader).close();
- }
- if (producer != null) {
- ((DmaapProducer) producer).close();
- }
+ if (reader != null) {
+ reader.close();
+ }
+ if (producer != null) {
+ producer.close();
}
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestListenerImpl.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestListenerImpl.java
deleted file mode 100644
index 63c98458a..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestListenerImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.impl;
-
-import java.util.Properties;
-
-import org.junit.Before;
-import org.openecomp.appc.configuration.ConfigurationFactory;
-import org.openecomp.appc.listener.ListenerProperties;
-import org.openecomp.appc.listener.CL.impl.ListenerImpl;
-
-public class TestListenerImpl {
-
- ListenerImpl listener;
-
- @Before
- public void setup() {
- Properties props = ConfigurationFactory.getConfiguration().getProperties();
- ListenerProperties lProps = new ListenerProperties((String) props.get("test.prefix"), props);
- lProps.getProperties().setProperty("topic.read.timeout", "5"); // Just for this test
- listener = new ListenerImpl(lProps);
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestProviderOperations.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestProviderOperations.java
deleted file mode 100644
index 3d7a7182f..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestProviderOperations.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.util.Properties;
-
-import org.eclipse.osgi.internal.signedcontent.Base64;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.appc.configuration.ConfigurationFactory;
-import org.openecomp.appc.exceptions.APPCException;
-import org.openecomp.appc.listener.CL.impl.ProviderOperations;
-import org.openecomp.appc.listener.CL.model.IncomingMessage;
-
-public class TestProviderOperations {
-
- private String ACTIVE_ENDPOINT;
-
- @Before
- public void setup() {
- Properties props = ConfigurationFactory.getConfiguration().getProperties();
- ACTIVE_ENDPOINT = props.getProperty("appc.ClosedLoop.provider.url");
- assertNotNull(ACTIVE_ENDPOINT);
- ProviderOperations.setUrl(ACTIVE_ENDPOINT);
-
- props.getProperty("test.vm_url");
- assertNotNull("VM_URL");
- }
-
- @Test
- public void testTopologyOperation() {
- IncomingMessage msg = new IncomingMessage();
- // Client and Time are for ID
- msg.setRequestClient("APPC");
- msg.setRequestTime("TEST");
- msg.setRequest("Restart");
-
- // Null Input
- try {
- ProviderOperations.topologyDG(null);
- fail("Topology Operation with null input should fail");
- } catch (APPCException e) {
- assertNotNull(e.getMessage());
- }
-
- // Bad URL
- msg.setUrl("some bad url here");
- try {
- ProviderOperations.topologyDG(msg);
- // Could also be issue in IaaS Adapter
- fail("Topology Operation with bad url should fail");
- } catch (APPCException e) {
- assertNotNull(e.getMessage());
- }
-
- // Will be tested in worker
- // msg.setUrl(VM_URL);
- // System.out.println("Rebooting real VM. Test can take up to 90s");
- // try {
- // assertTrue(ProviderOperations.topologyDG(msg));
- // } catch (APPCException e) {
- // fail("Topology Operation with good url should succeed. Check url in gui first");
- // }
-
- }
-
- @Test
- public void testConfigurationOperation() {
- try {
- ProviderOperations.topologyDG(null);
- fail("Configuration Operation should throw execption. Not yet supported");
- } catch (APPCException e) {
- assertNotNull(e.getMessage());
- }
- }
-
- @Test
- public void testBasicAuthFormating() {
- String user = "user";
- String pass = "pass";
-
- String result = ProviderOperations.setAuthentication(user, pass);
-
- assertNotNull(result);
- String decode = new String(Base64.decode(result.getBytes()));
- assertEquals(user + ":" + pass, decode);
- }
-
- @Test
- public void testGetSet() {
- // Every test URL will get reset
- assertEquals(ACTIVE_ENDPOINT, ProviderOperations.getUrl());
-
- String newUrl = "http://example.com";
- ProviderOperations.setUrl(newUrl);
- assertEquals(newUrl, ProviderOperations.getUrl());
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestWorker.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestWorker.java
deleted file mode 100644
index 1cd9cdc44..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/impl/TestWorker.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.impl;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.appc.configuration.ConfigurationFactory;
-import org.openecomp.appc.listener.EventHandler;
-import org.openecomp.appc.listener.ListenerProperties;
-import org.openecomp.appc.listener.CL.impl.ProviderOperations;
-import org.openecomp.appc.listener.CL.impl.WorkerImpl;
-import org.openecomp.appc.listener.CL.model.IncomingMessage;
-import org.openecomp.appc.listener.impl.EventHandlerImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TestWorker {
-
- private static final Logger LOG = LoggerFactory.getLogger(WorkerImpl.class);
-
- private IncomingMessage msg;
- private EventHandler dmaap;
-
- @Before
- public void setup() {
- Properties props = ConfigurationFactory.getConfiguration().getProperties();
- String activeEndpoint = props.getProperty("appc.ClosedLoop.provider.url");
- assertNotNull(activeEndpoint);
- ProviderOperations.setUrl(activeEndpoint);
-
- String vmUrl = props.getProperty("test.vm_url");
- assertNotNull(vmUrl);
- msg = new IncomingMessage();
- // Client and Time are for ID
- msg.setRequestClient("APPC");
- msg.setRequestTime("TEST");
- msg.setRequest("Restart");
- msg.setUrl(vmUrl);
-
- dmaap = new EventHandlerImpl(new ListenerProperties("appc.ClosedLoop", props));
- }
-
- @Test
- public void testWorker() {
- WorkerImpl w = new WorkerImpl(msg, dmaap);
- w.run();
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/model/TestMessages.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/model/TestMessages.java
deleted file mode 100644
index e9fa1ace8..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/model/TestMessages.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import org.apache.commons.io.IOUtils;
-import org.json.JSONObject;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.appc.listener.CL.model.IncomingMessage;
-import org.openecomp.appc.listener.CL.model.OutgoingMessage;
-import org.openecomp.appc.listener.CL.model.Status;
-import org.openecomp.appc.listener.util.Mapper;
-
-public class TestMessages {
- private IncomingMessage in;
- private OutgoingMessage out;
-
- private String incomingStr;
- private String outgoingStr;
-
- @Before
- public void setup() {
- try {
- incomingStr = IOUtils.toString(getClass().getResourceAsStream("/IncomingMessage.txt"), "UTF-8");
- outgoingStr = IOUtils.toString(getClass().getResourceAsStream("/OutgoingMessage.txt"), "UTF-8");
- assertNotNull(incomingStr);
- assertNotNull(outgoingStr);
-
- in = Mapper.mapOne(incomingStr, IncomingMessage.class);
-
- out = Mapper.mapOne(in.toOutgoing(Status.PENDING), OutgoingMessage.class);
- out.updateResponseTime();
-
- assertNotNull(in);
- assertNotNull(out);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- // NOTE Test Mapper will be used to test an event from dmaap.
- @Test
- public void testGetterSetter() {
- assertNotNull(in);
- assertNotNull(in.getRequestClient());
- assertNotNull(in.getRequestTime());
- assertNotNull(in.getMessage());
- assertNotNull(in.getTenantId());
- assertNotNull(in.getVmId());
- assertNotNull(in.getVmName());
- assertNotNull(in.getAction());
- assertNotNull(in.getId());
- assertNotNull(in.getPolicyName());
- assertNotNull(in.getPolicyVersion());
- assertNotNull(in.getRequest());
-
- out = Mapper.mapOne(in.toOutgoing(null), OutgoingMessage.class);
- assertNotNull(out.getRequestClient());
- assertEquals(in.getRequestClient(), out.getRequestClient());
- assertNotNull(out.getRequestTime());
- assertEquals(in.getRequestTime(), out.getRequestTime());
- assertNotNull(out.getMessage());
- assertEquals(in.getMessage(), out.getMessage());
- assertNotNull(out.getVmName());
- assertEquals(in.getVmName(), out.getVmName());
- assertNotNull(out.getPolicyName());
- assertEquals(in.getPolicyName(), out.getPolicyName());
- assertNotNull(out.getPolicyVersion());
- assertEquals(in.getPolicyVersion(), out.getPolicyVersion());
- assertNotNull(out.getOriginalRequest());
- assertNotNull(in.getRequest(), out.getOriginalRequest());
- }
-
- @Test
- public void testToString() {
- in = new IncomingMessage();
- assertNotNull(in.toString());
- String id = "test";
- in.setId(id);
- assertNotNull(in.toString());
- assertTrue(in.toString().contains(id));
- }
-
- @Test
- public void testOutgoingUpdateTime() {
- String old = out.getResponseTime();
- out.updateResponseTime();
- assertFalse(old.equals(out.getResponseTime()));
- }
-
- // Testing for 1510
- @Test
- public void testOutgoingToJson() {
- // Message Set
- String message = "MSG";
- out.setMessage(message);
- JSONObject json = out.toResponse();
- assertNotNull(json);
- String respStr = json.getString("response");
- assertTrue(respStr.contains(out.getResponse().getValue()));
-
- String msgStr = json.getString("message");
- assertNotNull(msgStr);
- assertFalse(msgStr.contains(out.getOriginalRequest())); // False for 1602
- assertTrue(msgStr.contains(out.getMessage()));
-
- // Null Message
- out.setMessage(null);
- json = out.toResponse();
- assertNotNull(json);
- msgStr = json.getString("message");
- assertNotNull(msgStr);
- assertFalse(msgStr.contains(out.getOriginalRequest())); // False for 1602
- assertTrue(msgStr.contains(out.getResponse().getValue()));
-
- // Echoing request
- assertNotNull(out.getOriginalRequest());
- }
-
- @Test
- public void testOutgoingToString() {
- String s = out.toString();
- assertTrue(s.contains(out.getId()));
- }
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL1607/model/TestEnums.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL1607/model/TestEnums.java
deleted file mode 100644
index 73e38aa4f..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL1607/model/TestEnums.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : APP-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.appc.listener.CL1607.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import org.junit.Test;
-import org.openecomp.appc.listener.CL.model.Action;
-import org.openecomp.appc.listener.CL.model.Status;
-
-public class TestEnums {
-
- @Test
- public void testAction() {
- assertEquals(Action.Rebuild, Action.toAction("Rebuild"));
- assertEquals(Action.Restart, Action.toAction("restart"));
- assertEquals(Action.Migrate, Action.toAction("MIGRATE"));
- assertEquals(Action.Evacuate, Action.toAction("Evacuate"));
- assertNull(Action.toAction("Unknown"));
- assertNull(Action.toAction(null));
-
- assertEquals(4, Action.values().length);
- }
-
- @Test
- public void testStatus() {
-
- assertEquals(Status.PENDING, Status.toStatus("Pending"));
- assertEquals(Status.ACTIVE, Status.toStatus("active"));
- assertEquals(Status.SUCCESS, Status.toStatus("SuCcEsS"));
- assertEquals(Status.FAILURE, Status.toStatus("Failure"));
- assertNull(Status.toStatus("Unknown"));
- assertNull(Status.toStatus(null));
-
- assertEquals(4, Status.values().length);
-
- }
-
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM/TestConverter.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM/TestConverter.java
index 2062e80d8..35042ba95 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM/TestConverter.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/LCM/TestConverter.java
@@ -39,7 +39,7 @@ public class TestConverter {
public void buildDmaapOutgoingMessageWithUnexpectedErrorTest() throws JsonProcessingException {
DmaapIncomingMessage dmaapIncomingMessage = buildDmaapIncomingMessage();
String errMsg = "TestException";
- DmaapOutgoingMessage dmaapOutgoingMessage = Converter.buildDmaapOutgoingMessageWithUnexpectedError(dmaapIncomingMessage.getBody(), "test", new Exception(errMsg));
+ DmaapOutgoingMessage dmaapOutgoingMessage = Converter.buildDmaapOutgoingMessageWithUnexpectedError(dmaapIncomingMessage, new Exception(errMsg));
int code = dmaapOutgoingMessage.getBody().get("output").get("status").get("code").asInt();
String value = dmaapOutgoingMessage.getBody().get("output").get("status").get("value").asText();
Assert.assertEquals(200,code);
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestListenerProperties.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestListenerProperties.java
index 9a70a8427..a2ce827a5 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestListenerProperties.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/TestListenerProperties.java
@@ -32,6 +32,7 @@ import java.util.Properties;
import org.junit.Before;
import org.junit.Test;
+import org.openecomp.appc.adapter.factory.MessageService;
import org.openecomp.appc.listener.AbstractListener;
import org.openecomp.appc.listener.ListenerProperties;
import org.openecomp.appc.listener.ListenerProperties.KEYS;
@@ -101,19 +102,18 @@ public class TestListenerProperties {
@Test
public void testMessageServices() {
// Hardcode count so tests must be updated when values are added
- assertEquals(1, ListenerProperties.MessageService.values().length);
+ assertEquals(1, MessageService.values().length);
// Bad Input
- ListenerProperties.MessageService def = ListenerProperties.MessageService.DMaaP;
- assertEquals(def, ListenerProperties.MessageService.parse(null));
- assertEquals(def, ListenerProperties.MessageService.parse(""));
- assertEquals(def, ListenerProperties.MessageService.parse("NotDmaapOrDMaaP"));
+ MessageService def = MessageService.DMaaP;
+ assertEquals(def, MessageService.parse(null));
+ assertEquals(def, MessageService.parse(""));
+ assertEquals(def, MessageService.parse("NotDMaaP"));
-
// DMaaP case sensitivity
- assertEquals(ListenerProperties.MessageService.DMaaP, ListenerProperties.MessageService.parse("dmaap"));
- assertEquals(ListenerProperties.MessageService.DMaaP, ListenerProperties.MessageService.parse("DMAAP"));
- assertEquals(ListenerProperties.MessageService.DMaaP, ListenerProperties.MessageService.parse("DMaaP"));
+ assertEquals(MessageService.DMaaP, MessageService.parse("dmaap"));
+ assertEquals(MessageService.DMaaP, MessageService.parse("DMAAP"));
+ assertEquals(MessageService.DMaaP, MessageService.parse("DMaaP"));
}
@Test
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/model/TestEnums.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestEnums.java
index a934cb432..2170af46c 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL/model/TestEnums.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestEnums.java
@@ -19,14 +19,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL.model;
+package org.openecomp.appc.listener.demo.model;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
-import org.openecomp.appc.listener.CL.model.Action;
-import org.openecomp.appc.listener.CL1607.model.Status;
+import org.openecomp.appc.listener.demo.model.Action;
+import org.openecomp.appc.listener.demo.model.Status;
public class TestEnums {
@@ -39,13 +39,13 @@ public class TestEnums {
assertNull(Action.toAction("Unknown"));
assertNull(Action.toAction(null));
- assertEquals(4, Action.values().length);
+ assertEquals(6, Action.values().length);
}
@Test
public void testStatus() {
- assertEquals(Status.ACCEPTED, Status.toStatus("ACCEPTED"));
+ assertEquals(Status.ACCEPTED, Status.toStatus("accepted"));
assertEquals(Status.SUCCESS, Status.toStatus("SuCcEsS"));
assertEquals(Status.FAILURE, Status.toStatus("Failure"));
assertNull(Status.toStatus("Unknown"));
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL1607/model/TestMessages.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestMessages.java
index c7bc86300..98dc91b7d 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/CL1607/model/TestMessages.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/demo/model/TestMessages.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.appc.listener.CL1607.model;
+package org.openecomp.appc.listener.demo.model;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -32,9 +32,9 @@ import org.json.JSONObject;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import org.openecomp.appc.listener.CL1607.model.IncomingMessage;
-import org.openecomp.appc.listener.CL1607.model.OutgoingMessage;
-import org.openecomp.appc.listener.CL1607.model.Status;
+import org.openecomp.appc.listener.demo.model.IncomingMessage;
+import org.openecomp.appc.listener.demo.model.OutgoingMessage;
+import org.openecomp.appc.listener.demo.model.Status;
import org.openecomp.appc.listener.util.Mapper;
public class TestMessages {
@@ -47,8 +47,8 @@ public class TestMessages {
@Before
public void setup() {
try {
- incomingStr = IOUtils.toString(getClass().getResourceAsStream("/IncomingMessage1607.txt"), "UTF-8");
- outgoingStr = IOUtils.toString(getClass().getResourceAsStream("/OutgoingMessage1607.txt"), "UTF-8");
+ incomingStr = IOUtils.toString(getClass().getResourceAsStream("/IncomingMessagedemo.txt"), "UTF-8");
+ outgoingStr = IOUtils.toString(getClass().getResourceAsStream("/OutgoingMessagedemo.txt"), "UTF-8");
assertNotNull(incomingStr);
assertNotNull(outgoingStr);
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestEventHandler.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestEventHandler.java
index 788aa961a..a5a6e1e7f 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestEventHandler.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestEventHandler.java
@@ -126,8 +126,7 @@ public class TestEventHandler {
}
- @Test
- @Ignore
+// @Test
public void testRun() {
// Runoff any old data
List<String> result1 = adapter.getIncomingEvents();
@@ -144,7 +143,7 @@ public class TestEventHandler {
// Get data back
List<DummyObj> result2 = adapter.getIncomingEvents(DummyObj.class);
assertNotNull(result2);
- assertEquals(1, result2.size());
+// assertEquals(1, result2.size());
assertEquals(data.toJson(), result2.get(0).toJson());
}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestListener.java b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestListener.java
index a1c7917f9..af50e6d3d 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestListener.java
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/java/org/openecomp/appc/listener/impl/TestListener.java
@@ -31,7 +31,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.openecomp.appc.listener.Listener;
import org.openecomp.appc.listener.ListenerProperties;
-import org.openecomp.appc.listener.CL.impl.ListenerImpl;
+import org.openecomp.appc.listener.demo.impl.ListenerImpl;
@Ignore
public class TestListener {
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessage.txt b/appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessage.txt
deleted file mode 100644
index 0771a790a..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessage.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-"eventID": "SomeEventID-TBD",
-
-"APPCVDCName": "Delete this field not needed by App-C",
-"requestTime": "0000-00-00 00:00:00.000000",
-"policyVersion": "1",
-"VMName": "123",
-"from": "test",
-"msgOid": ".1.3.6.1.4.1.193.183.4.1.3.5.1.4",
-"VMID": "abc12345-1234-5678-890a-abcdefg12345",
-"trapID": "1234567",
-"requestClient": "test",
-"message": "Abnormal condition detected",
-"time": "123567890",
-"policyName": "RESTART",
-"trapIDOID": ".1.3.6.1.4.1.193.183.4.1.3.5.1.3",
-"request": "Restart",
-"OPS_CL_timer": "15",
-"nOID": ".1.3.6.1.4.1.193.183.4.2.0.4",
-"AgentAddress": "192.168.1.2",
-"vmOID": ".1.3.6.1.4.1.193.183.4.1.2.1",
-"TenantID": "abcde12345fghijk6789lmnopq123rst",
-"VServerSelfLink": "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345"
-} \ No newline at end of file
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessage1607.txt b/appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessagedemo.txt
index 667cfae8c..667cfae8c 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessage1607.txt
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/resources/IncomingMessagedemo.txt
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessage.txt b/appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessage.txt
deleted file mode 100644
index c5d6c5b56..000000000
--- a/appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessage.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-"eventID": "SomeEventID-TBD",
-
-"VMName": "test",
-"from": "appc@test",
-"message": "Some Text Here",
-"requestClient": "test",
-"requestTime": "0000-00-00 00:00:00.000000",
-"response": "PENDING",
-"responseTime": "0000-00-00 00:00:00.000000",
-
-"policyName": "RESTART",
-"policyVersion": "1"
-}
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessage1607.txt b/appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessagedemo.txt
index 898eb622e..898eb622e 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessage1607.txt
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/resources/OutgoingMessagedemo.txt
diff --git a/appc-event-listener/appc-event-listener-bundle/src/test/resources/org/openecomp/appc/default.properties b/appc-event-listener/appc-event-listener-bundle/src/test/resources/org/openecomp/appc/default.properties
index 7a65b7195..9aa518a29 100644
--- a/appc-event-listener/appc-event-listener-bundle/src/test/resources/org/openecomp/appc/default.properties
+++ b/appc-event-listener/appc-event-listener-bundle/src/test/resources/org/openecomp/appc/default.properties
@@ -38,7 +38,7 @@
### ###
test.prefix=appc.ClosedLoop
appc.ClosedLoop.disabled=false
-appc.ClosedLoop.service=UEB
+appc.ClosedLoop.service=dmaap
appc.ClosedLoop.poolMembers=192.168.1.2:3904
appc.ClosedLoop.topic.read=APPC-TEST1
appc.ClosedLoop.topic.read.timeout=5
diff --git a/appc-event-listener/appc-event-listener-features/src/main/resources/features.xml b/appc-event-listener/appc-event-listener-features/src/main/resources/features.xml
index 4d4d24fd3..14fa8ad25 100644
--- a/appc-event-listener/appc-event-listener-features/src/main/resources/features.xml
+++ b/appc-event-listener/appc-event-listener-features/src/main/resources/features.xml
@@ -32,8 +32,9 @@
<!-- Most applications will have a dependency on the ODL MD-SAL Broker -->
<!-- <feature version="${broker-mdsal.version}">odl-mdsal-broker</feature> -->
<feature version="${broker-mdsal.version}">odl-mdsal-broker</feature>
+ <bundle dependency="true">mvn:org.openecomp.appc/appc-common/${project.version}</bundle>
+ <bundle dependency="true">mvn:org.openecomp.appc/appc-metric-bundle/${project.version}</bundle>
<bundle>mvn:org.openecomp.appc/appc-event-listener-bundle/${project.version}</bundle>
-
</feature>
</features>
diff --git a/appc-event-listener/pom.xml b/appc-event-listener/pom.xml
index e99c71477..b21042a96 100644
--- a/appc-event-listener/pom.xml
+++ b/appc-event-listener/pom.xml
@@ -102,4 +102,4 @@
<module>appc-event-listener-features</module>
<module>appc-event-listener-installer</module>
</modules>
-</project> \ No newline at end of file
+</project>