summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-07-18 20:46:42 +0300
committerMichael Lando <ml636r@att.com>2017-07-18 20:46:42 +0300
commit39a4e0cb1b805470ad85ed4cf4fdeb69610ae98c (patch)
tree9faa499670544cce1ec5510c242ad984871ca32d /catalog-model/src/main/java/org
parentb8e2faf476202b6ffe61bc3a9a37df1304881d40 (diff)
[SDC] rebase 1710
Change-Id: I07fced02f40a57700d9d35ed3ba498bca351fb13 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-model/src/main/java/org')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/CsarInfo.java (renamed from catalog-model/src/main/java/org/openecomp/sdc/be/model/ImportCsarInfo.java)22
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java16
2 files changed, 31 insertions, 7 deletions
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/CsarInfo.java
index 460a107c89..575cc68f7f 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ImportCsarInfo.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/CsarInfo.java
@@ -5,21 +5,25 @@ import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
-public class ImportCsarInfo {
+public class CsarInfo {
String vfResourceName;
User modifier;
String csarUUID;
Map<String, byte[]> csar;
Map<String, String> createdNodesToscaResourceNames;
Queue<String> cvfcToCreateQueue;
+ boolean isUpdate;
+ Map<String, Resource> createdNodes;
- public ImportCsarInfo(String vfResourceName, User modifier, String csarUUID, Map<String, byte[]> csar){
+ public CsarInfo(String vfResourceName, User modifier, String csarUUID, Map<String, byte[]> 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() {
@@ -69,5 +73,17 @@ public class ImportCsarInfo {
public void setCvfcToCreateQueue(Queue<String> cvfcToCreateQueue) {
this.cvfcToCreateQueue = cvfcToCreateQueue;
}
-
+
+ public boolean isUpdate() {
+ return isUpdate;
+ }
+
+ public void setUpdate(boolean isUpdate) {
+ this.isUpdate = isUpdate;
+ }
+
+ public Map<String, Resource> getCreatedNodes() {
+ return createdNodes;
+ }
+
}
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<Edge> 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<ToscaElement,StorageOperationStatus> forceCerificationOfToscaElement(String toscaElementId, String modifierId, String ownerId) {
+ public Either<ToscaElement,StorageOperationStatus> forceCerificationOfToscaElement(String toscaElementId, String modifierId, String ownerId, String currVersion) {
Either<GraphVertex, StorageOperationStatus> resultUpdate = null;
Either<ToscaElement, StorageOperationStatus> 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()) {