From 4d97d5fac309ce0d66938e5ccd0349e2660d4e23 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sat, 17 Jun 2017 22:40:44 +0300 Subject: [sdc] update code of sdc Change-Id: If9f37c80b659cb67b34d18e6c019defecca58b9a Signed-off-by: Michael Lando --- .../jsontitan/operations/ArtifactsOperations.java | 44 +++++++++++++++++----- .../model/jsontitan/operations/BaseOperation.java | 4 +- .../jsontitan/operations/ToscaOperationFacade.java | 28 +++++++++++--- 3 files changed, 58 insertions(+), 18 deletions(-) (limited to 'catalog-model') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java index a3cb41f1c0..4d9ec8c2fe 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ArtifactsOperations.java @@ -212,22 +212,46 @@ public class ArtifactsOperations extends BaseOperation { } - public void updateUUID(ArtifactDataDefinition artifactData, String oldChecksum, String oldVesrion, boolean isUpdate) { + public void updateUUID(ArtifactDataDefinition artifactData, String oldChecksum, String oldVesrion, boolean isUpdate, EdgeLabelEnum edgeLabel) { if (oldVesrion == null || oldVesrion.isEmpty()) oldVesrion = "0"; String currentChecksum = artifactData.getArtifactChecksum(); - if(isUpdate && artifactData.getArtifactType().equalsIgnoreCase(ArtifactTypeEnum.HEAT_ENV.getType())){ - generateUUID(artifactData, oldVesrion); - } - if (oldChecksum == null || oldChecksum.isEmpty()) { - if (currentChecksum != null) { + + if ( isUpdate ){ + ArtifactTypeEnum type = ArtifactTypeEnum.findType(artifactData.getArtifactType()); + switch ( type ){ + case HEAT_ENV: + if ( edgeLabel == EdgeLabelEnum.INST_DEPLOYMENT_ARTIFACTS ){ + generateUUID(artifactData, oldVesrion); + }else{ + updateVersionAndDate(artifactData, oldVesrion); + } + break; + case HEAT: + case HEAT_NET: + case HEAT_VOL: + generateUUID(artifactData, oldVesrion); + break; + default: + if (oldChecksum == null || oldChecksum.isEmpty()) { + if (currentChecksum != null) { + generateUUID(artifactData, oldVesrion); + } + } else if ((currentChecksum != null && !currentChecksum.isEmpty()) && !oldChecksum.equals(currentChecksum)) { + generateUUID(artifactData, oldVesrion); + } + break; + } + }else{ + if (oldChecksum == null || oldChecksum.isEmpty()) { + if (currentChecksum != null) { + generateUUID(artifactData, oldVesrion); + } + } else if ((currentChecksum != null && !currentChecksum.isEmpty()) && !oldChecksum.equals(currentChecksum)) { generateUUID(artifactData, oldVesrion); } - } else if ((currentChecksum != null && !currentChecksum.isEmpty()) && !oldChecksum.equals(currentChecksum)) { - generateUUID(artifactData, oldVesrion); } - } // @TODO add implementation @@ -483,7 +507,7 @@ public class ArtifactsOperations extends BaseOperation { } } } - updateUUID(artifactToUpdate, oldChecksum, oldVersion, isUpdate); + updateUUID(artifactToUpdate, oldChecksum, oldVersion, isUpdate, edgeLabelEnum ); if (artifactInfo.getPayloadData() == null) { if (!artifactToUpdate.getMandatory() || artifactToUpdate.getEsId() != null) { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java index ed14bac8bb..ed8846010b 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java @@ -1348,9 +1348,7 @@ public abstract class BaseOperation { } protected String buildGroupInstanceName(String instanceName, String groupName) { - int groupNameIndex = groupName.indexOf(".."); - //turn group name from VFName..heatfile..module-n to VFiName..heatfile..module-n - return ValidationUtils.normaliseComponentName(instanceName) + groupName.substring(groupNameIndex); + return ValidationUtils.normaliseComponentName(instanceName) + ".." + groupName; } protected String generateCustomizationUUID() { diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java index 458bbbe226..e078f8eb86 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java @@ -1,9 +1,9 @@ package org.openecomp.sdc.be.model.jsontitan.operations; import java.util.ArrayList; -import java.util.Collection; import java.util.EnumMap; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -1536,7 +1536,8 @@ public class ToscaOperationFacade { public Either, StorageOperationStatus> getLatestComponentListByUuid(String componentUuid) { Map propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class); propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true); - return getComponentListByUuid(componentUuid, propertiesToMatch); + Either, StorageOperationStatus> componentListByUuid = getComponentListByUuid(componentUuid, propertiesToMatch); + return componentListByUuid; } public Either, StorageOperationStatus> getComponentListByUuid(String componentUuid, Map additionalPropertiesToMatch) { @@ -1565,11 +1566,28 @@ public class ToscaOperationFacade { return Either.right(StorageOperationStatus.NOT_FOUND); } - List latestComponents = new ArrayList(); + ArrayList latestComponents = new ArrayList<>(); for (GraphVertex vertex : vertexList) { - latestComponents.add(getToscaElementByOperation(vertex).left().value()); + Either toscaElementByOperation = getToscaElementByOperation(vertex); + + if(toscaElementByOperation.isRight()){ + log.debug("Could not fetch the following Component by UUID {}", vertex.getUniqueId()); + return Either.right(toscaElementByOperation.right().value()); + } + + latestComponents.add(toscaElementByOperation.left().value()); + } + + if(latestComponents.size() > 1) { + for (Component component : latestComponents) { + if(component.isHighestVersion()){ + LinkedList highestComponent = new LinkedList<>(); + highestComponent.add(component); + return Either.left(highestComponent); + } + } } - + return Either.left(latestComponents); } -- cgit 1.2.3-korg