Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Make naming consistent regarding synchronization
[nonrtric.git]
/
policy-agent
/
src
/
main
/
java
/
org
/
oransc
/
policyagent
/
dmaap
/
DmaapMessageHandler.java
diff --git
a/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java
b/policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java
index
cce4a92
..
b23595a
100644
(file)
--- a/
policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java
+++ b/
policy-agent/src/main/java/org/oransc/policyagent/dmaap/DmaapMessageHandler.java
@@
-2,7
+2,7
@@
* ========================LICENSE_START=================================
* O-RAN-SC
* %%
* ========================LICENSE_START=================================
* O-RAN-SC
* %%
- * Copyright (C) 20
19
Nordix Foundation
+ * Copyright (C) 20
20
Nordix Foundation
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-22,7
+22,9
@@
package org.oransc.policyagent.dmaap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+
import java.io.IOException;
import java.io.IOException;
+
import org.onap.dmaap.mr.client.MRBatchingPublisher;
import org.oransc.policyagent.clients.AsyncRestClient;
import org.oransc.policyagent.dmaap.DmaapRequestMessage.Operation;
import org.onap.dmaap.mr.client.MRBatchingPublisher;
import org.oransc.policyagent.clients.AsyncRestClient;
import org.oransc.policyagent.dmaap.DmaapRequestMessage.Operation;
@@
-36,7
+38,6
@@
public class DmaapMessageHandler {
private static final Logger logger = LoggerFactory.getLogger(DmaapMessageHandler.class);
private static Gson gson = new GsonBuilder() //
private static final Logger logger = LoggerFactory.getLogger(DmaapMessageHandler.class);
private static Gson gson = new GsonBuilder() //
- .serializeNulls() //
.create(); //
private final MRBatchingPublisher dmaapClient;
.create(); //
private final MRBatchingPublisher dmaapClient;
@@
-83,15
+84,24
@@
public class DmaapMessageHandler {
} else if (operation == Operation.GET) {
result = agentClient.get(uri);
} else if (operation == Operation.PUT) {
} else if (operation == Operation.GET) {
result = agentClient.get(uri);
} else if (operation == Operation.PUT) {
- result = agentClient.put(uri,
dmaapRequestMessage.payload(
));
+ result = agentClient.put(uri,
payload(dmaapRequestMessage
));
} else if (operation == Operation.POST) {
} else if (operation == Operation.POST) {
- result = agentClient.post(uri,
dmaapRequestMessage.payload(
));
+ result = agentClient.post(uri,
payload(dmaapRequestMessage
));
} else {
return Mono.error(new Exception("Not implemented operation: " + operation));
}
return result;
}
} else {
return Mono.error(new Exception("Not implemented operation: " + operation));
}
return result;
}
+ private String payload(DmaapRequestMessage message) {
+ if (message.payload().isPresent()) {
+ return gson.toJson(message.payload().get());
+ } else {
+ logger.warn("Expected payload in message from DMAAP: {}", message);
+ return "";
+ }
+ }
+
private Mono<String> sendDmaapResponse(String response, DmaapRequestMessage dmaapRequestMessage,
HttpStatus status) {
return getDmaapResponseMessage(dmaapRequestMessage, response, status) //
private Mono<String> sendDmaapResponse(String response, DmaapRequestMessage dmaapRequestMessage,
HttpStatus status) {
return getDmaapResponseMessage(dmaapRequestMessage, response, status) //