diff options
Diffstat (limited to 'appc-adapters/appc-dmaap-adapter')
4 files changed, 27 insertions, 13 deletions
diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/CommonHttpClient.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/CommonHttpClient.java index a2e15797a..ed2f13ff0 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/CommonHttpClient.java +++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/CommonHttpClient.java @@ -50,19 +50,23 @@ public class CommonHttpClient { } public HttpGet getReq(URI uri, int timeoutMs) throws Exception { - HttpGet out = (uri == null) ? new HttpGet() : new HttpGet(uri); - if (AUTH_STR != null) { - out.setHeader("Authorization", String.format("Basic %s", AUTH_STR)); - } + if (AUTH_STR == null) { + throw new Exception("All DMaaP requests require authentication and none was provided."); + } + + HttpGet out = (uri == null) ? new HttpGet() : new HttpGet(uri); + out.setHeader("Authorization", String.format("Basic %s", AUTH_STR)); out.setConfig(getConfig(timeoutMs)); return out; } public HttpPost postReq(String url) throws Exception { - HttpPost out = (url == null) ? new HttpPost() : new HttpPost(url); - if (AUTH_STR != null) { - out.setHeader("Authorization", String.format("Basic %s", AUTH_STR)); + if (AUTH_STR == null) { + throw new Exception("All DMaaP requests require authentication and none was provided."); } + + HttpPost out = (url == null) ? new HttpPost() : new HttpPost(url); + out.setHeader("Authorization", String.format("Basic %s", AUTH_STR)); out.setConfig(getConfig(0)); return out; } diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java index 1073e152f..aeb248c9b 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java +++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/main/java/org/openecomp/appc/adapter/messaging/dmaap/http/HttpDmaapProducerImpl.java @@ -119,7 +119,7 @@ public class HttpDmaapProducerImpl extends CommonHttpClient implements Producer } /** - * Format the body for the application/cambria content type with no partitioning. + * Format the body for the application/cambria content type with no partitioning. See * * @param msg * The message body to format diff --git a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/DCAEResponse.txt b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/DCAEResponse.txt index 0d7ea2afa..884a8525f 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/DCAEResponse.txt +++ b/appc-adapters/appc-dmaap-adapter/appc-dmaap-adapter-bundle/src/test/resources/DCAEResponse.txt @@ -15,4 +15,6 @@ "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", +"AICTenantID": "0123456789abcdef0123456789", +"AICVServerSelfLink": "http://somewhere" }
\ No newline at end of file diff --git a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java index ed27db93e..d555f3952 100644 --- a/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java +++ b/appc-adapters/appc-dmaap-adapter/appc-message-adapter-factory/src/main/java/org/openecomp/appc/adapter/factory/DmaapMessageAdapterFactoryImpl.java @@ -30,21 +30,29 @@ import java.util.Set; 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.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl; import org.openecomp.appc.adapter.messaging.dmaap.http.HttpDmaapProducerImpl; +import org.openecomp.appc.adapter.messaging.dmaap.impl.DmaapConsumerImpl; +import org.openecomp.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl; + public class DmaapMessageAdapterFactoryImpl implements MessageAdapterFactory { + //Set to true if the HttpDmaap... should be used instead of the regular Dmaap... + private static final boolean HTTP = true; + public Producer createProducer(Collection<String> pools, String writeTopic, String apiKey, String apiSecret) { - return new HttpDmaapProducerImpl(pools, writeTopic); + return HTTP ? new HttpDmaapProducerImpl(pools, writeTopic) : new DmaapProducerImpl(pools, writeTopic,apiKey, apiSecret); } - + public Producer createProducer(Collection<String> pools, Set<String> writeTopics, String apiKey, String apiSecret) { - return new HttpDmaapProducerImpl(pools, writeTopics); + return HTTP ? new HttpDmaapProducerImpl(pools, writeTopics) : new DmaapProducerImpl(pools, writeTopics, apiKey, apiSecret); } public Consumer createConsumer(Collection<String> pool, String readTopic, - String clientName, String clientId, String filter_json, String apiKey, String apiSecret) { - return new HttpDmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filter_json); + String clientName, String clientId, String filter_json, String apiKey, String apiSecret) { + return HTTP ? new HttpDmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filter_json) : + new DmaapConsumerImpl(pool, readTopic, clientName, clientId, apiKey, apiSecret, filter_json); } } |