Merge "Changed in config will add and recover Rics"
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / controllers / ServiceController.java
index 844d6e8..bda5e09 100644 (file)
 
 package org.oransc.policyagent.controllers;
 
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
 import java.time.Duration;
 import java.util.Collection;
 import java.util.Vector;
 
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
 import org.oransc.policyagent.exceptions.ServiceException;
 import org.oransc.policyagent.repository.Service;
 import org.oransc.policyagent.repository.Services;
@@ -86,15 +86,16 @@ public class ServiceController {
     }
 
     private Service toService(ServiceRegistrationInfo s) {
-        return new Service(s.name(), Duration.ofSeconds(s.keepAliveInterval()));
+        return new Service(s.name(), Duration.ofSeconds(s.keepAliveInterval()), s.callbackUrl());
     }
 
     @GetMapping("/services")
     public ResponseEntity<?> getServices() {
-        Collection<Service> allServices = this.services.getAll();
-        Collection<ServiceStatus> result = new Vector<>(allServices.size());
-        for (Service s : allServices) {
-            result.add(toServiceStatus(s));
+        Collection<ServiceStatus> result = new Vector<>();
+        synchronized (this.services) {
+            for (Service s : this.services.getAll()) {
+                result.add(toServiceStatus(s));
+            }
         }
         return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
     }