summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2023-01-20 22:31:39 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-01-23 19:53:48 +0000
commitf6b1fff5f297765305c17b1c6bdf540132232233 (patch)
tree1bbc06d426b2bfbe4b80a2c1b137eb6487dab401 /catalog-be/src
parentf0100abd146b8c97e4b1ff0ba74175a24bbc5e98 (diff)
Disable editing of normative data types
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4341 Change-Id: Id7673624032883c641e05fd6e5e3d599f7da14df
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesUploadServlet.java2
2 files changed, 6 insertions, 4 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java
index d488c65b22..3ebd0bee5b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java
@@ -66,7 +66,7 @@ public class DataTypeImportManager {
public Either<List<ImmutablePair<DataTypeDefinition, Boolean>>, ResponseFormat> createDataTypes(final String dataTypeYml, final String modelName,
final boolean includeToModelDefaultImports) {
final Either<List<ImmutablePair<DataTypeDefinition, Boolean>>, ResponseFormat> elementTypes = commonImportManager.createElementTypes(
- dataTypeYml, dataTypesFromYml -> createDataTypesFromYml(dataTypeYml, modelName), this::createDataTypesByDao, ElementTypeEnum.DATA_TYPE);
+ dataTypeYml, dataTypesFromYml -> createDataTypesFromYml(dataTypeYml, modelName, !includeToModelDefaultImports), this::createDataTypesByDao, ElementTypeEnum.DATA_TYPE);
if (includeToModelDefaultImports && StringUtils.isNotEmpty(modelName)) {
commonImportManager.addTypesToDefaultImports(ElementTypeEnum.DATA_TYPE, dataTypeYml, modelName);
@@ -77,7 +77,7 @@ public class DataTypeImportManager {
return elementTypes;
}
- private Either<List<DataTypeDefinition>, ActionStatus> createDataTypesFromYml(final String dataTypesYml, final String modelName) {
+ private Either<List<DataTypeDefinition>, ActionStatus> createDataTypesFromYml(final String dataTypesYml, final String modelName, final boolean normative) {
final Either<List<DataTypeDefinition>, ActionStatus> dataTypesEither = commonImportManager.createElementTypesFromYml(dataTypesYml,
this::createDataType);
if (dataTypesEither.isRight()) {
@@ -87,10 +87,12 @@ public class DataTypeImportManager {
if (StringUtils.isNotEmpty(modelName)) {
final Optional<Model> modelOptional = modelOperation.findModelByName(modelName);
if (modelOptional.isPresent()) {
- dataTypes.forEach(dataType -> dataType.setModel(modelName));
+ dataTypes.forEach(dataType -> {dataType.setModel(modelName); dataType.setNormative(normative);});
} else {
return Either.right(ActionStatus.INVALID_MODEL);
}
+ } else {
+ dataTypes.forEach(dataType -> dataType.setNormative(normative));
}
if (log.isTraceEnabled()) {
log.trace("Unsorted datatypes order:");
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesUploadServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesUploadServlet.java
index f07a742ab5..786c0338c4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesUploadServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesUploadServlet.java
@@ -228,7 +228,7 @@ public class TypesUploadServlet extends AbstractValidationsServlet {
public Response uploadDataTypes(@Parameter(description = "FileInputStream") @FormDataParam("dataTypesZip") File file,
@Context final HttpServletRequest request, @HeaderParam("USER_ID") String creator,
@Parameter(description = "model") @FormDataParam("model") String modelName,
- @Parameter(description = "includeToModelImport") @FormDataParam("includeToModelImport") boolean includeToModelDefaultImports) {
+ @Parameter(description = "includeToModelImport") @FormDataParam("includeToModelImport") boolean includeToModelDefaultImports) {
return uploadElementTypeServletLogic(this::createDataTypes, file, request, creator, NodeTypeEnum.DataType.getName(), modelName,
includeToModelDefaultImports);
}