From c947189eb1a342ee14e1aebc43d45b41bf0d3dd6 Mon Sep 17 00:00:00 2001 From: shikha0203 Date: Fri, 17 Feb 2023 13:15:51 +0000 Subject: AbstractTemplateServlet- fix null test for "tags" Issue-ID: SDC-4397 Signed-off-by: shikha0203 Change-Id: Ia95e76c5ddbed740cbfbab581b0d8fdc56e90194 --- .../sdc/be/externalapi/servlet/AbstractTemplateServlet.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'catalog-be/src/main/java/org') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServlet.java index 19b2c3468b..411e0dcfd9 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AbstractTemplateServlet.java @@ -26,6 +26,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.servers.Server; import io.swagger.v3.oas.annotations.tags.Tag; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import javax.servlet.http.HttpServletRequest; @@ -38,6 +39,8 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + +import org.apache.commons.collections.CollectionUtils; import org.openecomp.sdc.be.components.impl.AbstractTemplateBusinessLogic; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; import org.openecomp.sdc.be.components.impl.ElementBusinessLogic; @@ -226,13 +229,16 @@ public class AbstractTemplateServlet extends AbstractValidationsServlet { log.debug("getServiceAbstractStatus: Service Fetching Success"); Service service = (Service) assetTypeData.left().value().get(0); List tags = service.getTags(); - if (tags != null && !tags.isEmpty()) { + if (CollectionUtils.isNotEmpty(tags)) { + for (int i = tags.size() - 1; i >= 0; i--) { String tag = tags.get(i); if (service.getName().equals(tag)) { tags.remove(tag); } } + } else { + tags = new ArrayList<>(); } service.setName(copyServiceInfo.getNewServiceName()); tags.add(copyServiceInfo.getNewServiceName()); -- cgit 1.2.3-korg