diff options
author | Michael Lando <ml636r@att.com> | 2017-06-17 22:40:44 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2017-06-18 07:20:49 +0300 |
commit | 4d97d5fac309ce0d66938e5ccd0349e2660d4e23 (patch) | |
tree | 3f921054f997d1962fa6f9db9a0119e31a851eea /catalog-model | |
parent | 89786d31f266a205857cae0177904c249ac6a512 (diff) |
[sdc] update code of sdc
Change-Id: If9f37c80b659cb67b34d18e6c019defecca58b9a
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-model')
3 files changed, 58 insertions, 18 deletions
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<List<Component>, StorageOperationStatus> getLatestComponentListByUuid(String componentUuid) { Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class); propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true); - return getComponentListByUuid(componentUuid, propertiesToMatch); + Either<List<Component>, StorageOperationStatus> componentListByUuid = getComponentListByUuid(componentUuid, propertiesToMatch); + return componentListByUuid; } public Either<List<Component>, StorageOperationStatus> getComponentListByUuid(String componentUuid, Map<GraphPropertyEnum, Object> additionalPropertiesToMatch) { @@ -1565,11 +1566,28 @@ public class ToscaOperationFacade { return Either.right(StorageOperationStatus.NOT_FOUND); } - List<Component> latestComponents = new ArrayList<Component>(); + ArrayList<Component> latestComponents = new ArrayList<>(); for (GraphVertex vertex : vertexList) { - latestComponents.add(getToscaElementByOperation(vertex).left().value()); + Either<Component, StorageOperationStatus> 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<Component> highestComponent = new LinkedList<>(); + highestComponent.add(component); + return Either.left(highestComponent); + } + } } - + return Either.left(latestComponents); } |