aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-01-18 22:16:17 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-01-19 12:30:39 +0000
commit8edfa4dee9fed9be5b38133847c60136294eba80 (patch)
treecd5d9593ed7c8778912a1941e52dde2c8a0748b7 /catalog-be/src
parentc183513f5c5813f6a911a5ceb7ac81405007aaff (diff)
Fix 'Primitive types should not be shown under data types in catalog'-bug
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: Ic20f7c5a0784c2107061f268c5c2e03ab34c13cc Issue-ID: SDC-4338
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java21
1 files changed, 14 insertions, 7 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
index fe08b5cd74..fd8b61887a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
@@ -37,6 +37,7 @@ import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
@@ -47,7 +48,6 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.collections4.ListUtils;
import org.openecomp.sdc.be.components.impl.ArtifactTypeBusinessLogic;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.CapabilitiesBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
@@ -73,6 +73,7 @@ import org.openecomp.sdc.be.model.Model;
import org.openecomp.sdc.be.model.RelationshipTypeDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.impl.ModelOperation;
+import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.datastructure.Wrapper;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
@@ -165,24 +166,29 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
@ApiResponse(responseCode = "404", description = "Data types not found")})
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response getAllDataTypesFromAllModels(@Context final HttpServletRequest request,
- @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
+ @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
+ @QueryParam("excludePrimitives") @DefaultValue("false") String excludePrimitives) {
Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<User> userWrapper = new Wrapper<>();
init();
validateUserExist(responseWrapper, userWrapper, userId);
if (responseWrapper.isEmpty()) {
+ final boolean exclude = Boolean.parseBoolean(excludePrimitives);
String url = request.getMethod() + " " + request.getRequestURI();
log.debug("Start handle request of {} - modifier id is {}", url, userId);
resourceBusinessLogic.getApplicationDataTypeCache().refreshDataTypesCacheIfStale();
final List<Map<String, DataTypeDefinition>> dataTypesList = new ArrayList<>();
List<Model> models = modelOperation.findAllModels();
- Model defaultModel = new Model();
- defaultModel.setName(null);
- models.add(defaultModel);
+ models.add(new Model(null));
models.forEach(model -> {
final Map<String, DataTypeDefinition> dataTypes = resourceBusinessLogic.getComponentsUtils()
.getAllDataTypes(resourceBusinessLogic.getApplicationDataTypeCache(), model.getName());
- dataTypesList.add(dataTypes);
+ if (exclude) {
+ dataTypesList.add(dataTypes.entrySet().stream().filter(entry -> !ToscaPropertyType.isScalarType(entry.getKey()))
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
+ } else {
+ dataTypesList.add(dataTypes);
+ }
});
String dataTypeJson = gson.toJson(dataTypesList);
Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), dataTypeJson);
@@ -382,7 +388,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
public Response getAllToscaArtifactTypes(@Parameter(description = "Model name") @QueryParam("model") String model,
@Context final HttpServletRequest request, @HeaderParam(Constants.USER_ID_HEADER) String creator) {
try {
- return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), artifactTypeBusinessLogic.getAllToscaArtifactTypes(model));
+ return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK),
+ artifactTypeBusinessLogic.getAllToscaArtifactTypes(model));
} catch (final BusinessException e) {
throw e;
} catch (final Exception e) {