aboutsummaryrefslogtreecommitdiffstats
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/validation/InterfaceOperationValidation.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java27
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java16
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtil.java31
5 files changed, 53 insertions, 33 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java
index f84c9a4d86..30d006f501 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java
@@ -589,7 +589,7 @@ public class InterfaceOperationValidation {
ListDataDefinition<OperationInputDefinition> inputs = operationEntry.getValue().getInputs();
String expectedOperationIdentifier =
interfaceDefinitionEntry.getValue().getType() + "." + operationEntry.getValue().getName();
- if (!currentOperationIdentifier.equals(expectedOperationIdentifier) && !inputs.isEmpty()) {
+ if (!currentOperationIdentifier.equals(expectedOperationIdentifier) && Objects.nonNull(inputs) && !inputs.isEmpty()) {
otherOperationInputs.addAll(inputs.getListToscaDataDefinition());
}
}
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 bea65cf187..c6dec0bcc4 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
@@ -37,6 +37,7 @@ import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.cassandra.SdcSchemaFilesCassandraDao;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
@@ -431,10 +432,10 @@ public class CsarUtils {
}
private Either<ZipOutputStream, ResponseFormat> writeComponentInterface(Component component, ZipOutputStream zip,
- String fileName, boolean isAssociatedResourceComponent) {
+ String fileName, boolean isAssociatedComponent) {
try {
Either<ToscaRepresentation, ToscaError> componentInterface = toscaExportUtils
- .exportComponentInterface(component, isAssociatedResourceComponent);
+ .exportComponentInterface(component, isAssociatedComponent);
ToscaRepresentation componentInterfaceYaml = componentInterface.left().value();
String mainYaml = componentInterfaceYaml.getMainYaml();
String interfaceFileName = DEFINITIONS_PATH + ToscaExportHandler.getInterfaceFilename(fileName);
@@ -872,11 +873,11 @@ public class CsarUtils {
ComponentTypeArtifacts componentInstanceArtifacts = componentTypeArtifacts.get(keyAssetName);
ArtifactsInfo componentArtifacts2 = componentInstanceArtifacts.getComponentArtifacts();
String pathWithAssetName = currentPath + keyAssetName + "/";
- Either<ZipOutputStream, ResponseFormat> writeArtifactsInfoToSpecifiedtPath = writeArtifactsInfoToSpecifiedPath(
+ Either<ZipOutputStream, ResponseFormat> writeArtifactsInfoToSpecifiedPath = writeArtifactsInfoToSpecifiedPath(
mainComponent, componentArtifacts2, zipstream, pathWithAssetName, isInCertificationRequest);
- if (writeArtifactsInfoToSpecifiedtPath.isRight()) {
- return writeArtifactsInfoToSpecifiedtPath;
+ if (writeArtifactsInfoToSpecifiedPath.isRight()) {
+ return writeArtifactsInfoToSpecifiedPath;
}
}
@@ -1188,7 +1189,7 @@ public class CsarUtils {
}
private ComponentTypeArtifacts collectComponentTypeArtifacts(Map<String, ComponentTypeArtifacts> resourcesArtifacts,
- ComponentInstance componentInstance, Resource fetchedComponent) {
+ ComponentInstance componentInstance, Component fetchedComponent) {
String toscaComponentName = componentInstance.getToscaComponentName() + "_v"
+ componentInstance.getComponentVersion();
@@ -1210,15 +1211,21 @@ public class CsarUtils {
ComponentInstance componentInstance, Map<String, ComponentTypeArtifacts> resourcesTypeArtifacts,
ComponentTypeArtifacts instanceArtifactsLocation) {
// 1. get the component instance component
- String componentUid = componentInstance.getComponentUid();
- Either<Resource, StorageOperationStatus> resource = toscaOperationFacade.getToscaElement(componentUid);
- if (resource.isRight()) {
+ String componentUid;
+ if (componentInstance.getOriginType() == OriginTypeEnum.ServiceProxy) {
+ componentUid = componentInstance.getSourceModelUid();
+ }
+ else {
+ componentUid = componentInstance.getComponentUid();
+ }
+ Either<Component, StorageOperationStatus> component = toscaOperationFacade.getToscaElement(componentUid);
+ if (component.isRight()) {
log.error("Failed to fetch resource with id {} for instance {}", componentUid, parentComponent.getUUID());
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ASSET_NOT_FOUND_DURING_CSAR_CREATION,
parentComponent.getComponentType().getValue(), parentComponent.getUUID(),
componentInstance.getOriginType().getComponentType().getValue(), componentUid));
}
- Resource fetchedComponent = resource.left().value();
+ Component fetchedComponent = component.left().value();
// 2. fill the artifacts for the current component parent type
ComponentTypeArtifacts componentParentArtifacts = collectComponentTypeArtifacts(resourcesTypeArtifacts,
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 d3d4c2d073..54cf4cf096 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
@@ -135,7 +135,7 @@ public class ToscaExportHandler {
}
public Either<ToscaRepresentation, ToscaError> exportComponentInterface(Component component,
- boolean isAssociatedResourceComponent) {
+ boolean isAssociatedComponent) {
if (null == DEFAULT_IMPORTS) {
log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
return Either.right(ToscaError.GENERAL_ERROR);
@@ -145,7 +145,7 @@ public class ToscaExportHandler {
toscaTemplate.setImports(new ArrayList<>(DEFAULT_IMPORTS));
Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
Either<ToscaTemplate, ToscaError> toscaTemplateRes = convertInterfaceNodeType(new HashMap<>(), component,
- toscaTemplate, nodeTypes, isAssociatedResourceComponent);
+ toscaTemplate, nodeTypes, isAssociatedComponent);
if (toscaTemplateRes.isRight()) {
return Either.right(toscaTemplateRes.right().value());
}
@@ -517,7 +517,7 @@ public class ToscaExportHandler {
private Either<ToscaTemplate, ToscaError> convertInterfaceNodeType(Map<String, Component> componentsCache,
Component component, ToscaTemplate toscaNode,
Map<String, ToscaNodeType> nodeTypes,
- boolean isAssociatedResourceComponent) {
+ boolean isAssociatedComponent) {
log.debug("start convert node type for {}", component.getUniqueId());
ToscaNodeType toscaNodeType = createNodeType(component);
@@ -544,7 +544,7 @@ public class ToscaExportHandler {
List<InputDefinition> inputDef = component.getInputs();
Map<String, ToscaProperty> mergedProperties = new HashMap<>();
- addInterfaceDefinitionElement(component, toscaNodeType, dataTypes, isAssociatedResourceComponent);
+ addInterfaceDefinitionElement(component, toscaNodeType, dataTypes, isAssociatedComponent);
if (inputDef != null) {
addInputsToProperties(dataTypes, inputDef, mergedProperties);
}
@@ -780,7 +780,7 @@ public class ToscaExportHandler {
.getUniqueId(), instInterface));
interfaces = InterfacesOperationsToscaUtil
- .getInterfacesMap(parentComponent, tmpInterfaces, dataTypes, true, true);
+ .getInterfacesMap(parentComponent, componentInstance, tmpInterfaces, dataTypes, true, true);
}
} else {
interfaces =
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java
index d69e4f67b3..87c4bfa2a6 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java
@@ -29,6 +29,7 @@ import org.apache.commons.collections.MapUtils;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Product;
@@ -104,7 +105,7 @@ public class InterfacesOperationsToscaUtil {
*/
public static void addInterfaceDefinitionElement(Component component, ToscaNodeType nodeType,
Map<String, DataTypeDefinition> dataTypes,
- boolean isAssociatedResourceComponent) {
+ boolean isAssociatedComponent) {
if (component instanceof Product) {
return;
}
@@ -113,7 +114,7 @@ public class InterfacesOperationsToscaUtil {
return;
}
Map<String, Object> toscaInterfaceDefinitions = getInterfacesMap(component, dataTypes,
- isAssociatedResourceComponent);
+ isAssociatedComponent);
if (MapUtils.isNotEmpty(toscaInterfaceDefinitions)) {
nodeType.setInterfaces(toscaInterfaceDefinitions);
}
@@ -121,14 +122,15 @@ public class InterfacesOperationsToscaUtil {
private static Map<String, Object> getInterfacesMap(Component component,
Map<String, DataTypeDefinition> dataTypes,
- boolean isAssociatedResourceComponent) {
- return getInterfacesMap(component, component.getInterfaces(), dataTypes, isAssociatedResourceComponent, false);
+ boolean isAssociatedComponent) {
+ return getInterfacesMap(component, null, component.getInterfaces(), dataTypes, isAssociatedComponent, false);
}
public static Map<String, Object> getInterfacesMap(Component component,
+ ComponentInstance componentInstance,
Map<String, InterfaceDefinition> interfaces,
Map<String, DataTypeDefinition> dataTypes,
- boolean isAssociatedResourceComponent,
+ boolean isAssociatedComponent,
boolean isServiceProxyInterface) {
if(MapUtils.isEmpty(interfaces)) {
return null;
@@ -147,8 +149,8 @@ public class InterfacesOperationsToscaUtil {
ToscaLifecycleOperationDefinition toscaOperation = new ToscaLifecycleOperationDefinition();
if (isArtifactPresent(operationEntry)) {
operationArtifactPath = OperationArtifactUtil
- .createOperationArtifactPath(component, operationEntry.getValue(),
- isAssociatedResourceComponent);
+ .createOperationArtifactPath(component, componentInstance, operationEntry.getValue(),
+ isAssociatedComponent);
toscaOperation.setImplementation(operationArtifactPath);
}
toscaOperation.setDescription(operationEntry.getValue().getDescription());
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 0d772cfcab..b10a8883d2 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
@@ -20,6 +20,7 @@ import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@@ -30,6 +31,7 @@ import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.Resource;
@@ -52,22 +54,31 @@ public class OperationArtifactUtil {
* @param operation the specific operation name
* @return the full path including file name for operation's artifacts
*/
- static String createOperationArtifactPath(Component component, OperationDataDefinition operation,
- boolean isAssociatedResourceComponent) {
+ static String createOperationArtifactPath(Component component, ComponentInstance componentInstance,
+ OperationDataDefinition operation, boolean isAssociatedComponent) {
if (!(component instanceof Resource || component instanceof Service)) {
return null;
}
- if (isAssociatedResourceComponent) {
- ResourceMetadataDataDefinition resourceMetadataDataDefinition = (ResourceMetadataDataDefinition)
- component.getComponentMetadataDefinition().getMetadataDataDefinition();
- return createOperationArtifactPathInService(resourceMetadataDataDefinition.getToscaResourceName() +
- "_v" + component.getVersion(), operation);
+
+ if (isAssociatedComponent) {
+ // Service Proxy is only in Node Template interface
+ if(componentInstance != null) {
+ return createOperationArtifactPathInService(componentInstance.getToscaComponentName()
+ + "_v" + component.getVersion(), operation);
+ }
+ // Resource Instance is part of Node Type interface
+ else {
+ ResourceMetadataDataDefinition resourceMetadataDataDefinition =
+ (ResourceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition();
+ return createOperationArtifactPathInService(resourceMetadataDataDefinition.getToscaResourceName()
+ + "_v" + component.getVersion(), operation);
+ }
}
- return createOperationArtifactPathInResource(operation);
+ return createOperationArtifactPathInComponent(operation);
}
- private static String createOperationArtifactPathInResource(OperationDataDefinition operation) {
+ private static String createOperationArtifactPathInComponent(OperationDataDefinition operation) {
return CsarUtils.ARTIFACTS + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name())
+ File.separator + ArtifactTypeEnum.WORKFLOW.name() + File.separator + BPMN_ARTIFACT_PATH
+ File.separator + operation.getImplementation().getArtifactName();
@@ -89,7 +100,7 @@ public class OperationArtifactUtil {
}
Map<String, ArtifactDefinition> interfaceArtifacts = interfaces.values().stream()
.flatMap(interfaceDefinition -> interfaceDefinition.getOperationsMap().values().stream())
- .map(Operation::getImplementationArtifact)
+ .map(Operation::getImplementationArtifact).filter(Objects::nonNull)
.collect(Collectors.toMap(ArtifactDataDefinition::getUniqueId,
artifactDefinition -> artifactDefinition));
if (MapUtils.isNotEmpty(interfaceArtifacts)) {