summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rwxr-xr-xsrc/main/java/org/onap/nbi/apis/hub/model/Subscriber.java2
-rw-r--r--src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java10
-rwxr-xr-xsrc/main/java/org/onap/nbi/apis/hub/service/NotifierService.java6
-rw-r--r--src/main/java/org/onap/nbi/apis/hub/service/SubscriptionService.java2
4 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/org/onap/nbi/apis/hub/model/Subscriber.java b/src/main/java/org/onap/nbi/apis/hub/model/Subscriber.java
index df0cffd..ab2b05f 100755
--- a/src/main/java/org/onap/nbi/apis/hub/model/Subscriber.java
+++ b/src/main/java/org/onap/nbi/apis/hub/model/Subscriber.java
@@ -56,7 +56,7 @@ public class Subscriber implements Resource {
return query;
}
- public static Subscriber createFromRequest(Subscription request) {
+ public static Subscriber createFromSubscription(Subscription request) {
Subscriber sub = new Subscriber();
sub.setCallback(request.getCallback());
diff --git a/src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java b/src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java
index b2a017c..3e04b84 100644
--- a/src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java
+++ b/src/main/java/org/onap/nbi/apis/hub/service/EventFactory.java
@@ -59,13 +59,15 @@ public class EventFactory {
*/
private static Object filterServiceOrder(final ServiceOrder serviceOrder) {
- Object filteredServiceOrder;
+ Object filteredServiceOrder = null;
- JsonRepresentation jsonRepresentation = new JsonRepresentation();
- jsonRepresentation.add("id").add("href").add("externalId").add("state").add("orderDate").add
+ if (serviceOrder != null) {
+ JsonRepresentation jsonRepresentation = new JsonRepresentation();
+ jsonRepresentation.add("id").add("href").add("externalId").add("state").add("orderDate").add
("completionDateTime").add("orderItem");
- filteredServiceOrder = JacksonFilter.createNode(serviceOrder, jsonRepresentation);
+ filteredServiceOrder = JacksonFilter.createNode(serviceOrder, jsonRepresentation);
+ }
return filteredServiceOrder;
}
diff --git a/src/main/java/org/onap/nbi/apis/hub/service/NotifierService.java b/src/main/java/org/onap/nbi/apis/hub/service/NotifierService.java
index 2bfbca1..4f7a549 100755
--- a/src/main/java/org/onap/nbi/apis/hub/service/NotifierService.java
+++ b/src/main/java/org/onap/nbi/apis/hub/service/NotifierService.java
@@ -19,6 +19,7 @@ import org.onap.nbi.apis.hub.model.Event;
import org.onap.nbi.apis.hub.model.Subscriber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
@@ -31,9 +32,12 @@ import javax.validation.Valid;
public class NotifierService {
private final Logger logger = LoggerFactory.getLogger(NotifierService.class);
+ @Autowired
+ RestTemplate restTemplate;
+
@Async
public void run(Subscriber subscriber, @Valid Event event) {
- ResponseEntity<String> re = new RestTemplate().postForEntity(subscriber.getCallback(), event, String.class);
+ ResponseEntity<String> re = restTemplate.postForEntity(subscriber.getCallback(), event, String.class);
if (re.getStatusCode() == HttpStatus.OK) logger.debug("FAILED");
}
}
diff --git a/src/main/java/org/onap/nbi/apis/hub/service/SubscriptionService.java b/src/main/java/org/onap/nbi/apis/hub/service/SubscriptionService.java
index cf9ab66..09826bc 100644
--- a/src/main/java/org/onap/nbi/apis/hub/service/SubscriptionService.java
+++ b/src/main/java/org/onap/nbi/apis/hub/service/SubscriptionService.java
@@ -32,7 +32,7 @@ public class SubscriptionService {
}
public Subscriber createSubscription(Subscription subscription){
- Subscriber sub = Subscriber.createFromRequest(subscription);
+ Subscriber sub = Subscriber.createFromSubscription(subscription);
return subscriberRepository.save(sub);
}