aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2019-10-08 18:27:36 +0100
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-11-20 17:23:14 +0000
commit13af621442b4c74d9e63ede8e42dbae48aaa64c9 (patch)
tree93b192acc70f6b9eed7fba41402bf33bf9970442 /catalog-model
parent86655742cf36bdc056837f5b74bc32c58201a600 (diff)
Onboard PNF software version
Change-Id: Id9e32e01f6c2f4c39c8ff10816d982cbb3063bf7 Issue-ID: SDC-2589 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java63
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/exception/ToscaOperationException.java36
2 files changed, 65 insertions, 34 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
index 43f3487924..ab08f5c339 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
@@ -2229,50 +2229,45 @@ public class ToscaOperationFacade {
return nodeTemplateOperation.generateCustomizationUUIDOnInstanceGroup(componentId, instanceId, groupInstances);
}
- public Either<PropertyDefinition, StorageOperationStatus> addPropertyToComponent(String propertyName,
+ public Either<PropertyDefinition, StorageOperationStatus> addPropertyToComponent(String propertyName,
PropertyDefinition newPropertyDefinition,
Component component) {
-
- Either<PropertyDefinition, StorageOperationStatus> result = null;
- Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
newPropertyDefinition.setName(propertyName);
StorageOperationStatus status = getToscaElementOperation(component)
.addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, newPropertyDefinition, JsonPresentationFields.NAME);
if (status != StorageOperationStatus.OK) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the property {} to the component {}. Status is {}. ", propertyName, component.getName(), status);
- result = Either.right(status);
- }
- if (result == null) {
- ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreProperties(false);
- filter.setIgnoreInputs(false);
- getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
- if (getUpdatedComponentRes.isRight()) {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get updated component {}. Status is {}. ", component.getUniqueId(), getUpdatedComponentRes.right().value());
- result = Either.right(status);
- }
- }
- if (result == null) {
- PropertyDefinition newProperty = null;
- List<PropertyDefinition> properties =
- (getUpdatedComponentRes.left().value()).getProperties();
- if (CollectionUtils.isNotEmpty(properties)) {
- Optional<PropertyDefinition> propertyOptional = properties.stream().filter(
- propertyEntry -> propertyEntry.getName().equals(propertyName)).findAny();
- if (propertyOptional.isPresent()) {
- newProperty = propertyOptional.get();
- }
- }
- if (newProperty == null) {
- CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to find recently added property {} on the component {}. Status is {}. ", propertyName, component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
- result = Either.right(StorageOperationStatus.NOT_FOUND);
- } else {
- result = Either.left(newProperty);
- }
+ return Either.right(status);
}
- return result;
+
+ ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreProperties(false);
+ filter.setIgnoreInputs(false);
+ Either<Component, StorageOperationStatus> getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
+ if (getUpdatedComponentRes.isRight()) {
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get updated component {}. Status is {}. ", component.getUniqueId(), getUpdatedComponentRes.right().value());
+ return Either.right(status);
+ }
+
+ PropertyDefinition newProperty = null;
+ List<PropertyDefinition> properties =
+ (getUpdatedComponentRes.left().value()).getProperties();
+ if (CollectionUtils.isNotEmpty(properties)) {
+ Optional<PropertyDefinition> propertyOptional = properties.stream().filter(
+ propertyEntry -> propertyEntry.getName().equals(propertyName)).findAny();
+ if (propertyOptional.isPresent()) {
+ newProperty = propertyOptional.get();
+ }
+ }
+ if (newProperty == null) {
+ CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to find recently added property {} on the component {}. Status is {}. ", propertyName, component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+ return Either.right(StorageOperationStatus.NOT_FOUND);
+ }
+
+ return Either.left(newProperty);
}
+
public StorageOperationStatus deletePropertyOfComponent(Component component, String propertyName) {
return getToscaElementOperation(component).deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, propertyName, JsonPresentationFields.NAME);
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/exception/ToscaOperationException.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/exception/ToscaOperationException.java
new file mode 100644
index 0000000000..b5b7da8d26
--- /dev/null
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/exception/ToscaOperationException.java
@@ -0,0 +1,36 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.model.jsonjanusgraph.operations.exception;
+
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+
+public class ToscaOperationException extends Exception {
+
+ private final StorageOperationStatus storageOperationStatus;
+
+ public ToscaOperationException(String s, StorageOperationStatus storageOperationStatus) {
+ super(String.format("%s. Operation Status: %s", s, storageOperationStatus.name()));
+ this.storageOperationStatus = storageOperationStatus;
+ }
+
+ public StorageOperationStatus getStorageOperationStatus() {
+ return storageOperationStatus;
+ }
+}