<type>xml</type>
<classifier>features</classifier>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.features</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ </dependencies>
</project>
--- /dev/null
+# CCSDK Message Router Extension\r
+\r
+This maven module builds re-usable code that interacts with message router\r
+\r
+## High level modules\r
+- **publisher** used for sending messages to a dmaap message router topic\r
+- **consumer** not yet created, this will be used for pulling messages from a dmaap message router topic\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.2.1-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>publisher</module>
+ </modules>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
--- /dev/null
+# Publisher\r
+\r
+## Modules\r
+- api - exports the publisher interface for clients and providers to import\r
+- features - used for managing the feature repository for publisher\r
+- installer - provides a simple install script \r
+- provider - provides an implementation of the publisher api, this implementation assumes the controller has a single identity for publishing to DMAAP message router\r
+- sample.client - a dummy client that posts a simple message to a configured topic during its initialization\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.aggregate</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>publisher.api</artifactId>
+ <packaging>bundle</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>org.onap.ccsdk.messagerouter.publisher.api</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package org.onap.ccsdk.messagerouter.publisher.api;\r
+\r
+public interface PublisherApi {\r
+ public Boolean publish(String topic, String body);\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.aggregate</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>publisher.features</artifactId>
+ <packaging>pom</packaging>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/feature</directory>
+ <filtering>true</filtering>
+ <targetPath>${project.build.directory}/feature</targetPath>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>target/feature/feature.xml</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<features name="messagerouter-publisher-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
+ <feature name='messagerouter-publisher' description="exposes message router publisher service" version='${project.version}'>
+ <bundle>mvn:org.onap.ccsdk.messagerouter/publisher.api/${project.version}</bundle>
+ <bundle>mvn:org.onap.ccsdk.messagerouter/publisher.provider/${project.version}</bundle>
+ </feature>
+
+ <feature name='sample-client' description="initializes a dummy client" version='${project.version}'>
+ <bundle>mvn:org.onap.ccsdk.messagerouter/sample.client/${project.version}</bundle>
+ </feature>
+
+</features>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.aggregate</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.installer</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <properties>
+ <application.name>messagerouter-publisher</application.name>
+ <features.boot>messagerouter-publisher</features.boot>
+ <features.repositories>mvn:${project.groupId}/publisher.features/${project.version}/xml/features</features.repositories>
+ <include.transitive.dependencies>false</include.transitive.dependencies>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.features</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>sample.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>maven-repo-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <attach>true</attach>
+ <finalName>stage/${application.name}-${project.version}</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_mvnrepo_zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>true</appendAssemblyId>
+ </configuration>
+ </execution>
+ <execution>
+ <id>installer-zip</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <attach>true</attach>
+ <finalName>${application.name}-${project.version}-installer</finalName>
+ <descriptors>
+ <descriptor>src/assembly/assemble_installer_zip.xml</descriptor>
+ </descriptors>
+ <appendAssemblyId>false</appendAssemblyId>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>prepare-package</phase>
+ <configuration>
+ <transitive>false</transitive>
+ <outputDirectory>${project.build.directory}/assembly/system</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <useRepositoryLayout>true</useRepositoryLayout>
+ <addParentPoms>false</addParentPoms>
+ <copyPom>false</copyPom>
+ <includeGroupIds>org.onap.ccsdk.messagerouter</includeGroupIds>
+ <scope>provided</scope>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-version</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals><!-- here the phase you need -->
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources/scripts</directory>
+ <includes>
+ <include>install-feature.sh</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
--- /dev/null
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-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=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>installer_zip</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
\ No newline at end of file
--- /dev/null
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-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=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>repo</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+
+
+</assembly>
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-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=========================================================
+###
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories}
+${ODL_KARAF_CLIENT} feature:install ${features.boot}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>publisher.aggregate</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>api</module>
+ <module>features</module>
+ <module>provider</module>
+ <module>sample.client</module>
+ <module>installer</module>
+ </modules>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.aggregate</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>publisher.provider</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Private-Package>org.onap.ccsdk.messagerouter.publisher.provider.impl</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package org.onap.ccsdk.messagerouter.publisher.provider.impl;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.DataOutputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.InputStreamReader;\r
+import java.net.HttpURLConnection;\r
+import java.net.SocketException;\r
+import java.net.URL;\r
+import java.util.Base64;\r
+\r
+import org.onap.ccsdk.messagerouter.publisher.api.PublisherApi;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+public class PublisherApiImpl implements PublisherApi {\r
+ private static final Logger logger = LoggerFactory.getLogger(PublisherApiImpl.class);\r
+ protected final Integer DEFAULT_CONNECT_TIMEOUT = 30000; // will be treated as 30 seconds\r
+ protected final Integer DEFAULT_READ_TIMEOUT = 180000; // will be treated as 3 minutes\r
+ private String authorizationString;\r
+ protected Integer connectTimeout;\r
+ protected Integer readTimeout;\r
+ protected String baseUrl;\r
+ protected String username;\r
+ protected String[] hosts;\r
+ private String password;\r
+\r
+ public void setUsername(String username) {\r
+ this.username = username;\r
+ buildAuthorizationString();\r
+ }\r
+\r
+ public void setPassword(String password) {\r
+ this.password = password;\r
+ buildAuthorizationString();\r
+ }\r
+\r
+ public void setHost(String hostString) {\r
+ // a comma separated list of hosts can be passed in or a single host may be used\r
+ if (!hostString.contains(",")) {\r
+ this.hosts = new String[] { hostString };\r
+ } else {\r
+ this.hosts = hostString.split(",");\r
+ }\r
+ }\r
+\r
+ public PublisherApiImpl() {\r
+ connectTimeout = DEFAULT_CONNECT_TIMEOUT;\r
+ readTimeout = DEFAULT_READ_TIMEOUT;\r
+ }\r
+\r
+ public void init() {\r
+ buildAuthorizationString();\r
+ }\r
+\r
+ private String buildUrlString(Integer hostIndex, String topic) {\r
+ return hosts[hostIndex] + "/events/" + topic;\r
+ }\r
+\r
+ protected void configureHttpURLConnection(HttpURLConnection httpUrlConnection) {\r
+ httpUrlConnection.setRequestProperty("Content-Type", "application/json");\r
+ }\r
+\r
+ public Boolean publish(String topic, String body) {\r
+ for (int hostIndex = 0; hostIndex < hosts.length; hostIndex++) {\r
+ HttpURLConnection httpUrlConnection = null;\r
+ URL url = null;\r
+ try {\r
+ url = new URL(buildUrlString(hostIndex, topic));\r
+ logger.info("Publishing body to topic {} using the url {}", topic, url);\r
+ logger.info("Message to publish is\n{}", body);\r
+ httpUrlConnection = buildHttpURLConnection(url);\r
+ httpUrlConnection.setDoInput(true);\r
+ httpUrlConnection.setDoOutput(true);\r
+ httpUrlConnection.setUseCaches(false);\r
+ httpUrlConnection.setRequestMethod("POST");\r
+\r
+ // Write message\r
+ httpUrlConnection.setRequestProperty("Content-Length", Integer.toString(body.length()));\r
+ DataOutputStream outStr = new DataOutputStream(httpUrlConnection.getOutputStream());\r
+ outStr.write(body.getBytes());\r
+ outStr.close();\r
+\r
+ int status = httpUrlConnection.getResponseCode();\r
+ logger.info("Publishing body for topic {} using url {} returned status {}.", topic, url, status);\r
+ if (status < 300) {\r
+ String responseFromDMaaP = readFromStream(httpUrlConnection.getInputStream());\r
+ logger.info("Message router response is\n{}", responseFromDMaaP);\r
+ return true;\r
+ } else {\r
+ if (httpUrlConnection.getErrorStream() != null) {\r
+ String responseFromDMaaP = readFromStream(httpUrlConnection.getErrorStream());\r
+ logger.warn("Publishing body for topic {} using url {} failed." + " Error message is\n{}",\r
+ topic, url, responseFromDMaaP);\r
+ }\r
+ return false;\r
+ }\r
+\r
+ } catch (SocketException socketException) {\r
+ logger.error("SocketException was thrown during publishing message to DMaaP on url {}.", url,\r
+ socketException);\r
+ if (hostIndex < hosts.length) {\r
+ logger.info("Message sent to {} failed with a SocketException, but will be tried on {}",\r
+ hosts[hostIndex], hosts[hostIndex + 1]);\r
+ }\r
+ } catch (Exception e) {\r
+ logger.warn("Exception was thrown during publishing message to DMaaP on url {}.", url, e);\r
+ return false;\r
+ } finally {\r
+ if (httpUrlConnection != null) {\r
+ httpUrlConnection.disconnect();\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ private void buildAuthorizationString() {\r
+ String basicAuthString = username + ":" + password;\r
+ basicAuthString = Base64.getEncoder().encodeToString(basicAuthString.getBytes());\r
+ this.authorizationString = "Basic " + basicAuthString;\r
+ }\r
+\r
+ protected HttpURLConnection buildHttpURLConnection(URL url) throws IOException {\r
+ HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection();\r
+ if (authorizationString != null) {\r
+ httpUrlConnection.setRequestProperty("Authorization", authorizationString);\r
+ }\r
+ httpUrlConnection.setRequestProperty("Accept", "application/json");\r
+ httpUrlConnection.setUseCaches(false);\r
+ httpUrlConnection.setConnectTimeout(connectTimeout);\r
+ httpUrlConnection.setReadTimeout(readTimeout);\r
+ configureHttpURLConnection(httpUrlConnection);\r
+ return httpUrlConnection;\r
+ }\r
+\r
+ protected String readFromStream(InputStream stream) throws IOException {\r
+ BufferedReader br = new BufferedReader(new InputStreamReader(stream));\r
+ StringBuilder sb = new StringBuilder();\r
+ String line;\r
+ while ((line = br.readLine()) != null) {\r
+ sb.append(line);\r
+ }\r
+ br.close();\r
+ return sb.toString();\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.2.0">
+
+ <bean id="publisher"
+ class="org.onap.ccsdk.messagerouter.publisher.provider.impl.PublisherApiImpl">
+ <cm:managed-properties
+ persistent-id="org.onap.ccsdk.messagerouter.publisher.provider"
+ update-strategy="container-managed" />
+ </bean>
+
+ <service ref="publisher" interface="org.onap.ccsdk.messagerouter.publisher.api.PublisherApi" />
+
+</blueprint>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.aggregate</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>sample.client</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.messagerouter</groupId>
+ <artifactId>publisher.api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Private-Package>org.onap.ccsdk.messagerouter.publisher.client.impl</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package org.onap.ccsdk.messagerouter.publisher.client.impl;\r
+\r
+import org.onap.ccsdk.messagerouter.publisher.api.PublisherApi;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+public class ClientImpl {\r
+ private static final Logger logger = LoggerFactory.getLogger(ClientImpl.class);\r
+ private String topic;\r
+ private PublisherApi publisher;\r
+\r
+ public void setPublisher(PublisherApi publisherApi) {\r
+ this.publisher = publisherApi;\r
+ }\r
+\r
+ public void setTopic(String topic) {\r
+ this.topic = topic;\r
+ }\r
+\r
+ public ClientImpl() {\r
+\r
+ }\r
+\r
+ public void init() {\r
+ for (int i = 0; i < 5; i++) {\r
+ String body = "{\"hello\":\"world " + String.valueOf(Math.random()) + "\"}";\r
+ logger.error("Loop iteration " + i + " sending body " + body + " to the topic " + topic);\r
+ Boolean result = publisher.publish(topic, body);\r
+ logger.error("Loop iteration " + i + " returned the boolean value " + result);\r
+ }\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.2.0">
+
+ <bean id="client"
+ class="org.onap.ccsdk.messagerouter.publisher.client.impl.ClientImpl"
+ init-method="init">
+ <property name="publisher" ref="publisher" />
+ <cm:managed-properties
+ persistent-id="org.onap.ccsdk.messagerouter.publisher.client"
+ update-strategy="container-managed" />
+ </bean>
+
+ <reference id="publisher" interface="org.onap.ccsdk.messagerouter.publisher.api.PublisherApi" />
+
+</blueprint>
\ No newline at end of file
<module>sql-resource</module>
<module>features</module>
<module>artifacts</module>
+ <module>message-router</module>
</modules>
<organization>
<name>ONAP</name>