From 39a4e0cb1b805470ad85ed4cf4fdeb69610ae98c Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Tue, 18 Jul 2017 20:46:42 +0300 Subject: [SDC] rebase 1710 Change-Id: I07fced02f40a57700d9d35ed3ba498bca351fb13 Signed-off-by: Michael Lando --- .../java/org/openecomp/sdc/be/model/CsarInfo.java | 89 ++++++++++++++++++++++ .../org/openecomp/sdc/be/model/ImportCsarInfo.java | 73 ------------------ .../operations/ToscaElementLifecycleOperation.java | 16 +++- 3 files changed, 101 insertions(+), 77 deletions(-) create mode 100644 catalog-model/src/main/java/org/openecomp/sdc/be/model/CsarInfo.java delete mode 100644 catalog-model/src/main/java/org/openecomp/sdc/be/model/ImportCsarInfo.java (limited to 'catalog-model/src') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/CsarInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CsarInfo.java new file mode 100644 index 0000000000..575cc68f7f --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CsarInfo.java @@ -0,0 +1,89 @@ +package org.openecomp.sdc.be.model; + +import java.util.HashMap; +import java.util.Map; +import java.util.PriorityQueue; +import java.util.Queue; + +public class CsarInfo { + String vfResourceName; + User modifier; + String csarUUID; + Map csar; + Map createdNodesToscaResourceNames; + Queue cvfcToCreateQueue; + boolean isUpdate; + Map createdNodes; + + public CsarInfo(String vfResourceName, User modifier, String csarUUID, Map csar, boolean isUpdate){ + this.vfResourceName = vfResourceName; + this.modifier = modifier; + this.csarUUID = csarUUID; + this.csar = csar; + this.createdNodesToscaResourceNames = new HashMap<>(); + this.cvfcToCreateQueue = new PriorityQueue<>(); + this.isUpdate = isUpdate; + this.createdNodes = new HashMap<>(); + } + + public String getVfResourceName() { + return vfResourceName; + } + + public void setVfResourceName(String vfResourceName) { + this.vfResourceName = vfResourceName; + } + + public User getModifier() { + return modifier; + } + + public void setModifier(User modifier) { + this.modifier = modifier; + } + + public String getCsarUUID() { + return csarUUID; + } + + public void setCsarUUID(String csarUUID) { + this.csarUUID = csarUUID; + } + + public Map getCsar() { + return csar; + } + + public void setCsar(Map csar) { + this.csar = csar; + } + + public Map getCreatedNodesToscaResourceNames() { + return createdNodesToscaResourceNames; + } + + public void setCreatedNodesToscaResourceNames(Map createdNodesToscaResourceNames) { + this.createdNodesToscaResourceNames = createdNodesToscaResourceNames; + } + + public Queue getCvfcToCreateQueue() { + return cvfcToCreateQueue; + } + + public void setCvfcToCreateQueue(Queue cvfcToCreateQueue) { + this.cvfcToCreateQueue = cvfcToCreateQueue; + } + + public boolean isUpdate() { + return isUpdate; + } + + public void setUpdate(boolean isUpdate) { + this.isUpdate = isUpdate; + } + + public Map getCreatedNodes() { + return createdNodes; + } + +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ImportCsarInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ImportCsarInfo.java deleted file mode 100644 index 460a107c89..0000000000 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ImportCsarInfo.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.openecomp.sdc.be.model; - -import java.util.HashMap; -import java.util.Map; -import java.util.PriorityQueue; -import java.util.Queue; - -public class ImportCsarInfo { - String vfResourceName; - User modifier; - String csarUUID; - Map csar; - Map createdNodesToscaResourceNames; - Queue cvfcToCreateQueue; - - public ImportCsarInfo(String vfResourceName, User modifier, String csarUUID, Map csar){ - this.vfResourceName = vfResourceName; - this.modifier = modifier; - this.csarUUID = csarUUID; - this.csar = csar; - this.createdNodesToscaResourceNames = new HashMap<>(); - this.cvfcToCreateQueue = new PriorityQueue<>(); - } - - public String getVfResourceName() { - return vfResourceName; - } - - public void setVfResourceName(String vfResourceName) { - this.vfResourceName = vfResourceName; - } - - public User getModifier() { - return modifier; - } - - public void setModifier(User modifier) { - this.modifier = modifier; - } - - public String getCsarUUID() { - return csarUUID; - } - - public void setCsarUUID(String csarUUID) { - this.csarUUID = csarUUID; - } - - public Map getCsar() { - return csar; - } - - public void setCsar(Map csar) { - this.csar = csar; - } - - public Map getCreatedNodesToscaResourceNames() { - return createdNodesToscaResourceNames; - } - - public void setCreatedNodesToscaResourceNames(Map createdNodesToscaResourceNames) { - this.createdNodesToscaResourceNames = createdNodesToscaResourceNames; - } - - public Queue getCvfcToCreateQueue() { - return cvfcToCreateQueue; - } - - public void setCvfcToCreateQueue(Queue cvfcToCreateQueue) { - this.cvfcToCreateQueue = cvfcToCreateQueue; - } - -} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java index 4282a2cba8..d34d3aa9f9 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java @@ -882,8 +882,9 @@ public class ToscaElementLifecycleOperation extends BaseOperation { // check if component with the next version doesn't exist. Iterator nextVersionComponentIter = toscaElementVertex.getVertex().edges(Direction.OUT, EdgeLabelEnum.VERSION.name()); if (nextVersionComponentIter != null && nextVersionComponentIter.hasNext()) { - String fetchedVersion = (String) nextVersionComponentIter.next().inVertex().property(GraphPropertyEnum.VERSION.getProperty()).value(); - String fetchedName = (String) nextVersionComponentIter.next().inVertex().property(GraphPropertyEnum.NORMALIZED_NAME.getProperty()).value(); + Vertex nextVersionVertex = nextVersionComponentIter.next().inVertex(); + String fetchedVersion = (String) nextVersionVertex.property(GraphPropertyEnum.VERSION.getProperty()).value(); + String fetchedName = (String)nextVersionVertex.property(GraphPropertyEnum.NORMALIZED_NAME.getProperty()).value(); CommonUtility.addRecordToLog(logger, LogLevelEnum.DEBUG, "Failed to checkout component {} with version {}. The component with name {} and version {} was fetched from graph as existing following version. ", toscaElementVertex.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME).toString(), toscaElementVertex.getMetadataProperty(GraphPropertyEnum.VERSION).toString(), fetchedName, fetchedVersion); result = Either.right(StorageOperationStatus.ENTITY_ALREADY_EXISTS); @@ -1429,6 +1430,13 @@ public class ToscaElementLifecycleOperation extends BaseOperation { return verticesToGetParameters; } + + private String getNextCertifiedVersion(String version) { + String[] versionParts = version.split(VERSION_DELIMETER_REGEXP); + Integer nextMajorVersion = Integer.parseInt(versionParts[0]) + 1; + return nextMajorVersion + VERSION_DELIMETER + "0"; + } + private String getNextVersion(String currVersion) { String[] versionParts = currVersion.split(VERSION_DELIMETER_REGEXP); Integer minorVersion = Integer.parseInt(versionParts[1]) + 1; @@ -1452,7 +1460,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation { return false; } - public Either forceCerificationOfToscaElement(String toscaElementId, String modifierId, String ownerId) { + public Either forceCerificationOfToscaElement(String toscaElementId, String modifierId, String ownerId, String currVersion) { Either resultUpdate = null; Either result = null; GraphVertex toscaElement = null; @@ -1478,7 +1486,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation { LifecycleStateEnum nextState = LifecycleStateEnum.CERTIFIED; toscaElement.addMetadataProperty(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name()); - toscaElement.addMetadataProperty(GraphPropertyEnum.VERSION, "1.0"); + toscaElement.addMetadataProperty(GraphPropertyEnum.VERSION, getNextCertifiedVersion(currVersion)); resultUpdate = updateToscaElementVertexMetadataPropertiesAndJson(toscaElement); if (resultUpdate.isRight()) { -- cgit 1.2.3-korg