aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
diff options
context:
space:
mode:
authorEinat Vinouze <einat.vinouze@intl.att.com>2019-08-27 16:01:01 +0300
committerIttay Stern <ittay.stern@att.com>2019-09-09 07:01:36 +0000
commite1f7974f0badbd4440d5b7ea5f1b1cb2d4973818 (patch)
tree46be9cdc44cbb475527bc3c43df23d16f7579d29 /vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
parente25b88b5a7a0f3bf63ca7160a441b53145484bcc (diff)
Adding feature: Replace vfmodule
Issue-ID: VID-603 Change-Id: I59068a0979d6fb733e4243c8f78921f396dc9d17 Signed-off-by: Einat Vinouze <einat.vinouze@intl.att.com> Signed-off-by: Amichai Hemli <amichai.hemli@intl.att.com> Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java29
1 files changed, 23 insertions, 6 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
index 0fe7255c4..2b6b57ade 100644
--- a/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
+++ b/vid-app-common/src/main/java/org/onap/vid/job/command/CommandUtils.java
@@ -21,8 +21,10 @@
package org.onap.vid.job.command;
import org.apache.commons.lang3.StringUtils;
+import org.onap.vid.aai.model.ModelVer;
import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.model.ServiceModel;
+import org.onap.vid.services.AaiService;
import org.onap.vid.services.VidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -31,18 +33,16 @@ import org.springframework.stereotype.Component;
public class CommandUtils {
private final VidService vidService;
+ private final AaiService aaiService;
@Autowired
- public CommandUtils(VidService vidService) {
+ public CommandUtils(VidService vidService, AaiService aaiService) {
this.vidService = vidService;
+ this.aaiService = aaiService;
}
public boolean isVfModuleBaseModule(String serviceModelUuid, String vfModuleModelUUID) throws AsdcCatalogException{
- ServiceModel serviceModel = vidService.getService(serviceModelUuid);
-
- if (serviceModel==null) {
- throw new AsdcCatalogException("Failed to retrieve model with uuid "+serviceModelUuid +" from SDC");
- }
+ ServiceModel serviceModel = getServiceModel(serviceModelUuid);
if (serviceModel.getVfModules() == null) {
throw createAsdcCatalogVfModuleModelUUIDNotFoundException(serviceModelUuid, vfModuleModelUUID);
@@ -58,6 +58,23 @@ public class CommandUtils {
.getBaseModule();
}
+ public ServiceModel getServiceModel(String serviceModelUuid) throws AsdcCatalogException{
+ ServiceModel serviceModel = vidService.getService(serviceModelUuid);
+
+ if (serviceModel==null) {
+ throw new AsdcCatalogException("Failed to retrieve model with uuid "+serviceModelUuid +" from SDC");
+ }
+
+ return serviceModel;
+ }
+
+ public String getNewestModelUuid(String serviceModelInvariantId)
+ {
+ ModelVer serviceModelLatestVersion = aaiService.getNewestModelVersionByInvariantId(serviceModelInvariantId);
+
+ return serviceModelLatestVersion.getModelVersionId();
+ }
+
private AsdcCatalogException createAsdcCatalogVfModuleModelUUIDNotFoundException(String serviceModelUuid, String vfModuleModelUUID) {
return new AsdcCatalogException("Failed to find vfModuleModelUUID: " + vfModuleModelUUID +
"in model with uuid: " + serviceModelUuid);