Topology tree: enrich vfModules data from other versions of same model
[vid.git] / vid-app-common / src / main / java / org / onap / vid / services / VidServiceImpl.java
index a5988a1..ef62bf9 100644 (file)
@@ -52,6 +52,7 @@ import org.onap.vid.properties.VidProperties;
 import org.onap.vid.utils.Logging;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpMethod;
+import org.springframework.lang.NonNull;
 import org.togglz.core.manager.FeatureManager;
 
 /**
@@ -99,11 +100,6 @@ public class VidServiceImpl implements VidService {
                 });
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.onap.vid.controller.VidService#getService(java.lang.String)
-     */
     @Override
     public ServiceModel getService(String uuid) throws AsdcCatalogException {
         if (featureManager.isActive(FLAG_SERVICE_MODEL_CACHE)) {
@@ -113,6 +109,20 @@ public class VidServiceImpl implements VidService {
         }
     }
 
+    @NonNull
+    @Override
+    public ServiceModel getServiceModelOrThrow(String modelVersionId) {
+        try {
+            final ServiceModel serviceModel = getService(modelVersionId);
+            if (serviceModel == null) {
+                throw new GenericUncheckedException("Model version '" + modelVersionId + "' not found");
+            }
+            return serviceModel;
+        } catch (AsdcCatalogException e) {
+            throw new GenericUncheckedException("Exception while loading model version '" + modelVersionId + "'", e);
+        }
+    }
+
     private ServiceModel getServiceFromCache(String uuid) throws AsdcCatalogException {
         try {
             return serviceModelCache.get(uuid);