diff options
author | sebdet <sebastien.determe@intl.att.com> | 2020-06-19 14:40:16 +0200 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-07-05 07:58:46 +0000 |
commit | e4092fe48f6dd74c778a03d84df00835d6ca0a3d (patch) | |
tree | 7399f6c525be428cacd7c6b2e4dffd3e3d7e6b91 /catalog-be/src/main/java/org | |
parent | df10d0be06468d55818fa734321c14827fef61bb (diff) |
Fix sonar issues
Fix sonar/checkstyle issues in sdc code
Issue-ID: SDC-3116
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Change-Id: Ic29f9233838e15b195d1a339bfac8e6d56888609
Diffstat (limited to 'catalog-be/src/main/java/org')
5 files changed, 110 insertions, 150 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java index 1eb4bf651c..3955fdd519 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java @@ -29,9 +29,25 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.servers.Server; -import io.swagger.v3.oas.annotations.servers.Servers; import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.tags.Tags; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; @@ -59,25 +75,6 @@ import org.openecomp.sdc.common.util.GeneralUtility; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.stereotype.Controller; -import javax.inject.Inject; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; - /** * This Servlet serves external users operations on artifacts. * @@ -86,8 +83,8 @@ import java.util.Map; */ @Loggable(prepend = true, value = Loggable.DEBUG, trim = false) @Path("/v1/catalog") -@Tags({@Tag(name = "SDC External APIs")}) -@Servers({@Server(url = "/sdc")}) +@Tag(name = "SDC External APIs") +@Server(url = "/sdc") @Controller public class ArtifactExternalServlet extends AbstractValidationsServlet { @@ -170,7 +167,7 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet { ResponseFormat responseFormat = null; String requestURI = request.getRequestURI(); String url = request.getMethod() + " " + requestURI; - log.debug("{} {}", startLog, url); + log.debug(DOUBLE_CURLY_BRACKETS, startLog, url); ResourceCommonInfo resourceCommonInfo = new ResourceCommonInfo(assetType); ArtifactDefinition artifactDefinition = null; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java index 4f374e0f54..b9412f680f 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/CrudExternalServlet.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,6 +20,8 @@ package org.openecomp.sdc.be.externalapi.servlet; +import static com.google.common.base.Strings.isNullOrEmpty; + import com.fasterxml.jackson.databind.ObjectMapper; import com.jcabi.aspects.Loggable; import fj.data.Either; @@ -30,9 +32,23 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.servers.Server; -import io.swagger.v3.oas.annotations.servers.Servers; import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.tags.Tags; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +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.lang3.StringUtils; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; @@ -81,31 +97,10 @@ import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.stereotype.Controller; -import javax.inject.Inject; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import static com.google.common.base.Strings.isNullOrEmpty; - - @Loggable(prepend = true, value = Loggable.DEBUG, trim = false) @Path("/v1/catalog") -@Tags({@Tag(name = "SDC External APIs")}) -@Servers({@Server(url = "/sdc")}) +@Tag(name = "SDC External APIs") +@Server(url = "/sdc") @Controller public class CrudExternalServlet extends AbstractValidationsServlet { @@ -228,7 +223,6 @@ public class CrudExternalServlet extends AbstractValidationsServlet { ResourceCommonInfo resourceCommonInfo = new ResourceCommonInfo(ComponentTypeEnum.RESOURCE.getValue()); Service service = null; - ServletContext context = request.getSession().getServletContext(); try { // Validate X-ECOMP-InstanceID Header if (responseWrapper.isEmpty()) { @@ -328,12 +322,9 @@ public class CrudExternalServlet extends AbstractValidationsServlet { } //validate name exist - if(responseWrapper.isEmpty()){ - if(isNullOrEmpty(resource.getName())){ + if(responseWrapper.isEmpty() && isNullOrEmpty(resource.getName())){ responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat( ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue())); - - } } if(responseWrapper.isEmpty()){ @@ -634,10 +625,10 @@ public class CrudExternalServlet extends AbstractValidationsServlet { validateHttpCspUserIdHeader(request.getHeader(Constants.USER_ID_HEADER),responseWrapper); } // Validate assetType - if (responseWrapper.isEmpty()) { - if( !AssetTypeEnum.RESOURCES.getValue().equals(assetType) && !AssetTypeEnum.SERVICES.getValue().equals(assetType)){ + if (responseWrapper.isEmpty() + && !AssetTypeEnum.RESOURCES.getValue().equals(assetType) + && !AssetTypeEnum.SERVICES.getValue().equals(assetType)) { responseWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.RESTRICTED_OPERATION)); - } } return responseWrapper; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ServiceActivationServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ServiceActivationServlet.java index 929d77e0fc..f590ebd96f 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ServiceActivationServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ServiceActivationServlet.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,9 +27,19 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.servers.Server; -import io.swagger.v3.oas.annotations.servers.Servers; import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.tags.Tags; +import java.io.IOException; +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +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.lang3.StringUtils; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; import org.openecomp.sdc.be.components.impl.ResourceImportManager; @@ -53,27 +63,14 @@ import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.stereotype.Controller; -import javax.inject.Inject; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.IOException; - /** * Created by chaya on 10/17/2017. */ @SuppressWarnings("ALL") @Loggable(prepend = true, value = Loggable.DEBUG, trim = false) @Path("/v1/catalog") -@Tags({@Tag(name = "SDC External APIs")}) -@Servers({@Server(url = "/sdc")}) +@Tag(name = "SDC External APIs") +@Server(url = "/sdc") @Controller public class ServiceActivationServlet extends AbstractValidationsServlet { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java index fb1290310d..7e94c8506a 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java @@ -26,7 +26,21 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import fj.data.Either; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Optional; +import java.util.function.Supplier; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections4.MapUtils; import org.apache.commons.io.IOUtils; @@ -68,21 +82,6 @@ import org.openecomp.sdc.common.zip.exception.ZipException; import org.openecomp.sdc.exception.ResponseFormat; import org.yaml.snakeyaml.Yaml; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Type; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Supplier; - public abstract class AbstractValidationsServlet extends BeGenericServlet { private static final Logger log = Logger.getLogger(AbstractValidationsServlet.class); @@ -603,11 +602,10 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet { } // User Defined Type Resources - if (resourceAuthorityEnum.isUserTypeResource() && !CsarValidationUtils.isCsarPayloadName(uploadResourceInfoWrapper.getInnerElement().getPayloadName())) { - if (responseWrapper.isEmpty()) { - validatePayloadNameSpace(responseWrapper, uploadResourceInfoWrapper.getInnerElement(), user, yamlStringWrapper.getInnerElement()); - } - + if (resourceAuthorityEnum.isUserTypeResource() + && !CsarValidationUtils.isCsarPayloadName(uploadResourceInfoWrapper.getInnerElement().getPayloadName()) + && responseWrapper.isEmpty()) { + validatePayloadNameSpace(responseWrapper, uploadResourceInfoWrapper.getInnerElement(), user, yamlStringWrapper.getInnerElement()); } } } @@ -815,8 +813,6 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet { } catch (final ZipException e) { log.info("Failed to unzip received csar {}", csarUUID, e); } - if (MapUtils.isEmpty(csar)) { - } return csar; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java index 64f6550bec..34b261b106 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,9 +35,7 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.servers.Server; -import io.swagger.v3.oas.annotations.servers.Servers; import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.tags.Tags; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Type; @@ -104,12 +102,12 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.stereotype.Controller; /** - * Root resource (exposed at "/" path) .json + * Root resource (exposed at "/" path) .json. */ @Loggable(prepend = true, value = Loggable.DEBUG, trim = false) @Path("/v1/catalog") -@Tags({@Tag(name = "SDC Internal APIs")}) -@Servers({@Server(url = "/sdc2/rest")}) +@Tag(name = "SDC Internal APIs") +@Server(url = "/sdc2/rest") @Controller public class ComponentInstanceServlet extends AbstractValidationsServlet { @@ -132,7 +130,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { private static final LoggerSupportability loggerSupportability = LoggerSupportability.getLogger(ComponentInstanceServlet.class.getName()); private final GroupBusinessLogic groupBL; - private final ComponentInstanceBusinessLogic componentInstanceBusinessLogic; private final ComponentNodeFilterBusinessLogic nodeFilterBusinessLogic; @@ -144,7 +141,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { ComponentNodeFilterBusinessLogic nodeFilterBusinessLogic) { super(userBusinessLogic, componentInstanceBL, componentsUtils, servletUtils, resourceImportManager); this.groupBL = groupBL; - this.componentInstanceBusinessLogic = componentInstanceBL; this.nodeFilterBusinessLogic = nodeFilterBusinessLogic; } @@ -168,7 +164,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @HeaderParam(value = Constants.USER_ID_HEADER) @Parameter(description = "USER_ID of modifier user", required = true) String userId, @Context final HttpServletRequest request) { - + validateNotEmptyBody(data); ComponentInstance componentInstance = null; try { @@ -214,8 +210,13 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { log.debug(START_HANDLE_REQUEST_OF, url); loggerSupportability.log(LoggerSupportabilityActions.UPDATE_COMPONENT_INSTANCE,StatusCode.STARTED,"update Component Instance Metadata"); final String userId = request.getHeader(Constants.USER_ID_HEADER); - componentInstanceBusinessLogic.validateUser(userId); - try { + try { + if (componentInstanceBusinessLogic == null) { + log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, + containerComponentType)); + } + componentInstanceBusinessLogic.validateUser(userId); log.debug(START_HANDLE_REQUEST_OF, url); final byte[] bytes = IOUtils.toByteArray(request.getInputStream()); @@ -226,11 +227,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { final String data = new String(bytes); final ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); - if (componentInstanceBusinessLogic == null) { - log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); - return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, - containerComponentType)); - } final Either<ComponentInstance, ResponseFormat> convertResponse = convertToResourceInstance(data); if (convertResponse.isRight()) { BeEcompErrorManager.getInstance().logBeSystemError(RESOURCE_INSTANCE_UPDATE_RESOURCE_INSTANCE); @@ -317,7 +313,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { String userId = request.getHeader(Constants.USER_ID_HEADER); - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); @@ -363,12 +358,11 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { ComponentTypeEnum.SERVICE_PARAM_NAME, ComponentTypeEnum.PRODUCT_PARAM_NAME})) @PathParam("containerComponentType") final String containerComponentType, @Context final HttpServletRequest request) { - + String url = request.getMethod() + " " + request.getRequestURI(); try { log.debug(START_HANDLE_REQUEST_OF, url); - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); @@ -414,7 +408,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { String url = request.getMethod() + " " + request.getRequestURI(); log.debug(START_HANDLE_REQUEST_OF, url); - Response response = null; loggerSupportability.log(LoggerSupportabilityActions.ASSOCIATE_RI_TO_RI, StatusCode.STARTED,"Starting to associate RI To RI for component {} ",componentId + " by " + userId ); try { @@ -524,10 +517,8 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { } String userId = request.getHeader(Constants.USER_ID_HEADER); - String data = new String(bytes); - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); @@ -599,7 +590,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { return buildErrorResponse(errorWrapper.getInnerElement()); } log.debug(START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_PROPERTY_RECEIVED_PROPERTY_IS, propertiesToUpdate); - + ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); @@ -664,7 +655,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { return buildErrorResponse(errorWrapper.getInnerElement()); } log.debug(START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_PROPERTY_RECEIVED_PROPERTY_IS, inputsToUpdate); - + ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); @@ -786,7 +777,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { value = Constants.USER_ID_HEADER) String userId, @Context final HttpServletRequest request) { - + loggerSupportability.log(LoggerSupportabilityActions.UPDATE_PROPERTIES, StatusCode.STARTED,"Starting to delete Resource Instance Property for component {} ",componentId + " by " + userId ); String url = request.getMethod() + " " + request.getRequestURI(); log.debug(START_HANDLE_REQUEST_OF, url); @@ -842,10 +833,8 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { } String userId = request.getHeader(Constants.USER_ID_HEADER); - String data = new String(bytes); - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); @@ -918,7 +907,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { log.debug(START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_PROPERTY_RECEIVED_PROPERTY_IS, property); - + ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { @@ -999,7 +988,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @PathParam("componentInstanceUniqueId") final String componentInstanceUniqueId, @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) { - + String url = request.getMethod() + " " + request.getRequestURI(); log.debug(GET_START_HANDLE_REQUEST_OF, url); @@ -1027,13 +1016,11 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @PathParam("capabilityName") final String capabilityName, @PathParam("ownerId") final String ownerId, @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) { - + String url = request.getMethod() + " " + request.getRequestURI(); log.debug(GET_START_HANDLE_REQUEST_OF, url); try { - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); - List<ComponentInstanceProperty> componentInstancePropertiesById = componentInstanceBusinessLogic.getComponentInstanceCapabilityPropertiesById(containerComponentType, containerComponentId, componentInstanceUniqueId, capabilityType, capabilityName, ownerId, userId); @@ -1168,16 +1155,14 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { schema = @Schema(allowableValues = {ComponentTypeEnum.RESOURCE_PARAM_NAME, ComponentTypeEnum.SERVICE_PARAM_NAME})) @PathParam("containerComponentType") final String containerComponentType, @Context final HttpServletRequest request) { - + String url = request.getMethod() + " " + request.getRequestURI(); try { log.debug(START_HANDLE_REQUEST_OF, url); - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); } - String userId = request.getHeader(Constants.USER_ID_HEADER); Either<ComponentInstance, ResponseFormat> actionResponse = componentInstanceBusinessLogic.deleteServiceProxy(); if (actionResponse.isRight()) { @@ -1209,15 +1194,11 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { schema = @Schema(allowableValues = {ComponentTypeEnum.RESOURCE_PARAM_NAME, ComponentTypeEnum.SERVICE_PARAM_NAME})) @PathParam("containerComponentType") final String containerComponentType, @Context final HttpServletRequest request) { - + String url = request.getMethod() + " " + request.getRequestURI(); log.debug(START_HANDLE_REQUEST_OF, url); try { - - String userId = request.getHeader(Constants.USER_ID_HEADER); - - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); @@ -1260,7 +1241,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @PathParam("componentId") final String componentId, @PathParam("relationId") final String relationId, @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) { - + String url = request.getMethod() + " " + request.getRequestURI(); log.debug(GET_START_HANDLE_REQUEST_OF, url); try { @@ -1332,8 +1313,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { if (convertStatus.isRight()) { throw new ByActionStatusComponentException(convertStatus.right().value()); } - RequirementCapabilityRelDef requirementCapabilityRelDef = convertStatus.left().value(); - return requirementCapabilityRelDef; + return convertStatus.left().value(); } public <T> Either<T, ActionStatus> convertJsonToObject(String data, Class<T> clazz) { @@ -1376,11 +1356,10 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { if (newComponentInstanceId == null){ return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.MISSING_NEW_COMPONENT_INSTANCE)); } - + String url = request.getMethod() + " " + request.getRequestURI(); log.debug(START_HANDLE_REQUEST_OF, url); - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); @@ -1472,7 +1451,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { if (componentInstanceBusinessLogic == null) { - log.error("Unsupported component type {}", containerComponentType); + log.error(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); } @@ -1480,7 +1459,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { if (convertResponse.isRight()) { BeEcompErrorManager.getInstance().logBeSystemError("Resource Instance - batchDeleteResourceInstances"); - log.error("Failed to convert received data to BE format."); + log.error(FAILED_TO_CONVERT_RECEIVED_DATA_TO_BE_FORMAT); return buildErrorResponse(convertResponse.right().value()); } @@ -1520,7 +1499,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @HeaderParam(value = Constants.USER_ID_HEADER) String userId, @Parameter(description = "RelationshipInfo", required = true) String data, @Context final HttpServletRequest request) { - + try { if (data == null || data.length() == 0) { @@ -1531,7 +1510,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { - log.debug("Unsupported component type {}", containerComponentType); + log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); } |