summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-02-18 13:13:50 +0000
committervasraz <vasyl.razinkov@est.tech>2021-02-18 13:13:50 +0000
commitfee0f29212b10c940ec4b19fc8f4794d06964eee (patch)
tree794d90ad0c299e85143e1ffee55916078285c4ef /catalog-be/src
parent26e5029d922779fd7e786c1a31b6b37492132388 (diff)
Implement Attributes/Outputs BE (part 1)
This commit includes support for: - import VFC with attributes - add VFC to VF/Service - show attributes in VF/Service Change-Id: I2cda966ab878ae7aee4bcfecf266c5c251c91164 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3448 Signed-off-by: JulienBe <julien.bertozzi@intl.att.com>
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java147
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java80
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java102
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java19
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java1165
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/path/ForwardingPathValidator.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java13
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java124
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentAttributeServlet.java142
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java29
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/OutputsServlet.java119
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java48
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java571
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java11
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java174
19 files changed, 1661 insertions, 1108 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
index cef4d8f6df..81e06a2138 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
@@ -7,9 +7,9 @@
* 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.
@@ -28,10 +28,12 @@ import java.util.Optional;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
@@ -48,15 +50,13 @@ import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
/**
* This class holds the business logic relevant for attributes manipulation.
- *
- * @author mshitrit
*
+ * @author mshitrit
*/
-@Component("attributeBusinessLogic")
+@org.springframework.stereotype.Component("attributeBusinessLogic")
public class AttributeBusinessLogic extends BaseBusinessLogic {
private static final String CREATE_ATTRIBUTE = "CreateAttribute";
@@ -68,12 +68,12 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
@Autowired
public AttributeBusinessLogic(IElementOperation elementDao,
- IGroupOperation groupOperation,
- IGroupInstanceOperation groupInstanceOperation,
- IGroupTypeOperation groupTypeOperation,
- InterfaceOperation interfaceOperation,
- InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
- ArtifactsOperations artifactToscaOperation) {
+ IGroupOperation groupOperation,
+ IGroupInstanceOperation groupInstanceOperation,
+ IGroupTypeOperation groupTypeOperation,
+ InterfaceOperation interfaceOperation,
+ InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
+ ArtifactsOperations artifactToscaOperation) {
super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
}
@@ -86,13 +86,16 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return AttributeDefinition if created successfully Or ResponseFormat
*/
- public Either<AttributeDataDefinition, ResponseFormat> createAttribute(String resourceId, AttributeDataDefinition newAttributeDef, String userId) {
- Either<AttributeDataDefinition, ResponseFormat> result = null;
+ public Either<AttributeDefinition, ResponseFormat> createAttribute(String resourceId,
+ AttributeDefinition newAttributeDef,
+ String userId) {
+ Either<AttributeDefinition, ResponseFormat> result = null;
validateUserExists(userId);
StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceId, NodeTypeEnum.Resource);
if (lockResult != StorageOperationStatus.OK) {
- BeEcompErrorManager.getInstance().logBeFailedLockObjectError(CREATE_ATTRIBUTE, NodeTypeEnum.Resource.name().toLowerCase(), resourceId);
+ BeEcompErrorManager.getInstance()
+ .logBeFailedLockObjectError(CREATE_ATTRIBUTE, NodeTypeEnum.Resource.name().toLowerCase(), resourceId);
log.info(FAILED_TO_LOCK_COMPONENT_ERROR, resourceId, lockResult);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
}
@@ -112,11 +115,13 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
// verify attribute does not exist in resource
if (isAttributeExist(resource.getAttributes(), resourceId, newAttributeDef.getName())) {
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_ALREADY_EXIST, newAttributeDef.getName()));
+ return Either.right(
+ componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_ALREADY_EXIST, newAttributeDef.getName()));
}
Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
// validate property default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttributeDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttributeDef,
+ eitherAllDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
@@ -126,9 +131,12 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
// add the new attribute to resource on graph
// need to get StorageOperationStatus and convert to ActionStatus from
// componentsUtils
- Either<AttributeDataDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
+ Either<AttributeDefinition, StorageOperationStatus> either = toscaOperationFacade
+ .addAttributeOfResource(resource, newAttributeDef);
if (either.isRight()) {
- result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(either.right().value()), resource.getName()));
+ result = Either.right(componentsUtils
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(either.right().value()),
+ resource.getName()));
return result;
}
result = Either.left(either.left().value());
@@ -140,14 +148,15 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
}
- private Either<Boolean, ResponseFormat> validateAttributeDefaultValue(final AttributeDataDefinition attributeDefinition,
+ private Either<Boolean, ResponseFormat> validateAttributeDefaultValue(final AttributeDefinition attributeDefinition,
final Map<String, DataTypeDefinition> dataTypes) {
-
if (!attributeOperation.isAttributeTypeValid(attributeDefinition)) {
- log.info("Invalid type for attribute '{}' type '{}'", attributeDefinition.getName(), attributeDefinition.getType());
- final ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_TYPE, attributeDefinition
- .getType(), attributeDefinition.getName());
+ log.info("Invalid type for attribute '{}' type '{}'", attributeDefinition.getName(),
+ attributeDefinition.getType());
+ final ResponseFormat responseFormat = componentsUtils
+ .getResponseFormat(ActionStatus.INVALID_PROPERTY_TYPE, attributeDefinition
+ .getType(), attributeDefinition.getName());
return Either.right(responseFormat);
}
String type = attributeDefinition.getType();
@@ -156,11 +165,12 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
final ImmutablePair<String, Boolean> propertyInnerTypeValid = attributeOperation.isAttributeInnerTypeValid(
attributeDefinition, dataTypes);
innerType = propertyInnerTypeValid.getLeft();
- if (!propertyInnerTypeValid.getRight()) {
+ if (!Boolean.TRUE.equals(propertyInnerTypeValid.getRight())) {
log.info("Invalid inner type for attribute '{}' type '{}', dataTypeCount '{}'",
attributeDefinition.getName(), attributeDefinition.getType(), dataTypes.size());
final ResponseFormat responseFormat = componentsUtils
- .getResponseFormat(ActionStatus.INVALID_PROPERTY_INNER_TYPE, innerType, attributeDefinition.getName());
+ .getResponseFormat(ActionStatus.INVALID_PROPERTY_INNER_TYPE, innerType,
+ attributeDefinition.getName());
return Either.right(responseFormat);
}
}
@@ -182,7 +192,7 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
return Either.left(true);
}
- private void handleAttributeDefaultValue(final AttributeDataDefinition newAttributeDefinition,
+ private void handleAttributeDefaultValue(final AttributeDefinition newAttributeDefinition,
final Map<String, DataTypeDefinition> dataTypes) {
final ToscaPropertyType type = ToscaPropertyType.isValidType(newAttributeDefinition.getType());
final PropertyValueConverter converter = type.getConverter();
@@ -201,10 +211,11 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
}
- private boolean isAttributeExist(List<AttributeDataDefinition> attributes, String resourceUid, String propertyName) {
+ private boolean isAttributeExist(List<AttributeDefinition> attributes, String resourceUid, String propertyName) {
boolean isExist = false;
if (attributes != null) {
- isExist = attributes.stream().anyMatch(p -> Objects.equals(p.getName(), propertyName) && Objects.equals(p.getOwnerId(), resourceUid));
+ isExist = attributes.stream().anyMatch(
+ p -> Objects.equals(p.getName(), propertyName) && Objects.equals(p.getOwnerId(), resourceUid));
}
return isExist;
@@ -216,7 +227,8 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<AttributeDataDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId, String userId) {
+ public Either<AttributeDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId,
+ String userId) {
validateUserExists(userId);
@@ -227,14 +239,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
Resource resource = status.left().value();
- List<AttributeDataDefinition> attributes = resource.getAttributes();
+ List<AttributeDefinition> attributes = resource.getAttributes();
if (attributes == null) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, ""));
} else {
// verify attribute exist in resource
- Optional<AttributeDataDefinition> optionalAtt = attributes.stream().filter(att ->
+ Optional<AttributeDefinition> optionalAtt = attributes.stream().filter(att ->
att.getUniqueId().equals(attributeId)).findAny();
- return optionalAtt.<Either<AttributeDataDefinition, ResponseFormat>>map(Either::left).orElseGet(() ->
+ return optionalAtt.<Either<AttributeDefinition, ResponseFormat>>map(Either::left).orElseGet(() ->
Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, "")));
}
}
@@ -248,12 +260,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<AttributeDataDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId, AttributeDataDefinition newAttDef, String userId) {
- Either<AttributeDataDefinition, ResponseFormat> result = null;
+ public Either<AttributeDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId,
+ AttributeDefinition newAttDef, String userId) {
+ Either<AttributeDefinition, ResponseFormat> result = null;
StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceId, NodeTypeEnum.Resource);
if (lockResult != StorageOperationStatus.OK) {
- BeEcompErrorManager.getInstance().logBeFailedLockObjectError(UPDATE_ATTRIBUTE, NodeTypeEnum.Resource.name().toLowerCase(), resourceId);
+ BeEcompErrorManager.getInstance()
+ .logBeFailedLockObjectError(UPDATE_ATTRIBUTE, NodeTypeEnum.Resource.name().toLowerCase(), resourceId);
log.info(FAILED_TO_LOCK_COMPONENT_ERROR, resourceId, lockResult);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
}
@@ -271,30 +285,38 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
// verify attribute exist in resource
- Either<AttributeDataDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
+ Either<AttributeDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
if (eitherAttribute.isRight()) {
return Either.right(eitherAttribute.right().value());
}
Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
// validate attribute default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validateAttributeDefaultValue(newAttDef,
+ eitherAllDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
// add the new property to resource on graph
- StorageOperationStatus validateAndUpdateAttribute = attributeOperation.validateAndUpdateAttribute(newAttDef, eitherAllDataTypes);
+ StorageOperationStatus validateAndUpdateAttribute = attributeOperation
+ .validateAndUpdateAttribute(newAttDef, eitherAllDataTypes);
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
- log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, validateAndUpdateAttribute);
- result = Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(validateAndUpdateAttribute), resource.getName()));
+ log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId,
+ validateAndUpdateAttribute);
+ result = Either.right(componentsUtils
+ .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(validateAndUpdateAttribute),
+ resource.getName()));
}
- Either<AttributeDataDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade.updateAttributeOfResource(resource, newAttDef);
+ Either<AttributeDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade
+ .updateAttributeOfResource(resource, newAttDef);
if (eitherAttUpdate.isRight()) {
- log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, eitherAttUpdate.right().value());
- result = Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(eitherAttUpdate.right().value()), resource.getName()));
+ log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId,
+ eitherAttUpdate.right().value());
+ result = Either.right(componentsUtils.getResponseFormatByResource(
+ componentsUtils.convertFromStorageResponse(eitherAttUpdate.right().value()), resource.getName()));
return result;
}
@@ -315,15 +337,17 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<AttributeDataDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId, String userId) {
+ public Either<AttributeDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId,
+ String userId) {
- Either<AttributeDataDefinition, ResponseFormat> result = null;
+ Either<AttributeDefinition, ResponseFormat> result = null;
validateUserExists(userId);
StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceId, NodeTypeEnum.Resource);
if (lockResult != StorageOperationStatus.OK) {
- BeEcompErrorManager.getInstance().logBeFailedLockObjectError(DELETE_ATTRIBUTE, NodeTypeEnum.Resource.name().toLowerCase(), resourceId);
+ BeEcompErrorManager.getInstance()
+ .logBeFailedLockObjectError(DELETE_ATTRIBUTE, NodeTypeEnum.Resource.name().toLowerCase(), resourceId);
log.info(FAILED_TO_LOCK_COMPONENT_ERROR, resourceId, lockResult);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
}
@@ -342,16 +366,20 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
// verify attribute exist in resource
- Either<AttributeDataDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId, userId);
+ Either<AttributeDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId,
+ userId);
if (eitherAttributeExist.isRight()) {
return Either.right(eitherAttributeExist.right().value());
}
String attributeName = eitherAttributeExist.left().value().getName();
// delete attribute of resource from graph
- StorageOperationStatus eitherAttributeDelete = toscaOperationFacade.deleteAttributeOfResource(resource, attributeName);
+ StorageOperationStatus eitherAttributeDelete = toscaOperationFacade
+ .deleteAttributeOfResource(resource, attributeName);
if (eitherAttributeDelete != StorageOperationStatus.OK) {
- result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(eitherAttributeDelete), resource.getName()));
+ result = Either.right(componentsUtils
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(eitherAttributeDelete),
+ resource.getName()));
return result;
}
@@ -362,4 +390,21 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
graphLockOperation.unlockComponent(resourceId, NodeTypeEnum.Resource);
}
}
+
+ public Either<List<AttributeDefinition>, ResponseFormat> getAttributesList(final String componentId,
+ final String userId) {
+ validateUserExists(userId);
+
+ // Get the resource from DB
+ final ComponentParametersView filter = new ComponentParametersView(true);
+ filter.setIgnoreAttributes(false);
+ final Either<Component, StorageOperationStatus> status = toscaOperationFacade.getToscaElement(componentId, filter);
+ if (status.isRight()) {
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND, ""));
+ }
+
+ return Either.left(status.left().value().getAttributes());
+ }
+
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index be2a45b24f..0b04f70779 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -49,7 +49,6 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.utils.MapUtil;
import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
@@ -59,6 +58,7 @@ import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.facade.operations.CatalogOperation;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapReqDef;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
@@ -941,8 +941,8 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic", validPropertiesMerge.right().value());
return false;
}
- List<AttributeDataDefinition> genericTypeAttributes = latestGeneric.getAttributes();
- final Either<Map<String, AttributeDataDefinition>, String> validAttributesMerge = validateNoConflictingProperties(
+ List<AttributeDefinition> genericTypeAttributes = latestGeneric.getAttributes();
+ final Either<Map<String, AttributeDefinition>, String> validAttributesMerge = validateNoConflictingProperties(
genericTypeAttributes, ((Resource) componentToCheckOut).getAttributes());
if (validAttributesMerge.isRight()) {
log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic", validAttributesMerge.right().value());
@@ -1038,5 +1038,3 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
}
}
-
-
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 1104621379..5af6f41938 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -363,7 +363,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
return createComponent(needLock, containerComponent,origComponent, resourceInstance, user);
}
-
+
private Component getOrigComponentForServiceProxy(org.openecomp.sdc.be.model.Component containerComponent, ComponentInstance resourceInstance) {
Either<Component, StorageOperationStatus> serviceProxyOrigin = toscaOperationFacade.getLatestByName("serviceProxy");
if (isServiceProxyOrigin(serviceProxyOrigin)) {
@@ -378,14 +378,14 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
validateOriginAndResourceInstanceTypes(containerComponent, origComponent, OriginTypeEnum.ServiceProxy);
return origComponent;
}
-
+
private Component getOrigComponentForServiceSubstitution(ComponentInstance resourceInstance) {
final Either<Component, StorageOperationStatus> getServiceResult = toscaOperationFacade.getToscaFullElement(resourceInstance.getComponentUid());
if (getServiceResult.isRight()) {
throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getServiceResult.right().value()));
}
final Component service = getServiceResult.left().value();
-
+
final Either<Component, StorageOperationStatus> getServiceDerivedFromTypeResult = toscaOperationFacade.getLatestByToscaResourceName(service.getDerivedFromGenericType());
if (getServiceDerivedFromTypeResult.isRight()) {
throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getServiceResult.right().value()));
@@ -658,6 +658,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
filter.setIgnoreRequirements(false);
filter.setIgnoreInterfaces(false);
filter.setIgnoreProperties(false);
+ filter.setIgnoreAttributes(false);
filter.setIgnoreInputs(false);
Either<Component, StorageOperationStatus> serviceRes =
toscaOperationFacade.getToscaElement(resourceInstance.getComponentUid(), filter);
@@ -674,6 +675,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
serviceInterfaces.forEach(resourceInstance::addInterface);
}
resourceInstance.setProperties(PropertiesUtils.getProperties(service));
+ resourceInstance.setAttributes(service.getAttributes());
final List<InputDefinition> serviceInputs = service.getInputs();
resourceInstance.setInputs(serviceInputs);
@@ -683,17 +685,17 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
resourceInstance.setSourceModelUid(service.getUniqueId());
resourceInstance.setComponentUid(origComponent.getUniqueId());
resourceInstance.setComponentVersion(service.getVersion());
-
+
switch(resourceInstance.getOriginType()) {
case ServiceProxy:
return fillProxyInstanceData(resourceInstance, origComponent, service);
case ServiceSubstitution:
return fillServiceSubstitutableNodeTypeData(resourceInstance, service);
- default:
+ default:
return StorageOperationStatus.OK;
}
}
-
+
private StorageOperationStatus fillProxyInstanceData(final ComponentInstance resourceInstance, final Component origComponent, final Component service) {
final String name = ValidationUtils.normalizeComponentInstanceName(service.getName()) + ToscaOperationFacade.PROXY_SUFFIX;
final String toscaResourceName = ((Resource) origComponent).getToscaResourceName();
@@ -707,7 +709,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
resourceInstance.setDescription("A Proxy for Service " + service.getName());
return StorageOperationStatus.OK;
}
-
+
private StorageOperationStatus fillServiceSubstitutableNodeTypeData(final ComponentInstance resourceInstance, final Component service) {
resourceInstance.setToscaComponentName("org.openecomp.service." + ValidationUtils.convertToSystemName(service.getName()));
resourceInstance.setName(ValidationUtils.normalizeComponentInstanceName(service.getName()));
@@ -1288,7 +1290,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
return componentInstance;
}
-
+
/**
* Try to modify the delete and return two cases
*
@@ -1441,7 +1443,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
private Collection<ForwardingPathDataDefinition> getForwardingPathDataDefinitions(String containerComponentId) {
ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreForwardingPath(false);
+ filter.setIgnoreServicePath(false);
Either<Service, StorageOperationStatus> forwardingPathOrigin = toscaOperationFacade
.getToscaElement(containerComponentId, filter);
return forwardingPathOrigin.left().value().getForwardingPaths().values();
@@ -2510,7 +2512,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
private ComponentParametersView getComponentParametersViewForForwardingPath() {
ComponentParametersView componentParametersView = new ComponentParametersView();
componentParametersView.setIgnoreCapabiltyProperties(false);
- componentParametersView.setIgnoreForwardingPath(false);
+ componentParametersView.setIgnoreServicePath(false);
return componentParametersView;
}
@@ -2602,14 +2604,14 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getServiceResult.right().value()));
}
final Component service = getServiceResult.left().value();
-
+
final Either<Component, StorageOperationStatus> getServiceDerivedFromTypeResult = toscaOperationFacade.getLatestByToscaResourceName(service.getDerivedFromGenericType());
if (getServiceDerivedFromTypeResult.isRight()) {
throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getServiceResult.right().value()));
}
origComponent = getServiceDerivedFromTypeResult.left().value();
-
+
final StorageOperationStatus fillProxyRes = fillInstanceData(newComponentInstance, origComponent);
if (isFillProxyRes(fillProxyRes)) {
throw new ByActionStatusComponentException(
@@ -2698,16 +2700,54 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
instanceProperties = new ArrayList<>();
}
return instanceProperties;
- }catch (ComponentException e){
+ } catch (ComponentException e) {
failed = true;
throw e;
- }finally {
+ } finally {
+ unlockComponent(failed, containerComponent);
+ }
+ }
+
+ public List<ComponentInstanceAttribute> getComponentInstanceAttributesById(final String containerComponentTypeParam,
+ final String containerComponentId,
+ final String componentInstanceUniqueId,
+ final String userId) {
+ Component containerComponent = null;
+
+ boolean failed = false;
+ try {
+ validateUserExists(userId);
+ validateComponentType(containerComponentTypeParam);
+
+ final Either<Component, StorageOperationStatus> validateContainerComponentExists =
+ toscaOperationFacade.getToscaElement(containerComponentId);
+ if (validateContainerComponentExists.isRight()) {
+ throw new ByActionStatusComponentException(
+ componentsUtils.convertFromStorageResponse(validateContainerComponentExists.right().value()));
+ }
+ containerComponent = validateContainerComponentExists.left().value();
+
+ if (getResourceInstanceById(containerComponent, componentInstanceUniqueId).isRight()) {
+ throw new ByActionStatusComponentException(
+ ActionStatus.RESOURCE_INSTANCE_NOT_FOUND_ON_SERVICE, componentInstanceUniqueId, containerComponentId);
+ }
+
+ final Map<String, List<ComponentInstanceAttribute>> componentInstancesAttributes = containerComponent.getComponentInstancesAttributes();
+ return componentInstancesAttributes == null ? new ArrayList<>()
+ : componentInstancesAttributes.getOrDefault(componentInstanceUniqueId, new ArrayList<>());
+ } catch (final ComponentException e) {
+ failed = true;
+ throw e;
+ } finally {
unlockComponent(failed, containerComponent);
}
}
- protected void validateIncrementCounter(String resourceInstanceId, GraphPropertiesDictionary counterType, Wrapper<Integer> instaceCounterWrapper, Wrapper<ResponseFormat> errorWrapper) {
- Either<Integer, StorageOperationStatus> counterRes = componentInstanceOperation.increaseAndGetResourceInstanceSpecificCounter(resourceInstanceId, counterType, true);
+ protected void validateIncrementCounter(String resourceInstanceId, GraphPropertiesDictionary counterType,
+ Wrapper<Integer> instaceCounterWrapper,
+ Wrapper<ResponseFormat> errorWrapper) {
+ Either<Integer, StorageOperationStatus> counterRes = componentInstanceOperation
+ .increaseAndGetResourceInstanceSpecificCounter(resourceInstanceId, counterType, true);
if (counterRes.isRight()) {
log.debug("increase And Get {} failed resource instance {}", counterType, resourceInstanceId);
@@ -2889,10 +2929,10 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
}
-
+
public Either<RequirementDefinition, ResponseFormat> updateInstanceRequirement(ComponentTypeEnum componentTypeEnum, String containerComponentId, String componentInstanceUniqueId, String capabilityType, String capabilityName,
RequirementDefinition requirementDef, String userId) {
-
+
Either<RequirementDefinition, ResponseFormat> resultOp = null;
validateUserExists(userId);
@@ -2922,7 +2962,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
log.debug("Failed to lock component {}", containerComponentId);
return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockStatus)));
}
-
+
try {
StorageOperationStatus updateRequirementStatus = toscaOperationFacade.updateComponentInstanceRequirement(containerComponentId, componentInstanceUniqueId, requirementDef);
if (updateRequirementStatus != StorageOperationStatus.OK) {
@@ -2947,7 +2987,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
// unlock resource
graphLockOperation.unlockComponent(containerComponentId, componentTypeEnum.getNodeType());
- }
+ }
}
public Either<List<ComponentInstanceProperty>, ResponseFormat> updateInstanceCapabilityProperties(ComponentTypeEnum componentTypeEnum, String containerComponentId, String componentInstanceUniqueId, String capabilityType, String capabilityName,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java
new file mode 100644
index 0000000000..eecb6eeba2
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java
@@ -0,0 +1,102 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.components.impl;
+
+import fj.data.Either;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import org.openecomp.sdc.be.components.validation.ComponentValidations;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstanceOutput;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
+import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
+import org.openecomp.sdc.be.model.operations.api.IElementOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupInstanceOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupOperation;
+import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
+import org.openecomp.sdc.common.log.elements.LoggerSupportability;
+import org.openecomp.sdc.common.log.enums.LoggerSupportabilityActions;
+import org.openecomp.sdc.common.log.enums.StatusCode;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.springframework.beans.factory.annotation.Autowired;
+
+@org.springframework.stereotype.Component("outputsBusinessLogic")
+public class OutputsBusinessLogic extends BaseBusinessLogic {
+
+ private static final Logger log = Logger.getLogger(OutputsBusinessLogic.class);
+ private static final String FAILED_TO_FOUND_COMPONENT_ERROR = "Failed to found component {}, error: {}";
+ private static final LoggerSupportability loggerSupportability = LoggerSupportability.getLogger(OutputsBusinessLogic.class);
+ private static final String FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_COMPONENT_INSTANCE_ID = "Failed to found component instance outputs componentInstanceId: {}";
+ private static final String FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_ERROR = "Failed to found component instance outputs {}, error: {}";
+
+ @Autowired
+ public OutputsBusinessLogic(final IElementOperation elementDao,
+ final IGroupOperation groupOperation,
+ final IGroupInstanceOperation groupInstanceOperation,
+ final IGroupTypeOperation groupTypeOperation,
+ final InterfaceOperation interfaceOperation,
+ final InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
+ final ArtifactsOperations artifactToscaOperation) {
+ super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+ interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
+ }
+
+ public Either<List<ComponentInstanceOutput>, ResponseFormat> getComponentInstanceOutputs(final String userId,
+ final String componentId,
+ final String componentInstanceId) {
+
+ validateUserExists(userId);
+ final ComponentParametersView filters = new ComponentParametersView();
+ filters.disableAll();
+ filters.setIgnoreOutputs(false);
+ filters.setIgnoreComponentInstances(false);
+ filters.setIgnoreComponentInstancesOutputs(false);
+
+ final Either<Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(componentId, filters);
+ if (getComponentEither.isRight()) {
+ ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
+ log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus);
+ return Either.right(componentsUtils.getResponseFormat(actionStatus));
+
+ }
+ final Component component = getComponentEither.left().value();
+
+ if (!ComponentValidations.validateComponentInstanceExist(component, componentInstanceId)) {
+ final ActionStatus actionStatus = ActionStatus.COMPONENT_INSTANCE_NOT_FOUND;
+ log.debug(FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_ERROR, componentInstanceId, actionStatus);
+ loggerSupportability.log(LoggerSupportabilityActions.CREATE_INPUTS, component.getComponentMetadataForSupportLog(),
+ StatusCode.ERROR, FAILED_TO_FOUND_COMPONENT_INSTANCE_OUTPUTS_COMPONENT_INSTANCE_ID, componentInstanceId);
+ return Either.right(componentsUtils.getResponseFormat(actionStatus));
+ }
+ final Map<String, List<ComponentInstanceOutput>> ciOutputs = Optional.ofNullable(component.getComponentInstancesOutputs())
+ .orElse(Collections.emptyMap());
+
+ return Either.left(ciOutputs.getOrDefault(componentInstanceId, Collections.emptyList()));
+ }
+
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 4c34ddaba0..80093bcf0a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -94,7 +94,6 @@ import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
@@ -2632,7 +2631,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
- Map<String, List<AttributeDataDefinition>> instAttributes = new HashMap<>();
+ Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -2693,7 +2692,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<String, Map<String, ArtifactDefinition>> instArtifacts, Map<String,
List<ComponentInstanceProperty>> instProperties, Map<String,
List<ComponentInstanceInput>> instInputs,
- Map<String, List<AttributeDataDefinition>> instAttributes) {
+ Map<String, List<AttributeDefinition>> instAttributes) {
Optional<ComponentInstance> foundInstance = findInstance(oldResource, instance);
if (foundInstance.isPresent()) {
if (MapUtils.isNotEmpty(foundInstance.get().getCapabilities())) {
@@ -2749,7 +2748,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private void associateInstAttributeToComponentToInstances(String yamlName, Resource resource,
- Map<String, List<AttributeDataDefinition>> instAttributes) {
+ Map<String, List<AttributeDefinition>> instAttributes) {
StorageOperationStatus addArtToInst;
addArtToInst = toscaOperationFacade.associateInstAttributeToComponentToInstances(instAttributes,
resource);
@@ -2905,7 +2904,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts,
Map<String, Map<String, ArtifactDefinition>> instArtifacts,
- Map<String, List<AttributeDataDefinition>> instAttributes,
+ Map<String, List<AttributeDefinition>> instAttributes,
Map<String, Resource> originCompMap,
Map<String, List<ComponentInstanceInput>> instInputs,
UploadComponentInstanceInfo uploadComponentInstanceInfo) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 6137a3ffca..b2e4ef298f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -60,7 +60,6 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -68,6 +67,7 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.DataTypeDefinition;
@@ -111,6 +111,7 @@ public class ResourceImportManager {
private AuditingManager auditingManager;
private ResourceBusinessLogic resourceBusinessLogic;
+
public ServiceBusinessLogic getServiceBusinessLogic() {
return serviceBusinessLogic;
}
@@ -243,7 +244,7 @@ public class ResourceImportManager {
componentsUtils
.getResponseFormat(((ComponentException) e).getActionStatus(), ((ComponentException) e).getParams())
:
- ((ComponentException) e).getResponseFormat();
+ ((ComponentException) e).getResponseFormat();
}
return null;
}
@@ -686,8 +687,8 @@ public class ResourceImportManager {
log.debug("Couldn't check whether imported resource capability derives from its parent's capability");
throw new ByActionStatusComponentException(
componentsUtils.convertFromStorageResponse(capabilityTypeDerivedFrom
- .right()
- .value()));
+ .right()
+ .value()));
}
return capabilityTypeDerivedFrom.left().value();
}
@@ -712,7 +713,7 @@ public class ResourceImportManager {
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES.getElementName())) {
capabilityDefinition.setValidSourceTypes(
(List<String>) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES
- .getElementName()));
+ .getElementName()));
}
// ValidSourceTypes
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName())) {
@@ -830,10 +831,10 @@ public class ResourceImportManager {
calculateResourceIsAbstract(resource, categories);
}
- private List<AttributeDataDefinition> getAttributes(final String payloadData) {
+ private List<AttributeDefinition> getAttributes(final String payloadData) {
final Map<String, Object> mappedToscaTemplate = decodePayload(payloadData);
- final List<AttributeDataDefinition> attributeDataDefinitionList = new ArrayList<>();
+ final List<AttributeDefinition> attributeDataDefinitionList = new ArrayList<>();
final Either<Map<String, Object>, ResultStatusEnum> firstToscaMapElement = ImportUtils
.findFirstToscaMapElement(mappedToscaTemplate, ToscaTagNamesEnum.ATTRIBUTES);
@@ -851,7 +852,7 @@ public class ResourceImportManager {
final Map<String, Object> attributeMap = (Map<String, Object>) value;
- final AttributeDataDefinition attributeDefinition = new AttributeDataDefinition();
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
attributeDefinition.setName(key);
setField(attributeMap, ToscaTagNamesEnum.DESCRIPTION, attributeDefinition::setDescription);
@@ -861,7 +862,7 @@ public class ResourceImportManager {
setField(attributeMap, ToscaTagNamesEnum.ENTRY_SCHEMA, attributeDefinition::setSchema);
attributeDataDefinitionList.add(attributeDefinition);
} else {
- final AttributeDataDefinition attributeDefinition = new AttributeDataDefinition();
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
attributeDefinition.setName(key);
attributeDataDefinitionList.add(attributeDefinition);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 550e2d9ea0..507abb5ed6 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -69,7 +69,6 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
@@ -79,6 +78,7 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.info.NodeTypeInfoToUpdateArtifacts;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
import org.openecomp.sdc.be.model.Component;
@@ -139,7 +139,7 @@ import org.yaml.snakeyaml.Yaml;
@Getter
@Setter
@org.springframework.stereotype.Component("serviceImportBusinessLogic")
-public class ServiceImportBusinessLogic{
+public class ServiceImportBusinessLogic {
private final UiComponentDataConverter uiComponentDataConverter;
private static final String INITIAL_VERSION = "0.1";
@@ -153,15 +153,14 @@ public class ServiceImportBusinessLogic{
private static final String CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES = "Create Resource - validateCapabilityTypesCreate";
private static final String CATEGORY_IS_EMPTY = "Resource category is empty";
-
@Autowired
private ServiceBusinessLogic serviceBusinessLogic;
+
public ServiceBusinessLogic getServiceBusinessLogic() {
return serviceBusinessLogic;
}
- public void setServiceBusinessLogic(
- ServiceBusinessLogic serviceBusinessLogic) {
+ public void setServiceBusinessLogic(ServiceBusinessLogic serviceBusinessLogic) {
this.serviceBusinessLogic = serviceBusinessLogic;
}
@@ -183,33 +182,35 @@ public class ServiceImportBusinessLogic{
private ServiceImportParseLogic serviceImportParseLogic;
private static final Logger log = Logger.getLogger(ServiceImportBusinessLogic.class);
+
@Autowired
public ServiceImportBusinessLogic(IElementOperation elementDao,
- IGroupOperation groupOperation,
- IGroupInstanceOperation groupInstanceOperation,
- IGroupTypeOperation groupTypeOperation,
- GroupBusinessLogic groupBusinessLogic,
- InterfaceOperation interfaceOperation,
- InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
- ArtifactsBusinessLogic artifactsBusinessLogic,
- IDistributionEngine distributionEngine, ComponentInstanceBusinessLogic componentInstanceBusinessLogic,
- ServiceDistributionValidation serviceDistributionValidation, ForwardingPathValidator forwardingPathValidator,
- UiComponentDataConverter uiComponentDataConverter, NodeFilterOperation serviceFilterOperation,
- NodeFilterValidator serviceFilterValidator, ArtifactsOperations artifactToscaOperation,
- ComponentContactIdValidator componentContactIdValidator,
- ComponentNameValidator componentNameValidator,
- ComponentTagsValidator componentTagsValidator,
- ComponentValidator componentValidator,
- ComponentIconValidator componentIconValidator,
- ComponentProjectCodeValidator componentProjectCodeValidator,
- ComponentDescriptionValidator componentDescriptionValidator) {
+ IGroupOperation groupOperation,
+ IGroupInstanceOperation groupInstanceOperation,
+ IGroupTypeOperation groupTypeOperation,
+ GroupBusinessLogic groupBusinessLogic,
+ InterfaceOperation interfaceOperation,
+ InterfaceLifecycleOperation interfaceLifecycleTypeOperation,
+ ArtifactsBusinessLogic artifactsBusinessLogic,
+ IDistributionEngine distributionEngine, ComponentInstanceBusinessLogic componentInstanceBusinessLogic,
+ ServiceDistributionValidation serviceDistributionValidation, ForwardingPathValidator forwardingPathValidator,
+ UiComponentDataConverter uiComponentDataConverter, NodeFilterOperation serviceFilterOperation,
+ NodeFilterValidator serviceFilterValidator, ArtifactsOperations artifactToscaOperation,
+ ComponentContactIdValidator componentContactIdValidator,
+ ComponentNameValidator componentNameValidator,
+ ComponentTagsValidator componentTagsValidator,
+ ComponentValidator componentValidator,
+ ComponentIconValidator componentIconValidator,
+ ComponentProjectCodeValidator componentProjectCodeValidator,
+ ComponentDescriptionValidator componentDescriptionValidator) {
this.componentInstanceBusinessLogic = componentInstanceBusinessLogic;
this.uiComponentDataConverter = uiComponentDataConverter;
}
private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
- public Service createService(Service service, AuditingActionEnum auditingAction, User user, Map<String, byte[]> csarUIPayload, String payloadName) {
+ public Service createService(Service service, AuditingActionEnum auditingAction, User user, Map<String, byte[]> csarUIPayload,
+ String payloadName) {
log.debug("enter createService");
service.setCreatorUserId(user.getUserId());
service.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
@@ -230,9 +231,8 @@ public class ServiceImportBusinessLogic{
csarBusinessLogic.validateCsarBeforeCreate(service, csarUUID);
log.debug("CsarUUID is {} - going to create resource from CSAR", csarUUID);
return createServiceFromCsar(service, user, csarUIPayload, csarUUID);
- }catch (Exception e){
- log.debug("Exception occured when createService,error is:{}",e.getMessage(),e);
- //ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR);
+ } catch (Exception e) {
+ log.debug("Exception occured when createService,error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
}
@@ -244,34 +244,34 @@ public class ServiceImportBusinessLogic{
Map<String, NodeTypeInfo> nodeTypesInfo = csarInfo.extractNodeTypesInfo();
Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = serviceImportParseLogic
- .findNodeTypesArtifactsToHandle(
- nodeTypesInfo, csarInfo, service);
+ .findNodeTypesArtifactsToHandle(
+ nodeTypesInfo, csarInfo, service);
if (findNodeTypesArtifactsToHandleRes.isRight()) {
log.debug("failed to find node types for update with artifacts during import csar {}. ",
- csarInfo.getCsarUUID());
+ csarInfo.getCsarUUID());
throw new ComponentException(findNodeTypesArtifactsToHandleRes.right().value());
}
- Service cService = createServiceFromYaml(service, csarInfo.getMainTemplateContent(), csarInfo.getMainTemplateName(),
- nodeTypesInfo, csarInfo, findNodeTypesArtifactsToHandleRes.left().value(), true, false,
- null);
- return cService;
- }catch (Exception e){
- log.debug("Exception occured when createServiceFromCsar,error is:{}",e.getMessage(),e);
+ return createServiceFromYaml(service, csarInfo.getMainTemplateContent(), csarInfo.getMainTemplateName(),
+ nodeTypesInfo, csarInfo, findNodeTypesArtifactsToHandleRes.left().value(), true, false,
+ null);
+ } catch (Exception e) {
+ log.debug("Exception occured when createServiceFromCsar,error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
}
protected Service createServiceFromYaml(Service service, String topologyTemplateYaml,
- String yamlName, Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
- boolean shouldLock, boolean inTransaction, String nodeName) {
+ String yamlName, Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
+ boolean shouldLock, boolean inTransaction, String nodeName) {
List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
Service createdService;
CreateServiceFromYamlParameter csfyp = new CreateServiceFromYamlParameter();
try {
ParsedToscaYamlInfo
- parsedToscaYamlInfo = csarBusinessLogic.getParsedToscaYamlInfo(topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, nodeName, service);
+ parsedToscaYamlInfo = csarBusinessLogic
+ .getParsedToscaYamlInfo(topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, nodeName, service);
if (MapUtils.isEmpty(parsedToscaYamlInfo.getInstances())) {
throw new ComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
@@ -297,8 +297,8 @@ public class ServiceImportBusinessLogic{
}
protected Service createServiceAndRIsFromYaml(Service service, boolean isNormative,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
- boolean shouldLock, boolean inTransaction, CreateServiceFromYamlParameter csfyp) {
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
+ boolean shouldLock, boolean inTransaction, CreateServiceFromYamlParameter csfyp) {
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
String yamlName = csfyp.getYamlName();
@@ -327,15 +327,15 @@ public class ServiceImportBusinessLogic{
log.trace("************* Finish to add inputs from yaml {}", yamlName);
Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap = parsedToscaYamlInfo
- .getInstances();
+ .getInstances();
log.trace("************* Going to create nodes, RI's and Relations from yaml {}", yamlName);
service = createRIAndRelationsFromYaml(yamlName, service, uploadComponentInstanceInfoMap,
- topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
- nodeTypesArtifactsToCreate, nodeName);
+ topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
+ nodeTypesArtifactsToCreate, nodeName);
log.trace("************* Finished to create nodes, RI and Relation from yaml {}", yamlName);
Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes = serviceBusinessLogic.groupBusinessLogic
- .validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), service.getSystemName());
+ .validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), service.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
serviceImportParseLogic.rollback(inTransaction, service, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ComponentException(validateUpdateVfGroupNamesRes.right().value());
@@ -358,11 +358,11 @@ public class ServiceImportBusinessLogic{
log.trace("************* Going to add artifacts from yaml {}", yamlName);
NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(nodeName,
- nodeTypesArtifactsToCreate);
+ nodeTypesArtifactsToCreate);
Either<Service, ResponseFormat> createArtifactsEither = createOrUpdateArtifacts(
- ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, createdArtifacts, yamlName,
- csarInfo, service, nodeTypeInfoToUpdateArtifacts, inTransaction, shouldLock);
+ ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, createdArtifacts, yamlName,
+ csarInfo, service, nodeTypeInfoToUpdateArtifacts, inTransaction, shouldLock);
if (createArtifactsEither.isRight()) {
serviceImportParseLogic.rollback(inTransaction, service, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ComponentException(createArtifactsEither.right().value());
@@ -379,32 +379,33 @@ public class ServiceImportBusinessLogic{
}
if (shouldLock) {
serviceBusinessLogic.graphLockOperation.unlockComponentByName(service.getSystemName(), service.getUniqueId(),
- NodeTypeEnum.Resource);
+ NodeTypeEnum.Resource);
}
}
}
protected Either<Resource, ResponseFormat> createOrUpdateArtifacts(
- ArtifactsBusinessLogic.ArtifactOperationEnum operation, List<ArtifactDefinition> createdArtifacts,
- String yamlFileName, CsarInfo csarInfo, Resource preparedResource,
- NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts, boolean inTransaction, boolean shouldLock) {
+ ArtifactsBusinessLogic.ArtifactOperationEnum operation, List<ArtifactDefinition> createdArtifacts,
+ String yamlFileName, CsarInfo csarInfo, Resource preparedResource,
+ NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts, boolean inTransaction, boolean shouldLock) {
String nodeName = nodeTypeInfoToUpdateArtifacts.getNodeName();
Resource resource = preparedResource;
Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = nodeTypeInfoToUpdateArtifacts
- .getNodeTypesArtifactsToHandle();
+ .getNodeTypesArtifactsToHandle();
if (preparedResource.getResourceType() == ResourceTypeEnum.VF) {
if (nodeName != null && nodeTypesArtifactsToHandle.get(nodeName) != null && !nodeTypesArtifactsToHandle.get(nodeName).isEmpty()) {
Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes =
- handleNodeTypeArtifacts(preparedResource, nodeTypesArtifactsToHandle.get(nodeName), createdArtifacts, csarInfo.getModifier(), inTransaction, true);
+ handleNodeTypeArtifacts(preparedResource, nodeTypesArtifactsToHandle.get(nodeName), createdArtifacts, csarInfo.getModifier(),
+ inTransaction, true);
if (handleNodeTypeArtifactsRes.isRight()) {
return Either.right(handleNodeTypeArtifactsRes.right().value());
}
}
} else {
Either<Resource, ResponseFormat> createdCsarArtifactsEither = handleVfCsarArtifacts(preparedResource, csarInfo, createdArtifacts,
- new ArtifactOperationInfo(false, false, operation), shouldLock, inTransaction);
+ new ArtifactOperationInfo(false, false, operation), shouldLock, inTransaction);
log.trace("************* Finished to add artifacts from yaml {}", yamlFileName);
if (createdCsarArtifactsEither.isRight()) {
return createdCsarArtifactsEither;
@@ -415,27 +416,30 @@ public class ServiceImportBusinessLogic{
}
protected Either<Resource, ResponseFormat> handleVfCsarArtifacts(Resource resource, CsarInfo csarInfo,
- List<ArtifactDefinition> createdArtifacts, ArtifactOperationInfo artifactOperation, boolean shouldLock,
- boolean inTransaction) {
+ List<ArtifactDefinition> createdArtifacts,
+ ArtifactOperationInfo artifactOperation, boolean shouldLock,
+ boolean inTransaction) {
if (csarInfo.getCsar() != null) {
createOrUpdateSingleNonMetaArtifactToComstants(resource, csarInfo, artifactOperation, shouldLock, inTransaction);
Either<Resource, ResponseFormat> eitherCreateResult = createOrUpdateNonMetaArtifacts(csarInfo, resource,
- createdArtifacts, shouldLock, inTransaction, artifactOperation);
+ createdArtifacts, shouldLock, inTransaction, artifactOperation);
if (eitherCreateResult.isRight()) {
return Either.right(eitherCreateResult.right().value());
}
Either<Resource, StorageOperationStatus> eitherGerResource = toscaOperationFacade.getToscaElement(resource.getUniqueId());
if (eitherGerResource.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(eitherGerResource.right().value()), resource);
+ componentsUtils.convertFromStorageResponse(eitherGerResource.right().value()), resource);
return Either.right(responseFormat);
}
resource = eitherGerResource.left().value();
- Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus = CsarValidationUtils.getArtifactsMeta(csarInfo.getCsar(), csarInfo.getCsarUUID(), componentsUtils);
+ Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus = CsarValidationUtils
+ .getArtifactsMeta(csarInfo.getCsar(), csarInfo.getCsarUUID(), componentsUtils);
if (artifacsMetaCsarStatus.isLeft()) {
- return getResourceResponseFormatEither(resource, csarInfo, createdArtifacts, artifactOperation, shouldLock, inTransaction, artifacsMetaCsarStatus);
+ return getResourceResponseFormatEither(resource, csarInfo, createdArtifacts, artifactOperation, shouldLock, inTransaction,
+ artifacsMetaCsarStatus);
} else {
return csarArtifactsAndGroupsBusinessLogic.deleteVFModules(resource, csarInfo, shouldLock, inTransaction);
}
@@ -443,7 +447,8 @@ public class ServiceImportBusinessLogic{
return Either.left(resource);
}
- protected void createOrUpdateSingleNonMetaArtifactToComstants(Resource resource, CsarInfo csarInfo, ArtifactOperationInfo artifactOperation, boolean shouldLock, boolean inTransaction) {
+ protected void createOrUpdateSingleNonMetaArtifactToComstants(Resource resource, CsarInfo csarInfo, ArtifactOperationInfo artifactOperation,
+ boolean shouldLock, boolean inTransaction) {
String vendorLicenseModelId = null;
String vfLicenseModelId = null;
if (artifactOperation.getArtifactOperationEnum() == ArtifactOperationEnum.UPDATE) {
@@ -460,19 +465,23 @@ public class ServiceImportBusinessLogic{
}
}
createOrUpdateSingleNonMetaArtifact(resource, csarInfo,
- CsarUtils.ARTIFACTS_PATH + Constants.VENDOR_LICENSE_MODEL, Constants.VENDOR_LICENSE_MODEL,
- ArtifactTypeEnum.VENDOR_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
- Constants.VENDOR_LICENSE_LABEL, Constants.VENDOR_LICENSE_DISPLAY_NAME,
- Constants.VENDOR_LICENSE_DESCRIPTION, vendorLicenseModelId, artifactOperation, null, true, shouldLock,
- inTransaction);
+ CsarUtils.ARTIFACTS_PATH + Constants.VENDOR_LICENSE_MODEL, Constants.VENDOR_LICENSE_MODEL,
+ ArtifactTypeEnum.VENDOR_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
+ Constants.VENDOR_LICENSE_LABEL, Constants.VENDOR_LICENSE_DISPLAY_NAME,
+ Constants.VENDOR_LICENSE_DESCRIPTION, vendorLicenseModelId, artifactOperation, null, true, shouldLock,
+ inTransaction);
createOrUpdateSingleNonMetaArtifact(resource, csarInfo,
- CsarUtils.ARTIFACTS_PATH + Constants.VF_LICENSE_MODEL, Constants.VF_LICENSE_MODEL,
- ArtifactTypeEnum.VF_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, Constants.VF_LICENSE_LABEL,
- Constants.VF_LICENSE_DISPLAY_NAME, Constants.VF_LICENSE_DESCRIPTION, vfLicenseModelId,
- artifactOperation, null, true, shouldLock, inTransaction);
+ CsarUtils.ARTIFACTS_PATH + Constants.VF_LICENSE_MODEL, Constants.VF_LICENSE_MODEL,
+ ArtifactTypeEnum.VF_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, Constants.VF_LICENSE_LABEL,
+ Constants.VF_LICENSE_DISPLAY_NAME, Constants.VF_LICENSE_DESCRIPTION, vfLicenseModelId,
+ artifactOperation, null, true, shouldLock, inTransaction);
}
- protected Either<Resource, ResponseFormat> getResourceResponseFormatEither(Resource resource, CsarInfo csarInfo, List<ArtifactDefinition> createdArtifacts, ArtifactOperationInfo artifactOperation, boolean shouldLock, boolean inTransaction, Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus) {
+ protected Either<Resource, ResponseFormat> getResourceResponseFormatEither(Resource resource, CsarInfo csarInfo,
+ List<ArtifactDefinition> createdArtifacts,
+ ArtifactOperationInfo artifactOperation, boolean shouldLock,
+ boolean inTransaction,
+ Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus) {
try {
String artifactsFileName = artifacsMetaCsarStatus.left().value().getKey();
String artifactsContents = artifacsMetaCsarStatus.left().value().getValue();
@@ -497,22 +506,23 @@ public class ServiceImportBusinessLogic{
return Either.right(createArtifactsFromCsar.right().value());
}
return Either.left(createArtifactsFromCsar.left().value());
- }catch(Exception e) {
+ } catch (Exception e) {
log.debug("Exception occured in getResourceResponseFormatEither, message:{}", e.getMessage(), e);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
}
}
private <T extends Component> Either<T, ResponseFormat> createOrUpdateNonMetaArtifactsComp(CsarInfo csarInfo, T component,
- List<ArtifactDefinition> createdArtifacts, boolean shouldLock, boolean inTransaction,
- ArtifactOperationInfo artifactOperation) {
+ List<ArtifactDefinition> createdArtifacts,
+ boolean shouldLock, boolean inTransaction,
+ ArtifactOperationInfo artifactOperation) {
Either<T, ResponseFormat> resStatus = null;
Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
try {
Either<List<CsarUtils.NonMetaArtifactInfo>, String> artifactPathAndNameList = getValidArtifactNames(csarInfo, collectedWarningMessages);
if (artifactPathAndNameList.isRight()) {
return Either.right(getComponentsUtils().getResponseFormatByArtifactId(
- ActionStatus.ARTIFACT_NAME_INVALID, artifactPathAndNameList.right().value()));
+ ActionStatus.ARTIFACT_NAME_INVALID, artifactPathAndNameList.right().value()));
}
EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> vfCsarArtifactsToHandle = null;
@@ -521,7 +531,7 @@ public class ServiceImportBusinessLogic{
vfCsarArtifactsToHandle.put(artifactOperation.getArtifactOperationEnum(), artifactPathAndNameList.left().value());
} else {
Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandleRes = findVfCsarArtifactsToHandle(
- component, artifactPathAndNameList.left().value(), csarInfo.getModifier());
+ component, artifactPathAndNameList.left().value(), csarInfo.getModifier());
if (findVfCsarArtifactsToHandleRes.isRight()) {
resStatus = Either.right(findVfCsarArtifactsToHandleRes.right().value());
}
@@ -530,7 +540,8 @@ public class ServiceImportBusinessLogic{
}
}
if (resStatus == null && vfCsarArtifactsToHandle != null) {
- resStatus = processCsarArtifacts(csarInfo, component, createdArtifacts, shouldLock, inTransaction, resStatus, vfCsarArtifactsToHandle);
+ resStatus = processCsarArtifacts(csarInfo, component, createdArtifacts, shouldLock, inTransaction, resStatus,
+ vfCsarArtifactsToHandle);
}
if (resStatus == null) {
resStatus = Either.left(component);
@@ -545,27 +556,31 @@ public class ServiceImportBusinessLogic{
}
protected Either<Resource, ResponseFormat> createOrUpdateNonMetaArtifacts(CsarInfo csarInfo, Resource resource,
- List<ArtifactDefinition> createdArtifacts, boolean shouldLock, boolean inTransaction,
- ArtifactOperationInfo artifactOperation) {
+ List<ArtifactDefinition> createdArtifacts, boolean shouldLock,
+ boolean inTransaction,
+ ArtifactOperationInfo artifactOperation) {
return createOrUpdateNonMetaArtifactsComp(csarInfo, resource, createdArtifacts, shouldLock, inTransaction, artifactOperation);
}
- protected <T extends Component> Either<T, ResponseFormat> processCsarArtifacts(CsarInfo csarInfo, Component comp, List<ArtifactDefinition> createdArtifacts, boolean shouldLock, boolean inTransaction,
- Either<T, ResponseFormat> resStatus, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> vfCsarArtifactsToHandle) {
+ protected <T extends Component> Either<T, ResponseFormat> processCsarArtifacts(CsarInfo csarInfo, Component comp,
+ List<ArtifactDefinition> createdArtifacts, boolean shouldLock,
+ boolean inTransaction,
+ Either<T, ResponseFormat> resStatus,
+ EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> vfCsarArtifactsToHandle) {
for (Map.Entry<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> currArtifactOperationPair : vfCsarArtifactsToHandle
- .entrySet()) {
+ .entrySet()) {
Optional<ResponseFormat> optionalCreateInDBError =
- currArtifactOperationPair.getValue().stream()
- .map(e -> createOrUpdateSingleNonMetaArtifact(comp, csarInfo, e.getPath(),
- e.getArtifactName(), e.getArtifactType(),
- e.getArtifactGroupType(), e.getArtifactLabel(), e.getDisplayName(),
- CsarUtils.ARTIFACT_CREATED_FROM_CSAR, e.getArtifactUniqueId(),
- new ArtifactOperationInfo(false, false,
- currArtifactOperationPair.getKey()),
- createdArtifacts, e.isFromCsar(), shouldLock, inTransaction))
- .filter(Either::isRight).
- map(e -> e.right().value()).
- findAny();
+ currArtifactOperationPair.getValue().stream()
+ .map(e -> createOrUpdateSingleNonMetaArtifact(comp, csarInfo, e.getPath(),
+ e.getArtifactName(), e.getArtifactType(),
+ e.getArtifactGroupType(), e.getArtifactLabel(), e.getDisplayName(),
+ CsarUtils.ARTIFACT_CREATED_FROM_CSAR, e.getArtifactUniqueId(),
+ new ArtifactOperationInfo(false, false,
+ currArtifactOperationPair.getKey()),
+ createdArtifacts, e.isFromCsar(), shouldLock, inTransaction))
+ .filter(Either::isRight).
+ map(e -> e.right().value()).
+ findAny();
if (optionalCreateInDBError.isPresent()) {
resStatus = Either.right(optionalCreateInDBError.get());
break;
@@ -575,9 +590,13 @@ public class ServiceImportBusinessLogic{
}
protected Either<Boolean, ResponseFormat> createOrUpdateSingleNonMetaArtifact(Component component, CsarInfo csarInfo,
- String artifactPath, String artifactFileName, String artifactType, ArtifactGroupTypeEnum artifactGroupType,
- String artifactLabel, String artifactDisplayName, String artifactDescription, String artifactId,
- ArtifactOperationInfo operation, List<ArtifactDefinition> createdArtifacts, boolean isFromCsar, boolean shouldLock,
+ String artifactPath, String artifactFileName, String artifactType,
+ ArtifactGroupTypeEnum artifactGroupType,
+ String artifactLabel, String artifactDisplayName,
+ String artifactDescription, String artifactId,
+ ArtifactOperationInfo operation,
+ List<ArtifactDefinition> createdArtifacts, boolean isFromCsar,
+ boolean shouldLock,
boolean inTransaction) {
byte[] artifactFileBytes = null;
@@ -585,9 +604,11 @@ public class ServiceImportBusinessLogic{
artifactFileBytes = csarInfo.getCsar().get(artifactPath);
}
Either<Boolean, ResponseFormat> result = Either.left(true);
- if (operation.getArtifactOperationEnum() == ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE || operation.getArtifactOperationEnum() == ArtifactsBusinessLogic.ArtifactOperationEnum.DELETE) {
+ if (operation.getArtifactOperationEnum() == ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE
+ || operation.getArtifactOperationEnum() == ArtifactsBusinessLogic.ArtifactOperationEnum.DELETE) {
if (serviceImportParseLogic.isArtifactDeletionRequired(artifactId, artifactFileBytes, isFromCsar)) {
- Either<ArtifactDefinition, ResponseFormat> handleDelete = serviceBusinessLogic.artifactsBusinessLogic.handleDelete(component.getUniqueId(), artifactId, csarInfo.getModifier(), component,
+ Either<ArtifactDefinition, ResponseFormat> handleDelete = serviceBusinessLogic.artifactsBusinessLogic
+ .handleDelete(component.getUniqueId(), artifactId, csarInfo.getModifier(), component,
shouldLock, inTransaction);
if (handleDelete.isRight()) {
result = Either.right(handleDelete.right().value());
@@ -596,23 +617,24 @@ public class ServiceImportBusinessLogic{
}
if (org.apache.commons.lang.StringUtils.isEmpty(artifactId) && artifactFileBytes != null) {
operation = new ArtifactOperationInfo(false, false,
- ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE);
+ ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE);
}
}
if (artifactFileBytes != null) {
Map<String, Object> vendorLicenseModelJson = ArtifactUtils
- .buildJsonForUpdateArtifact(artifactId, artifactFileName,
- artifactType, artifactGroupType, artifactLabel, artifactDisplayName, artifactDescription,
- artifactFileBytes, null, isFromCsar);
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherNonMetaArtifacts = csarArtifactsAndGroupsBusinessLogic.createOrUpdateCsarArtifactFromJson(
+ .buildJsonForUpdateArtifact(artifactId, artifactFileName,
+ artifactType, artifactGroupType, artifactLabel, artifactDisplayName, artifactDescription,
+ artifactFileBytes, null, isFromCsar);
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherNonMetaArtifacts = csarArtifactsAndGroupsBusinessLogic
+ .createOrUpdateCsarArtifactFromJson(
component, csarInfo.getModifier(), vendorLicenseModelJson, operation);
serviceImportParseLogic
- .addNonMetaCreatedArtifactsToSupportRollback(operation, createdArtifacts, eitherNonMetaArtifacts);
+ .addNonMetaCreatedArtifactsToSupportRollback(operation, createdArtifacts, eitherNonMetaArtifacts);
if (eitherNonMetaArtifacts.isRight()) {
BeEcompErrorManager.getInstance()
- .logInternalFlowError("UploadLicenseArtifact", "Failed to upload license artifact: "
- + artifactFileName + "With csar uuid: " + csarInfo.getCsarUUID(),
- BeEcompErrorManager.ErrorSeverity.WARNING);
+ .logInternalFlowError("UploadLicenseArtifact", "Failed to upload license artifact: "
+ + artifactFileName + "With csar uuid: " + csarInfo.getCsarUUID(),
+ BeEcompErrorManager.ErrorSeverity.WARNING);
return Either.right(eitherNonMetaArtifacts.right().value());
}
}
@@ -621,7 +643,8 @@ public class ServiceImportBusinessLogic{
public Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifacts(Resource nodeTypeResource,
Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
- List<ArtifactDefinition> createdArtifacts, User user, boolean inTransaction, boolean ignoreLifecycleState) {
+ List<ArtifactDefinition> createdArtifacts, User user,
+ boolean inTransaction, boolean ignoreLifecycleState) {
List<ArtifactDefinition> handleNodeTypeArtifactsRequestRes;
Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes = null;
Either<Resource, ResponseFormat> changeStateResponse;
@@ -635,17 +658,17 @@ public class ServiceImportBusinessLogic{
List<ArtifactDefinition> handledNodeTypeArtifacts = new ArrayList<>();
log.debug("************* Going to handle artifacts of node type resource {}. ", nodeTypeResource.getName());
for (Map.Entry<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> curOperationEntry : nodeTypeArtifactsToHandle
- .entrySet()) {
+ .entrySet()) {
ArtifactsBusinessLogic.ArtifactOperationEnum curOperation = curOperationEntry.getKey();
List<ArtifactDefinition> curArtifactsToHandle = curOperationEntry.getValue();
if (curArtifactsToHandle != null && !curArtifactsToHandle.isEmpty()) {
log.debug("************* Going to {} artifact to vfc {}", curOperation.name(),
- nodeTypeResource.getName());
+ nodeTypeResource.getName());
handleNodeTypeArtifactsRequestRes = serviceBusinessLogic.artifactsBusinessLogic
- .handleArtifactsRequestForInnerVfcComponent(curArtifactsToHandle, nodeTypeResource, user,
- createdArtifacts, new ArtifactOperationInfo(false,
- ignoreLifecycleState, curOperation),
- false, inTransaction);
+ .handleArtifactsRequestForInnerVfcComponent(curArtifactsToHandle, nodeTypeResource, user,
+ createdArtifacts, new ArtifactOperationInfo(false,
+ ignoreLifecycleState, curOperation),
+ false, inTransaction);
if (ArtifactsBusinessLogic.ArtifactOperationEnum.isCreateOrLink(curOperation)) {
createdArtifacts.addAll(handleNodeTypeArtifactsRequestRes);
}
@@ -667,12 +690,12 @@ public class ServiceImportBusinessLogic{
Either<Resource, ResponseFormat> checkoutResourceRes;
try {
if (!resource.getComponentMetadataDefinition().getMetadataDataDefinition().getState()
- .equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name())) {
+ .equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name())) {
Either<? extends Component, ResponseFormat> checkoutRes = lifecycleBusinessLogic.changeComponentState(
- resource.getComponentType(), resource.getUniqueId(), user, LifeCycleTransitionEnum.CHECKOUT,
- new LifecycleChangeInfoWithAction(CERTIFICATION_ON_IMPORT,
- LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR),
- inTransaction, true);
+ resource.getComponentType(), resource.getUniqueId(), user, LifeCycleTransitionEnum.CHECKOUT,
+ new LifecycleChangeInfoWithAction(CERTIFICATION_ON_IMPORT,
+ LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR),
+ inTransaction, true);
if (checkoutRes.isRight()) {
checkoutResourceRes = Either.right(checkoutRes.right().value());
} else {
@@ -685,33 +708,30 @@ public class ServiceImportBusinessLogic{
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR);
checkoutResourceRes = Either.right(responseFormat);
log.debug("Exception occured when checkoutResource {} , error is:{}", resource.getName(), e.getMessage(),
- e);
+ e);
}
return checkoutResourceRes;
}
protected Either<Service, ResponseFormat> createOrUpdateArtifacts(
- ArtifactsBusinessLogic.ArtifactOperationEnum operation, List<ArtifactDefinition> createdArtifacts,
- String yamlFileName, CsarInfo csarInfo, Service preparedService,
- NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts, boolean inTransaction, boolean shouldLock) {
-
- Service resource = preparedService;
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = nodeTypeInfoToUpdateArtifacts
- .getNodeTypesArtifactsToHandle();
+ ArtifactOperationEnum operation, List<ArtifactDefinition> createdArtifacts,
+ String yamlFileName, CsarInfo csarInfo, Service preparedService,
+ NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts, boolean inTransaction, boolean shouldLock) {
Either<Service, ResponseFormat> createdCsarArtifactsEither = handleVfCsarArtifacts(preparedService, csarInfo, createdArtifacts,
- new ArtifactOperationInfo(false, false, operation), shouldLock, inTransaction);
+ new ArtifactOperationInfo(false, false, operation), shouldLock, inTransaction);
log.trace("************* Finished to add artifacts from yaml {}", yamlFileName);
if (createdCsarArtifactsEither.isRight()) {
return createdCsarArtifactsEither;
}
- resource = createdCsarArtifactsEither.left().value();
- return Either.left(resource);
+
+ return Either.left(createdCsarArtifactsEither.left().value());
}
protected Either<Service, ResponseFormat> handleVfCsarArtifacts(Service service, CsarInfo csarInfo,
- List<ArtifactDefinition> createdArtifacts, ArtifactOperationInfo artifactOperation, boolean shouldLock,
- boolean inTransaction) {
+ List<ArtifactDefinition> createdArtifacts,
+ ArtifactOperationInfo artifactOperation, boolean shouldLock,
+ boolean inTransaction) {
if (csarInfo.getCsar() != null) {
String vendorLicenseModelId = null;
@@ -730,40 +750,44 @@ public class ServiceImportBusinessLogic{
}
}
createOrUpdateSingleNonMetaArtifact(service, csarInfo,
- CsarUtils.ARTIFACTS_PATH + Constants.VENDOR_LICENSE_MODEL, Constants.VENDOR_LICENSE_MODEL,
- ArtifactTypeEnum.VENDOR_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
- Constants.VENDOR_LICENSE_LABEL, Constants.VENDOR_LICENSE_DISPLAY_NAME,
- Constants.VENDOR_LICENSE_DESCRIPTION, vendorLicenseModelId, artifactOperation, null, true, shouldLock,
- inTransaction);
+ CsarUtils.ARTIFACTS_PATH + Constants.VENDOR_LICENSE_MODEL, Constants.VENDOR_LICENSE_MODEL,
+ ArtifactTypeEnum.VENDOR_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
+ Constants.VENDOR_LICENSE_LABEL, Constants.VENDOR_LICENSE_DISPLAY_NAME,
+ Constants.VENDOR_LICENSE_DESCRIPTION, vendorLicenseModelId, artifactOperation, null, true, shouldLock,
+ inTransaction);
createOrUpdateSingleNonMetaArtifact(service, csarInfo,
- CsarUtils.ARTIFACTS_PATH + Constants.VF_LICENSE_MODEL, Constants.VF_LICENSE_MODEL,
- ArtifactTypeEnum.VF_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, Constants.VF_LICENSE_LABEL,
- Constants.VF_LICENSE_DISPLAY_NAME, Constants.VF_LICENSE_DESCRIPTION, vfLicenseModelId,
- artifactOperation, null, true, shouldLock, inTransaction);
+ CsarUtils.ARTIFACTS_PATH + Constants.VF_LICENSE_MODEL, Constants.VF_LICENSE_MODEL,
+ ArtifactTypeEnum.VF_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, Constants.VF_LICENSE_LABEL,
+ Constants.VF_LICENSE_DISPLAY_NAME, Constants.VF_LICENSE_DESCRIPTION, vfLicenseModelId,
+ artifactOperation, null, true, shouldLock, inTransaction);
Either<Service, ResponseFormat> eitherCreateResult = createOrUpdateNonMetaArtifacts(csarInfo, service,
- createdArtifacts, shouldLock, inTransaction, artifactOperation);
+ createdArtifacts, shouldLock, inTransaction, artifactOperation);
if (eitherCreateResult.isRight()) {
return Either.right(eitherCreateResult.right().value());
}
Either<Service, StorageOperationStatus> eitherGerResource = toscaOperationFacade
- .getToscaElement(service.getUniqueId());
+ .getToscaElement(service.getUniqueId());
if (eitherGerResource.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByComponent(
- componentsUtils.convertFromStorageResponse(eitherGerResource.right().value()), service, ComponentTypeEnum.SERVICE);
+ componentsUtils.convertFromStorageResponse(eitherGerResource.right().value()), service, ComponentTypeEnum.SERVICE);
return Either.right(responseFormat);
}
service = eitherGerResource.left().value();
- Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus = CsarValidationUtils.getArtifactsMeta(csarInfo.getCsar(), csarInfo.getCsarUUID(), componentsUtils);
+ Either<ImmutablePair<String, String>, ResponseFormat> artifacsMetaCsarStatus = CsarValidationUtils
+ .getArtifactsMeta(csarInfo.getCsar(), csarInfo.getCsarUUID(), componentsUtils);
if (artifacsMetaCsarStatus.isLeft()) {
String artifactsFileName = artifacsMetaCsarStatus.left().value().getKey();
String artifactsContents = artifacsMetaCsarStatus.left().value().getValue();
Either<Service, ResponseFormat> createArtifactsFromCsar;
if (ArtifactsBusinessLogic.ArtifactOperationEnum.isCreateOrLink(artifactOperation.getArtifactOperationEnum())) {
- createArtifactsFromCsar = csarArtifactsAndGroupsBusinessLogic.createResourceArtifactsFromCsar(csarInfo, service, artifactsContents, artifactsFileName, createdArtifacts);
+ createArtifactsFromCsar = csarArtifactsAndGroupsBusinessLogic
+ .createResourceArtifactsFromCsar(csarInfo, service, artifactsContents, artifactsFileName, createdArtifacts);
} else {
- Either<Component, ResponseFormat> result = csarArtifactsAndGroupsBusinessLogic.updateResourceArtifactsFromCsar(csarInfo, service, artifactsContents, artifactsFileName, createdArtifacts, shouldLock, inTransaction);
+ Either<Component, ResponseFormat> result = csarArtifactsAndGroupsBusinessLogic
+ .updateResourceArtifactsFromCsar(csarInfo, service, artifactsContents, artifactsFileName, createdArtifacts, shouldLock,
+ inTransaction);
if ((result.left().value() instanceof Service) && result.isLeft()) {
Service service1 = (Service) result.left().value();
createArtifactsFromCsar = Either.left(service1);
@@ -784,13 +808,14 @@ public class ServiceImportBusinessLogic{
}
protected Either<Service, ResponseFormat> createOrUpdateNonMetaArtifacts(CsarInfo csarInfo, Service resource,
- List<ArtifactDefinition> createdArtifacts, boolean shouldLock, boolean inTransaction,
- ArtifactOperationInfo artifactOperation) {
+ List<ArtifactDefinition> createdArtifacts, boolean shouldLock,
+ boolean inTransaction,
+ ArtifactOperationInfo artifactOperation) {
return createOrUpdateNonMetaArtifactsComp(csarInfo, resource, createdArtifacts, shouldLock, inTransaction, artifactOperation);
}
protected Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandle(
- Component component, List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList, User user) {
+ Component component, List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList, User user) {
List<ArtifactDefinition> existingArtifacts = new ArrayList<>();
if (component.getDeploymentArtifacts() != null && !component.getDeploymentArtifacts().isEmpty()) {
existingArtifacts.addAll(component.getDeploymentArtifacts().values());
@@ -809,7 +834,7 @@ public class ServiceImportBusinessLogic{
});
}
existingArtifacts = existingArtifacts.stream()
- .filter(a -> !artifactsToIgnore.contains(a.getUniqueId())).collect(toList());
+ .filter(a -> !artifactsToIgnore.contains(a.getUniqueId())).collect(toList());
return organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, existingArtifacts, component, user);
}
@@ -824,20 +849,21 @@ public class ServiceImportBusinessLogic{
private boolean isValidArtifactType(ArtifactDefinition artifact) {
boolean result = true;
if (artifact.getArtifactType() == null
- || ArtifactTypeEnum.findType(artifact.getArtifactType()).equals(ArtifactTypeEnum.VENDOR_LICENSE)
- || ArtifactTypeEnum.findType(artifact.getArtifactType()).equals(ArtifactTypeEnum.VF_LICENSE)) {
+ || ArtifactTypeEnum.findType(artifact.getArtifactType()).equals(ArtifactTypeEnum.VENDOR_LICENSE)
+ || ArtifactTypeEnum.findType(artifact.getArtifactType()).equals(ArtifactTypeEnum.VF_LICENSE)) {
result = false;
}
return result;
}
+
protected Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat> organizeVfCsarArtifactsByArtifactOperation(
- List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList, List<ArtifactDefinition> existingArtifactsToHandle,
- Component component, User user) {
+ List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList, List<ArtifactDefinition> existingArtifactsToHandle,
+ Component component, User user) {
EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> nodeTypeArtifactsToHandle = new EnumMap<>(
- ArtifactsBusinessLogic.ArtifactOperationEnum.class);
+ ArtifactsBusinessLogic.ArtifactOperationEnum.class);
Wrapper<ResponseFormat> responseWrapper = new Wrapper<>();
Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat> nodeTypeArtifactsToHandleRes = Either
- .left(nodeTypeArtifactsToHandle);
+ .left(nodeTypeArtifactsToHandle);
try {
List<CsarUtils.NonMetaArtifactInfo> artifactsToUpload = new ArrayList<>(artifactPathAndNameList);
List<CsarUtils.NonMetaArtifactInfo> artifactsToUpdate = new ArrayList<>();
@@ -847,11 +873,11 @@ public class ServiceImportBusinessLogic{
if (!existingArtifactsToHandle.isEmpty()) {
foundArtifact = existingArtifactsToHandle.stream()
- .filter(a -> a.getArtifactName().equals(currNewArtifact.getArtifactName())).findFirst()
- .orElse(null);
+ .filter(a -> a.getArtifactName().equals(currNewArtifact.getArtifactName())).findFirst()
+ .orElse(null);
if (foundArtifact != null) {
if (ArtifactTypeEnum.findType(foundArtifact.getArtifactType()).equals(currNewArtifact
- .getArtifactType())) {
+ .getArtifactType())) {
if (!foundArtifact.getArtifactChecksum().equals(currNewArtifact.getArtifactChecksum())) {
currNewArtifact.setArtifactUniqueId(foundArtifact.getUniqueId());
artifactsToUpdate.add(currNewArtifact);
@@ -860,17 +886,17 @@ public class ServiceImportBusinessLogic{
artifactsToUpload.remove(currNewArtifact);
} else {
log.debug("Can't upload two artifact with the same name {}.",
- currNewArtifact.getArtifactName());
+ currNewArtifact.getArtifactName());
ResponseFormat responseFormat = ResponseFormatManager.getInstance().getResponseFormat(
- ActionStatus.ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR,
- currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType(),
- foundArtifact.getArtifactType());
+ ActionStatus.ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR,
+ currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType(),
+ foundArtifact.getArtifactType());
AuditingActionEnum auditingAction = serviceBusinessLogic.artifactsBusinessLogic
- .detectAuditingType(new ArtifactOperationInfo(false, false,
- ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE), foundArtifact.getArtifactChecksum());
+ .detectAuditingType(new ArtifactOperationInfo(false, false,
+ ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE), foundArtifact.getArtifactChecksum());
serviceBusinessLogic.artifactsBusinessLogic.handleAuditing(auditingAction, component, component.getUniqueId(),
- user, null, null, foundArtifact.getUniqueId(), responseFormat,
- component.getComponentType(), null);
+ user, null, null, foundArtifact.getUniqueId(), responseFormat,
+ component.getComponentType(), null);
responseWrapper.setInnerElement(responseFormat);
break;
}
@@ -880,9 +906,13 @@ public class ServiceImportBusinessLogic{
if (responseWrapper.isEmpty()) {
for (ArtifactDefinition currArtifact : existingArtifactsToHandle) {
if (currArtifact.getIsFromCsar()) {
- artifactsToDelete.add(new CsarUtils.NonMetaArtifactInfo(currArtifact.getArtifactName(), null, ArtifactTypeEnum.findType(currArtifact.getArtifactType()), currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), currArtifact.getIsFromCsar()));
+ artifactsToDelete.add(new CsarUtils.NonMetaArtifactInfo(currArtifact.getArtifactName(), null,
+ ArtifactTypeEnum.findType(currArtifact.getArtifactType()), currArtifact.getArtifactGroupType(), null,
+ currArtifact.getUniqueId(), currArtifact.getIsFromCsar()));
} else {
- artifactsToUpdate.add(new CsarUtils.NonMetaArtifactInfo(currArtifact.getArtifactName(), null, ArtifactTypeEnum.findType(currArtifact.getArtifactType()), currArtifact.getArtifactGroupType(), null, currArtifact.getUniqueId(), currArtifact.getIsFromCsar()));
+ artifactsToUpdate.add(new CsarUtils.NonMetaArtifactInfo(currArtifact.getArtifactName(), null,
+ ArtifactTypeEnum.findType(currArtifact.getArtifactType()), currArtifact.getArtifactGroupType(), null,
+ currArtifact.getUniqueId(), currArtifact.getIsFromCsar()));
}
}
}
@@ -918,16 +948,17 @@ public class ServiceImportBusinessLogic{
this.componentsUtils = componentsUtils;
}
- protected Either<List<CsarUtils.NonMetaArtifactInfo>, String> getValidArtifactNames(CsarInfo csarInfo, Map<String, Set<List<String>>> collectedWarningMessages) {
+ protected Either<List<CsarUtils.NonMetaArtifactInfo>, String> getValidArtifactNames(CsarInfo csarInfo,
+ Map<String, Set<List<String>>> collectedWarningMessages) {
List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList =
- csarInfo.getCsar().entrySet().stream()
- .filter(e -> Pattern.compile(VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN).matcher(e.getKey())
- .matches())
- .map(e -> CsarUtils.validateNonMetaArtifact(e.getKey(), e.getValue(),
- collectedWarningMessages))
- .filter(Either::isLeft)
- .map(e -> e.left().value())
- .collect(toList());
+ csarInfo.getCsar().entrySet().stream()
+ .filter(e -> Pattern.compile(VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN).matcher(e.getKey())
+ .matches())
+ .map(e -> CsarUtils.validateNonMetaArtifact(e.getKey(), e.getValue(),
+ collectedWarningMessages))
+ .filter(Either::isLeft)
+ .map(e -> e.left().value())
+ .collect(toList());
Pattern englishNumbersAndUnderScoresOnly = Pattern.compile(CsarUtils.VALID_ENGLISH_ARTIFACT_NAME);
for (CsarUtils.NonMetaArtifactInfo nonMetaArtifactInfo : artifactPathAndNameList) {
if (!englishNumbersAndUnderScoresOnly.matcher(nonMetaArtifactInfo.getDisplayName()).matches()) {
@@ -938,13 +969,13 @@ public class ServiceImportBusinessLogic{
}
protected Either<Service, ResponseFormat> createGroupsOnResource(Service service,
- Map<String, GroupDefinition> groups) {
+ Map<String, GroupDefinition> groups) {
if (groups != null && !groups.isEmpty()) {
List<GroupDefinition> groupsAsList = updateGroupsMembersUsingResource(groups, service);
serviceImportParseLogic.handleGroupsProperties(service, groups);
serviceImportParseLogic.fillGroupsFinalFields(groupsAsList);
Either<List<GroupDefinition>, ResponseFormat> createGroups = serviceBusinessLogic.groupBusinessLogic.createGroups(service,
- groupsAsList, true);
+ groupsAsList, true);
if (createGroups.isRight()) {
return Either.right(createGroups.right().value());
}
@@ -952,10 +983,10 @@ public class ServiceImportBusinessLogic{
return Either.left(service);
}
Either<Service, StorageOperationStatus> updatedResource = toscaOperationFacade
- .getToscaElement(service.getUniqueId());
+ .getToscaElement(service.getUniqueId());
if (updatedResource.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByComponent(
- componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, ComponentTypeEnum.SERVICE);
+ componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, ComponentTypeEnum.SERVICE);
return Either.right(responseFormat);
}
return Either.left(updatedResource.left().value());
@@ -977,7 +1008,7 @@ public class ServiceImportBusinessLogic{
Map<String, String> members = groupDefinition.getMembers();
if (members != null) {
serviceImportParseLogic
- .updateGroupMembers(groups, updatedGroupDefinition, component, componentInstances, groupName, members);
+ .updateGroupMembers(groups, updatedGroupDefinition, component, componentInstances, groupName, members);
}
result.add(updatedGroupDefinition);
}
@@ -987,18 +1018,18 @@ public class ServiceImportBusinessLogic{
protected Resource createRIAndRelationsFromYaml(String yamlName, Resource resource,
- Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap,
- String topologyTemplateYaml, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
- Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
- String nodeName) {
+ Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap,
+ String topologyTemplateYaml, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
+ String nodeName) {
try {
log.debug("************* Going to create all nodes {}", yamlName);
handleNodeTypes(yamlName, resource, topologyTemplateYaml, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts,
- nodeTypesInfo, csarInfo, nodeName);
+ nodeTypesInfo, csarInfo, nodeName);
log.debug("************* Going to create all resource instances {}", yamlName);
resource = createResourceInstances(yamlName, resource,
- uploadComponentInstanceInfoMap, csarInfo.getCreatedNodes());
+ uploadComponentInstanceInfoMap, csarInfo.getCreatedNodes());
log.debug("************* Finished to create all resource instances {}", yamlName);
resource = createResourceInstancesRelations(csarInfo.getModifier(), yamlName, resource, uploadComponentInstanceInfoMap);
log.debug("************* Going to create positions {}", yamlName);
@@ -1011,13 +1042,16 @@ public class ServiceImportBusinessLogic{
}
protected Resource createResourceInstancesRelations(User user, String yamlName, Resource resource,
- Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
log.debug("#createResourceInstancesRelations - Going to create relations ");
List<ComponentInstance> componentInstancesList = resource.getComponentInstances();
if (((MapUtils.isEmpty(uploadResInstancesMap) || CollectionUtils.isEmpty(componentInstancesList)) &&
- resource.getResourceType() != ResourceTypeEnum.PNF)) { // PNF can have no resource instances
- log.debug("#createResourceInstancesRelations - No instances found in the resource {} is empty, yaml template file name {}, ", resource.getUniqueId(), yamlName);
- BeEcompErrorManager.getInstance().logInternalDataError("createResourceInstancesRelations", "No instances found in a resource or nn yaml template. ", BeEcompErrorManager.ErrorSeverity.ERROR);
+ resource.getResourceType() != ResourceTypeEnum.PNF)) { // PNF can have no resource instances
+ log.debug("#createResourceInstancesRelations - No instances found in the resource {} is empty, yaml template file name {}, ",
+ resource.getUniqueId(), yamlName);
+ BeEcompErrorManager.getInstance()
+ .logInternalDataError("createResourceInstancesRelations", "No instances found in a resource or nn yaml template. ",
+ BeEcompErrorManager.ErrorSeverity.ERROR);
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName));
}
Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
@@ -1025,7 +1059,7 @@ public class ServiceImportBusinessLogic{
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
- Map<String, List<AttributeDataDefinition>> instAttributes = new HashMap<>();
+ Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -1035,27 +1069,27 @@ public class ServiceImportBusinessLogic{
if (allDataTypes.isRight()) {
JanusGraphOperationStatus status = allDataTypes.right().value();
BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
- "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
+ "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
throw new ComponentException(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(
- DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)), yamlName));
+ DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)), yamlName));
}
Resource finalResource = resource;
uploadResInstancesMap
- .values()
- .forEach(i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes,
- instProperties, instCapabilities, instRequirements, instDeploymentArtifacts,
- instArtifacts, instAttributes, originCompMap, instInputs, i));
+ .values()
+ .forEach(i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes,
+ instProperties, instCapabilities, instRequirements, instDeploymentArtifacts,
+ instArtifacts, instAttributes, originCompMap, instInputs, i));
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties);
serviceImportParseLogic.associateComponentInstanceInputsToComponent(yamlName, resource, instInputs);
serviceImportParseLogic
- .associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts);
+ .associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts);
serviceImportParseLogic.associateArtifactsToInstances(yamlName, resource, instArtifacts);
serviceImportParseLogic.associateOrAddCalculatedCapReq(yamlName, resource, instCapabilities, instRequirements);
serviceImportParseLogic.associateInstAttributeToComponentToInstances(yamlName, resource, instAttributes);
resource = serviceImportParseLogic.getResourceAfterCreateRelations(resource);
serviceImportParseLogic
- .addRelationsToRI(yamlName, resource, uploadResInstancesMap, componentInstancesList, relations);
+ .addRelationsToRI(yamlName, resource, uploadResInstancesMap, componentInstancesList, relations);
serviceImportParseLogic.associateResourceInstances(yamlName, resource, relations);
handleSubstitutionMappings(resource, uploadResInstancesMap);
log.debug("************* in create relations, getResource start");
@@ -1063,22 +1097,26 @@ public class ServiceImportBusinessLogic{
log.debug("************* in create relations, getResource end");
if (eitherGetResource.isRight()) {
throw new ComponentException(componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource));
+ componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource));
}
return eitherGetResource.left().value();
}
- protected void processProperty(Resource resource, ComponentInstance currentCompInstance, Map<String, DataTypeDefinition> allDataTypes, Map<String, InputDefinition> currPropertiesMap, List<ComponentInstanceInput> instPropList, List<UploadPropInfo> propertyList) {
+ protected void processProperty(Resource resource, ComponentInstance currentCompInstance, Map<String, DataTypeDefinition> allDataTypes,
+ Map<String, InputDefinition> currPropertiesMap, List<ComponentInstanceInput> instPropList,
+ List<UploadPropInfo> propertyList) {
UploadPropInfo propertyInfo = propertyList.get(0);
String propName = propertyInfo.getName();
if (!currPropertiesMap.containsKey(propName)) {
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND,
- propName));
+ propName));
}
processProperty(allDataTypes, currPropertiesMap, instPropList, propertyInfo, propName, resource.getInputs());
}
- private void processProperty(Map<String, DataTypeDefinition> allDataTypes, Map<String, InputDefinition> currPropertiesMap, List<ComponentInstanceInput> instPropList, UploadPropInfo propertyInfo, String propName, List<InputDefinition> inputs2) {
+ private void processProperty(Map<String, DataTypeDefinition> allDataTypes, Map<String, InputDefinition> currPropertiesMap,
+ List<ComponentInstanceInput> instPropList, UploadPropInfo propertyInfo, String propName,
+ List<InputDefinition> inputs2) {
InputDefinition curPropertyDef = currPropertiesMap.get(propName);
ComponentInstanceInput property = null;
@@ -1090,10 +1128,10 @@ public class ServiceImportBusinessLogic{
isValidate = getInputs == null || getInputs.isEmpty();
if (isValidate) {
value = getPropertyJsonStringValue(propertyInfo.getValue(),
- curPropertyDef.getType());
+ curPropertyDef.getType());
} else {
value = getPropertyJsonStringValue(propertyInfo.getValue(),
- TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName());
+ TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName());
}
}
property = new ComponentInstanceInput(curPropertyDef, value, null);
@@ -1109,7 +1147,7 @@ public class ServiceImportBusinessLogic{
}
Optional<InputDefinition> optional = inputs.stream()
- .filter(p -> p.getName().equals(getInput.getInputName())).findAny();
+ .filter(p -> p.getName().equals(getInput.getInputName())).findAny();
if (!optional.isPresent()) {
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
}
@@ -1131,22 +1169,22 @@ public class ServiceImportBusinessLogic{
Either<Resource, StorageOperationStatus> getResourceRes = toscaOperationFacade.getToscaFullElement(resource.getUniqueId());
if (getResourceRes.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), resource);
+ componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), resource);
throw new ComponentException(responseFormat);
}
getResourceRes = updateCalculatedCapReqWithSubstitutionMappings(getResourceRes.left().value(),
- uploadResInstancesMap);
+ uploadResInstancesMap);
if (getResourceRes.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), resource);
+ componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), resource);
throw new ComponentException(responseFormat);
}
}
}
protected Resource createResourceInstances(String yamlName, Resource resource,
- Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
- Map<String, Resource> nodeNamespaceMap) {
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
+ Map<String, Resource> nodeNamespaceMap) {
Either<Resource, ResponseFormat> eitherResource = null;
log.debug("createResourceInstances is {} - going to create resource instanse from CSAR", yamlName);
if (MapUtils.isEmpty(uploadResInstancesMap) && resource.getResourceType() != ResourceTypeEnum.PNF) { // PNF can have no resource instances
@@ -1159,18 +1197,18 @@ public class ServiceImportBusinessLogic{
}
Map<ComponentInstance, Resource> resourcesInstancesMap = new HashMap<>();
uploadResInstancesMap
- .values()
- .forEach(i -> createAndAddResourceInstance(i, yamlName, resource, nodeNamespaceMap, existingNodeTypeMap, resourcesInstancesMap));
+ .values()
+ .forEach(i -> createAndAddResourceInstance(i, yamlName, resource, nodeNamespaceMap, existingNodeTypeMap, resourcesInstancesMap));
if (MapUtils.isNotEmpty(resourcesInstancesMap)) {
try {
toscaOperationFacade.associateComponentInstancesToComponent(resource,
- resourcesInstancesMap, false, false);
+ resourcesInstancesMap, false, false);
} catch (StorageException exp) {
if (exp.getStorageOperationStatus() != null && exp.getStorageOperationStatus() != StorageOperationStatus.OK) {
log.debug("Failed to add component instances to container component {}", resource.getName());
ResponseFormat responseFormat = componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(exp.getStorageOperationStatus()));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(exp.getStorageOperationStatus()));
eitherResource = Either.right(responseFormat);
throw new ByResponseFormatComponentException(eitherResource.right().value());
}
@@ -1178,181 +1216,190 @@ public class ServiceImportBusinessLogic{
}
log.debug("*************Going to get resource {}", resource.getUniqueId());
Either<Resource, StorageOperationStatus> eitherGetResource = toscaOperationFacade
- .getToscaElement(resource.getUniqueId(), serviceImportParseLogic.getComponentWithInstancesFilter());
+ .getToscaElement(resource.getUniqueId(), serviceImportParseLogic.getComponentWithInstancesFilter());
log.debug("*************finished to get resource {}", resource.getUniqueId());
if (eitherGetResource.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource);
+ componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource);
throw new ComponentException(responseFormat);
}
if (CollectionUtils.isEmpty(eitherGetResource.left().value().getComponentInstances()) &&
- resource.getResourceType() != ResourceTypeEnum.PNF) { // PNF can have no resource instances
+ resource.getResourceType() != ResourceTypeEnum.PNF) { // PNF can have no resource instances
log.debug("Error when create resource instance from csar. ComponentInstances list empty");
BeEcompErrorManager.getInstance().logBeDaoSystemError(
- "Error when create resource instance from csar. ComponentInstances list empty");
+ "Error when create resource instance from csar. ComponentInstances list empty");
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE));
}
return eitherGetResource.left().value();
}
protected void handleNodeTypes(String yamlName, Resource resource,
- String topologyTemplateYaml, boolean needLock,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo,
- CsarInfo csarInfo, String nodeName) {
+ String topologyTemplateYaml, boolean needLock,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo,
+ CsarInfo csarInfo, String nodeName) {
try {
for (Map.Entry<String, NodeTypeInfo> nodeTypeEntry : nodeTypesInfo.entrySet()) {
if (nodeTypeEntry.getValue().isNested()) {
handleNestedVfc(resource, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts,
- nodeTypesInfo, csarInfo, nodeTypeEntry.getKey());
+ nodeTypesInfo, csarInfo, nodeTypeEntry.getKey());
log.trace("************* finished to create node {}", nodeTypeEntry.getKey());
}
}
Map<String, Object> mappedToscaTemplate = null;
if (org.apache.commons.lang.StringUtils.isNotEmpty(nodeName) && MapUtils.isNotEmpty(nodeTypesInfo)
- && nodeTypesInfo.containsKey(nodeName)) {
+ && nodeTypesInfo.containsKey(nodeName)) {
mappedToscaTemplate = nodeTypesInfo.get(nodeName).getMappedToscaTemplate();
}
if (MapUtils.isEmpty(mappedToscaTemplate)) {
mappedToscaTemplate = (Map<String, Object>) new Yaml().load(topologyTemplateYaml);
}
createResourcesFromYamlNodeTypesList(yamlName, resource, mappedToscaTemplate, needLock, nodeTypesArtifactsToHandle,
- nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo);
+ nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo);
} catch (ComponentException e) {
ResponseFormat responseFormat = e.getResponseFormat() != null ? e.getResponseFormat()
- : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
+ : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams());
componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.IMPORT_RESOURCE);
throw e;
} catch (StorageException e) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(e.getStorageOperationStatus()));
+ ResponseFormat responseFormat = componentsUtils
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(e.getStorageOperationStatus()));
componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.IMPORT_RESOURCE);
throw e;
- }catch (Exception e){
+ } catch (Exception e) {
log.debug("Exception occured when handleNodeTypes, error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
}
- protected Resource handleNestedVfc(Service service, Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
+ protected Resource handleNestedVfc(Service service,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
String nodeName) {
try {
String yamlName = nodesInfo.get(nodeName).getTemplateFileName();
Map<String, Object> nestedVfcJsonMap = nodesInfo.get(nodeName).getMappedToscaTemplate();
createResourcesFromYamlNodeTypesList(yamlName, service, nestedVfcJsonMap, false,
- nodesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo);
+ nodesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo);
log.debug("************* Finished to create node types from yaml {}", yamlName);
if (nestedVfcJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.TOPOLOGY_TEMPLATE.getElementName())) {
log.debug("************* Going to handle complex VFC from yaml {}", yamlName);
- Resource resource = handleComplexVfc(nodesArtifactsToHandle, createdArtifacts, nodesInfo,
- csarInfo, nodeName, yamlName);
- return resource;
+ return handleComplexVfc(nodesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName, yamlName);
}
return new Resource();
- } catch (Exception e) {
+ } catch (Exception e) {
log.debug("Exception occured when handleNestedVFc, error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
}
- protected Resource handleNestedVfc(Resource resource, Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
- List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
- String nodeName) {
+ protected Resource handleNestedVfc(Resource resource,
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
+ List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
+ String nodeName) {
String yamlName = nodesInfo.get(nodeName).getTemplateFileName();
Map<String, Object> nestedVfcJsonMap = nodesInfo.get(nodeName).getMappedToscaTemplate();
log.debug("************* Going to create node types from yaml {}", yamlName);
createResourcesFromYamlNodeTypesList(yamlName, resource, nestedVfcJsonMap, false,
- nodesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo);
+ nodesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo);
if (nestedVfcJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.TOPOLOGY_TEMPLATE.getElementName())) {
log.debug("************* Going to handle complex VFC from yaml {}", yamlName);
resource = handleComplexVfc(resource, nodesArtifactsToHandle, createdArtifacts, nodesInfo,
- csarInfo, nodeName, yamlName);
+ csarInfo, nodeName, yamlName);
}
return resource;
}
- protected Resource handleComplexVfc(Resource resource, Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
- List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
- String nodeName, String yamlName) {
+ protected Resource handleComplexVfc(Resource resource,
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
+ List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
+ String nodeName, String yamlName) {
Resource oldComplexVfc = null;
Resource newComplexVfc = serviceImportParseLogic.buildValidComplexVfc(resource, csarInfo, nodeName, nodesInfo);
Either<Resource, StorageOperationStatus> oldComplexVfcRes = toscaOperationFacade
- .getFullLatestComponentByToscaResourceName(newComplexVfc.getToscaResourceName());
+ .getFullLatestComponentByToscaResourceName(newComplexVfc.getToscaResourceName());
if (oldComplexVfcRes.isRight() && oldComplexVfcRes.right().value() == StorageOperationStatus.NOT_FOUND) {
oldComplexVfcRes = toscaOperationFacade.getFullLatestComponentByToscaResourceName(
- serviceImportParseLogic.buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(),
- nodeName).getRight());
+ serviceImportParseLogic.buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(),
+ nodeName).getRight());
}
if (oldComplexVfcRes.isRight() && oldComplexVfcRes.right().value() != StorageOperationStatus.NOT_FOUND) {
throw new ComponentException(ActionStatus.GENERAL_ERROR);
} else if (oldComplexVfcRes.isLeft()) {
log.debug(VALIDATE_DERIVED_BEFORE_UPDATE);
Either<Boolean, ResponseFormat> eitherValidation = serviceImportParseLogic.validateNestedDerivedFromDuringUpdate(
- oldComplexVfcRes.left().value(), newComplexVfc,
- ValidationUtils.hasBeenCertified(oldComplexVfcRes.left().value().getVersion()));
+ oldComplexVfcRes.left().value(), newComplexVfc,
+ ValidationUtils.hasBeenCertified(oldComplexVfcRes.left().value().getVersion()));
if (eitherValidation.isLeft()) {
oldComplexVfc = oldComplexVfcRes.left().value();
}
}
newComplexVfc = handleComplexVfc(nodesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName, yamlName,
- oldComplexVfc, newComplexVfc);
+ oldComplexVfc, newComplexVfc);
csarInfo.getCreatedNodesToscaResourceNames().put(nodeName, newComplexVfc.getToscaResourceName());
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction(
- CERTIFICATION_ON_IMPORT, LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR);
+ CERTIFICATION_ON_IMPORT, LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR);
log.debug("Going to certify cvfc {}. ", newComplexVfc.getName());
final Resource result = serviceImportParseLogic
- .propagateStateToCertified(csarInfo.getModifier(), newComplexVfc, lifecycleChangeInfo, true, false,
- true);
+ .propagateStateToCertified(csarInfo.getModifier(), newComplexVfc, lifecycleChangeInfo, true, false,
+ true);
csarInfo.getCreatedNodes().put(nodeName, result);
csarInfo.removeNodeFromQueue();
return result;
}
- public Map<String, Resource> createResourcesFromYamlNodeTypesList(String yamlName, Resource resource, Map<String, Object> mappedToscaTemplate, boolean needLock,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo,
+ public Map<String, Resource> createResourcesFromYamlNodeTypesList(String yamlName, Resource resource, Map<String, Object> mappedToscaTemplate,
+ boolean needLock,
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ Map<String, NodeTypeInfo> nodeTypesInfo,
CsarInfo csarInfo) {
Either<String, ImportUtils.ResultStatusEnum> toscaVersion = findFirstToscaStringElement(mappedToscaTemplate,
- TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
+ TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
if (toscaVersion.isRight()) {
throw new ComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE);
}
Map<String, Object> mapToConvert = new HashMap<>();
mapToConvert.put(TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION.getElementName(), toscaVersion.left().value());
Map<String, Object> nodeTypes = serviceImportParseLogic.getNodeTypesFromTemplate(mappedToscaTemplate);
- createNodeTypes(yamlName, resource, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, mapToConvert, nodeTypes);
+ createNodeTypes(yamlName, resource, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, mapToConvert,
+ nodeTypes);
return csarInfo.getCreatedNodes();
}
- protected void createNodeTypes(String yamlName, Resource resource, boolean needLock, Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo, Map<String, Object> mapToConvert, Map<String, Object> nodeTypes) {
+ protected void createNodeTypes(String yamlName, Resource resource, boolean needLock,
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
+ Map<String, Object> mapToConvert, Map<String, Object> nodeTypes) {
Iterator<Map.Entry<String, Object>> nodesNameValueIter = nodeTypes.entrySet().iterator();
Resource vfcCreated = null;
while (nodesNameValueIter.hasNext()) {
Map.Entry<String, Object> nodeType = nodesNameValueIter.next();
Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle = nodeTypesArtifactsToHandle == null
- || nodeTypesArtifactsToHandle.isEmpty() ? null
- : nodeTypesArtifactsToHandle.get(nodeType.getKey());
+ || nodeTypesArtifactsToHandle.isEmpty() ? null
+ : nodeTypesArtifactsToHandle.get(nodeType.getKey());
if (nodeTypesInfo.containsKey(nodeType.getKey())) {
log.trace("************* Going to handle nested vfc {}", nodeType.getKey());
vfcCreated = handleNestedVfc(resource,
- nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
- nodeType.getKey());
+ nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
+ nodeType.getKey());
log.trace("************* Finished to handle nested vfc {}", nodeType.getKey());
} else if (csarInfo.getCreatedNodesToscaResourceNames() != null
- && !csarInfo.getCreatedNodesToscaResourceNames().containsKey(nodeType.getKey())) {
+ && !csarInfo.getCreatedNodesToscaResourceNames().containsKey(nodeType.getKey())) {
log.trace("************* Going to create node {}", nodeType.getKey());
- ImmutablePair<Resource, ActionStatus> resourceCreated = createNodeTypeResourceFromYaml(yamlName, nodeType, csarInfo.getModifier(), mapToConvert,
- resource, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, true,
- csarInfo, true);
+ ImmutablePair<Resource, ActionStatus> resourceCreated = createNodeTypeResourceFromYaml(yamlName, nodeType, csarInfo.getModifier(),
+ mapToConvert,
+ resource, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, true,
+ csarInfo, true);
log.debug("************* Finished to create node {}", nodeType.getKey());
vfcCreated = resourceCreated.getLeft();
csarInfo.getCreatedNodesToscaResourceNames().put(nodeType.getKey(),
- vfcCreated.getToscaResourceName());
+ vfcCreated.getToscaResourceName());
}
if (vfcCreated != null) {
csarInfo.getCreatedNodes().put(nodeType.getKey(), vfcCreated);
@@ -1362,30 +1409,31 @@ public class ServiceImportBusinessLogic{
}
protected ImmutablePair<Resource, ActionStatus> createNodeTypeResourceFromYaml(
- String yamlName, Map.Entry<String, Object> nodeNameValue, User user, Map<String, Object> mapToConvert,
- Resource resourceVf, boolean needLock,
- Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed, CsarInfo csarInfo,
- boolean isNested) {
+ String yamlName, Map.Entry<String, Object> nodeNameValue, User user, Map<String, Object> mapToConvert,
+ Resource resourceVf, boolean needLock,
+ Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed, CsarInfo csarInfo,
+ boolean isNested) {
UploadResourceInfo resourceMetaData = serviceImportParseLogic
- .fillResourceMetadata(yamlName, resourceVf, nodeNameValue.getKey(), user);
+ .fillResourceMetadata(yamlName, resourceVf, nodeNameValue.getKey(), user);
String singleVfcYaml = serviceImportParseLogic.buildNodeTypeYaml(nodeNameValue, mapToConvert,
- resourceMetaData.getResourceType(), csarInfo);
+ resourceMetaData.getResourceType(), csarInfo);
user = serviceBusinessLogic.validateUser(user, "CheckIn Resource", resourceVf, AuditingActionEnum.CHECKIN_RESOURCE, true);
return serviceImportParseLogic.createResourceFromNodeType(singleVfcYaml, resourceMetaData, user, true, needLock,
- nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo,
- nodeNameValue.getKey(), isNested);
+ nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo,
+ nodeNameValue.getKey(), isNested);
}
protected Service createRIAndRelationsFromYaml(String yamlName, Service service,
- Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap,
- String topologyTemplateYaml, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
- Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
- String nodeName) {
+ Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap,
+ String topologyTemplateYaml, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
+ Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
+ String nodeName) {
log.debug("************* Going to create all nodes {}", yamlName);
- handleServiceNodeTypes(yamlName, service, topologyTemplateYaml, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeName);
+ handleServiceNodeTypes(yamlName, service, topologyTemplateYaml, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts,
+ nodeTypesInfo, csarInfo, nodeName);
log.debug("************* Going to create all resource instances {}", yamlName);
service = createServiceInstances(yamlName, service, uploadComponentInstanceInfoMap, csarInfo.getCreatedNodes());
log.debug("************* Going to create all relations {}", yamlName);
@@ -1397,12 +1445,15 @@ public class ServiceImportBusinessLogic{
}
protected Service createServiceInstancesRelations(User user, String yamlName, Service service,
- Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
log.debug("#createResourceInstancesRelations - Going to create relations ");
List<ComponentInstance> componentInstancesList = service.getComponentInstances();
if (((MapUtils.isEmpty(uploadResInstancesMap) || CollectionUtils.isEmpty(componentInstancesList)))) { // PNF can have no resource instances
- log.debug("#createResourceInstancesRelations - No instances found in the resource {} is empty, yaml template file name {}, ", service.getUniqueId(), yamlName);
- BeEcompErrorManager.getInstance().logInternalDataError("createResourceInstancesRelations", "No instances found in a component or nn yaml template. ", BeEcompErrorManager.ErrorSeverity.ERROR);
+ log.debug("#createResourceInstancesRelations - No instances found in the resource {} is empty, yaml template file name {}, ",
+ service.getUniqueId(), yamlName);
+ BeEcompErrorManager.getInstance()
+ .logInternalDataError("createResourceInstancesRelations", "No instances found in a component or nn yaml template. ",
+ BeEcompErrorManager.ErrorSeverity.ERROR);
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName));
}
Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
@@ -1410,7 +1461,7 @@ public class ServiceImportBusinessLogic{
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
- Map<String, List<AttributeDataDefinition>> instAttributes = new HashMap<>();
+ Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -1420,23 +1471,23 @@ public class ServiceImportBusinessLogic{
if (allDataTypes.isRight()) {
JanusGraphOperationStatus status = allDataTypes.right().value();
BeEcompErrorManager.getInstance().logInternalFlowError("UpdatePropertyValueOnComponentInstance",
- "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
+ "Failed to update property value on instance. Status is " + status, BeEcompErrorManager.ErrorSeverity.ERROR);
throw new ComponentException(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(
- DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)), yamlName));
+ DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status)), yamlName));
}
Service finalResource = service;
uploadResInstancesMap
- .values()
- .forEach(i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes,
- instProperties, instCapabilities, instRequirements, instDeploymentArtifacts,
- instArtifacts, instAttributes, originCompMap, instInputs, i));
+ .values()
+ .forEach(i -> processComponentInstance(yamlName, finalResource, componentInstancesList, allDataTypes,
+ instProperties, instCapabilities, instRequirements, instDeploymentArtifacts,
+ instArtifacts, instAttributes, originCompMap, instInputs, i));
serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, service, instProperties);
serviceImportParseLogic.associateComponentInstanceInputsToComponent(yamlName, service, instInputs);
serviceImportParseLogic.associateDeploymentArtifactsToInstances(user, yamlName, service, instDeploymentArtifacts);
serviceImportParseLogic.associateArtifactsToInstances(yamlName, service, instArtifacts);
serviceImportParseLogic.associateOrAddCalculatedCapReq(yamlName, service, instCapabilities, instRequirements);
log.debug("enter createServiceInstancesRelations test,instRequirements:{},instCapabilities:{}",
- instRequirements, instCapabilities);
+ instRequirements, instCapabilities);
serviceImportParseLogic.associateInstAttributeToComponentToInstances(yamlName, service, instAttributes);
ToscaElement serviceTemplate = ModelConverter.convertToToscaElement(service);
Map<String, ListCapabilityDataDefinition> capabilities = serviceTemplate.getCapabilities();
@@ -1454,7 +1505,7 @@ public class ServiceImportBusinessLogic{
log.debug("************* in create relations, getResource end");
if (eitherGetResource.isRight()) {
throw new ComponentException(componentsUtils.getResponseFormatByComponent(
- componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), service, service.getComponentType()));
+ componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), service, service.getComponentType()));
}
return eitherGetResource.left().value();
}
@@ -1467,22 +1518,22 @@ public class ServiceImportBusinessLogic{
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts,
Map<String, Map<String, ArtifactDefinition>> instArtifacts,
- Map<String, List<AttributeDataDefinition>> instAttributes,
+ Map<String, List<AttributeDefinition>> instAttributes,
Map<String, Resource> originCompMap,
Map<String, List<ComponentInstanceInput>> instInputs,
UploadComponentInstanceInfo uploadComponentInstanceInfo) {
log.debug("enter ServiceImportBusinessLogic processComponentInstance");
Optional<ComponentInstance> currentCompInstanceOpt = componentInstancesList.stream()
- .filter(i -> i.getName().equals(uploadComponentInstanceInfo.getName()))
- .findFirst();
+ .filter(i -> i.getName().equals(uploadComponentInstanceInfo.getName()))
+ .findFirst();
if (!currentCompInstanceOpt.isPresent()) {
log.debug(COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE, uploadComponentInstanceInfo.getName(),
- component.getUniqueId());
+ component.getUniqueId());
BeEcompErrorManager.getInstance().logInternalDataError(
- COMPONENT_INSTANCE_WITH_NAME + uploadComponentInstanceInfo.getName() + IN_RESOURCE,
- component.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ COMPONENT_INSTANCE_WITH_NAME + uploadComponentInstanceInfo.getName() + IN_RESOURCE,
+ component.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
ResponseFormat responseFormat = componentsUtils
- .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
throw new ComponentException(responseFormat);
}
ComponentInstance currentCompInstance = currentCompInstanceOpt.get();
@@ -1494,7 +1545,7 @@ public class ServiceImportBusinessLogic{
}
if (MapUtils.isNotEmpty(originResource.getCapabilities())) {
processComponentInstanceCapabilities(allDataTypes, instCapabilties, uploadComponentInstanceInfo,
- currentCompInstance, originResource);
+ currentCompInstance, originResource);
}
if (originResource.getDeploymentArtifacts() != null && !originResource.getDeploymentArtifacts().isEmpty()) {
instDeploymentArtifacts.put(resourceInstanceId, originResource.getDeploymentArtifacts());
@@ -1507,13 +1558,13 @@ public class ServiceImportBusinessLogic{
}
if (originResource.getResourceType() != ResourceTypeEnum.VF) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, component,
- originResource, currentCompInstance, instProperties, allDataTypes.left().value());
+ originResource, currentCompInstance, instProperties, allDataTypes.left().value());
if (addPropertiesValueToRiRes.getStatus() != 200) {
throw new ComponentException(addPropertiesValueToRiRes);
}
} else {
addInputsValuesToRi(uploadComponentInstanceInfo, component,
- originResource, currentCompInstance, instInputs, allDataTypes.left().value());
+ originResource, currentCompInstance, instInputs, allDataTypes.left().value());
}
}
@@ -1544,22 +1595,25 @@ public class ServiceImportBusinessLogic{
}
}
- protected void processProperty(Component component, ComponentInstance currentCompInstance, Map<String, DataTypeDefinition> allDataTypes, Map<String, InputDefinition> currPropertiesMap, List<ComponentInstanceInput> instPropList, List<UploadPropInfo> propertyList) {
+ protected void processProperty(Component component, ComponentInstance currentCompInstance, Map<String, DataTypeDefinition> allDataTypes,
+ Map<String, InputDefinition> currPropertiesMap, List<ComponentInstanceInput> instPropList,
+ List<UploadPropInfo> propertyList) {
UploadPropInfo propertyInfo = propertyList.get(0);
String propName = propertyInfo.getName();
if (!currPropertiesMap.containsKey(propName)) {
log.debug("failed to find property {} ", propName);
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND,
- propName));
+ propName));
}
processProperty(allDataTypes, currPropertiesMap, instPropList, propertyInfo, propName, component.getInputs());
}
- protected void processGetInput(List<GetInputValueDataDefinition> getInputValues, List<InputDefinition> inputs, GetInputValueDataDefinition getInputIndex) {
+ protected void processGetInput(List<GetInputValueDataDefinition> getInputValues, List<InputDefinition> inputs,
+ GetInputValueDataDefinition getInputIndex) {
Optional<InputDefinition> optional;
if (getInputIndex != null) {
optional = inputs.stream().filter(p -> p.getName().equals(getInputIndex.getInputName()))
- .findAny();
+ .findAny();
if (!optional.isPresent()) {
log.debug("Failed to find input {} ", getInputIndex.getInputName());
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
@@ -1571,8 +1625,9 @@ public class ServiceImportBusinessLogic{
}
protected ResponseFormat addPropertyValuesToRi(UploadComponentInstanceInfo uploadComponentInstanceInfo,
- Component component, Resource originResource, ComponentInstance currentCompInstance,
- Map<String, List<ComponentInstanceProperty>> instProperties, Map<String, DataTypeDefinition> allDataTypes) {
+ Component component, Resource originResource, ComponentInstance currentCompInstance,
+ Map<String, List<ComponentInstanceProperty>> instProperties,
+ Map<String, DataTypeDefinition> allDataTypes) {
Map<String, List<UploadPropInfo>> propMap = uploadComponentInstanceInfo.getProperties();
Map<String, PropertyDefinition> currPropertiesMap = new HashMap<>();
@@ -1598,7 +1653,7 @@ public class ServiceImportBusinessLogic{
if (!currPropertiesMap.containsKey(propName)) {
log.debug("failed to find property {} ", propName);
return componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND,
- propName);
+ propName);
}
PropertyDefinition curPropertyDef = currPropertiesMap.get(propName);
ComponentInstanceProperty property = null;
@@ -1611,10 +1666,10 @@ public class ServiceImportBusinessLogic{
isValidate = getInputs == null || getInputs.isEmpty();
if (isValidate) {
value = getPropertyJsonStringValue(propertyInfo.getValue(),
- curPropertyDef.getType());
+ curPropertyDef.getType());
} else {
value = getPropertyJsonStringValue(propertyInfo.getValue(),
- TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName());
+ TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName());
}
}
property = new ComponentInstanceProperty(curPropertyDef, value, null);
@@ -1629,9 +1684,9 @@ public class ServiceImportBusinessLogic{
if (inputs == null || inputs.isEmpty()) {
log.debug("Failed to add property {} to instance. Inputs list is empty ", property);
serviceBusinessLogic.rollbackWithException(ActionStatus.INPUTS_NOT_FOUND, property.getGetInputValues()
- .stream()
- .map(GetInputValueDataDefinition::getInputName)
- .collect(toList()).toString());
+ .stream()
+ .map(GetInputValueDataDefinition::getInputName)
+ .collect(toList()).toString());
}
InputDefinition input = serviceImportParseLogic.findInputByName(inputs, getInput);
getInput.setInputId(input.getUniqueId());
@@ -1659,16 +1714,19 @@ public class ServiceImportBusinessLogic{
return componentsUtils.getResponseFormat(ActionStatus.OK);
}
- protected void processComponentInstanceCapabilities(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes, Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties, UploadComponentInstanceInfo uploadComponentInstanceInfo, ComponentInstance currentCompInstance, Resource originResource) {
+ protected void processComponentInstanceCapabilities(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
+ UploadComponentInstanceInfo uploadComponentInstanceInfo,
+ ComponentInstance currentCompInstance, Resource originResource) {
log.debug("enter processComponentInstanceCapabilities");
Map<String, List<CapabilityDefinition>> originCapabilities;
if (MapUtils.isNotEmpty(uploadComponentInstanceInfo.getCapabilities())) {
originCapabilities = new HashMap<>();
Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
originResource.getCapabilities().forEach((k, v) -> serviceImportParseLogic
- .addCapabilities(originCapabilities, k, v));
+ .addCapabilities(originCapabilities, k, v));
uploadComponentInstanceInfo.getCapabilities().values().forEach(l -> serviceImportParseLogic
- .addCapabilitiesProperties(newPropertiesMap, l));
+ .addCapabilitiesProperties(newPropertiesMap, l));
updateCapabilityPropertiesValues(allDataTypes, originCapabilities, newPropertiesMap);
} else {
originCapabilities = originResource.getCapabilities();
@@ -1676,20 +1734,22 @@ public class ServiceImportBusinessLogic{
instCapabilties.put(currentCompInstance, originCapabilities);
}
- protected void updateCapabilityPropertiesValues(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes, Map<String, List<CapabilityDefinition>> originCapabilities, Map<String, Map<String, UploadPropInfo>> newPropertiesMap) {
+ protected void updateCapabilityPropertiesValues(Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes,
+ Map<String, List<CapabilityDefinition>> originCapabilities,
+ Map<String, Map<String, UploadPropInfo>> newPropertiesMap) {
originCapabilities.values().stream()
- .flatMap(Collection::stream)
- .filter(c -> newPropertiesMap.containsKey(c.getName()))
- .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes.left().value()));
+ .flatMap(Collection::stream)
+ .filter(c -> newPropertiesMap.containsKey(c.getName()))
+ .forEach(c -> updatePropertyValues(c.getProperties(), newPropertiesMap.get(c.getName()), allDataTypes.left().value()));
}
protected void updatePropertyValues(List<ComponentInstanceProperty> properties, Map<String, UploadPropInfo> newProperties,
- Map<String, DataTypeDefinition> allDataTypes) {
+ Map<String, DataTypeDefinition> allDataTypes) {
properties.forEach(p -> updatePropertyValue(p, newProperties.get(p.getName()), allDataTypes));
}
protected String updatePropertyValue(ComponentInstanceProperty property, UploadPropInfo propertyInfo,
- Map<String, DataTypeDefinition> allDataTypes) {
+ Map<String, DataTypeDefinition> allDataTypes) {
String value = null;
List<GetInputValueDataDefinition> getInputs = null;
boolean isValidate = true;
@@ -1700,7 +1760,7 @@ public class ServiceImportBusinessLogic{
value = getPropertyJsonStringValue(propertyInfo.getValue(), property.getType());
} else {
value = getPropertyJsonStringValue(propertyInfo.getValue(),
- TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName());
+ TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName());
}
}
property.setValue(value);
@@ -1712,10 +1772,10 @@ public class ServiceImportBusinessLogic{
log.debug("after enter ServiceImportBusinessLogic processComponentInstance, enter getOriginResource");
if (!originCompMap.containsKey(currentCompInstance.getComponentUid())) {
Either<Resource, StorageOperationStatus> getOriginResourceRes = toscaOperationFacade
- .getToscaFullElement(currentCompInstance.getComponentUid());
+ .getToscaFullElement(currentCompInstance.getComponentUid());
if (getOriginResourceRes.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(
- componentsUtils.convertFromStorageResponse(getOriginResourceRes.right().value()), yamlName);
+ componentsUtils.convertFromStorageResponse(getOriginResourceRes.right().value()), yamlName);
throw new ComponentException(responseFormat);
}
originResource = getOriginResourceRes.left().value();
@@ -1731,37 +1791,37 @@ public class ServiceImportBusinessLogic{
Either<Resource, StorageOperationStatus> getResourceRes = toscaOperationFacade.getToscaFullElement(service.getUniqueId());
if (getResourceRes.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByComponent(
- componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), service, ComponentTypeEnum.SERVICE);
+ componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), service, ComponentTypeEnum.SERVICE);
throw new ComponentException(responseFormat);
}
getResourceRes = updateCalculatedCapReqWithSubstitutionMappings(getResourceRes.left().value(),
- uploadResInstancesMap);
+ uploadResInstancesMap);
if (getResourceRes.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByComponent(
- componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), service, ComponentTypeEnum.SERVICE);
+ componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), service, ComponentTypeEnum.SERVICE);
throw new ComponentException(responseFormat);
}
}
}
protected Either<Resource, StorageOperationStatus> updateCalculatedCapReqWithSubstitutionMappings(Resource resource,
- Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
Either<Resource, StorageOperationStatus> updateRes = null;
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilities = new HashMap<>();
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements = new HashMap<>();
StorageOperationStatus status = toscaOperationFacade
- .deleteAllCalculatedCapabilitiesRequirements(resource.getUniqueId());
+ .deleteAllCalculatedCapabilitiesRequirements(resource.getUniqueId());
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
log.debug(
- "Failed to delete all calculated capabilities and requirements of resource {} upon update. Status is {}",
- resource.getUniqueId(), status);
+ "Failed to delete all calculated capabilities and requirements of resource {} upon update. Status is {}",
+ resource.getUniqueId(), status);
updateRes = Either.right(status);
}
if (updateRes == null) {
fillUpdatedInstCapabilitiesRequirements(resource.getComponentInstances(), uploadResInstancesMap,
- updatedInstCapabilities, updatedInstRequirements);
+ updatedInstCapabilities, updatedInstRequirements);
status = toscaOperationFacade.associateOrAddCalculatedCapReq(updatedInstCapabilities, updatedInstRequirements,
- resource);
+ resource);
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
updateRes = Either.right(status);
}
@@ -1773,34 +1833,34 @@ public class ServiceImportBusinessLogic{
}
protected void fillUpdatedInstCapabilitiesRequirements(List<ComponentInstance> componentInstances,
- Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
- Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilities,
- Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements) {
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilities,
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements) {
componentInstances.stream().forEach(i -> {
fillUpdatedInstCapabilities(updatedInstCapabilities, i,
- uploadResInstancesMap.get(i.getName()).getCapabilitiesNamesToUpdate());
+ uploadResInstancesMap.get(i.getName()).getCapabilitiesNamesToUpdate());
fillUpdatedInstRequirements(updatedInstRequirements, i,
- uploadResInstancesMap.get(i.getName()).getRequirementsNamesToUpdate());
+ uploadResInstancesMap.get(i.getName()).getRequirementsNamesToUpdate());
});
}
protected void fillUpdatedInstCapabilities(
- Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilties,
- ComponentInstance instance, Map<String, String> capabilitiesNamesToUpdate) {
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilties,
+ ComponentInstance instance, Map<String, String> capabilitiesNamesToUpdate) {
Map<String, List<CapabilityDefinition>> updatedCapabilities = new HashMap<>();
Set<String> updatedCapNames = new HashSet<>();
if (MapUtils.isNotEmpty(capabilitiesNamesToUpdate)) {
for (Map.Entry<String, List<CapabilityDefinition>> requirements : instance.getCapabilities().entrySet()) {
updatedCapabilities.put(requirements.getKey(),
- requirements.getValue().stream()
- .filter(c -> capabilitiesNamesToUpdate.containsKey(c.getName())
- && !updatedCapNames.contains(capabilitiesNamesToUpdate.get(c.getName())))
- .map(c -> {
- c.setParentName(c.getName());
- c.setName(capabilitiesNamesToUpdate.get(c.getName()));
- updatedCapNames.add(c.getName());
- return c;
- }).collect(toList()));
+ requirements.getValue().stream()
+ .filter(c -> capabilitiesNamesToUpdate.containsKey(c.getName())
+ && !updatedCapNames.contains(capabilitiesNamesToUpdate.get(c.getName())))
+ .map(c -> {
+ c.setParentName(c.getName());
+ c.setName(capabilitiesNamesToUpdate.get(c.getName()));
+ updatedCapNames.add(c.getName());
+ return c;
+ }).collect(toList()));
}
}
if (MapUtils.isNotEmpty(updatedCapabilities)) {
@@ -1809,22 +1869,22 @@ public class ServiceImportBusinessLogic{
}
protected void fillUpdatedInstRequirements(
- Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements,
- ComponentInstance instance, Map<String, String> requirementsNamesToUpdate) {
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements,
+ ComponentInstance instance, Map<String, String> requirementsNamesToUpdate) {
Map<String, List<RequirementDefinition>> updatedRequirements = new HashMap<>();
Set<String> updatedReqNames = new HashSet<>();
if (MapUtils.isNotEmpty(requirementsNamesToUpdate)) {
for (Map.Entry<String, List<RequirementDefinition>> requirements : instance.getRequirements().entrySet()) {
updatedRequirements.put(requirements.getKey(),
- requirements.getValue().stream()
- .filter(r -> requirementsNamesToUpdate.containsKey(r.getName())
- && !updatedReqNames.contains(requirementsNamesToUpdate.get(r.getName())))
- .map(r -> {
- r.setParentName(r.getName());
- r.setName(requirementsNamesToUpdate.get(r.getName()));
- updatedReqNames.add(r.getName());
- return r;
- }).collect(toList()));
+ requirements.getValue().stream()
+ .filter(r -> requirementsNamesToUpdate.containsKey(r.getName())
+ && !updatedReqNames.contains(requirementsNamesToUpdate.get(r.getName())))
+ .map(r -> {
+ r.setParentName(r.getName());
+ r.setName(requirementsNamesToUpdate.get(r.getName()));
+ updatedReqNames.add(r.getName());
+ return r;
+ }).collect(toList()));
}
}
if (MapUtils.isNotEmpty(updatedRequirements)) {
@@ -1832,7 +1892,8 @@ public class ServiceImportBusinessLogic{
}
}
- protected void addRelationsToRI(String yamlName, Service service, Map<String, UploadComponentInstanceInfo> uploadResInstancesMap, List<ComponentInstance> componentInstancesList, List<RequirementCapabilityRelDef> relations) {
+ protected void addRelationsToRI(String yamlName, Service service, Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
+ List<ComponentInstance> componentInstancesList, List<RequirementCapabilityRelDef> relations) {
for (Map.Entry<String, UploadComponentInstanceInfo> entry : uploadResInstancesMap.entrySet()) {
UploadComponentInstanceInfo uploadComponentInstanceInfo = entry.getValue();
ComponentInstance currentCompInstance = null;
@@ -1844,12 +1905,12 @@ public class ServiceImportBusinessLogic{
}
if (currentCompInstance == null) {
log.debug(COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE, uploadComponentInstanceInfo.getName(),
- service.getUniqueId());
+ service.getUniqueId());
BeEcompErrorManager.getInstance().logInternalDataError(
- COMPONENT_INSTANCE_WITH_NAME + uploadComponentInstanceInfo.getName() + IN_RESOURCE,
- service.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ COMPONENT_INSTANCE_WITH_NAME + uploadComponentInstanceInfo.getName() + IN_RESOURCE,
+ service.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
ResponseFormat responseFormat = componentsUtils
- .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
throw new ComponentException(responseFormat);
}
@@ -1861,7 +1922,7 @@ public class ServiceImportBusinessLogic{
}
protected ResponseFormat addRelationToRI(String yamlName, Service service,
- UploadComponentInstanceInfo nodesInfoValue, List<RequirementCapabilityRelDef> relations) {
+ UploadComponentInstanceInfo nodesInfoValue, List<RequirementCapabilityRelDef> relations) {
List<ComponentInstance> componentInstancesList = service.getComponentInstances();
ComponentInstance currentCompInstance = null;
for (ComponentInstance compInstance : componentInstancesList) {
@@ -1872,12 +1933,12 @@ public class ServiceImportBusinessLogic{
}
if (currentCompInstance == null) {
log.debug(COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE, nodesInfoValue.getName(),
- service.getUniqueId());
+ service.getUniqueId());
BeEcompErrorManager.getInstance().logInternalDataError(
- COMPONENT_INSTANCE_WITH_NAME + nodesInfoValue.getName() + IN_RESOURCE,
- service.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ COMPONENT_INSTANCE_WITH_NAME + nodesInfoValue.getName() + IN_RESOURCE,
+ service.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE,
- yamlName);
+ yamlName);
}
String resourceInstanceId = currentCompInstance.getUniqueId();
Map<String, List<UploadReqInfo>> regMap = nodesInfoValue.getRequirements();
@@ -1894,17 +1955,17 @@ public class ServiceImportBusinessLogic{
regCapRelDef.setFromNode(resourceInstanceId);
log.debug("try to find available requirement {} ", regName);
Either<RequirementDefinition, ResponseFormat> eitherReqStatus = serviceImportParseLogic.findAviableRequiremen(regName,
- yamlName, nodesInfoValue, currentCompInstance,
- uploadRegInfo.getCapabilityName());
+ yamlName, nodesInfoValue, currentCompInstance,
+ uploadRegInfo.getCapabilityName());
if (eitherReqStatus.isRight()) {
log.debug("failed to find available requirement {} status is {}", regName,
- eitherReqStatus.right().value());
+ eitherReqStatus.right().value());
return eitherReqStatus.right().value();
}
RequirementDefinition validReq = eitherReqStatus.left().value();
List<CapabilityRequirementRelationship> reqAndRelationshipPairList = regCapRelDef
- .getRelationships();
+ .getRelationships();
if (reqAndRelationshipPairList == null) {
reqAndRelationshipPairList = new ArrayList<>();
}
@@ -1925,27 +1986,27 @@ public class ServiceImportBusinessLogic{
}
if (currentCapCompInstance == null) {
log.debug("The component instance with name {} not found on resource {} ",
- uploadRegInfo.getNode(), service.getUniqueId());
+ uploadRegInfo.getNode(), service.getUniqueId());
BeEcompErrorManager.getInstance().logInternalDataError(
- COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE,
- service.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE,
+ service.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
return componentsUtils
- .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
regCapRelDef.setToNode(currentCapCompInstance.getUniqueId());
log.debug("try to find aviable Capability req name is {} ", validReq.getName());
CapabilityDefinition aviableCapForRel = serviceImportParseLogic.findAvailableCapabilityByTypeOrName(validReq,
- currentCapCompInstance, uploadRegInfo);
+ currentCapCompInstance, uploadRegInfo);
reqAndRelationshipPair.setCapability(aviableCapForRel.getName());
reqAndRelationshipPair.setCapabilityUid(aviableCapForRel.getUniqueId());
reqAndRelationshipPair.setCapabilityOwnerId(aviableCapForRel.getOwnerId());
if (aviableCapForRel == null) {
BeEcompErrorManager.getInstance().logInternalDataError(
- "aviable capability was not found. req name is " + validReq.getName()
- + " component instance is " + currentCapCompInstance.getUniqueId(),
- service.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ "aviable capability was not found. req name is " + validReq.getName()
+ + " component instance is " + currentCapCompInstance.getUniqueId(),
+ service.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
return componentsUtils
- .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
capReqRel.setRelation(reqAndRelationshipPair);
@@ -1961,7 +2022,7 @@ public class ServiceImportBusinessLogic{
protected Service getResourceAfterCreateRelations(Service service) {
ComponentParametersView parametersView = serviceImportParseLogic.getComponentFilterAfterCreateRelations();
Either<Service, StorageOperationStatus> eitherGetResource = toscaOperationFacade
- .getToscaElement(service.getUniqueId(), parametersView);
+ .getToscaElement(service.getUniqueId(), parametersView);
if (eitherGetResource.isRight()) {
serviceImportParseLogic.throwComponentExceptionByResource(eitherGetResource.right().value(), service);
}
@@ -1969,8 +2030,8 @@ public class ServiceImportBusinessLogic{
}
protected Service createServiceInstances(String yamlName, Service service,
- Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
- Map<String, Resource> nodeNamespaceMap) {
+ Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
+ Map<String, Resource> nodeNamespaceMap) {
Either<Resource, ResponseFormat> eitherResource = null;
log.debug("createResourceInstances is {} - going to create resource instanse from CSAR", yamlName);
if (MapUtils.isEmpty(uploadResInstancesMap)) { // PNF can have no resource instances
@@ -1983,50 +2044,51 @@ public class ServiceImportBusinessLogic{
}
Map<ComponentInstance, Resource> resourcesInstancesMap = new HashMap<>();
uploadResInstancesMap
- .values()
- .forEach(i -> createAndAddResourceInstance(i, yamlName, service, nodeNamespaceMap, existingNodeTypeMap, resourcesInstancesMap));
+ .values()
+ .forEach(i -> createAndAddResourceInstance(i, yamlName, service, nodeNamespaceMap, existingNodeTypeMap, resourcesInstancesMap));
if (MapUtils.isNotEmpty(resourcesInstancesMap)) {
try {
toscaOperationFacade.associateComponentInstancesToComponent(service,
- resourcesInstancesMap, false, false);
+ resourcesInstancesMap, false, false);
} catch (StorageException exp) {
if (exp.getStorageOperationStatus() != null && exp.getStorageOperationStatus() != StorageOperationStatus.OK) {
log.debug("Failed to add component instances to container component {}", service.getName());
ResponseFormat responseFormat = componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(exp.getStorageOperationStatus()));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(exp.getStorageOperationStatus()));
eitherResource = Either.right(responseFormat);
throw new ComponentException(eitherResource.right().value());
}
}
}
Either<Service, StorageOperationStatus> eitherGetResource = toscaOperationFacade
- .getToscaElement(service.getUniqueId(), serviceImportParseLogic.getComponentWithInstancesFilter());
+ .getToscaElement(service.getUniqueId(), serviceImportParseLogic.getComponentWithInstancesFilter());
log.debug("*************finished to get resource {}", service.getUniqueId());
if (eitherGetResource.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByComponent(
- componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), service, ComponentTypeEnum.SERVICE);
+ componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), service, ComponentTypeEnum.SERVICE);
throw new ComponentException(responseFormat);
}
if (CollectionUtils.isEmpty(eitherGetResource.left().value().getComponentInstances())) { // PNF can have no resource instances
log.debug("Error when create resource instance from csar. ComponentInstances list empty");
BeEcompErrorManager.getInstance().logBeDaoSystemError(
- "Error when create resource instance from csar. ComponentInstances list empty");
+ "Error when create resource instance from csar. ComponentInstances list empty");
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE));
}
return eitherGetResource.left().value();
}
protected void createAndAddResourceInstance(UploadComponentInstanceInfo uploadComponentInstanceInfo, String yamlName,
- Component component, Map<String, Resource> nodeNamespaceMap, Map<String, Resource> existingnodeTypeMap, Map<ComponentInstance, Resource> resourcesInstancesMap) {
+ Component component, Map<String, Resource> nodeNamespaceMap,
+ Map<String, Resource> existingnodeTypeMap, Map<ComponentInstance, Resource> resourcesInstancesMap) {
log.debug("*************Going to create resource instances {}", uploadComponentInstanceInfo.getName());
try {
if (nodeNamespaceMap.containsKey(uploadComponentInstanceInfo.getType())) {
uploadComponentInstanceInfo
- .setType(nodeNamespaceMap.get(uploadComponentInstanceInfo.getType()).getToscaResourceName());
+ .setType(nodeNamespaceMap.get(uploadComponentInstanceInfo.getType()).getToscaResourceName());
}
Resource refResource = validateResourceInstanceBeforeCreate(yamlName, uploadComponentInstanceInfo,
- existingnodeTypeMap);
+ existingnodeTypeMap);
ComponentInstance componentInstance = new ComponentInstance();
componentInstance.setComponentUid(refResource.getUniqueId());
@@ -2037,23 +2099,24 @@ public class ServiceImportBusinessLogic{
UploadNodeFilterInfo uploadNodeFilterInfo = uploadComponentInstanceInfo.getUploadNodeFilterInfo();
if (uploadNodeFilterInfo != null) {
componentInstance.setNodeFilter(new CINodeFilterUtils().getNodeFilterDataDefinition(uploadNodeFilterInfo,
- componentInstance.getUniqueId()));
+ componentInstance.getUniqueId()));
}
ComponentTypeEnum containerComponentType = component.getComponentType();
NodeTypeEnum containerNodeType = containerComponentType.getNodeType();
if (containerNodeType.equals(NodeTypeEnum.Resource)
- && MapUtils.isNotEmpty(uploadComponentInstanceInfo.getCapabilities())
- && MapUtils.isNotEmpty(refResource.getCapabilities())) {
+ && MapUtils.isNotEmpty(uploadComponentInstanceInfo.getCapabilities())
+ && MapUtils.isNotEmpty(refResource.getCapabilities())) {
serviceImportParseLogic.setCapabilityNamesTypes(refResource.getCapabilities(), uploadComponentInstanceInfo.getCapabilities());
- Map<String, List<CapabilityDefinition>> validComponentInstanceCapabilities = serviceImportParseLogic.getValidComponentInstanceCapabilities(
+ Map<String, List<CapabilityDefinition>> validComponentInstanceCapabilities = serviceImportParseLogic
+ .getValidComponentInstanceCapabilities(
refResource.getUniqueId(), refResource.getCapabilities(),
uploadComponentInstanceInfo.getCapabilities());
componentInstance.setCapabilities(validComponentInstanceCapabilities);
}
if (!existingnodeTypeMap.containsKey(uploadComponentInstanceInfo.getType())) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE,
- yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
+ yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
throw new ComponentException(responseFormat);
}
Resource origResource = existingnodeTypeMap.get(uploadComponentInstanceInfo.getType());
@@ -2061,22 +2124,22 @@ public class ServiceImportBusinessLogic{
componentInstance.setIcon(origResource.getIcon());
resourcesInstancesMap.put(componentInstance, origResource);
} catch (Exception e) {
- throw new ComponentException(ActionStatus.GENERAL_ERROR,e.getMessage());
+ throw new ComponentException(ActionStatus.GENERAL_ERROR, e.getMessage());
}
}
protected Resource validateResourceInstanceBeforeCreate(String yamlName, UploadComponentInstanceInfo uploadComponentInstanceInfo,
- Map<String, Resource> nodeNamespaceMap) {
+ Map<String, Resource> nodeNamespaceMap) {
Resource refResource;
try {
if (nodeNamespaceMap.containsKey(uploadComponentInstanceInfo.getType())) {
refResource = nodeNamespaceMap.get(uploadComponentInstanceInfo.getType());
} else {
Either<Resource, StorageOperationStatus> findResourceEither = toscaOperationFacade
- .getLatestResourceByToscaResourceName(uploadComponentInstanceInfo.getType());
+ .getLatestResourceByToscaResourceName(uploadComponentInstanceInfo.getType());
if (findResourceEither.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(
- componentsUtils.convertFromStorageResponse(findResourceEither.right().value()));
+ componentsUtils.convertFromStorageResponse(findResourceEither.right().value()));
throw new ComponentException(responseFormat);
}
refResource = findResourceEither.left().value();
@@ -2085,49 +2148,49 @@ public class ServiceImportBusinessLogic{
String componentState = refResource.getComponentMetadataDefinition().getMetadataDataDefinition().getState();
if (componentState.equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name())) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.ILLEGAL_COMPONENT_STATE,
- refResource.getComponentType().getValue(), refResource.getName(), componentState);
+ refResource.getComponentType().getValue(), refResource.getName(), componentState);
throw new ComponentException(responseFormat);
}
if (!ModelConverter.isAtomicComponent(refResource) && refResource.getResourceType() != ResourceTypeEnum.VF) {
log.debug("validateResourceInstanceBeforeCreate - ref resource type is ", refResource.getResourceType());
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE,
- yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
+ yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
throw new ComponentException(responseFormat);
}
return refResource;
} catch (Exception e) {
- throw new ComponentException(ActionStatus.GENERAL_ERROR,e.getMessage());
+ throw new ComponentException(ActionStatus.GENERAL_ERROR, e.getMessage());
}
}
protected void handleServiceNodeTypes(String yamlName, Service service,
- String topologyTemplateYaml, boolean needLock,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo,
- CsarInfo csarInfo, String nodeName) {
+ String topologyTemplateYaml, boolean needLock,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo,
+ CsarInfo csarInfo, String nodeName) {
try {
for (Map.Entry<String, NodeTypeInfo> nodeTypeEntry : nodeTypesInfo.entrySet()) {
boolean isResourceNotExisted = validateResourceNotExisted(nodeTypeEntry.getKey());
if (nodeTypeEntry.getValue().isNested() && isResourceNotExisted) {
handleNestedVF(service, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts,
- nodeTypesInfo, csarInfo, nodeTypeEntry.getKey());
+ nodeTypesInfo, csarInfo, nodeTypeEntry.getKey());
log.trace("************* finished to create node {}", nodeTypeEntry.getKey());
}
}
Map<String, Object> mappedToscaTemplate = null;
if (org.apache.commons.lang.StringUtils.isNotEmpty(nodeName) && MapUtils.isNotEmpty(nodeTypesInfo)
- && nodeTypesInfo.containsKey(nodeName)) {
+ && nodeTypesInfo.containsKey(nodeName)) {
mappedToscaTemplate = nodeTypesInfo.get(nodeName).getMappedToscaTemplate();
}
if (MapUtils.isEmpty(mappedToscaTemplate)) {
mappedToscaTemplate = (Map<String, Object>) new Yaml().load(topologyTemplateYaml);
}
createResourcesFromYamlNodeTypesList(yamlName, service, mappedToscaTemplate, needLock, nodeTypesArtifactsToHandle,
- nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo);
+ nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo);
} catch (ComponentException | StorageException e) {
throw e;
- } catch (Exception e){
- log.debug("Exception occured when handleServiceNodeTypes, error is:{}", e.getMessage(), e);
+ } catch (Exception e) {
+ log.debug("Exception occured when handleServiceNodeTypes, error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
}
@@ -2137,19 +2200,21 @@ public class ServiceImportBusinessLogic{
Either<Resource, StorageOperationStatus> latestResource = toscaOperationFacade.getLatestResourceByToscaResourceName(type);
return latestResource.isRight();
} catch (Exception e) {
- log.debug("Exception occured when validateResourceNotExisted, error is:{}", e.getMessage(), e);
+ log.debug("Exception occured when validateResourceNotExisted, error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
}
- protected Resource handleNestedVF(Service service, Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
- List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
- String nodeName) {
+ protected Resource handleNestedVF(Service service,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
+ List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
+ String nodeName) {
try {
String yamlName = nodesInfo.get(nodeName).getTemplateFileName();
Map<String, Object> nestedVfcJsonMap = nodesInfo.get(nodeName).getMappedToscaTemplate();
- createResourcesFromYamlNodeTypesList(yamlName, service, nestedVfcJsonMap, false, nodesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo);
+ createResourcesFromYamlNodeTypesList(yamlName, service, nestedVfcJsonMap, false, nodesArtifactsToHandle, createdArtifacts, nodesInfo,
+ csarInfo);
log.debug("************* Finished to create node types from yaml {}", yamlName);
if (nestedVfcJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.TOPOLOGY_TEMPLATE.getElementName())) {
@@ -2163,41 +2228,42 @@ public class ServiceImportBusinessLogic{
}
}
- protected Resource handleComplexVfc(Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
- List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
- String nodeName, String yamlName) {
+ protected Resource handleComplexVfc(
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
+ List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
+ String nodeName, String yamlName) {
try {
Resource oldComplexVfc = null;
Resource newComplexVfc = serviceImportParseLogic.buildValidComplexVfc(csarInfo, nodeName, nodesInfo);
Either<Resource, StorageOperationStatus> oldComplexVfcRes = toscaOperationFacade
- .getFullLatestComponentByToscaResourceName(newComplexVfc.getToscaResourceName());
+ .getFullLatestComponentByToscaResourceName(newComplexVfc.getToscaResourceName());
if (oldComplexVfcRes.isRight() && oldComplexVfcRes.right().value() == StorageOperationStatus.NOT_FOUND) {
oldComplexVfcRes = toscaOperationFacade.getFullLatestComponentByToscaResourceName(
- serviceImportParseLogic.buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(),
- nodeName).getRight());
+ serviceImportParseLogic.buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(),
+ nodeName).getRight());
}
if (oldComplexVfcRes.isRight() && oldComplexVfcRes.right().value() != StorageOperationStatus.NOT_FOUND) {
log.debug("Failed to fetch previous complex VFC by tosca resource name {}. Status is {}. ",
- newComplexVfc.getToscaResourceName(), oldComplexVfcRes.right().value());
+ newComplexVfc.getToscaResourceName(), oldComplexVfcRes.right().value());
throw new ComponentException(ActionStatus.GENERAL_ERROR);
} else if (oldComplexVfcRes.isLeft()) {
log.debug(VALIDATE_DERIVED_BEFORE_UPDATE);
Either<Boolean, ResponseFormat> eitherValidation = serviceImportParseLogic.validateNestedDerivedFromDuringUpdate(
- oldComplexVfcRes.left().value(), newComplexVfc,
- ValidationUtils.hasBeenCertified(oldComplexVfcRes.left().value().getVersion()));
+ oldComplexVfcRes.left().value(), newComplexVfc,
+ ValidationUtils.hasBeenCertified(oldComplexVfcRes.left().value().getVersion()));
if (eitherValidation.isLeft()) {
oldComplexVfc = oldComplexVfcRes.left().value();
}
}
newComplexVfc = handleComplexVfc(nodesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName, yamlName,
- oldComplexVfc, newComplexVfc);
+ oldComplexVfc, newComplexVfc);
csarInfo.getCreatedNodesToscaResourceNames().put(nodeName, newComplexVfc.getToscaResourceName());
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction(
- CERTIFICATION_ON_IMPORT, LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR);
+ CERTIFICATION_ON_IMPORT, LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR);
log.debug("Going to certify cvfc {}. ", newComplexVfc.getName());
final Resource result = serviceImportParseLogic
- .propagateStateToCertified(csarInfo.getModifier(), newComplexVfc, lifecycleChangeInfo, true, false,
- true);
+ .propagateStateToCertified(csarInfo.getModifier(), newComplexVfc, lifecycleChangeInfo, true, false,
+ true);
csarInfo.getCreatedNodes().put(nodeName, result);
csarInfo.removeNodeFromQueue();
return result;
@@ -2207,23 +2273,24 @@ public class ServiceImportBusinessLogic{
}
}
- protected Resource handleComplexVfc(Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
- List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
- String nodeName, String yamlName, Resource oldComplexVfc, Resource newComplexVfc) {
+ protected Resource handleComplexVfc(
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodesArtifactsToHandle,
+ List<ArtifactDefinition> createdArtifacts, Map<String, NodeTypeInfo> nodesInfo, CsarInfo csarInfo,
+ String nodeName, String yamlName, Resource oldComplexVfc, Resource newComplexVfc) {
Resource handleComplexVfcRes;
try {
Map<String, Object> mappedToscaTemplate = nodesInfo.get(nodeName).getMappedToscaTemplate();
String yamlContent = new String(csarInfo.getCsar().get(yamlName));
Map<String, NodeTypeInfo> newNodeTypesInfo = nodesInfo.entrySet().stream()
- .collect(toMap(Map.Entry::getKey, e -> e.getValue().getUnmarkedCopy()));
+ .collect(toMap(Map.Entry::getKey, e -> e.getValue().getUnmarkedCopy()));
CsarInfo.markNestedVfc(mappedToscaTemplate, newNodeTypesInfo);
if (oldComplexVfc == null) {
handleComplexVfcRes = createResourceFromYaml(newComplexVfc, yamlContent, yamlName, newNodeTypesInfo,
- csarInfo, nodesArtifactsToHandle, false, true, nodeName);
+ csarInfo, nodesArtifactsToHandle, false, true, nodeName);
} else {
handleComplexVfcRes = updateResourceFromYaml(oldComplexVfc, newComplexVfc,
- AuditingActionEnum.UPDATE_RESOURCE_METADATA, createdArtifacts, yamlContent, yamlName, csarInfo,
- newNodeTypesInfo, nodesArtifactsToHandle, nodeName, true);
+ AuditingActionEnum.UPDATE_RESOURCE_METADATA, createdArtifacts, yamlContent, yamlName, csarInfo,
+ newNodeTypesInfo, nodesArtifactsToHandle, nodeName, true);
}
return handleComplexVfcRes;
} catch (Exception e) {
@@ -2233,44 +2300,49 @@ public class ServiceImportBusinessLogic{
}
protected Resource updateResourceFromYaml(Resource oldRresource, Resource newRresource,
- AuditingActionEnum actionEnum, List<ArtifactDefinition> createdArtifacts,
- String yamlFileName, String yamlFileContent, CsarInfo csarInfo, Map<String, NodeTypeInfo> nodeTypesInfo,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
- String nodeName, boolean isNested) {
+ AuditingActionEnum actionEnum, List<ArtifactDefinition> createdArtifacts,
+ String yamlFileName, String yamlFileContent, CsarInfo csarInfo, Map<String, NodeTypeInfo> nodeTypesInfo,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ String nodeName, boolean isNested) {
boolean inTransaction = true;
boolean shouldLock = false;
Resource preparedResource = null;
ParsedToscaYamlInfo uploadComponentInstanceInfoMap = null;
try {
- uploadComponentInstanceInfoMap = csarBusinessLogic.getParsedToscaYamlInfo(yamlFileContent, yamlFileName, nodeTypesInfo, csarInfo, nodeName, oldRresource);
+ uploadComponentInstanceInfoMap = csarBusinessLogic
+ .getParsedToscaYamlInfo(yamlFileContent, yamlFileName, nodeTypesInfo, csarInfo, nodeName, oldRresource);
Map<String, UploadComponentInstanceInfo> instances = uploadComponentInstanceInfoMap.getInstances();
if (MapUtils.isEmpty(instances) && newRresource.getResourceType() != ResourceTypeEnum.PNF) {
throw new ComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlFileName);
}
preparedResource = updateExistingResourceByImport(newRresource, oldRresource, csarInfo.getModifier(),
- inTransaction, shouldLock, isNested).left;
+ inTransaction, shouldLock, isNested).left;
log.trace("YAML topology file found in CSAR, file name: {}, contents: {}", yamlFileName, yamlFileContent);
serviceImportParseLogic.handleResourceGenericType(preparedResource);
handleNodeTypes(yamlFileName, preparedResource, yamlFileContent,
- shouldLock, nodeTypesArtifactsToHandle, createdArtifacts, nodeTypesInfo, csarInfo, nodeName);
+ shouldLock, nodeTypesArtifactsToHandle, createdArtifacts, nodeTypesInfo, csarInfo, nodeName);
preparedResource = serviceImportParseLogic
- .createInputsOnResource(preparedResource, uploadComponentInstanceInfoMap.getInputs());
+ .createInputsOnResource(preparedResource, uploadComponentInstanceInfoMap.getInputs());
preparedResource = createResourceInstances(yamlFileName, preparedResource, instances, csarInfo.getCreatedNodes());
preparedResource = createResourceInstancesRelations(csarInfo.getModifier(), yamlFileName, preparedResource, instances);
} catch (ComponentException e) {
- ResponseFormat responseFormat = e.getResponseFormat() == null ? componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()) : e.getResponseFormat();
+ ResponseFormat responseFormat =
+ e.getResponseFormat() == null ? componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()) : e.getResponseFormat();
log.debug("#updateResourceFromYaml - failed to update resource from yaml {} .The error is {}", yamlFileName, responseFormat);
- componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), preparedResource == null ? oldRresource : preparedResource, actionEnum);
+ componentsUtils
+ .auditResource(responseFormat, csarInfo.getModifier(), preparedResource == null ? oldRresource : preparedResource, actionEnum);
throw e;
} catch (StorageException e) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(e.getStorageOperationStatus()));
+ ResponseFormat responseFormat = componentsUtils
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(e.getStorageOperationStatus()));
log.debug("#updateResourceFromYaml - failed to update resource from yaml {} .The error is {}", yamlFileName, responseFormat);
- componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), preparedResource == null ? oldRresource : preparedResource, actionEnum);
+ componentsUtils
+ .auditResource(responseFormat, csarInfo.getModifier(), preparedResource == null ? oldRresource : preparedResource, actionEnum);
throw e;
}
Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes = serviceBusinessLogic.groupBusinessLogic
- .validateUpdateVfGroupNames(uploadComponentInstanceInfoMap.getGroups(),
- preparedResource.getSystemName());
+ .validateUpdateVfGroupNames(uploadComponentInstanceInfoMap.getGroups(),
+ preparedResource.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
throw new ComponentException(validateUpdateVfGroupNamesRes.right().value());
}
@@ -2283,11 +2355,11 @@ public class ServiceImportBusinessLogic{
serviceImportParseLogic.handleGroupsProperties(preparedResource, groups);
preparedResource = serviceImportParseLogic.updateGroupsOnResource(preparedResource, groups);
NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(nodeName,
- nodeTypesArtifactsToHandle);
+ nodeTypesArtifactsToHandle);
Either<Resource, ResponseFormat> updateArtifactsEither = createOrUpdateArtifacts(
- ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE, createdArtifacts, yamlFileName,
- csarInfo, preparedResource, nodeTypeInfoToUpdateArtifacts, inTransaction, shouldLock);
+ ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE, createdArtifacts, yamlFileName,
+ csarInfo, preparedResource, nodeTypeInfoToUpdateArtifacts, inTransaction, shouldLock);
if (updateArtifactsEither.isRight()) {
log.debug("failed to update artifacts {}", updateArtifactsEither.right().value());
throw new ComponentException(updateArtifactsEither.right().value());
@@ -2297,7 +2369,7 @@ public class ServiceImportBusinessLogic{
ActionStatus mergingPropsAndInputsStatus = resourceDataMergeBusinessLogic.mergeResourceEntities(oldRresource, preparedResource);
if (mergingPropsAndInputsStatus != ActionStatus.OK) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(mergingPropsAndInputsStatus,
- preparedResource);
+ preparedResource);
throw new ComponentException(responseFormat);
}
compositionBusinessLogic.setPositionsForComponentInstances(preparedResource, csarInfo.getModifier().getUserId());
@@ -2305,27 +2377,30 @@ public class ServiceImportBusinessLogic{
}
protected Resource createResourceFromYaml(Resource resource, String topologyTemplateYaml,
- String yamlName, Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
- boolean shouldLock, boolean inTransaction, String nodeName) {
+ String yamlName, Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
+ boolean shouldLock, boolean inTransaction, String nodeName) {
List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
Resource createdResource;
try {
- ParsedToscaYamlInfo parsedToscaYamlInfo = csarBusinessLogic.getParsedToscaYamlInfo(topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, nodeName, resource);
+ ParsedToscaYamlInfo parsedToscaYamlInfo = csarBusinessLogic
+ .getParsedToscaYamlInfo(topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, nodeName, resource);
if (MapUtils.isEmpty(parsedToscaYamlInfo.getInstances()) && resource.getResourceType() != ResourceTypeEnum.PNF) {
throw new ComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
log.debug("#createResourceFromYaml - Going to create resource {} and RIs ", resource.getName());
createdResource = createResourceAndRIsFromYaml(yamlName, resource,
- parsedToscaYamlInfo, AuditingActionEnum.IMPORT_RESOURCE, false, createdArtifacts, topologyTemplateYaml,
- nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, shouldLock, inTransaction, nodeName);
+ parsedToscaYamlInfo, AuditingActionEnum.IMPORT_RESOURCE, false, createdArtifacts, topologyTemplateYaml,
+ nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, shouldLock, inTransaction, nodeName);
log.debug("#createResourceFromYaml - The resource {} has been created ", resource.getName());
} catch (ComponentException e) {
- ResponseFormat responseFormat = e.getResponseFormat() == null ? componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()) : e.getResponseFormat();
+ ResponseFormat responseFormat =
+ e.getResponseFormat() == null ? componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()) : e.getResponseFormat();
componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.IMPORT_RESOURCE);
throw e;
} catch (StorageException e) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(e.getStorageOperationStatus()));
+ ResponseFormat responseFormat = componentsUtils
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(e.getStorageOperationStatus()));
componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.IMPORT_RESOURCE);
throw e;
}
@@ -2333,15 +2408,15 @@ public class ServiceImportBusinessLogic{
}
protected Resource createResourceAndRIsFromYaml(String yamlName, Resource resource,
- ParsedToscaYamlInfo parsedToscaYamlInfo, AuditingActionEnum actionEnum, boolean isNormative,
- List<ArtifactDefinition> createdArtifacts, String topologyTemplateYaml,
- Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
- boolean shouldLock, boolean inTransaction, String nodeName) {
+ ParsedToscaYamlInfo parsedToscaYamlInfo, AuditingActionEnum actionEnum, boolean isNormative,
+ List<ArtifactDefinition> createdArtifacts, String topologyTemplateYaml,
+ Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate,
+ boolean shouldLock, boolean inTransaction, String nodeName) {
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
if (shouldLock) {
Either<Boolean, ResponseFormat> lockResult = serviceBusinessLogic.lockComponentByName(resource.getSystemName(), resource,
- CREATE_RESOURCE);
+ CREATE_RESOURCE);
if (lockResult.isRight()) {
serviceImportParseLogic.rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ComponentException(lockResult.right().value());
@@ -2352,25 +2427,26 @@ public class ServiceImportBusinessLogic{
log.trace("************* createResourceFromYaml before full create resource {}", yamlName);
Resource genericResource = serviceBusinessLogic.fetchAndSetDerivedFromGenericType(resource);
resource = createResourceTransaction(resource,
- csarInfo.getModifier(), isNormative);
+ csarInfo.getModifier(), isNormative);
log.trace("************* Going to add inputs from yaml {}", yamlName);
Map<String, Object> yamlMap = ImportUtils.loadYamlAsStrictMap(csarInfo.getMainTemplateContent());
Map<String, Object> metadata = (Map<String, Object>) yamlMap.get("metadata");
String type = (String) metadata.get("type");
- if (resource.shouldGenerateInputs() && !"Service".equalsIgnoreCase(type))
+ if (resource.shouldGenerateInputs() && !"Service".equalsIgnoreCase(type)) {
serviceBusinessLogic.generateAndAddInputsFromGenericTypeProperties(resource, genericResource);
+ }
Map<String, InputDefinition> inputs = parsedToscaYamlInfo.getInputs();
resource = serviceImportParseLogic.createInputsOnResource(resource, inputs);
Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap = parsedToscaYamlInfo
- .getInstances();
+ .getInstances();
resource = createRIAndRelationsFromYaml(yamlName, resource, uploadComponentInstanceInfoMap,
- topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
- nodeTypesArtifactsToCreate, nodeName);
+ topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
+ nodeTypesArtifactsToCreate, nodeName);
log.trace("************* Finished to create nodes, RI and Relation from yaml {}", yamlName);
// validate update vf module group names
Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes = serviceBusinessLogic.groupBusinessLogic
- .validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), resource.getSystemName());
+ .validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), resource.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
serviceImportParseLogic.rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ComponentException(validateUpdateVfGroupNamesRes.right().value());
@@ -2385,7 +2461,7 @@ public class ServiceImportBusinessLogic{
}
Either<Resource, ResponseFormat> createGroupsOnResource = createGroupsOnResource(resource,
- groups);
+ groups);
if (createGroupsOnResource.isRight()) {
serviceImportParseLogic.rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ComponentException(createGroupsOnResource.right().value());
@@ -2396,8 +2472,8 @@ public class ServiceImportBusinessLogic{
NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(nodeName, nodeTypesArtifactsToCreate);
Either<Resource, ResponseFormat> createArtifactsEither = createOrUpdateArtifacts(
- ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, createdArtifacts, yamlName,
- csarInfo, resource, nodeTypeInfoToUpdateArtifacts, inTransaction, shouldLock);
+ ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, createdArtifacts, yamlName,
+ csarInfo, resource, nodeTypeInfoToUpdateArtifacts, inTransaction, shouldLock);
if (createArtifactsEither.isRight()) {
serviceImportParseLogic.rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ComponentException(createArtifactsEither.right().value());
@@ -2416,20 +2492,21 @@ public class ServiceImportBusinessLogic{
serviceBusinessLogic.janusGraphDao.commit();
}
if (shouldLock) {
- serviceBusinessLogic.graphLockOperation.unlockComponentByName(resource.getSystemName(), resource.getUniqueId(), NodeTypeEnum.Resource);
+ serviceBusinessLogic.graphLockOperation
+ .unlockComponentByName(resource.getSystemName(), resource.getUniqueId(), NodeTypeEnum.Resource);
}
}
}
protected Either<Resource, ResponseFormat> createGroupsOnResource(Resource resource,
- Map<String, GroupDefinition> groups) {
+ Map<String, GroupDefinition> groups) {
if (groups != null && !groups.isEmpty()) {
List<GroupDefinition> groupsAsList = updateGroupsMembersUsingResource(
- groups, resource);
+ groups, resource);
serviceImportParseLogic.handleGroupsProperties(resource, groups);
serviceImportParseLogic.fillGroupsFinalFields(groupsAsList);
Either<List<GroupDefinition>, ResponseFormat> createGroups = serviceBusinessLogic.groupBusinessLogic.createGroups(resource,
- groupsAsList, true);
+ groupsAsList, true);
if (createGroups.isRight()) {
return Either.right(createGroups.right().value());
}
@@ -2437,10 +2514,10 @@ public class ServiceImportBusinessLogic{
return Either.left(resource);
}
Either<Resource, StorageOperationStatus> updatedResource = toscaOperationFacade
- .getToscaElement(resource.getUniqueId());
+ .getToscaElement(resource.getUniqueId());
if (updatedResource.isRight()) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource);
+ componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource);
return Either.right(responseFormat);
}
return Either.left(updatedResource.left().value());
@@ -2470,22 +2547,23 @@ public class ServiceImportBusinessLogic{
return result;
}
- protected void updateGroupMembers(Map<String, GroupDefinition> groups, GroupDefinition updatedGroupDefinition, Resource component, List<ComponentInstance> componentInstances, String groupName, Map<String, String> members) {
+ protected void updateGroupMembers(Map<String, GroupDefinition> groups, GroupDefinition updatedGroupDefinition, Resource component,
+ List<ComponentInstance> componentInstances, String groupName, Map<String, String> members) {
Set<String> compInstancesNames = members.keySet();
if (CollectionUtils.isEmpty(componentInstances)) {
String membersAstString = compInstancesNames.stream().collect(joining(","));
log.debug("The members: {}, in group: {}, cannot be found in component {}. There are no component instances.",
- membersAstString, groupName, component.getNormalizedName());
+ membersAstString, groupName, component.getNormalizedName());
throw new ComponentException(componentsUtils.getResponseFormat(
- ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
- component.getNormalizedName(), serviceImportParseLogic.getComponentTypeForResponse(component)));
+ ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
+ component.getNormalizedName(), serviceImportParseLogic.getComponentTypeForResponse(component)));
}
Map<String, String> memberNames = componentInstances.stream()
- .collect(toMap(ComponentInstance::getName, ComponentInstance::getUniqueId));
+ .collect(toMap(ComponentInstance::getName, ComponentInstance::getUniqueId));
memberNames.putAll(groups.keySet().stream().collect(toMap(g -> g, g -> "")));
Map<String, String> relevantInstances = memberNames.entrySet().stream()
- .filter(n -> compInstancesNames.contains(n.getKey()))
- .collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
+ .filter(n -> compInstancesNames.contains(n.getKey()))
+ .collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
if (relevantInstances == null || relevantInstances.size() != compInstancesNames.size()) {
List<String> foundMembers = new ArrayList<>();
@@ -2495,25 +2573,25 @@ public class ServiceImportBusinessLogic{
compInstancesNames.removeAll(foundMembers);
String membersAstString = compInstancesNames.stream().collect(joining(","));
throw new ComponentException(componentsUtils.getResponseFormat(
- ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
- component.getNormalizedName(), serviceImportParseLogic.getComponentTypeForResponse(component)));
+ ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
+ component.getNormalizedName(), serviceImportParseLogic.getComponentTypeForResponse(component)));
}
updatedGroupDefinition.setMembers(relevantInstances);
}
protected Resource createResourceTransaction(Resource resource, User user,
- boolean isNormative) {
+ boolean isNormative) {
Either<Boolean, StorageOperationStatus> eitherValidation = toscaOperationFacade.validateComponentNameExists(
- resource.getName(), resource.getResourceType(), resource.getComponentType());
+ resource.getName(), resource.getResourceType(), resource.getComponentType());
if (eitherValidation.isRight()) {
ResponseFormat errorResponse = componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(eitherValidation.right().value()));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(eitherValidation.right().value()));
throw new ComponentException(errorResponse);
}
if (eitherValidation.left().value()) {
log.debug("resource with name: {}, already exists", resource.getName());
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_NAME_ALREADY_EXIST,
- ComponentTypeEnum.RESOURCE.getValue(), resource.getName());
+ ComponentTypeEnum.RESOURCE.getValue(), resource.getName());
throw new ComponentException(errorResponse);
}
log.debug("send resource {} to dao for create", resource.getName());
@@ -2528,36 +2606,37 @@ public class ServiceImportBusinessLogic{
}
}
return toscaOperationFacade.createToscaComponent(resource)
- .left()
- .on(r -> serviceImportParseLogic.throwComponentExceptionByResource(r, resource));
+ .left()
+ .on(r -> serviceImportParseLogic.throwComponentExceptionByResource(r, resource));
}
protected ImmutablePair<Resource, ActionStatus> updateExistingResourceByImport(
- Resource newResource, Resource oldResource, User user, boolean inTransaction, boolean needLock,
- boolean isNested) {
+ Resource newResource, Resource oldResource, User user, boolean inTransaction, boolean needLock,
+ boolean isNested) {
String lockedResourceId = oldResource.getUniqueId();
log.debug("found resource: name={}, id={}, version={}, state={}", oldResource.getName(), lockedResourceId,
- oldResource.getVersion(), oldResource.getLifecycleState());
+ oldResource.getVersion(), oldResource.getLifecycleState());
ImmutablePair<Resource, ActionStatus> resourcePair = null;
try {
serviceBusinessLogic.lockComponent(lockedResourceId, oldResource, needLock, "Update Resource by Import");
oldResource = serviceImportParseLogic
- .prepareResourceForUpdate(oldResource, newResource, user, inTransaction, false);
+ .prepareResourceForUpdate(oldResource, newResource, user, inTransaction, false);
serviceImportParseLogic.mergeOldResourceMetadataWithNew(oldResource, newResource);
serviceImportParseLogic.validateResourceFieldsBeforeUpdate(oldResource, newResource, inTransaction, isNested);
serviceImportParseLogic
- .validateCapabilityTypesCreate(user, serviceImportParseLogic.getCapabilityTypeOperation(), newResource, AuditingActionEnum.IMPORT_RESOURCE, inTransaction);
+ .validateCapabilityTypesCreate(user, serviceImportParseLogic.getCapabilityTypeOperation(), newResource,
+ AuditingActionEnum.IMPORT_RESOURCE, inTransaction);
createNewResourceToOldResource(newResource, oldResource, user);
Either<Resource, StorageOperationStatus> overrideResource = toscaOperationFacade
- .overrideComponent(newResource, oldResource);
+ .overrideComponent(newResource, oldResource);
if (overrideResource.isRight()) {
ResponseFormat responseFormat = new ResponseFormat();
serviceBusinessLogic.throwComponentException(responseFormat);
}
log.debug("Resource updated successfully!!!");
resourcePair = new ImmutablePair<>(overrideResource.left().value(),
- ActionStatus.OK);
+ ActionStatus.OK);
return resourcePair;
} finally {
if (resourcePair == null) {
@@ -2609,52 +2688,58 @@ public class ServiceImportBusinessLogic{
}
}
- protected Map<String, Resource> createResourcesFromYamlNodeTypesList(String yamlName, Service service, Map<String, Object> mappedToscaTemplate, boolean needLock,
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo,
- CsarInfo csarInfo) {
+ protected Map<String, Resource> createResourcesFromYamlNodeTypesList(String yamlName, Service service, Map<String, Object> mappedToscaTemplate,
+ boolean needLock,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ Map<String, NodeTypeInfo> nodeTypesInfo,
+ CsarInfo csarInfo) {
try {
Either<String, ImportUtils.ResultStatusEnum> toscaVersion = findFirstToscaStringElement(mappedToscaTemplate,
- TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
+ TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
if (toscaVersion.isRight()) {
throw new ComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE);
}
Map<String, Object> mapToConvert = new HashMap<>();
mapToConvert.put(TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION.getElementName(), toscaVersion.left().value());
Map<String, Object> nodeTypes = serviceImportParseLogic.getNodeTypesFromTemplate(mappedToscaTemplate);
- createNodeTypes(yamlName, service, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, mapToConvert, nodeTypes);
+ createNodeTypes(yamlName, service, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
+ mapToConvert, nodeTypes);
return csarInfo.getCreatedNodes();
} catch (Exception e) {
- log.debug("Exception occured when createResourcesFromYamlNodeTypesList,error is:{}",e.getMessage(),e);
- throw new ComponentException(ActionStatus.GENERAL_ERROR);
+ log.debug("Exception occured when createResourcesFromYamlNodeTypesList,error is:{}", e.getMessage(), e);
+ throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
}
- protected void createNodeTypes(String yamlName, Service service, boolean needLock, Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo, Map<String, Object> mapToConvert, Map<String, Object> nodeTypes) {
+ protected void createNodeTypes(String yamlName, Service service, boolean needLock,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
+ Map<String, Object> mapToConvert, Map<String, Object> nodeTypes) {
Iterator<Map.Entry<String, Object>> nodesNameValueIter = nodeTypes.entrySet().iterator();
Resource vfcCreated = null;
while (nodesNameValueIter.hasNext()) {
Map.Entry<String, Object> nodeType = nodesNameValueIter.next();
Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle = nodeTypesArtifactsToHandle == null
- || nodeTypesArtifactsToHandle.isEmpty() ? null
- : nodeTypesArtifactsToHandle.get(nodeType.getKey());
+ || nodeTypesArtifactsToHandle.isEmpty() ? null
+ : nodeTypesArtifactsToHandle.get(nodeType.getKey());
if (nodeTypesInfo.containsKey(nodeType.getKey())) {
vfcCreated = handleNestedVfc(service,
- nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
- nodeType.getKey());
+ nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
+ nodeType.getKey());
log.trace("************* Finished to handle nested vfc {}", nodeType.getKey());
} else if (csarInfo.getCreatedNodesToscaResourceNames() != null
- && !csarInfo.getCreatedNodesToscaResourceNames().containsKey(nodeType.getKey())) {
+ && !csarInfo.getCreatedNodesToscaResourceNames().containsKey(nodeType.getKey())) {
ImmutablePair<Resource, ActionStatus> resourceCreated = serviceImportParseLogic
- .createNodeTypeResourceFromYaml(yamlName, nodeType, csarInfo.getModifier(), mapToConvert,
- service, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, true,
- csarInfo, true);
+ .createNodeTypeResourceFromYaml(yamlName, nodeType, csarInfo.getModifier(), mapToConvert,
+ service, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, true,
+ csarInfo, true);
log.debug("************* Finished to create node {}", nodeType.getKey());
vfcCreated = resourceCreated.getLeft();
csarInfo.getCreatedNodesToscaResourceNames().put(nodeType.getKey(),
- vfcCreated.getName());
+ vfcCreated.getName());
}
if (vfcCreated != null) {
csarInfo.getCreatedNodes().put(nodeType.getKey(), vfcCreated);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
index cf70d39743..a86d6047d4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
@@ -2260,7 +2260,7 @@ public class ServiceImportParseLogic {
}
}
- public void associateInstAttributeToComponentToInstances(String yamlName, Resource resource, Map<String, List<AttributeDataDefinition>> instAttributes) {
+ public void associateInstAttributeToComponentToInstances(String yamlName, Resource resource, Map<String, List<AttributeDefinition>> instAttributes) {
StorageOperationStatus addArtToInst;
addArtToInst = toscaOperationFacade.associateInstAttributeToComponentToInstances(instAttributes,
@@ -2375,7 +2375,7 @@ public class ServiceImportParseLogic {
}
}
- public void associateInstAttributeToComponentToInstances(String yamlName, Service resource, Map<String, List<AttributeDataDefinition>> instAttributes) {
+ public void associateInstAttributeToComponentToInstances(String yamlName, Service resource, Map<String, List<AttributeDefinition>> instAttributes) {
StorageOperationStatus addArtToInst;
addArtToInst = toscaOperationFacade.associateInstAttributeToComponentToInstances(instAttributes,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogic.java
index ee01aa0801..888ad2b71c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceMergeDataBusinessLogic.java
@@ -102,7 +102,7 @@ public class ComponentInstanceMergeDataBusinessLogic {
filter.setIgnoreCapabilities(false);
filter.setIgnoreCapabiltyProperties(false);
filter.setIgnoreArtifacts(false);
- filter.setIgnoreForwardingPath(false);
+ filter.setIgnoreServicePath(false);
filter.setIgnoreComponentInstancesInterfaces(false);
return toscaOperationFacade.getToscaElement(containerComponentId, filter);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/path/ForwardingPathValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/path/ForwardingPathValidator.java
index 9d1167a8c1..9150e5e91e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/path/ForwardingPathValidator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/path/ForwardingPathValidator.java
@@ -114,7 +114,7 @@ public class ForwardingPathValidator {
boolean isUpdate, ResponseFormatManager responseFormatManager) {
boolean isPathNameUnique = false;
ComponentParametersView filter = new ComponentParametersView(true);
- filter.setIgnoreForwardingPath(false);
+ filter.setIgnoreServicePath(false);
Either<Service, StorageOperationStatus> forwardingPathOrigin = toscaOperationFacade
.getToscaElement(serviceId, filter);
if (forwardingPathOrigin.isRight()){
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
index 494ec9c6e8..6e23454a62 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
@@ -138,6 +138,9 @@ public class UiComponentDataConverter {
case PROPERTIES:
setProperties(dataTransfer, component);
break;
+ case ATTRIBUTES:
+ setAttributes(dataTransfer, component);
+ break;
case INTERFACES:
setInterfaces(dataTransfer, component);
break;
@@ -308,6 +311,14 @@ public class UiComponentDataConverter {
}
}
+ private void setAttributes(final UiComponentDataTransfer dataTransfer, final Component component) {
+ if (component.getAttributes() == null) {
+ dataTransfer.setAttributes(new ArrayList<>());
+ } else {
+ dataTransfer.setAttributes(component.getAttributes());
+ }
+ }
+
private void setInterfaces(UiComponentDataTransfer dataTransfer, Component component) {
if (component.getInterfaces() == null) {
dataTransfer.setInterfaces(new HashMap<>());
@@ -385,7 +396,7 @@ public class UiComponentDataConverter {
final SubstitutionFilterConverter substitutionFilterConverter = new SubstitutionFilterConverter();
final Map<String, UINodeFilter> filterUiMap = new HashMap<>();
filterUiMap.put(resource.getUniqueId(),
- substitutionFilterConverter.convertToUi(resource.getSubstitutionFilter()));
+ substitutionFilterConverter.convertToUi(resource.getSubstitutionFilter()));
dataTransfer.setSubstitutionFilterForTopologyTemplate(filterUiMap);
}
break;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
index b4b2c15dcb..a1500a4204 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
@@ -7,9 +7,9 @@
* 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.
@@ -58,6 +58,7 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.Constants;
@@ -69,9 +70,8 @@ import org.springframework.stereotype.Controller;
/**
* Web Servlet for actions on Attributes
- *
- * @author mshitrit
*
+ * @author mshitrit
*/
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
@@ -79,13 +79,15 @@ import org.springframework.stereotype.Controller;
@Server(url = "/sdc2/rest")
@Controller
public class AttributeServlet extends AbstractValidationsServlet {
+
private static final Logger log = Logger.getLogger(AttributeServlet.class);
private static final String ATTRIBUTE_CONTENT_IS_INVALID = "Attribute content is invalid - {}";
+
@Inject
public AttributeServlet(UserBusinessLogic userBusinessLogic,
- ComponentInstanceBusinessLogic componentInstanceBL,
- ComponentsUtils componentsUtils, ServletUtils servletUtils,
- ResourceImportManager resourceImportManager) {
+ ComponentInstanceBusinessLogic componentInstanceBL,
+ ComponentsUtils componentsUtils, ServletUtils servletUtils,
+ ResourceImportManager resourceImportManager) {
super(userBusinessLogic, componentInstanceBL, componentsUtils, servletUtils, resourceImportManager);
}
@@ -103,18 +105,19 @@ public class AttributeServlet extends AbstractValidationsServlet {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Create Resource Attribute", method = "POST",
- summary = "Returns created resource attribute", responses = {
- @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
- @ApiResponse(responseCode = "201", description = "Resource property created"),
- @ApiResponse(responseCode = "403", description = "Restricted operation"),
- @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
- @ApiResponse(responseCode = "409", description = "Resource attribute already exist")})
+ summary = "Returns created resource attribute", responses = {
+ @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
+ @ApiResponse(responseCode = "201", description = "Resource property created"),
+ @ApiResponse(responseCode = "403", description = "Restricted operation"),
+ @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
+ @ApiResponse(responseCode = "409", description = "Resource attribute already exist")})
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response createAttribute(
- @Parameter(description = "resource id to update with new attribute",
- required = true) @PathParam("resourceId") final String resourceId,
- @Parameter(description = "Resource attribute to be created", required = true) String data,
- @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) throws IOException {
+ @Parameter(description = "resource id to update with new attribute",
+ required = true) @PathParam("resourceId") final String resourceId,
+ @Parameter(description = "Resource attribute to be created", required = true) String data,
+ @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId)
+ throws IOException {
ServletContext context = request.getSession().getServletContext();
@@ -123,12 +126,11 @@ public class AttributeServlet extends AbstractValidationsServlet {
try {
final Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
- AttributeDataDefinition attributeDataDefinition = convertJsonToObject(data, errorWrapper);
+ AttributeDefinition attributeDataDefinition = convertJsonToObject(data, errorWrapper);
if (errorWrapper.isEmpty()) {
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<AttributeDataDefinition, ResponseFormat> createAttribute = businessLogic
- .createAttribute(resourceId, attributeDataDefinition, userId);
+ Either<AttributeDefinition, ResponseFormat> createAttribute = businessLogic.createAttribute(resourceId, attributeDataDefinition, userId);
if (createAttribute.isRight()) {
errorWrapper.setInnerElement(createAttribute.right().value());
} else {
@@ -136,18 +138,15 @@ public class AttributeServlet extends AbstractValidationsServlet {
}
}
- Response response;
if (!errorWrapper.isEmpty()) {
log.info("Failed to create Attribute. Reason - ", errorWrapper.getInnerElement());
- response = buildErrorResponse(errorWrapper.getInnerElement());
+ return buildErrorResponse(errorWrapper.getInnerElement());
} else {
log.debug("Attribute {} created successfully with id {}", attributeDataDefinition.getName(), attributeDataDefinition.getUniqueId());
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.CREATED);
- response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(attributeDataDefinition));
+ return buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(attributeDataDefinition));
}
- return response;
-
} catch (Exception e) {
BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Create Attribute");
log.debug("create property failed with exception", e);
@@ -170,19 +169,20 @@ public class AttributeServlet extends AbstractValidationsServlet {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Update Resource Attribute", method = "PUT", summary = "Returns updated attribute",
- responses = {@ApiResponse(
- content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
- @ApiResponse(responseCode = "200", description = "Resource attribute updated"),
- @ApiResponse(responseCode = "403", description = "Restricted operation"),
- @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")})
+ responses = {@ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
+ @ApiResponse(responseCode = "200", description = "Resource attribute updated"),
+ @ApiResponse(responseCode = "403", description = "Restricted operation"),
+ @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")})
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response updateAttribute(
- @Parameter(description = "resource id to update with new attribute",
- required = true) @PathParam("resourceId") final String resourceId,
- @Parameter(description = "attribute id to update",
- required = true) @PathParam("attributeId") final String attributeId,
- @Parameter(description = "Resource attribute to update", required = true) String data,
- @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) throws IOException {
+ @Parameter(description = "resource id to update with new attribute",
+ required = true) @PathParam("resourceId") final String resourceId,
+ @Parameter(description = "attribute id to update",
+ required = true) @PathParam("attributeId") final String attributeId,
+ @Parameter(description = "Resource attribute to update", required = true) String data,
+ @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId)
+ throws IOException {
ServletContext context = request.getSession().getServletContext();
@@ -196,11 +196,11 @@ public class AttributeServlet extends AbstractValidationsServlet {
try {
final Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
- AttributeDataDefinition attributeDataDefinition = convertJsonToObject(data, errorWrapper);
+ AttributeDefinition attributeDataDefinition = convertJsonToObject(data, errorWrapper);
if (errorWrapper.isEmpty()) {
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<AttributeDataDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic
- .updateAttribute(resourceId, attributeId, attributeDataDefinition, userId);
+ Either<AttributeDefinition, ResponseFormat> eitherUpdateAttribute
+ = businessLogic.updateAttribute(resourceId, attributeId, attributeDataDefinition, userId);
if (eitherUpdateAttribute.isRight()) {
errorWrapper.setInnerElement(eitherUpdateAttribute.right().value());
} else {
@@ -208,18 +208,15 @@ public class AttributeServlet extends AbstractValidationsServlet {
}
}
- Response response;
if (!errorWrapper.isEmpty()) {
log.info("Failed to update Attribute. Reason - ", errorWrapper.getInnerElement());
- response = buildErrorResponse(errorWrapper.getInnerElement());
+ return buildErrorResponse(errorWrapper.getInnerElement());
} else {
log.debug("Attribute id {} updated successfully ", attributeDataDefinition.getUniqueId());
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
- response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(attributeDataDefinition));
+ return buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(attributeDataDefinition));
}
- return response;
-
} catch (Exception e) {
BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Update Attribute");
log.debug("update attribute failed with exception", e);
@@ -241,19 +238,20 @@ public class AttributeServlet extends AbstractValidationsServlet {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Create Resource Attribute", method = "DELETE", summary = "Returns deleted attribute",
- responses = {@ApiResponse(
- content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
- @ApiResponse(responseCode = "204", description = "deleted attribute"),
- @ApiResponse(responseCode = "403", description = "Restricted operation"),
- @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
- @ApiResponse(responseCode = "404", description = "Resource property not found")})
+ responses = {@ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
+ @ApiResponse(responseCode = "204", description = "deleted attribute"),
+ @ApiResponse(responseCode = "403", description = "Restricted operation"),
+ @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
+ @ApiResponse(responseCode = "404", description = "Resource property not found")})
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response deleteAttribute(
- @Parameter(description = "resource id of attribute",
- required = true) @PathParam("resourceId") final String resourceId,
- @Parameter(description = "Attribute id to delete",
- required = true) @PathParam("attributeId") final String attributeId,
- @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) throws IOException {
+ @Parameter(description = "resource id of attribute",
+ required = true) @PathParam("resourceId") final String resourceId,
+ @Parameter(description = "Attribute id to delete",
+ required = true) @PathParam("attributeId") final String attributeId,
+ @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId)
+ throws IOException {
ServletContext context = request.getSession().getServletContext();
@@ -263,13 +261,15 @@ public class AttributeServlet extends AbstractValidationsServlet {
try {
// delete the property
- AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<AttributeDataDefinition, ResponseFormat> eitherAttribute = businessLogic.deleteAttribute(resourceId, attributeId, userId);
+ AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context,
+ () -> AttributeBusinessLogic.class);
+ Either<AttributeDefinition, ResponseFormat> eitherAttribute = businessLogic
+ .deleteAttribute(resourceId, attributeId, userId);
if (eitherAttribute.isRight()) {
log.debug("Failed to delete Attribute. Reason - ", eitherAttribute.right().value());
return buildErrorResponse(eitherAttribute.right().value());
}
- AttributeDataDefinition attributeDefinition = eitherAttribute.left().value();
+ AttributeDefinition attributeDefinition = eitherAttribute.left().value();
String name = attributeDefinition.getName();
log.debug("Attribute {} deleted successfully with id {}", name, attributeDefinition.getUniqueId());
@@ -284,7 +284,7 @@ public class AttributeServlet extends AbstractValidationsServlet {
}
private void buildAttributeFromString(String data, Wrapper<AttributeDataDefinition> attributesWrapper,
- Wrapper<ResponseFormat> errorWrapper) {
+ Wrapper<ResponseFormat> errorWrapper) {
try {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
final AttributeDataDefinition attribute = gson.fromJson(data, AttributeDataDefinition.class);
@@ -304,12 +304,12 @@ public class AttributeServlet extends AbstractValidationsServlet {
}
}
- private AttributeDataDefinition convertJsonToObject(final String data,
- final Wrapper<ResponseFormat> errorWrapper) {
+ private AttributeDefinition convertJsonToObject(final String data,
+ final Wrapper<ResponseFormat> errorWrapper) {
final ObjectMapper mapper = new ObjectMapper();
try {
- return mapper.readValue(data, AttributeDataDefinition.class);
+ return mapper.readValue(data, AttributeDefinition.class);
} catch (final IOException e) {
log.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, ATTRIBUTE_CONTENT_IS_INVALID, data);
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentAttributeServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentAttributeServlet.java
new file mode 100644
index 0000000000..19df0e2cc6
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentAttributeServlet.java
@@ -0,0 +1,142 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.servlets;
+
+import com.jcabi.aspects.Loggable;
+import fj.data.Either;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.servers.Server;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import java.util.List;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.openecomp.sdc.be.components.impl.AttributeBusinessLogic;
+import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
+import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
+import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
+@Path("/v1/catalog")
+@Tag(name = "SDC Internal APIs")
+@Server(url = "/sdc2/rest")
+@Singleton
+public class ComponentAttributeServlet extends BeGenericServlet {
+
+ private final AttributeBusinessLogic attributeBusinessLogic;
+
+ @Inject
+ public ComponentAttributeServlet(final UserBusinessLogic userBusinessLogic,
+ final ComponentsUtils componentsUtils,
+ final AttributeBusinessLogic attributeBusinessLogic) {
+ super(userBusinessLogic, componentsUtils);
+ this.attributeBusinessLogic = attributeBusinessLogic;
+ }
+
+ private static final Logger log = LoggerFactory.getLogger(ComponentAttributeServlet.class);
+ private static final String CREATE_ATTRIBUTE = "Create Attribute";
+ private static final String DEBUG_MESSAGE = "Start handle request of {} modifier id is {}";
+
+ @GET
+ @Path("services/{serviceId}/attributes")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Operation(description = "Get Service Attribute", method = "GET", summary = "Returns attribute list of service",
+ responses = {@ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
+ @ApiResponse(responseCode = "200", description = "attribute"),
+ @ApiResponse(responseCode = "403", description = "Restricted operation"),
+ @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
+ @ApiResponse(responseCode = "404", description = "Service attribute not found")})
+ @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
+ public Response getAttributeListInService(
+ @Parameter(description = "service id of attribute",
+ required = true) @PathParam("serviceId") final String serviceId,
+ @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) final String userId) {
+
+ return getAttributeList(serviceId, request, userId);
+ }
+
+ @GET
+ @Path("resources/{resourceId}/attributes")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Operation(description = "Get Resource Attribute", method = "GET", summary = "Returns attribute list of resource",
+ responses = {@ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
+ @ApiResponse(responseCode = "200", description = "attribute"),
+ @ApiResponse(responseCode = "403", description = "Restricted operation"),
+ @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
+ @ApiResponse(responseCode = "404", description = "Resource attribute not found")})
+ @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
+ public Response getAttributeListInResource(
+ @Parameter(description = "resource id of attribute",
+ required = true) @PathParam("resourceId") final String resourceId,
+ @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) final String userId) {
+
+ return getAttributeList(resourceId, request, userId);
+ }
+
+ private Response getAttributeList(final String componentId, final HttpServletRequest request, final String userId) {
+
+ final String url = request.getMethod() + " " + request.getRequestURI();
+ log.debug(DEBUG_MESSAGE, url, userId);
+
+ try {
+ final Either<List<AttributeDefinition>, ResponseFormat> attributesList =
+ attributeBusinessLogic.getAttributesList(componentId, userId);
+
+ if (attributesList.isRight()) {
+ return buildErrorResponse(attributesList.right().value());
+ }
+
+ return buildOkResponse(attributesList.left().value());
+
+ } catch (final Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError(CREATE_ATTRIBUTE);
+ log.debug("get attribute failed with exception", e);
+ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
+ }
+ }
+
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java
index c5c89f7665..245ebc1bb8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java
@@ -86,6 +86,7 @@ import org.openecomp.sdc.be.impl.ServletUtils;
import org.openecomp.sdc.be.info.CreateAndAssotiateInfo;
import org.openecomp.sdc.be.info.GroupDefinitionInfo;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.PropertyConstraint;
@@ -1004,6 +1005,30 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet {
return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), componentInstancePropertiesById);
}
+ @GET
+ @Path("/{containerComponentType}/{containerComponentId}/componentInstances/{componentInstanceUniqueId}/attributes")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Operation(description = "Get component instance attributes", method = "GET",
+ summary = "Returns component instance attributes", responses = {
+ @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
+ @ApiResponse(responseCode = "200", description = "Attributes found"),
+ @ApiResponse(responseCode = "403", description = "Restricted operation"),
+ @ApiResponse(responseCode = "404", description = "Component/Component Instance - not found")})
+ @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
+ public Response getInstanceAttributesById(@PathParam("containerComponentType") final String containerComponentType,
+ @PathParam("containerComponentId") final String containerComponentId,
+ @PathParam("componentInstanceUniqueId") final String componentInstanceUniqueId,
+ @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) final String userId) {
+
+ final String url = request.getMethod() + " " + request.getRequestURI();
+ log.debug(GET_START_HANDLE_REQUEST_OF, url);
+
+ final List<ComponentInstanceAttribute> componentInstanceAttributesById = componentInstanceBusinessLogic
+ .getComponentInstanceAttributesById(containerComponentType, containerComponentId, componentInstanceUniqueId, userId);
+ return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), componentInstanceAttributesById);
+ }
+
// US330353
@GET
@Path("/{containerComponentType}/{containerComponentId}/componentInstances/{componentInstanceUniqueId}/capability/{capabilityType}/capabilityName/{capabilityName}/ownerId/{ownerId}/properties")
@@ -1385,6 +1410,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet {
return convertStatus.left().value();
}
+ @Override
public <T> Either<T, ActionStatus> convertJsonToObject(String data, Class<T> clazz) {
try {
log.trace("convert json to object. json=\n {}", data);
@@ -1673,7 +1699,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet {
ReplaceVNFInfo replaceVNFInfo = convertResponse.left().value();
String serviceUniqueId = replaceVNFInfo.getServiceUniqueId();
String abstractResourceUniqueId = replaceVNFInfo.getAbstractResourceUniqueId();
-
+
ComponentInstance componentInstance = replaceVNFInfo.getRealVNFComponentInstance();
log.debug("replaceVNF:get ReplaceVNFInfo,serviceUniqueId:{},abstractResourceUniqueId:{}",
serviceUniqueId,abstractResourceUniqueId);
@@ -1681,7 +1707,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet {
/**
* delete vnf
*/
- ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
if (componentInstanceBusinessLogic == null) {
log.debug("replaceVNF:Unsupported component type {}", containerComponentType);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/OutputsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/OutputsServlet.java
new file mode 100644
index 0000000000..16e6d79879
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/OutputsServlet.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021, Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.servlets;
+
+import com.jcabi.aspects.Loggable;
+import fj.data.Either;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.servers.Server;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import java.io.IOException;
+import java.util.List;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
+import org.openecomp.sdc.be.components.impl.OutputsBusinessLogic;
+import org.openecomp.sdc.be.components.impl.ResourceImportManager;
+import org.openecomp.sdc.be.config.BeEcompErrorManager;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.impl.ComponentsUtils;
+import org.openecomp.sdc.be.impl.ServletUtils;
+import org.openecomp.sdc.be.model.ComponentInstanceOutput;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.openecomp.sdc.common.api.Constants;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.openecomp.sdc.exception.ResponseFormat;
+import org.springframework.stereotype.Controller;
+
+@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
+@Tag(name = "SDC Internal APIs")
+@Server(url = "/sdc2/rest")
+@Path("/v1/catalog")
+@Controller
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+public class OutputsServlet extends AbstractValidationsServlet {
+
+ private static final Logger log = Logger.getLogger(OutputsServlet.class);
+ private static final String START_HANDLE_REQUEST_OF = "(get) Start handle request of {}";
+
+ private final OutputsBusinessLogic outputsBusinessLogic;
+
+ @Inject
+ public OutputsServlet(final UserBusinessLogic userBusinessLogic,
+ final OutputsBusinessLogic outputsBusinessLogic,
+ final ComponentInstanceBusinessLogic componentInstanceBL,
+ final ComponentsUtils componentsUtils,
+ final ServletUtils servletUtils,
+ final ResourceImportManager resourceImportManager) {
+ super(userBusinessLogic, componentInstanceBL, componentsUtils, servletUtils, resourceImportManager);
+ this.outputsBusinessLogic = outputsBusinessLogic;
+ }
+
+ @GET
+ @Path("/{componentType}/{componentId}/componentInstances/{instanceId}/{originComponentUid}/outputs")
+ @Operation(description = "Get Outputs only", method = "GET", summary = "Returns Outputs list", responses = {
+ @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Resource.class)))),
+ @ApiResponse(responseCode = "200", description = "Component found"),
+ @ApiResponse(responseCode = "403", description = "Restricted operation"),
+ @ApiResponse(responseCode = "404", description = "Component not found")})
+ public Response getComponentInstanceOutputs(@PathParam("componentType") final String componentType,
+ @PathParam("componentId") final String componentId,
+ @PathParam("instanceId") final String instanceId,
+ @PathParam("originComponentUid") final String originComponentUid,
+ @Context final HttpServletRequest request,
+ @HeaderParam(value = Constants.USER_ID_HEADER) final String userId) throws IOException {
+
+ final String url = request.getMethod() + " " + request.getRequestURI();
+ log.debug(START_HANDLE_REQUEST_OF, url);
+
+ try {
+ final Either<List<ComponentInstanceOutput>, ResponseFormat> outputsResponse =
+ outputsBusinessLogic.getComponentInstanceOutputs(userId, componentId, instanceId);
+ if (outputsResponse.isRight()) {
+ log.debug("failed to get component instance outputs {}", componentType);
+ return buildErrorResponse(outputsResponse.right().value());
+ }
+ final Object outputs = RepresentationUtils.toRepresentation(outputsResponse.left().value());
+ return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), outputs);
+
+ } catch (final Exception e) {
+ BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get Outputs " + componentType);
+ log.debug("getOutputs failed with exception", e);
+ throw e;
+ }
+ }
+
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index b4bf4e8d42..70834fd39a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -54,7 +54,6 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.apache.commons.lang3.tuple.Triple;
-import org.onap.sdc.tosca.datatypes.model.AttributeDefinition;
import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.be.components.impl.exceptions.SdcResourceNotFoundException;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -76,6 +75,7 @@ import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.exception.ToscaExportException;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
import org.openecomp.sdc.be.model.Component;
@@ -403,10 +403,10 @@ public class ToscaExportHandler {
private void convertSubstitutionMappingFilter(final Component component,
final SubstitutionMapping substitutionMapping) {
- if(component.getSubstitutionFilter() != null
- && (component.getSubstitutionFilter().getProperties()).getListToscaDataDefinition() != null) {
+ if (component.getSubstitutionFilter() != null
+ && (component.getSubstitutionFilter().getProperties()).getListToscaDataDefinition() != null) {
substitutionMapping
- .setSubstitution_filter(convertToSubstitutionFilterComponent(component.getSubstitutionFilter()));
+ .setSubstitution_filter(convertToSubstitutionFilterComponent(component.getSubstitutionFilter()));
}
}
@@ -584,7 +584,8 @@ public class ToscaExportHandler {
final ComponentInstance componentInstance,
final Component fetchedComponent) {
componentCache.put(fetchedComponent.getUniqueId(), fetchedComponent);
- if (componentInstance.getOriginType() == OriginTypeEnum.ServiceProxy || componentInstance.getOriginType() == OriginTypeEnum.ServiceSubstitution) {
+ if (componentInstance.getOriginType() == OriginTypeEnum.ServiceProxy
+ || componentInstance.getOriginType() == OriginTypeEnum.ServiceSubstitution) {
final Either<Component, StorageOperationStatus> sourceService = toscaOperationFacade
.getToscaFullElement(componentInstance.getSourceModelUid());
if (sourceService.isRight() && (log.isDebugEnabled())) {
@@ -1071,7 +1072,7 @@ public class ToscaExportHandler {
toscaNodeType.setDerived_from(derivedFrom);
}
if (component instanceof Resource) {
- final List<AttributeDataDefinition> attributes = ((Resource) component).getAttributes();
+ final List<AttributeDefinition> attributes = ((Resource) component).getAttributes();
if (CollectionUtils.isNotEmpty(attributes)) {
final Map<String, Object> attributeDataDefinitionMap = new HashMap<>();
attributes.forEach(attributeDataDefinition ->
@@ -1083,16 +1084,16 @@ public class ToscaExportHandler {
return toscaNodeType;
}
- private void buildAttributeData(final AttributeDataDefinition originalAttributeDataDefinition,
+ private void buildAttributeData(final AttributeDefinition originalAttributeDefinition,
final Map<String, Object> attributeDataDefinitionMap) {
- attributeDataDefinitionMap.put(originalAttributeDataDefinition.getName(),
- new ObjectMapper().convertValue(new AttributeDefinition(
- originalAttributeDataDefinition.getType(),
- originalAttributeDataDefinition.getDescription(),
- originalAttributeDataDefinition.get_default(),
- originalAttributeDataDefinition.getStatus(),
- originalAttributeDataDefinition.getEntry_schema()), Object.class));
+ attributeDataDefinitionMap.put(originalAttributeDefinition.getName(),
+ new ObjectMapper().convertValue(new org.onap.sdc.tosca.datatypes.model.AttributeDefinition(
+ originalAttributeDefinition.getType(),
+ originalAttributeDefinition.getDescription(),
+ originalAttributeDefinition.get_default(),
+ originalAttributeDefinition.getStatus(),
+ originalAttributeDefinition.getEntry_schema()), Object.class));
}
private Either<Map<String, Object>, ToscaError> createProxyInterfaceTypes(Component container) {
@@ -1206,19 +1207,21 @@ public class ToscaExportHandler {
}
private void createServiceSubstitutionNodeTypes(final Map<String, Component> componentCache,
- final Component container, final ToscaTemplate toscaNode) {
+ final Component container, final ToscaTemplate toscaNode) {
final List<ComponentInstance> componentInstances = container.getComponentInstances();
if (CollectionUtils.isEmpty(componentInstances)) {
return;
}
final List<ComponentInstance> serviceSubstitutionInstanceList = componentInstances.stream()
- .filter(p -> p.getOriginType().name().equals(OriginTypeEnum.ServiceSubstitution.name()))
- .collect(Collectors.toList());
+ .filter(p -> p.getOriginType().name().equals(OriginTypeEnum.ServiceSubstitution.name()))
+ .collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(serviceSubstitutionInstanceList)) {
for (ComponentInstance inst : serviceSubstitutionInstanceList) {
- final Map<String, ToscaNodeType> nodeTypes = toscaNode.getNode_types() == null ? new HashMap<>() : toscaNode.getNode_types();
- convertInterfaceNodeType(new HashMap<>(), componentCache.get(inst.getSourceModelUid()), toscaNode, nodeTypes, true);
+ final Map<String, ToscaNodeType> nodeTypes =
+ toscaNode.getNode_types() == null ? new HashMap<>() : toscaNode.getNode_types();
+ convertInterfaceNodeType(new HashMap<>(), componentCache.get(inst.getSourceModelUid()), toscaNode,
+ nodeTypes, true);
}
}
}
@@ -1576,7 +1579,7 @@ public class ToscaExportHandler {
NodeFilter nodeFilter = new NodeFilter();
ListDataDefinition<RequirementSubstitutionFilterPropertyDataDefinition> origProperties =
- substitutionFilterDataDefinition.getProperties();
+ substitutionFilterDataDefinition.getProperties();
List<Map<String, List<Object>>> propertiesCopy = new ArrayList<>();
copySubstitutionFilterProperties(origProperties, propertiesCopy);
@@ -1658,7 +1661,8 @@ public class ToscaExportHandler {
for (final RequirementSubstitutionFilterPropertyDataDefinition propertyDataDefinition : origProperties
.getListToscaDataDefinition()) {
for (final String propertyInfoEntry : propertyDataDefinition.getConstraints()) {
- final Map<String, List<Object>> propertyValObj = new YamlUtil().yamlToObject(propertyInfoEntry, Map.class);
+ final Map<String, List<Object>> propertyValObj = new YamlUtil()
+ .yamlToObject(propertyInfoEntry, Map.class);
final String propertyName = propertyDataDefinition.getName();
if (propertyMapCopy.containsKey(propertyName)) {
addPropertyConstraintValueToList(propertyName, propertyValObj, propertyMapCopy.get(propertyName));
@@ -1887,7 +1891,7 @@ public class ToscaExportHandler {
return Collections.emptyMap();
}
return component.getOutputs().stream()
- .map(PropertyDataDefinition::getName)
+ .map(AttributeDataDefinition::getName)
.collect(
Collectors.toMap(
outputName -> outputName,
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
index 0b11b2e0cf..7b0b40cc8b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java
@@ -39,7 +39,6 @@ import org.mockito.Mockito;
import org.openecomp.sdc.be.components.validation.UserValidations;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.Component;
@@ -56,323 +55,325 @@ import org.openecomp.sdc.exception.ResponseFormat;
public class AttributeBusinessLogicTest extends BaseBusinessLogicMock {
- private AttributeBusinessLogic createTestSubject() {
- return new AttributeBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
- interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation );
- }
-
- private UserValidations userValidations = Mockito.mock(UserValidations.class);
- private ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
- private JanusGraphDao janusGraphDao = Mockito.mock(JanusGraphDao.class);
- private ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
- private ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
- private AttributeOperation attributeOperation = Mockito.mock(AttributeOperation.class);
- private Field baseBusinessLogic;
- private AttributeBusinessLogic attributeBusinessLogic=createTestSubject();
- private IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class);
-
- @Before
- public void setup() throws Exception {
- baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("graphLockOperation");
- baseBusinessLogic.setAccessible(true);
- baseBusinessLogic.set(attributeBusinessLogic, igraphLockOperation);
-
- final Field baseBusinessLogic1 = attributeBusinessLogic.getClass().getSuperclass()
- .getDeclaredField("userValidations");
- baseBusinessLogic1.setAccessible(true);
- baseBusinessLogic1.set(attributeBusinessLogic, userValidations);
-
- final Field baseBusinessLogic2 = attributeBusinessLogic.getClass().getSuperclass()
- .getDeclaredField("componentsUtils");
- baseBusinessLogic2.setAccessible(true);
- baseBusinessLogic2.set(attributeBusinessLogic, componentsUtils);
-
- final Field baseBusinessLogic3 = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("janusGraphDao");
- baseBusinessLogic3.setAccessible(true);
- baseBusinessLogic3.set(attributeBusinessLogic, janusGraphDao);
-
- baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("toscaOperationFacade");
- baseBusinessLogic.setAccessible(true);
- baseBusinessLogic.set(attributeBusinessLogic, toscaOperationFacade);
-
- baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("applicationDataTypeCache");
- baseBusinessLogic.setAccessible(true);
- baseBusinessLogic.set(attributeBusinessLogic, applicationDataTypeCache);
-
- baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("attributeOperation");
- baseBusinessLogic.setAccessible(true);
- baseBusinessLogic.set(attributeBusinessLogic, attributeOperation);
- }
-
- @Test
- public void createAttribute_lockfail() {
- Either<AttributeDataDefinition, ResponseFormat> response;
- response = attributeBusinessLogic.createAttribute("RES01", new AttributeDataDefinition(), "USR01");
- assertTrue(response.isRight());
- }
-
- @Test
- public void createAttribute_Success() {
- Component resource = new Resource();
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- resource.setIsDeleted(false);
- resource.setLastUpdaterUserId("USR01");
+ private AttributeBusinessLogic createTestSubject() {
+ return new AttributeBusinessLogic(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation,
+ interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation);
+ }
+
+ private UserValidations userValidations = Mockito.mock(UserValidations.class);
+ private ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class);
+ private JanusGraphDao janusGraphDao = Mockito.mock(JanusGraphDao.class);
+ private ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ private ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class);
+ private AttributeOperation attributeOperation = Mockito.mock(AttributeOperation.class);
+ private Field baseBusinessLogic;
+ private AttributeBusinessLogic attributeBusinessLogic = createTestSubject();
+ private IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class);
+
+ @Before
+ public void setup() throws Exception {
+ baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("graphLockOperation");
+ baseBusinessLogic.setAccessible(true);
+ baseBusinessLogic.set(attributeBusinessLogic, igraphLockOperation);
+
+ final Field baseBusinessLogic1 = attributeBusinessLogic.getClass().getSuperclass()
+ .getDeclaredField("userValidations");
+ baseBusinessLogic1.setAccessible(true);
+ baseBusinessLogic1.set(attributeBusinessLogic, userValidations);
+
+ final Field baseBusinessLogic2 = attributeBusinessLogic.getClass().getSuperclass()
+ .getDeclaredField("componentsUtils");
+ baseBusinessLogic2.setAccessible(true);
+ baseBusinessLogic2.set(attributeBusinessLogic, componentsUtils);
+
+ final Field baseBusinessLogic3 = attributeBusinessLogic.getClass().getSuperclass()
+ .getDeclaredField("janusGraphDao");
+ baseBusinessLogic3.setAccessible(true);
+ baseBusinessLogic3.set(attributeBusinessLogic, janusGraphDao);
+
+ baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("toscaOperationFacade");
+ baseBusinessLogic.setAccessible(true);
+ baseBusinessLogic.set(attributeBusinessLogic, toscaOperationFacade);
+
+ baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass()
+ .getDeclaredField("applicationDataTypeCache");
+ baseBusinessLogic.setAccessible(true);
+ baseBusinessLogic.set(attributeBusinessLogic, applicationDataTypeCache);
+
+ baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("attributeOperation");
+ baseBusinessLogic.setAccessible(true);
+ baseBusinessLogic.set(attributeBusinessLogic, attributeOperation);
+ }
+
+ @Test
+ public void createAttribute_lockfail() {
+ Either<AttributeDefinition, ResponseFormat> response;
+ response = attributeBusinessLogic.createAttribute("RES01", new AttributeDefinition(), "USR01");
+ assertTrue(response.isRight());
+ }
+
+ @Test
+ public void createAttribute_Success() {
+ Component resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ resource.setIsDeleted(false);
+ resource.setLastUpdaterUserId("USR01");
+
+ AttributeDefinition attrib = new AttributeDefinition();
+ attrib.setType(ToscaPropertyType.STRING.getType());
+
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
+
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+ AttributeDefinition attributeDataDefinition = new AttributeDefinition();
+ Either<AttributeDefinition, StorageOperationStatus> either = Either.left(attributeDataDefinition);
+ when(toscaOperationFacade.addAttributeOfResource(any(), any())).thenReturn(either);
+
+ when(attributeOperation.isAttributeTypeValid(any())).thenReturn(true);
+
+ Map<String, DataTypeDefinition> data = new HashMap<>();
+ data.put("ONE", new DataTypeDefinition());
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
+ when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+
+ when(attributeOperation.isAttributeDefaultValueValid(any(), any())).thenReturn(true);
+ Either<AttributeDefinition, ResponseFormat> response;
+
+ response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
+
+ assertTrue(response.isLeft());
+ }
- AttributeDefinition attrib = new AttributeDefinition();
- attrib.setType(ToscaPropertyType.STRING.getType());
+ @Test
+ public void createAttribute_failtogettoscaelement() throws NoSuchFieldException, IllegalAccessException {
+ Component resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ resource.setIsDeleted(false);
+ resource.setLastUpdaterUserId("USR01");
- when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
-
- Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- AttributeDataDefinition attributeDataDefinition = new AttributeDataDefinition();
- Either<AttributeDataDefinition, StorageOperationStatus> either = Either.left(attributeDataDefinition);
- when(toscaOperationFacade.addAttributeOfResource(any(), any())).thenReturn(either);
-
- when(attributeOperation.isAttributeTypeValid(any())).thenReturn(true);
-
- Map<String, DataTypeDefinition> data = new HashMap<>();
- data.put("ONE", new DataTypeDefinition());
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
- when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
-
- when(attributeOperation.isAttributeDefaultValueValid(any(), any())).thenReturn(true);
- Either<AttributeDataDefinition, ResponseFormat> response;
-
- response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- assertTrue(response.isLeft());
- }
+ Either<AttributeDefinition, ResponseFormat> response;
+ AttributeDefinition prop = new AttributeDefinition();
+
+ baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("toscaOperationFacade");
+ baseBusinessLogic.setAccessible(true);
+ baseBusinessLogic.set(attributeBusinessLogic, toscaOperationFacade);
+ Either<Component, StorageOperationStatus> toscastatus = Either.right(StorageOperationStatus.GENERAL_ERROR);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+
+ response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
- @Test
- public void createAttribute_failtogettoscaelement() throws NoSuchFieldException, IllegalAccessException {
- Component resource= new Resource();
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- resource.setIsDeleted(false);
- resource.setLastUpdaterUserId("USR01");
+ assertTrue(response.isRight());
+ }
- when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
+ @Test
+ public void createAttribute_componentvalidationfails() {
+ Component resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.CERTIFIED);
+ resource.setIsDeleted(false);
+ resource.setLastUpdaterUserId("USR02");
- Either<AttributeDataDefinition, ResponseFormat> response;
- AttributeDataDefinition prop= new AttributeDataDefinition();
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("toscaOperationFacade");
- baseBusinessLogic.setAccessible(true);
- baseBusinessLogic.set(attributeBusinessLogic, toscaOperationFacade);
- Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.GENERAL_ERROR);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
-
- response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
+ Either<AttributeDefinition, ResponseFormat> response;
+ AttributeDefinition prop = new AttributeDefinition();
- assertTrue(response.isRight());
- }
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- @Test
- public void createAttribute_componentvalidationfails() {
- Component resource= new Resource();
- resource.setLifecycleState(LifecycleStateEnum.CERTIFIED);
- resource.setIsDeleted(false);
- resource.setLastUpdaterUserId("USR02");
+ response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
- when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
+ assertTrue(response.isRight());
+ }
- Either<AttributeDataDefinition, ResponseFormat> response;
- AttributeDataDefinition prop= new AttributeDataDefinition();
+ @Test
+ public void createAttribute_componentalreadyexist_fails() {
+ Either<AttributeDefinition, ResponseFormat> response;
+ AttributeDefinition attrib = new AttributeDefinition();
+ attrib.setName("RES01");
+ attrib.setOwnerId("RES01");
- Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+ List<AttributeDefinition> attributes = new ArrayList<>();
+ attributes.add(attrib);
- response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01");
+ final Resource resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ resource.setIsDeleted(false);
+ resource.setLastUpdaterUserId("USR01");
+ resource.setAttributes(attributes);
- assertTrue(response.isRight());
- }
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- @Test
- public void createAttribute_componentalreadyexist_fails() {
- Either<AttributeDataDefinition, ResponseFormat> response;
- AttributeDefinition attrib = new AttributeDefinition();
- attrib.setName("RES01");
- attrib.setOwnerId("RES01");
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- List<AttributeDataDefinition> attributes = new ArrayList<>();
- attributes.add(attrib);
+ response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
- final Resource resource = new Resource();
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- resource.setIsDeleted(false);
- resource.setLastUpdaterUserId("USR01");
- resource.setAttributes(attributes);
+ assertTrue(response.isRight());
+ }
- when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
+ @Test
+ public void createAttribute_addresourcetostoragefails() {
- Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+ Component resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ resource.setIsDeleted(false);
+ resource.setLastUpdaterUserId("USR01");
- response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
+ IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class);
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
- assertTrue(response.isRight());
- }
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+ AttributeDefinition attributeDataDefinition = new AttributeDefinition();
+ Either<AttributeDefinition, StorageOperationStatus> either = Either
+ .right(StorageOperationStatus.CONNECTION_FAILURE);
+ when(toscaOperationFacade.addAttributeOfResource(any(), any())).thenReturn(either);
- @Test
- public void createAttribute_addresourcetostoragefails() {
+ when(attributeOperation.isAttributeTypeValid(any())).thenReturn(true);
- Component resource = new Resource();
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- resource.setIsDeleted(false);
- resource.setLastUpdaterUserId("USR01");
+ Map<String, DataTypeDefinition> data = new HashMap<>();
+ data.put("ONE", new DataTypeDefinition());
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
+ when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
- IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class);
- when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
+ when(attributeOperation.isAttributeDefaultValueValid(any(), any())).thenReturn(true);
+ Either<AttributeDefinition, ResponseFormat> response;
- Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- AttributeDataDefinition attributeDataDefinition = new AttributeDataDefinition();
- Either<AttributeDataDefinition, StorageOperationStatus> either = Either
- .right(StorageOperationStatus.CONNECTION_FAILURE);
- when(toscaOperationFacade.addAttributeOfResource(any(),any())).thenReturn(either);
+ AttributeDefinition attrib = new AttributeDefinition();
+ response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
- when(attributeOperation.isAttributeTypeValid(any())).thenReturn(true);
+ assertTrue(response.isRight());
- Map<String, DataTypeDefinition> data = new HashMap<>();
- data.put("ONE", new DataTypeDefinition());
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = Either.left(data);
- when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes);
+ }
- when(attributeOperation.isAttributeDefaultValueValid(any(),any())).thenReturn(true);
- Either<AttributeDataDefinition, ResponseFormat> response;
+ @Test
+ public void testgetAttribute_ATTRIBUTE_NOT_FOUND() {
+ Either<AttributeDefinition, ResponseFormat> result;
- AttributeDataDefinition attrib = new AttributeDefinition();
- response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01");
+ Component resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ resource.setIsDeleted(false);
+ resource.setLastUpdaterUserId("USR01");
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- assertTrue( response.isRight());
+ result = attributeBusinessLogic.getAttribute("RES01", "ATTR01", "USR01");
+ assertTrue(result.isRight());
+ }
- }
+ @Test
+ public void testgetAttribute_success() {
+ Either<AttributeDefinition, ResponseFormat> result;
- @Test
- public void testgetAttribute_ATTRIBUTE_NOT_FOUND() {
- Either<AttributeDataDefinition, ResponseFormat> result;
+ final Resource resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ resource.setIsDeleted(false);
+ resource.setLastUpdaterUserId("USR01");
- Component resource= new Resource();
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- resource.setIsDeleted(false);
- resource.setLastUpdaterUserId("USR01");
- Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+ AttributeDefinition attrib = new AttributeDefinition();
+ attrib.setUniqueId("ATTR01");
+ attrib.setOwnerId("RES01");
- result=attributeBusinessLogic.getAttribute("RES01","ATTR01", "USR01");
- assertTrue(result.isRight());
- }
-
- @Test
- public void testgetAttribute_success() {
- Either<AttributeDataDefinition, ResponseFormat> result;
-
- final Resource resource = new Resource();
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- resource.setIsDeleted(false);
- resource.setLastUpdaterUserId("USR01");
-
- AttributeDefinition attrib = new AttributeDefinition();
- attrib.setUniqueId("ATTR01");
- attrib.setOwnerId("RES01");
-
- List<AttributeDataDefinition> attr = new ArrayList<>();
- attr.add(attrib);
-
- resource.setAttributes(attr);
- Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
-
- result = attributeBusinessLogic.getAttribute("RES01", "ATTR01", "USR01");
- assertTrue( result.isLeft());
- }
-
- @Test
- public void testgetAttribute_RESOURCE_NOT_FOUND() {
- Either<AttributeDataDefinition, ResponseFormat> result;
-
- Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
-
- result=attributeBusinessLogic.getAttribute("RES01","ATTR01", "USR01");
- assertTrue(result.isRight());
- }
-
- @Test
- public void testdeleteAttribute_FAILED_TO_LOCK_COMPONENT() {
- Either<AttributeDataDefinition, ResponseFormat> result;
-
- result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
- assertTrue(result.isRight());
- }
-
- @Test
- public void testdeleteAttribute_get_RESOURCE_from_DB_failed() {
- Either<AttributeDataDefinition, ResponseFormat> result;
-
- Either<Component, StorageOperationStatus> toscastatus=Either.right(StorageOperationStatus.CONNECTION_FAILURE);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
-
- result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
- assertTrue(result.isRight());
- }
-
- @Test
- public void testdeleteAttribute_get_RESOURCE_verification_failed() {
- Either<AttributeDataDefinition, ResponseFormat> result;
- Component resource= new Resource();
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- resource.setIsDeleted(true);
- resource.setLastUpdaterUserId("USR01");
- when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
- Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
- assertTrue(result.isRight());
- }
-
- @Test
- public void testdeleteAttribute_nonexistingresource() {
- Either<AttributeDataDefinition, ResponseFormat> result;
-
-
- Component resource= new Resource();
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- resource.setIsDeleted(false);
- resource.setLastUpdaterUserId("USR01");
-
- when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK);
-
- Either<Component, StorageOperationStatus> toscastatus=Either.left(resource);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
-
- result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01");
- assertTrue(result.isRight());
- }
-
- @Test
- public void testdeleteAttribute_success() {
- Either<AttributeDataDefinition, ResponseFormat> result;
- final Resource resource = new Resource();
- resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- resource.setIsDeleted(false);
- resource.setLastUpdaterUserId("USR01");
-
- when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
-
- Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
- when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
- when(toscaOperationFacade.deleteAttributeOfResource(any(), any())).thenReturn(StorageOperationStatus.OK);
-
- AttributeDefinition attrib = new AttributeDefinition();
- attrib.setUniqueId("ATTR01");
- attrib.setOwnerId("RES01");
- List<AttributeDataDefinition> attributes = new ArrayList<>();
- attributes.add(attrib);
- resource.setAttributes(attributes);
-
- result = attributeBusinessLogic.deleteAttribute("RES01", "ATTR01", "USR01");
- assertTrue( result.isLeft());
- }
+ List<AttributeDefinition> attr = new ArrayList<>();
+ attr.add(attrib);
+
+ resource.setAttributes(attr);
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+
+ result = attributeBusinessLogic.getAttribute("RES01", "ATTR01", "USR01");
+ assertTrue(result.isLeft());
+ }
+
+ @Test
+ public void testgetAttribute_RESOURCE_NOT_FOUND() {
+ Either<AttributeDefinition, ResponseFormat> result;
+
+ Either<Component, StorageOperationStatus> toscastatus = Either
+ .right(StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+
+ result = attributeBusinessLogic.getAttribute("RES01", "ATTR01", "USR01");
+ assertTrue(result.isRight());
+ }
+
+ @Test
+ public void testdeleteAttribute_FAILED_TO_LOCK_COMPONENT() {
+ Either<AttributeDefinition, ResponseFormat> result;
+
+ result = attributeBusinessLogic.deleteAttribute("RES01", "ATTR01", "USR01");
+ assertTrue(result.isRight());
+ }
+
+ @Test
+ public void testdeleteAttribute_get_RESOURCE_from_DB_failed() {
+ Either<AttributeDefinition, ResponseFormat> result;
+
+ Either<Component, StorageOperationStatus> toscastatus = Either.right(StorageOperationStatus.CONNECTION_FAILURE);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+
+ result = attributeBusinessLogic.deleteAttribute("RES01", "ATTR01", "USR01");
+ assertTrue(result.isRight());
+ }
+
+ @Test
+ public void testdeleteAttribute_get_RESOURCE_verification_failed() {
+ Either<AttributeDefinition, ResponseFormat> result;
+ Component resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ resource.setIsDeleted(true);
+ resource.setLastUpdaterUserId("USR01");
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+ result = attributeBusinessLogic.deleteAttribute("RES01", "ATTR01", "USR01");
+ assertTrue(result.isRight());
+ }
+
+ @Test
+ public void testdeleteAttribute_nonexistingresource() {
+ Either<AttributeDefinition, ResponseFormat> result;
+
+ Component resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ resource.setIsDeleted(false);
+ resource.setLastUpdaterUserId("USR01");
+
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
+
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+
+ result = attributeBusinessLogic.deleteAttribute("RES01", "ATTR01", "USR01");
+ assertTrue(result.isRight());
+ }
+
+ @Test
+ public void testdeleteAttribute_success() {
+ Either<AttributeDefinition, ResponseFormat> result;
+ final Resource resource = new Resource();
+ resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
+ resource.setIsDeleted(false);
+ resource.setLastUpdaterUserId("USR01");
+
+ when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
+
+ Either<Component, StorageOperationStatus> toscastatus = Either.left(resource);
+ when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus);
+ when(toscaOperationFacade.deleteAttributeOfResource(any(), any())).thenReturn(StorageOperationStatus.OK);
+
+ AttributeDefinition attrib = new AttributeDefinition();
+ attrib.setUniqueId("ATTR01");
+ attrib.setOwnerId("RES01");
+ List<AttributeDefinition> attributes = new ArrayList<>();
+ attributes.add(attrib);
+ resource.setAttributes(attributes);
+
+ result = attributeBusinessLogic.deleteAttribute("RES01", "ATTR01", "USR01");
+ assertTrue(result.isLeft());
+ }
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
index c176137193..bf51f90165 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
@@ -52,7 +52,6 @@ import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -784,7 +783,7 @@ public class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicB
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
- Map<String, List< AttributeDataDefinition >> instAttributes = new HashMap<>();
+ Map<String, List< AttributeDefinition >> instAttributes = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
originCompMap.put("componentUid",originResource);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -811,7 +810,7 @@ public class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicB
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
- Map<String, List< AttributeDataDefinition >> instAttributes = new HashMap<>();
+ Map<String, List< AttributeDefinition >> instAttributes = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
originCompMap.put("componentUid",originResource);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -1144,7 +1143,7 @@ public class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicB
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
- Map<String, List< AttributeDataDefinition >> instAttributes = new HashMap<>();
+ Map<String, List< AttributeDefinition >> instAttributes = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
originCompMap.put("componentUid",originResource);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -1171,7 +1170,7 @@ public class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicB
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
- Map<String, List< AttributeDataDefinition >> instAttributes = new HashMap<>();
+ Map<String, List< AttributeDefinition >> instAttributes = new HashMap<>();
Map<String, Resource> originCompMap = new HashMap<>();
originCompMap.put("componentUid",originResource);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -2381,4 +2380,4 @@ public class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicB
assertThat(expectedResponse.getStatus()).isEqualTo(actualResponse.getStatus());
assertThat(expectedResponse.getFormattedMessage()).isEqualTo(actualResponse.getFormattedMessage());
}
-} \ No newline at end of file
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
index ce57ff103a..8b291e60a0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
@@ -17,12 +17,9 @@
package org.openecomp.sdc.be.components.impl;
import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
-import static org.openecomp.sdc.be.auditing.impl.AuditTestUtils.RESOURCE_NAME;
import fj.data.Either;
import java.io.IOException;
@@ -31,17 +28,16 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-
+import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.MutablePair;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -49,36 +45,30 @@ import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
import org.openecomp.sdc.be.components.csar.CsarInfo;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
-import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
-import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.ComponentParametersView;
-import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.NodeTypeInfo;
-import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RequirementCapabilityRelDef;
import org.openecomp.sdc.be.model.RequirementDefinition;
@@ -88,30 +78,22 @@ import org.openecomp.sdc.be.model.UploadCapInfo;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
import org.openecomp.sdc.be.model.UploadPropInfo;
import org.openecomp.sdc.be.model.UploadReqInfo;
-import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
-import org.openecomp.sdc.be.model.User;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.common.api.Constants;
-import org.openecomp.sdc.common.util.ValidationUtils;
import org.openecomp.sdc.exception.ResponseFormat;
public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSetup {
- ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
+ ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
@@ -289,20 +271,20 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
artifactDefinition.setArtifactName("artifactDefinitionName");
vfcArtifacts.add(artifactDefinition);
- extractedVfcsArtifacts.put(namespace,vfcArtifacts);
+ extractedVfcsArtifacts.put(namespace, vfcArtifacts);
ImmutablePair p1 = ImmutablePair.<String, String>of("s", "sd");
Map<String, NodeTypeInfo> nodeTypesInfo = new HashedMap();
final Service service = createServiceObject(false);
Resource resource = new Resource();
Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(resource);
when(toscaOperationFacade.getLatestByToscaResourceName(anyString()))
- .thenReturn(getCompLatestResult);
+ .thenReturn(getCompLatestResult);
try {
bl.findAddNodeTypeArtifactsToHandle(getCsarInfo(), nodeTypesArtifactsToHandle, service,
- extractedVfcsArtifacts, namespace, p1);
+ extractedVfcsArtifacts, namespace, p1);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.INVALID_TOSCA_TEMPLATE,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -378,7 +360,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
existingArtifact.setArtifactName("ArtifactName");
existingArtifact.setArtifactType("ArtifactType");
existingArtifact.setArtifactChecksum("ArtifactChecksum");
- existingArtifacts.put("existingArtifactMap",existingArtifact);
+ existingArtifacts.put("existingArtifactMap", existingArtifact);
ArtifactDefinition currNewArtifact = new ArtifactDefinition();
currNewArtifact.setArtifactName("ArtifactName");
currNewArtifact.setArtifactType("ArtifactType");
@@ -472,7 +454,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
try {
bl.getServiceBusinessLogic().setElementDao(elementDao);
- bl.validateResourceBeforeCreate(resource, user, AuditingActionEnum.IMPORT_RESOURCE,false, getCsarInfo());
+ bl.validateResourceBeforeCreate(resource, user, AuditingActionEnum.IMPORT_RESOURCE, false, getCsarInfo());
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
ComponentTypeEnum.RESOURCE.getValue());
@@ -483,7 +465,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
@Test
public void testValidateResourceType() {
Resource resource = createParseResourceObject(true);
- bl.validateResourceType( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateResourceType(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@Test
@@ -502,7 +484,8 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
interfaceDefinition.setUniqueId(uniqueId);
mapInterfaces.put("uniqueId", interfaceDefinition);
resource.setInterfaces(mapInterfaces);
- when(interfaceTypeOperation.getInterface(anyString())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ when(interfaceTypeOperation.getInterface(anyString()))
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
bl.validateLifecycleTypesCreate(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@@ -511,7 +494,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Resource resource = createParseResourceObject(true);
Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
String uniqueId = "18982938994";
- List<CapabilityDefinition> capabilityDefinitionList= new ArrayList<>();
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
capabilityDefinitionList.add(capabilityDefinition);
capabilities.put(uniqueId, capabilityDefinitionList);
@@ -532,7 +515,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Resource resource = createParseResourceObject(true);
Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
String uniqueId = "18982938994";
- List<CapabilityDefinition> capabilityDefinitionList= new ArrayList<>();
+ List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
capabilityDefinitionList.add(capabilityDefinition);
capabilities.put(uniqueId, capabilityDefinitionList);
@@ -605,7 +588,6 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
-
List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
List<ComponentInstanceProperty> componentInstancePropertyList = new ArrayList<>();
ComponentInstanceProperty componentInstanceProperty = new ComponentInstanceProperty();
@@ -619,7 +601,6 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
capabilities.put(uniqueId, capabilityDefinitionList);
resource.setCapabilities(capabilities);
-
when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
thenReturn(Either.left(capabilityTypeDefinition));
for (Map.Entry<String, List<CapabilityDefinition>> typeEntry : resource.getCapabilities().entrySet()) {
@@ -654,7 +635,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testValidateResourceFieldsBeforeCreate() {
Resource resource = createParseResourceObject(true);
try {
- bl.validateResourceFieldsBeforeCreate( user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ bl.validateResourceFieldsBeforeCreate(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
ComponentTypeEnum.RESOURCE.getValue());
@@ -667,7 +648,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
try {
when(toscaOperationFacade.validateToscaResourceNameExists(anyString()))
.thenReturn(Either.left(true));
- bl.validateDerivedFromExist( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateDerivedFromExist(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
ComponentTypeEnum.RESOURCE.getValue());
@@ -680,7 +661,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
try {
when(toscaOperationFacade.validateToscaResourceNameExists(anyString()))
.thenReturn(Either.left(false));
- bl.validateDerivedFromExist( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateDerivedFromExist(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.PARENT_RESOURCE_NOT_FOUND,
ComponentTypeEnum.RESOURCE.getValue());
@@ -693,7 +674,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
try {
when(toscaOperationFacade.validateToscaResourceNameExists(anyString()))
.thenReturn(Either.right(StorageOperationStatus.OK));
- bl.validateDerivedFromExist( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateDerivedFromExist(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.OK,
ComponentTypeEnum.RESOURCE.getValue());
@@ -705,7 +686,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Resource resource = createParseResourceObject(true);
try {
- bl.validateLicenseType( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateLicenseType(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.INVALID_CONTENT,
ComponentTypeEnum.RESOURCE.getValue());
@@ -718,7 +699,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testValidateCost() {
Resource resource = createParseResourceObject(true);
try {
- bl.validateCost( resource);
+ bl.validateCost(resource);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.INVALID_CONTENT,
ComponentTypeEnum.RESOURCE.getValue());
@@ -728,7 +709,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
@Test
public void testValidateResourceVendorModelNumber() {
Resource resource = createParseResourceObject(true);
- bl.validateResourceVendorModelNumber( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateResourceVendorModelNumber(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@Test
@@ -736,7 +717,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Resource resource = createParseResourceObject(true);
resource.setResourceVendorModelNumber("000000000011122221111222333444443222556677788778889999998776554332340");
try {
- bl.validateResourceVendorModelNumber( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateResourceVendorModelNumber(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
e.printStackTrace();
}
@@ -747,7 +728,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Resource resource = createParseResourceObject(true);
resource.setResourceVendorModelNumber("");
try {
- bl.validateResourceVendorModelNumber( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateResourceVendorModelNumber(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.INVALID_RESOURCE_VENDOR_MODEL_NUMBER,
ComponentTypeEnum.RESOURCE.getValue());
@@ -758,7 +739,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testValidateVendorReleaseName() {
Resource resource = createParseResourceObject(true);
resource.setVendorRelease("0.1");
- bl.validateVendorReleaseName( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateVendorReleaseName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@Test
@@ -766,7 +747,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Resource resource = createParseResourceObject(true);
resource.setVendorRelease("");
try {
- bl.validateVendorReleaseName( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateVendorReleaseName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.MISSING_VENDOR_RELEASE,
ComponentTypeEnum.RESOURCE.getValue());
@@ -789,7 +770,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testValidateCategory() {
Resource resource = createParseResourceObject(true);
try {
- bl.validateCategory( user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
ComponentTypeEnum.RESOURCE.getValue());
@@ -898,7 +879,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
CategoryDefinition category = resource.getCategories().get(0);
SubCategoryDefinition subcategory = category.getSubcategories().get(0);
try {
- bl.validateCategoryListed( category, subcategory, user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
+ bl.validateCategoryListed(category, subcategory, user, resource, AuditingActionEnum.IMPORT_RESOURCE, true);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
ComponentTypeEnum.RESOURCE.getValue());
@@ -909,7 +890,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testFailOnInvalidCategory() {
Resource resource = createParseResourceObject(true);
try {
- bl.failOnInvalidCategory( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.failOnInvalidCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.COMPONENT_INVALID_CATEGORY,
ComponentTypeEnum.RESOURCE.getValue());
@@ -921,7 +902,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testValidateVendorName() {
Resource resource = createParseResourceObject(true);
try {
- bl.validateVendorName( user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateVendorName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
ComponentTypeEnum.RESOURCE.getValue());
@@ -950,6 +931,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
e.printStackTrace();
}
}
+
@Test
public void testValidateVendorName2() {
Resource resource = createParseResourceObject(true);
@@ -957,7 +939,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
SubCategoryDefinition subcategory = category.getSubcategories().get(0);
String vendorName = "vendorName";
try {
- bl.validateVendorName( vendorName, user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ bl.validateVendorName(vendorName, user, resource, AuditingActionEnum.IMPORT_RESOURCE);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
ComponentTypeEnum.RESOURCE.getValue());
@@ -971,7 +953,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "test";
resourceVf.setSystemName("systemName");
try {
- bl.fillResourceMetadata( yamlName, resourceVf, nodeName, user);
+ bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user);
} catch (ComponentException e) {
e.printStackTrace();
}
@@ -1004,7 +986,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
@Test
public void testGetNodeTypeActualName() {
- String fullName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX+"test";
+ String fullName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "test";
try {
bl.getNodeTypeActualName(fullName);
} catch (ComponentException e) {
@@ -1144,7 +1126,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
@Test
public void testGetComponentWithInstancesFilter() {
- try {
+ try {
bl.getComponentWithInstancesFilter();
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
@@ -1172,7 +1154,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
InputDefinition prop = new InputDefinition();
Resource resource = createParseResourceObject(true);
- Map<String, List<CapabilityDefinition>> capabilitiesMap = resource.getCapabilities();
+ Map<String, List<CapabilityDefinition>> capabilitiesMap = resource.getCapabilities();
capabilitiesMap.put(key, capabilityDefinitionList);
when(toscaOperationFacade.getToscaFullElement(anyString()))
@@ -1288,10 +1270,10 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Map<String, ArtifactDefinition> artifactMap = new HashMap<>();
String k = "key";
Object v = new Object();
- Map<String,List<String>> artifactDetails = new HashMap<>();
+ Map<String, List<String>> artifactDetails = new HashMap<>();
List<String> artifactTypes = new ArrayList<>();
artifactTypes.add(ResourceTypeEnum.VF.name());
- artifactDetails.put("validForResourceTypes",artifactTypes);
+ artifactDetails.put("validForResourceTypes", artifactTypes);
v = artifactDetails;
bl.processDeploymentResourceArtifacts(user, resource, artifactMap, k, v);
@@ -1348,7 +1330,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
try {
bl.createInputsOnResource(resource, inputs);
- } catch (ComponentException e) {
+ } catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
ComponentTypeEnum.RESOURCE.getValue());
}
@@ -1382,7 +1364,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Map<String, InputDefinition> inputs = new HashMap<>();
InputDefinition inputDefinitionMap = new InputDefinition();
inputDefinition.setName("inputDefinitionName");
- inputs.put("inputsMap",inputDefinitionMap);
+ inputs.put("inputsMap", inputDefinitionMap);
try {
bl.createInputsOnService(service, inputs);
@@ -1515,14 +1497,14 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
}
}
- @Test
+ @Test
public void testFailOnChangeState() {
ResponseFormat response = new ResponseFormat();
Resource oldResource = createParseResourceObject(true);
Resource newResource = createParseResourceObject(true);
try {
- bl.failOnChangeState(response, user, oldResource, newResource);
+ bl.failOnChangeState(response, user, oldResource, newResource);
} catch (Exception e) {
e.printStackTrace();
}
@@ -1535,7 +1517,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
try {
bl.handleResourceGenericType(resource);
} catch (Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
}
}
@@ -1558,7 +1540,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
groupDefinition.setInvariantName("groupDefinitionName");
groupsFromResource.add(groupDefinition);
List<GroupDefinition> groupsAsList = new ArrayList<>();
- GroupDefinition groupNewDefinition =getGroupDefinition();
+ GroupDefinition groupNewDefinition = getGroupDefinition();
groupsAsList.add(groupNewDefinition);
List<GroupDefinition> groupsToUpdate = new ArrayList<>();
List<GroupDefinition> groupsToCreate = new ArrayList<>();
@@ -1587,7 +1569,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
Map<String, GroupDefinition> groups = new HashMap<>();
GroupDefinition groupDefinition = getGroupDefinition();
groupDefinition.setMembers(null);
- groups.put("groupsMap",groupDefinition);
+ groups.put("groupsMap", groupDefinition);
bl.updateGroupsMembersUsingResource(groups, component);
}
@@ -1688,7 +1670,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testFillResourceMetadataForServiceWrongType() {
String yamlName = "yamlName";
Service resourceVf = createServiceObject(true);
- String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX+"nodeName";
+ String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "nodeName";
try {
bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user);
@@ -1701,7 +1683,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testFillResourceMetadataForServiceSuccess() {
String yamlName = "yamlName";
Service resourceVf = createServiceObject(true);
- String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX+"VFC";
+ String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "VFC";
try {
bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user);
@@ -1787,7 +1769,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>();
try {
- bl.rollback(false,resource, createdArtifacts,nodeTypesNewCreatedArtifacts);
+ bl.rollback(false, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
} catch (Exception e) {
e.printStackTrace();
}
@@ -1827,12 +1809,12 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.handleGroupsProperties(service, groups);
}
- @Test
+ @Test
public void testHandleGroupsProperties2() {
Resource resource = createParseResourceObject(true);
Map<String, GroupDefinition> groups = getGroups();
- bl.handleGroupsProperties(resource, groups);
+ bl.handleGroupsProperties(resource, groups);
}
@Test
@@ -1897,7 +1879,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -1924,7 +1906,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -1938,7 +1920,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -1952,7 +1934,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateArtifactsToInstances(yamlName, resource, instDeploymentArtifacts);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -1966,7 +1948,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateOrAddCalculatedCapReq(yamlName, resource, instCapabilities, instRequirements);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -1974,12 +1956,12 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testAssociateInstAttributeToComponentToInstances() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
- Map<String, List<AttributeDataDefinition>> instAttributes = new HashMap<>();
+ Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
try {
bl.associateInstAttributeToComponentToInstances(yamlName, resource, instAttributes);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -1991,7 +1973,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.throwComponentExceptionByResource(status, resource);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.OK,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -2001,7 +1983,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
try {
bl.getResourceAfterCreateRelations(resource);
- } catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -2014,12 +1996,12 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
capabilityDefinition.setName("Capability");
capabilityDefinition.setType("Resource");
capabilityDefinitionList.add(capabilityDefinition);
- originCapabilities.put("Capability",capabilityDefinitionList);
+ originCapabilities.put("Capability", capabilityDefinitionList);
Map<String, List<UploadCapInfo>> uploadedCapabilities = new HashMap<>();
List<UploadCapInfo> uploadCapInfoList = new ArrayList<>();
UploadCapInfo uploadCapInfo = new UploadCapInfo();
uploadCapInfoList.add(uploadCapInfo);
- uploadedCapabilities.put("Capability",uploadCapInfoList);
+ uploadedCapabilities.put("Capability", uploadCapInfoList);
bl.setCapabilityNamesTypes(originCapabilities, uploadedCapabilities);
}
@@ -2034,7 +2016,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateComponentInstanceInputsToComponent(yamlName, service, instInputs);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.OK,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -2061,7 +2043,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateDeploymentArtifactsToInstances(user, yamlName, service, instDeploymentArtifacts);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -2075,9 +2057,10 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateArtifactsToInstances(yamlName, service, instArtifacts);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
+
@Test
public void testAssociateOrAddCalculatedCapReq2() {
String yamlName = "yamlName";
@@ -2088,7 +2071,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateOrAddCalculatedCapReq(yamlName, resource, instCapabilities, instRequirements);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -2096,12 +2079,12 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
public void testAssociateInstAttributeToComponentToInstances2() {
String yamlName = "yamlName";
Service resource = createServiceObject(true);
- Map<String, List<AttributeDataDefinition>> instAttributes = new HashMap<>();
+ Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
try {
bl.associateInstAttributeToComponentToInstances(yamlName, resource, instAttributes);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -2114,7 +2097,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateRequirementsToService(yamlName, resource, requirements);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -2127,7 +2110,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
bl.associateCapabilitiesToService(yamlName, resource, capabilities);
} catch (ComponentException e) {
assertComponentException(e, ActionStatus.GENERAL_ERROR,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
}
@@ -2139,7 +2122,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
try {
bl.associateResourceInstances(yamlName, resource, relations);
} catch (Exception e) {
- e.printStackTrace();
+ e.printStackTrace();
}
}
@@ -2217,7 +2200,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
}
@Test
- public void testAddRelationsToRI_null(){
+ public void testAddRelationsToRI_null() {
String yamlName = "group.yml";
Resource resource = createParseResourceObject(true);
Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
@@ -2227,8 +2210,8 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
try {
- bl.addRelationsToRI(yamlName,resource,uploadResInstancesMap,componentInstancesList,
- relations);
+ bl.addRelationsToRI(yamlName, resource, uploadResInstancesMap, componentInstancesList,
+ relations);
} catch (Exception e) {
e.printStackTrace();
}
@@ -2239,14 +2222,14 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
resource.setComponentInstances(creatComponentInstances());
- UploadComponentInstanceInfo nodesInfoValue =getuploadComponentInstanceInfo();
+ UploadComponentInstanceInfo nodesInfoValue = getuploadComponentInstanceInfo();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
bl.addRelationToRI(yamlName, resource, nodesInfoValue, relations);
}
@Test
- public void testAddRelationToRI_null(){
+ public void testAddRelationToRI_null() {
String yamlName = "yamlName.yml";
Resource resource = createParseResourceObject(false);
List<ComponentInstance> componentInstancesList = new ArrayList<>();
@@ -2273,7 +2256,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
}
}
- protected GroupDefinition getGroupDefinition(){
+ protected GroupDefinition getGroupDefinition() {
GroupDefinition groupDefinition = new GroupDefinition();
Map<String, String> members = new HashMap<>();
members.put("members", "members");
@@ -2310,7 +2293,6 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
resource.setCost("cost");
resource.setResourceVendorModelNumber("02312233");
-
Map<String, ArtifactDefinition> artifacts = new HashMap<>();
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
artifacts.put("artifact", artifactDefinition);
@@ -2358,7 +2340,7 @@ public class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBase
return new String(fileContent);
}
- protected Service createServiceObject (boolean afterCreate) {
+ protected Service createServiceObject(boolean afterCreate) {
Service service = new Service();
service.setUniqueId("sid");
service.setName("Service");