summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java55
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java38
-rw-r--r--catalog-be/src/main/resources/config/error-configuration.yaml8
3 files changed, 69 insertions, 32 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 d17762fc90..250fc03c21 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
@@ -179,11 +179,11 @@ public class InterfaceOperationValidation {
}
if (MapUtils.isNotEmpty(component.getInterfaces()) && isUpdate) {
- Either<Boolean, ResponseFormat> mappedOutputDeletedResponse =
- validateMappedOutputNotDeleted(interfaceOperation, component, inputInterfaceDefinition,
+ Either<Boolean, ResponseFormat> mappedOutputModifiedResponse =
+ validateMappedOutputNotModified(interfaceOperation, component, inputInterfaceDefinition,
responseFormatManager);
- if (mappedOutputDeletedResponse.isRight()) {
- return Either.right(mappedOutputDeletedResponse.right().value());
+ if (mappedOutputModifiedResponse.isRight()) {
+ return Either.right(mappedOutputModifiedResponse.right().value());
}
}
@@ -191,7 +191,7 @@ public class InterfaceOperationValidation {
}
- private Either<Boolean, ResponseFormat> validateMappedOutputNotDeleted(Operation interfaceOperation,
+ private Either<Boolean, ResponseFormat> validateMappedOutputNotModified(Operation interfaceOperation,
org.openecomp.sdc.be.model.Component component, InterfaceDefinition interfaceDefinition,
ResponseFormatManager responseFormatManager) {
@@ -222,6 +222,18 @@ public class InterfaceOperationValidation {
if (CollectionUtils.isNotEmpty(deletedMappedOutputs)) {
return getMappedOutputErrorResponse(responseFormatManager, deletedMappedOutputs);
}
+
+ if (currentOutputs != null && !currentOutputs.isEmpty()) {
+ Set<String> unchangedOutputNames = Sets.intersection(existingOperationOutputNames,
+ currentOperationOutputNames);
+ Set<String> modifiedMappedOutputNames =
+ getModifiedMappedOutputNames(currentOutputs.getListToscaDataDefinition(),
+ existingOperationOutputs, unchangedOutputNames);
+ if (CollectionUtils.isNotEmpty(modifiedMappedOutputNames)) {
+ return getMappedOutputErrorResponse(responseFormatManager, modifiedMappedOutputNames);
+ }
+ }
+
return Either.left(Boolean.TRUE);
}
@@ -234,13 +246,36 @@ public class InterfaceOperationValidation {
.equals(mappedOutputPrefix + "." + outputName));
}
+ private static Set<String> getModifiedMappedOutputNames(List<OperationOutputDefinition> currentOperationOutputs,
+ List<OperationOutputDefinition> existingOperationOutputs,
+ Set<String> unchangedOutputNames) {
+ Set<String> modifiedOutputDefinitionNames = new HashSet<>();
+ Map<String, OperationOutputDefinition> newOutputMap =
+ currentOperationOutputs.stream().collect(Collectors.toMap(OperationOutputDefinition::getName,
+ (OperationOutputDefinition operationOutputDefinition) -> operationOutputDefinition));
+
+ Map<String, OperationOutputDefinition> existingOutputMap =
+ existingOperationOutputs.stream().collect(Collectors.toMap(OperationOutputDefinition::getName,
+ (OperationOutputDefinition operationOutputDefinition) -> operationOutputDefinition));
+
+ for (String outputName : unchangedOutputNames) {
+ OperationOutputDefinition existingOutputDefinition = existingOutputMap.get(outputName);
+ OperationOutputDefinition newOutputDefinition = newOutputMap.get(outputName);
+ if (!existingOutputDefinition.getType().equals(newOutputDefinition.getType())
+ || !existingOutputDefinition.isRequired().equals(newOutputDefinition.isRequired())) {
+ modifiedOutputDefinitionNames.add(outputName);
+ }
+ }
+ return modifiedOutputDefinitionNames;
+ }
+
private Either<Boolean, ResponseFormat> getMappedOutputErrorResponse(ResponseFormatManager responseFormatManager,
- Set<String> deletedMappedOutputs) {
- String deletedOutputNameList = String.join(",", deletedMappedOutputs);
- LOGGER.error("Cannot update name or delete interface operation output(s) '{}' mapped to an operation input",
- deletedOutputNameList);
+ Set<String> modifiedMappedOutputs) {
+ String modifiedOutputNameList = String.join(",", modifiedMappedOutputs);
+ LOGGER.error("Cannot update or delete interface operation output(s) '{}' mapped to an operation input",
+ modifiedOutputNameList);
ResponseFormat errorResponse = responseFormatManager.getResponseFormat(ActionStatus
- .INTERFACE_OPERATION_MAPPED_OUTPUT_DELETED, deletedOutputNameList);
+ .INTERFACE_OPERATION_MAPPED_OUTPUT_MODIFIED, modifiedOutputNameList);
return Either.right(errorResponse);
}
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 efed3e9f15..106aa58133 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
@@ -20,14 +20,12 @@ import static org.openecomp.sdc.be.components.utils.InterfaceOperationUtils.isOp
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-
import org.apache.commons.collections.MapUtils;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
@@ -59,7 +57,7 @@ public class InterfacesOperationsToscaUtil {
}
/**
- * Creates the interface_types element
+ * Creates the interface_types element.
*
* @param component to work on
* @return the added element
@@ -99,7 +97,7 @@ public class InterfacesOperationsToscaUtil {
}
/**
- * Adds the 'interfaces' element to the node type provided
+ * Adds the 'interfaces' element to the node type provided.
*
* @param component to work on
* @param nodeType to which the interfaces element will be added
@@ -131,7 +129,7 @@ public class InterfacesOperationsToscaUtil {
toscaOperation.setImplementation(operationArtifactPath);
}
toscaOperation.setDescription(operationEntry.getValue().getDescription());
- fillToscaOperationInputs(operationEntry.getValue(), toscaOperation, interfaceType, component);
+ fillToscaOperationInputs(operationEntry.getValue(), toscaOperation, component);
toscaOperations.put(operationEntry.getValue().getName(), toscaOperation);
}
@@ -148,7 +146,7 @@ public class InterfacesOperationsToscaUtil {
}
}
- /***
+ /*
* workaround for : currently "defaultp" is not being converted to "default" by the relevant code in
* ToscaExportHandler so, any string Map key named "defaultp" will have its named changed to "default"
* @param operationsMap the map to update
@@ -181,7 +179,6 @@ public class InterfacesOperationsToscaUtil {
private static void fillToscaOperationInputs(OperationDataDefinition operation,
ToscaLifecycleOperationDefinition toscaOperation,
- String interfaceType,
Component component) {
if (Objects.isNull(operation.getInputs()) || operation.getInputs().isEmpty()) {
toscaOperation.setInputs(null);
@@ -199,7 +196,7 @@ public class InterfacesOperationsToscaUtil {
toscaInput.setDefaultp(createMappedInputPropertyDefaultValue(mappedPropertyName));
} else {
mappedPropertyName = input.getInputId();
- toscaInput.setDefaultp(createMappedOutputDefaultValue(mappedPropertyName, interfaceType));
+ toscaInput.setDefaultp(createMappedOutputDefaultValue(mappedPropertyName));
}
}
toscaInput.setType(input.getType());
@@ -224,23 +221,28 @@ public class InterfacesOperationsToscaUtil {
}
/**
- * Create the value for operation input mapped to an operation output
+ * Create the value for operation input mapped to an operation output.
* @param propertyName the mapped other operation output full name
- * @param interfaceType full interface name
* @return input map for tosca
*/
- private static Map<String, List<String>> createMappedOutputDefaultValue(String propertyName, String interfaceType) {
+ private static Map<String, List<String>> createMappedOutputDefaultValue(String propertyName) {
Map<String, List<String>> getOperationOutputMap = new HashMap<>();
//For operation input mapped to other operation output parameter, the mapped property value
// should be of the format <interface name>.<operation name>.<output parameter name>
+ // Operation name and output param name should not contain "."
List<String> defaultMappedOperationOutputValue = new ArrayList<>();
- defaultMappedOperationOutputValue.add(SELF);
- String fullOutputPropertyName =
- propertyName.substring(propertyName.indexOf(interfaceType) + interfaceType.length() + 1);
- defaultMappedOperationOutputValue.add(interfaceType);
- //Output name should not contain dot
- defaultMappedOperationOutputValue.addAll(Arrays.asList(fullOutputPropertyName.split("\\.")));
- getOperationOutputMap.put(GET_OPERATION_OUTPUT, defaultMappedOperationOutputValue);
+ String[] tokens = propertyName.split("\\.");
+ if (tokens.length > 2) {
+ defaultMappedOperationOutputValue.add(SELF);
+ String outputPropertyName = tokens[tokens.length - 1];
+ String operationName = tokens[tokens.length - 2];
+ String mappedPropertyInterfaceType =
+ propertyName.substring(0, propertyName.indexOf(operationName + '.' + outputPropertyName) - 1);
+ String interfaceName =
+ mappedPropertyInterfaceType.substring(mappedPropertyInterfaceType.lastIndexOf('.') + 1);
+ defaultMappedOperationOutputValue.addAll(Arrays.asList(interfaceName, operationName, outputPropertyName));
+ getOperationOutputMap.put(GET_OPERATION_OUTPUT, defaultMappedOperationOutputValue);
+ }
return getOperationOutputMap;
}
diff --git a/catalog-be/src/main/resources/config/error-configuration.yaml b/catalog-be/src/main/resources/config/error-configuration.yaml
index 69f67e63ed..c92b0fd771 100644
--- a/catalog-be/src/main/resources/config/error-configuration.yaml
+++ b/catalog-be/src/main/resources/config/error-configuration.yaml
@@ -2235,10 +2235,10 @@ errors:
message: "Error: Property type %1 provided against %2 is not supported for static value.",
messageId: "SVC4721"
}
-#---------SVC4714-----------------------------
+#---------SVC4723-----------------------------
# %1 - Interface Operation output name
- INTERFACE_OPERATION_MAPPED_OUTPUT_DELETED: {
+ INTERFACE_OPERATION_MAPPED_OUTPUT_MODIFIED: {
code: 400,
- message: "Error: Cannot update name or delete interface operation output(s) '%1' mapped to an operation input",
- messageId: "SVC4714"
+ message: "Error: Cannot update or delete interface operation output(s) '%1' mapped to an operation input",
+ messageId: "SVC4723"
} \ No newline at end of file
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030