summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java191
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java80
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/InterfaceOperationUtils.java11
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java2
7 files changed, 200 insertions, 100 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java
index 2b23c52cd0..d0a1273210 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java
@@ -58,9 +58,9 @@ public class ArtifactResolverImpl implements ArtifactsResolver {
if (MapUtils.isNotEmpty(interfaces)) {
interfaceArtifacts = interfaces.values().stream()
.flatMap(inte -> inte.getOperationsMap().values().stream())
- .map(operation -> operation.getImplementationArtifact())
+ .map(operation -> operation.getImplementationArtifact()).filter(Objects::nonNull)
.collect(Collectors.toMap(artifactDefinition -> artifactDefinition.getUniqueId(),
- artifactDefinition -> artifactDefinition));
+ artifactDefinition -> artifactDefinition, (a1, a2) -> a1));
}
Map<String, ArtifactDefinition> serviceApiArtifacts = Collections.emptyMap();
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index 8f1f5864d5..361f6c610f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -54,7 +54,6 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.info.ArtifactTemplateInfo;
import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.heat.HeatParameterType;
-import org.openecomp.sdc.be.model.jsontitan.operations.InterfaceOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
import org.openecomp.sdc.be.components.utils.InterfaceOperationUtils;
import org.openecomp.sdc.be.model.operations.api.*;
@@ -3096,69 +3095,33 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
}
NodeTypeEnum convertParentType = convertParentType(componentType);
- // fetch the resource from storage
- Either<Component, StorageOperationStatus> componentStorageOperationStatusEither =
- toscaOperationFacade.getToscaElement(parentId);
- if (componentStorageOperationStatusEither.isRight()) {
- StorageOperationStatus errorStatus = componentStorageOperationStatusEither.right().value();
- log.debug("Failed to fetch resource information by resource id, error {}", errorStatus);
- return Either.right(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(errorStatus)));
+ // Set additional fields for artifact
+ artifactInfo.setArtifactLabel(artifactInfo.getArtifactName());
+ artifactInfo.setArtifactDisplayName(artifactInfo.getArtifactName());
+
+ Either<ArtifactDefinition, StorageOperationStatus> updateArtifactOnResourceEither =
+ artifactToscaOperation.updateArtifactOnResource(artifactInfo, parent.getUniqueId(), artifactId, convertParentType, parentId);
+ if(updateArtifactOnResourceEither.isRight()){
+ log.debug("Failed to persist operation artifact {} in resource, error is {}",artifactInfo.getArtifactName(), updateArtifactOnResourceEither.right().value());
+ ActionStatus convertedFromStorageResponse = componentsUtils.convertFromStorageResponse(updateArtifactOnResourceEither.right().value());
+ return Either.right(componentsUtils.getResponseFormat(convertedFromStorageResponse));
}
- Component storedComponent = componentStorageOperationStatusEither.left().value();
-
- Optional<InterfaceDefinition> optionalInterface = InterfaceOperationUtils
- .getInterfaceDefinitionFromComponentByInterfaceType(storedComponent, interfaceType);
- if(!optionalInterface.isPresent()) {
- log.debug("Failed to get resource interface for resource Id {}", parentId);
- return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_NOT_FOUND_IN_COMPONENT, interfaceType));
+ if (artifactData.getData() != null) {
+ CassandraOperationStatus cassandraOperationStatus = artifactCassandraDao.saveArtifact(artifactData);
+ if(cassandraOperationStatus != CassandraOperationStatus.OK){
+ log.debug("Failed to persist operation artifact {}, error is {}",artifactInfo.getArtifactName(),cassandraOperationStatus);
+ StorageOperationStatus storageStatus = DaoStatusConverter.convertCassandraStatusToStorageStatus(cassandraOperationStatus);
+ ActionStatus convertedFromStorageResponse = componentsUtils.convertFromStorageResponse(storageStatus);
+ return Either.right(componentsUtils.getResponseFormat(convertedFromStorageResponse));
+ }
}
- //fetch the operation from storage
- InterfaceDefinition gotInterface = optionalInterface.get();
- Map<String, Operation> operationsMap = gotInterface.getOperationsMap();
- Optional<Operation> optionalOperation = operationsMap.values()
- .stream()
- .filter(o -> o.getUniqueId().equals(operationUuid))
- .findFirst();
- if (!optionalOperation.isPresent()) {
- log.debug("Failed to get resource interface operation for resource Id {} " +
- " and operationId {}", parentId, operationUuid);
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(
- ActionStatus.INTERFACE_OPERATION_NOT_FOUND, parentId);
- handleAuditing(auditingAction, parent, parentId, user, artifactInfo, prevArtifactId,
- currArtifactId, responseFormat, componentType, null);
- return Either.right(responseFormat);
+ Either<ArtifactDefinition, ResponseFormat> updateOprEither = updateOperationArtifact(parentId, interfaceType, operationUuid, updateArtifactOnResourceEither.left().value());
+ if(updateOprEither.isRight()){
+ return Either.right(updateOprEither.right().value());
}
- Operation operation = optionalOperation.get();
- ArtifactDefinition implementationArtifact = operation.getImplementationArtifact();
- implementationArtifact.setArtifactName(artifactInfo.getArtifactName());
- implementationArtifact.setDescription(artifactInfo.getDescription());
- implementationArtifact.setArtifactType(artifactInfo.getArtifactType());
- implementationArtifact.setArtifactLabel(artifactInfo.getUniqueId());
- implementationArtifact.setEsId(artifactInfo.getEsId());
- operation.setImplementation(implementationArtifact);
- gotInterface.setOperationsMap(operationsMap);
- Either<List<InterfaceDefinition>, StorageOperationStatus> interfaceDefinitionStorageOperationStatusEither =
- interfaceOperation.updateInterfaces(storedComponent.getUniqueId(), Collections.singletonList(gotInterface));
- if (interfaceDefinitionStorageOperationStatusEither.isRight()){
- StorageOperationStatus storageOperationStatus = interfaceDefinitionStorageOperationStatusEither.right().value();
- ActionStatus actionStatus =
- componentsUtils.convertFromStorageResponseForDataType(storageOperationStatus);
- return Either.right(componentsUtils.getResponseFormat(actionStatus));
- }
-
- String uniqueId = implementationArtifact.getUniqueId();
- artifactData.setId(uniqueId);
- CassandraOperationStatus cassandraOperationStatus = artifactCassandraDao.saveArtifact(artifactData);
- if(cassandraOperationStatus != CassandraOperationStatus.OK){
- log.debug("Failed to persist operation {} artifact, error is {}",operation.getName(),cassandraOperationStatus);
- StorageOperationStatus storageStatus = DaoStatusConverter.convertCassandraStatusToStorageStatus(cassandraOperationStatus);
- ActionStatus convertedFromStorageResponse = componentsUtils.convertFromStorageResponse(storageStatus);
- return Either.right(componentsUtils.getResponseFormat(convertedFromStorageResponse));
- }
- return Either.left(Either.left(implementationArtifact));
+ return Either.left(Either.left(updateOprEither.left().value()));
}
private Either<byte[], ResponseFormat> handlePayload(ArtifactDefinition artifactInfo, boolean isArtifactMetadataUpdate) {
@@ -5007,6 +4970,58 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
return updateArtifactResult;
}
+ private Either<ArtifactDefinition, ResponseFormat> updateOperationArtifact(String componentId, String interfaceType, String operationUuid, ArtifactDefinition artifactInfo){
+ Either<Component, StorageOperationStatus> componentStorageOperationStatusEither = toscaOperationFacade.getToscaElement(componentId);
+ if (componentStorageOperationStatusEither.isRight()) {
+ StorageOperationStatus errorStatus = componentStorageOperationStatusEither.right().value();
+ log.debug("Failed to fetch resource information by resource id, error {}", errorStatus);
+ return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(errorStatus)));
+ }
+ Component storedComponent = componentStorageOperationStatusEither.left().value();
+
+ Optional<InterfaceDefinition> optionalInterface = InterfaceOperationUtils.getInterfaceDefinitionFromComponentByInterfaceType(storedComponent, interfaceType);
+ if(!optionalInterface.isPresent()) {
+ log.debug("Failed to get resource interface for resource Id {}", componentId);
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_NOT_FOUND_IN_COMPONENT, interfaceType));
+ }
+
+ //fetch the operation from storage
+ InterfaceDefinition gotInterface = optionalInterface.get();
+ Map<String, Operation> operationsMap = gotInterface.getOperationsMap();
+ Optional<Operation> optionalOperation = operationsMap.values()
+ .stream()
+ .filter(o -> o.getUniqueId().equals(operationUuid))
+ .findFirst();
+ if (!optionalOperation.isPresent()) {
+ log.debug("Failed to get resource interface operation for resource Id {} and operationId {}", componentId, operationUuid);
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INTERFACE_OPERATION_NOT_FOUND, componentId);
+ return Either.right(responseFormat);
+ }
+
+ Operation operation = optionalOperation.get();
+ ArtifactDefinition implementationArtifact = operation.getImplementationArtifact();
+ implementationArtifact.setArtifactUUID(artifactInfo.getArtifactUUID());
+ implementationArtifact.setUniqueId(artifactInfo.getUniqueId());
+ implementationArtifact.setArtifactName(artifactInfo.getArtifactName());
+ implementationArtifact.setDescription(artifactInfo.getDescription());
+ implementationArtifact.setArtifactType(artifactInfo.getArtifactType());
+ implementationArtifact.setArtifactLabel(artifactInfo.getArtifactLabel());
+ implementationArtifact.setArtifactDisplayName(artifactInfo.getArtifactDisplayName());
+ implementationArtifact.setEsId(artifactInfo.getEsId());
+ operation.setImplementation(implementationArtifact);
+ gotInterface.setOperationsMap(operationsMap);
+ Either<List<InterfaceDefinition>, StorageOperationStatus> interfaceDefinitionStorageOperationStatusEither =
+ interfaceOperation.updateInterfaces(storedComponent.getUniqueId(), Collections.singletonList(gotInterface));
+ if (interfaceDefinitionStorageOperationStatusEither.isRight()){
+ StorageOperationStatus storageOperationStatus = interfaceDefinitionStorageOperationStatusEither.right().value();
+ ActionStatus actionStatus =
+ componentsUtils.convertFromStorageResponseForDataType(storageOperationStatus);
+ return Either.right(componentsUtils.getResponseFormat(actionStatus));
+ }
+
+ return Either.left(artifactInfo);
+ }
+
/**
* updates an artifact on a component by UUID
*
@@ -5030,6 +5045,8 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
ArtifactDefinition artifactInfo = RepresentationUtils.convertJsonToArtifactDefinitionForUpdate(data, ArtifactDefinition.class);
String origMd5 = request.getHeader(Constants.MD5_HEADER);
String userId = request.getHeader(Constants.USER_ID_HEADER);
+ ArtifactDefinition existingArtifactInfo = null;
+ String interfaceName = null;
Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, true);
if (getComponentRes.isRight()) {
@@ -5037,6 +5054,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
log.debug("Could not fetch component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, status);
errorWrapper.setInnerElement(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status)));
}
+
if (errorWrapper.isEmpty()) {
componentId = getComponentRes.left().value().getMetadataDataDefinition().getUniqueId();
String componentName = getComponentRes.left().value().getMetadataDataDefinition().getName();
@@ -5054,23 +5072,52 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
resourceCommonInfo.setResourceName(componentName);
}
- if (errorWrapper.isEmpty()) {
- Either<String, ResponseFormat> interfaceName = fetchInterfaceName(componentId, interfaceUUID);
- if (interfaceName.isRight()) {
- errorWrapper.setInnerElement(interfaceName.right().value());
+
+ if(errorWrapper.isEmpty()){
+ Either<String, ResponseFormat> interfaceNameEither = fetchInterfaceName(componentId, interfaceUUID);
+ if (interfaceNameEither.isRight()) {
+ errorWrapper.setInnerElement(interfaceNameEither.right().value());
}
- if (errorWrapper.isEmpty()) {
- actionResult = handleArtifactRequest(componentId, userId, componentType, operation,
- artifactUUID, artifactInfo, origMd5, data, interfaceName.left().value(),
- operationUUID, null, null);
- if (actionResult.isRight()) {
- log.debug(FAILED_UPLOAD_ARTIFACT_TO_COMPONENT, componentType, componentUuid, actionResult
- .right()
- .value());
- errorWrapper.setInnerElement(actionResult.right().value());
+ else {
+ interfaceName = interfaceNameEither.left().value();
+ }
+
+ if(errorWrapper.isEmpty()){
+ Either<Component, StorageOperationStatus> toscaComponentEither = toscaOperationFacade.getToscaElement(componentId);
+ if (toscaComponentEither.isRight()) {
+ StorageOperationStatus status = toscaComponentEither.right().value();
+ log.debug("Could not fetch component with type {} and id {}. Status is {}. ", componentType, componentId, status);
+ errorWrapper.setInnerElement(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status)));
}
+
+ if (errorWrapper.isEmpty()) {
+ NodeTypeEnum parentType = convertParentType(componentType);
+ List<ArtifactDefinition> existingDeploymentArtifacts = getDeploymentArtifacts(toscaComponentEither.left().value(), parentType,null);
+ for (ArtifactDefinition artifactDefinition: existingDeploymentArtifacts){
+ if(artifactDefinition.getArtifactName().equalsIgnoreCase(artifactInfo.getArtifactName())){
+ existingArtifactInfo = artifactDefinition;
+ break;
+ }
+ }
+ if(existingArtifactInfo != null){
+ return updateOperationArtifact(componentId, interfaceName, operationUUID, existingArtifactInfo);
+ }
+ }
+ }
+ }
+
+ if (errorWrapper.isEmpty()) {
+ actionResult = handleArtifactRequest(componentId, userId, componentType, operation,
+ artifactUUID, artifactInfo, origMd5, data, interfaceName,
+ operationUUID, null, null);
+ if (actionResult.isRight()) {
+ log.debug(FAILED_UPLOAD_ARTIFACT_TO_COMPONENT, componentType, componentUuid, actionResult
+ .right()
+ .value());
+ errorWrapper.setInnerElement(actionResult.right().value());
}
}
+
if (errorWrapper.isEmpty()) {
updateArtifact = actionResult.left().value().left().value();
updateArtifactResult = Either.left(updateArtifact);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
index 71d79e0410..7f19e824e5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
@@ -41,6 +41,7 @@ import java.util.stream.Collectors;
import fj.data.Either;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
+import org.openecomp.sdc.be.components.utils.InterfaceOperationUtils;
import org.openecomp.sdc.be.components.validation.InterfaceOperationValidation;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
@@ -122,14 +123,34 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
if (validateDeleteOperationContainsNoMappedOutputResponse.isRight()) {
return Either.right(validateDeleteOperationContainsNoMappedOutputResponse.right().value());
}
- String artifactUuId = storedOperation.getImplementation().getArtifactUUID();
- CassandraOperationStatus cassandraStatus = artifactCassandraDao.deleteArtifact(artifactUuId);
- if (cassandraStatus != CassandraOperationStatus.OK) {
- ResponseFormat responseFormatByArtifactId = componentsUtils.getResponseFormatByArtifactId(
- componentsUtils.convertFromStorageResponse(
- componentsUtils.convertToStorageOperationStatus(cassandraStatus)),
- storedOperation.getImplementation().getArtifactDisplayName());
- return Either.right(responseFormatByArtifactId);
+
+ String artifactUniqueId = storedOperation.getImplementation().getUniqueId();
+ if(!InterfaceOperationUtils.isArtifactInUse(storedComponent, operationId, artifactUniqueId)){
+ Either<ArtifactDefinition, StorageOperationStatus> getArtifactEither =
+ artifactToscaOperation.getArtifactById(storedComponent.getUniqueId(), artifactUniqueId);
+ if(getArtifactEither.isLeft()){
+ Either<ArtifactDefinition, StorageOperationStatus> removeArifactFromComponent =
+ artifactToscaOperation.removeArifactFromResource(componentId, artifactUniqueId,
+ NodeTypeEnum.getByNameIgnoreCase(storedComponent.getComponentType().getValue()),
+ true);
+ if(removeArifactFromComponent.isRight()){
+ titanDao.rollback();
+ ResponseFormat responseFormatByArtifactId = componentsUtils.getResponseFormatByArtifactId(
+ componentsUtils.convertFromStorageResponse(removeArifactFromComponent.right().value()),
+ storedOperation.getImplementation().getArtifactDisplayName());
+ return Either.right(responseFormatByArtifactId);
+ }
+
+ CassandraOperationStatus cassandraStatus = artifactCassandraDao.deleteArtifact(artifactUniqueId);
+ if (cassandraStatus != CassandraOperationStatus.OK) {
+ titanDao.rollback();
+ ResponseFormat responseFormatByArtifactId = componentsUtils.getResponseFormatByArtifactId(
+ componentsUtils.convertFromStorageResponse(
+ componentsUtils.convertToStorageOperationStatus(cassandraStatus)),
+ storedOperation.getImplementation().getArtifactDisplayName());
+ return Either.right(responseFormatByArtifactId);
+ }
+ }
}
operationsCollection.put(operationId, interfaceDefinition.getOperationsMap().get(operationId));
@@ -317,20 +338,35 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
Operation storedOperation = optionalOperation.get().getValue();
String artifactUuId = storedOperation.getImplementation().getArtifactUUID();
- Either<Long, CassandraOperationStatus> artifactCount =
- artifactCassandraDao.getCountOfArtifactById(artifactUuId);
- if (artifactCount.isLeft()) {
- CassandraOperationStatus cassandraStatus =
- artifactCassandraDao.deleteArtifact(artifactUuId);
- if (cassandraStatus != CassandraOperationStatus.OK) {
- titanDao.rollback();
- ResponseFormat responseFormatByArtifactId =
- componentsUtils.getResponseFormatByArtifactId(
- componentsUtils.convertFromStorageResponse(
- componentsUtils.convertToStorageOperationStatus(
- cassandraStatus)),
- storedOperation.getImplementation().getArtifactDisplayName());
- return Either.right(responseFormatByArtifactId);
+ String artifactUniqueId = storedOperation.getImplementation().getUniqueId();
+
+ if(!InterfaceOperationUtils.isArtifactInUse(storedComponent, storedOperation.getUniqueId(), artifactUniqueId)){
+ Either<ArtifactDefinition, StorageOperationStatus> getArtifactEither =
+ artifactToscaOperation.getArtifactById(storedComponent.getUniqueId(), artifactUniqueId);
+ if(getArtifactEither.isLeft()){
+ Either<ArtifactDefinition, StorageOperationStatus> removeArifactFromComponent =
+ artifactToscaOperation.removeArifactFromResource(componentId, artifactUniqueId,
+ NodeTypeEnum.getByNameIgnoreCase(storedComponent.getComponentType().getValue()),
+ true);
+ if(removeArifactFromComponent.isRight()){
+ titanDao.rollback();
+ ResponseFormat responseFormatByArtifactId = componentsUtils.getResponseFormatByArtifactId(
+ componentsUtils.convertFromStorageResponse(removeArifactFromComponent.right().value()),
+ storedOperation.getImplementation().getArtifactDisplayName());
+ return Either.right(responseFormatByArtifactId);
+ }
+
+ CassandraOperationStatus cassandraStatus = artifactCassandraDao.deleteArtifact(artifactUniqueId);
+ if (cassandraStatus != CassandraOperationStatus.OK) {
+ titanDao.rollback();
+ ResponseFormat responseFormatByArtifactId =
+ componentsUtils.getResponseFormatByArtifactId(
+ componentsUtils.convertFromStorageResponse(
+ componentsUtils.convertToStorageOperationStatus(
+ cassandraStatus)),
+ storedOperation.getImplementation().getArtifactDisplayName());
+ return Either.right(responseFormatByArtifactId);
+ }
}
}
updateOperationOnInterface(interfaceDef, operation, artifactUuId);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index 6c0e0c9fba..ba3b8dfc45 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -2324,7 +2324,12 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
@Override
public void setDeploymentArtifactsPlaceHolder(Component component, User user) {
-
+ Service service = (Service) component;
+ Map<String, ArtifactDefinition> artifactMap = service.getDeploymentArtifacts();
+ if (artifactMap == null) {
+ artifactMap = new HashMap<>();
+ }
+ service.setDeploymentArtifacts(artifactMap);
}
@Override
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/InterfaceOperationUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/InterfaceOperationUtils.java
index 2727a8b94a..0ee6264f4d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/InterfaceOperationUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/utils/InterfaceOperationUtils.java
@@ -23,9 +23,9 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-
+import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
+import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
@@ -180,4 +180,11 @@ public class InterfaceOperationUtils {
? fullOutputIdentifier.substring(fullOutputIdentifier.lastIndexOf('.') + 1)
: fullOutputIdentifier;
}
+
+ public static boolean isArtifactInUse(Component component, String operationId, String artifactUniqueId) {
+ return MapUtils.emptyIfNull(component.getInterfaces()).values().stream()
+ .filter(o -> MapUtils.isNotEmpty(o.getOperations()) && !o.getOperations().containsKey(operationId))
+ .flatMap(o -> o.getOperations().values().stream()).collect(Collectors.toList()).stream()
+ .anyMatch(op -> op.getImplementation().getUniqueId().equals(artifactUniqueId));
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
index c6dec0bcc4..7b40781f3f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
@@ -900,6 +900,11 @@ public class CsarUtils {
for (ArtifactTypeEnum artifactTypeEnum : artifactTypeEnumKeySet) {
List<ArtifactDefinition> artifactDefinitionList = artifactTypesMap.get(artifactTypeEnum);
String artifactTypeFolder = groupTypeFolder + artifactTypeEnum.toString() + File.separator;
+
+ if(artifactTypeEnum == ArtifactTypeEnum.WORKFLOW && path.contains(ARTIFACTS_PATH + RESOURCES_PATH)){
+ // Ignore this packaging as BPMN artifacts needs to be packaged in different manner
+ continue;
+ }
if (artifactTypeEnum == ArtifactTypeEnum.WORKFLOW) {
artifactTypeFolder += OperationArtifactUtil.BPMN_ARTIFACT_PATH + File.separator;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java
index b10a8883d2..401c03d44f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java
@@ -102,7 +102,7 @@ public class OperationArtifactUtil {
.flatMap(interfaceDefinition -> interfaceDefinition.getOperationsMap().values().stream())
.map(Operation::getImplementationArtifact).filter(Objects::nonNull)
.collect(Collectors.toMap(ArtifactDataDefinition::getUniqueId,
- artifactDefinition -> artifactDefinition));
+ artifactDefinition -> artifactDefinition, (a1, a2) -> a1));
if (MapUtils.isNotEmpty(interfaceArtifacts)) {
Set<String> artifactNameSet = new HashSet<>();
for (Map.Entry<String, ArtifactDefinition> interfaceArtifactEntry : interfaceArtifacts.entrySet()) {