Changed the config loading from consul
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / clients / A1ClientFactory.java
index 546979c..57ac980 100644 (file)
@@ -86,13 +86,20 @@ public class A1ClientFactory {
     private ControllerConfig getControllerConfig(Ric ric) throws ServiceException {
         String controllerName = ric.getConfig().controllerName();
         if (controllerName.isEmpty()) {
+            ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
             throw new ServiceException("No controller configured for RIC: " + ric.name());
         }
-        return this.appConfig.getControllerConfig(controllerName);
+        try {
+            return this.appConfig.getControllerConfig(controllerName);
+        } catch (ServiceException e) {
+            ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
+            throw e;
+        }
     }
 
     private void assertNoControllerConfig(Ric ric, A1ProtocolType version) throws ServiceException {
         if (!ric.getConfig().controllerName().isEmpty()) {
+            ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
             throw new ServiceException(
                 "Controller config should be empty, ric: " + ric.name() + " when using protocol version: " + version);
         }