diff options
Diffstat (limited to 'openecomp-be/api')
20 files changed, 233 insertions, 294 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java index 2ed5235867..e6f5e6b1a3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java @@ -20,86 +20,9 @@ package org.openecomp.sdcrests.action.rest.services; -import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_NAME; -import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_SUPPORTED_COMPONENTS; -import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_SUPPORTED_MODELS; -import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_FILE; -import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_NAME; -import static org.openecomp.sdc.action.ActionConstants.BE_FQDN; -import static org.openecomp.sdc.action.ActionConstants.CATEGORY_LOG_LEVEL; -import static org.openecomp.sdc.action.ActionConstants.CLIENT_IP; -import static org.openecomp.sdc.action.ActionConstants.ERROR_DESCRIPTION; -import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY; -import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT; -import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL; -import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME; -import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE; -import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_VENDOR; -import static org.openecomp.sdc.action.ActionConstants.INSTANCE_UUID; -import static org.openecomp.sdc.action.ActionConstants.LOCAL_ADDR; -import static org.openecomp.sdc.action.ActionConstants.MAX_ACTION_ARTIFACT_SIZE; -import static org.openecomp.sdc.action.ActionConstants.MDC_ASDC_INSTANCE_UUID; -import static org.openecomp.sdc.action.ActionConstants.PARTNER_NAME; -import static org.openecomp.sdc.action.ActionConstants.REMOTE_HOST; -import static org.openecomp.sdc.action.ActionConstants.REQUEST_EMPTY_BODY; -import static org.openecomp.sdc.action.ActionConstants.REQUEST_ID; -import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_CREATE_ACTION; -import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_UPDATE_ACTION; -import static org.openecomp.sdc.action.ActionConstants.REQUEST_TYPE_VERSION_ACTION; -import static org.openecomp.sdc.action.ActionConstants.SERVICE_INSTANCE_ID; -import static org.openecomp.sdc.action.ActionConstants.SERVICE_METRIC_BEGIN_TIMESTAMP; -import static org.openecomp.sdc.action.ActionConstants.SERVICE_NAME; -import static org.openecomp.sdc.action.ActionConstants.STATUS; -import static org.openecomp.sdc.action.ActionConstants.STATUS_CODE; -import static org.openecomp.sdc.action.ActionConstants.SUPPORTED_COMPONENTS_ID; -import static org.openecomp.sdc.action.ActionConstants.SUPPORTED_MODELS_VERSION_ID; -import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY; -import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_API; -import static org.openecomp.sdc.action.ActionConstants.TARGET_SERVICE_NAME; -import static org.openecomp.sdc.action.ActionConstants.TIMESTAMP; -import static org.openecomp.sdc.action.ActionConstants.UPDATED_BY; -import static org.openecomp.sdc.action.ActionConstants.X_OPEN_ECOMP_INSTANCE_ID_HEADER_PARAM; -import static org.openecomp.sdc.action.ActionConstants.X_OPEN_ECOMP_REQUEST_ID_HEADER_PARAM; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_PROTECTION_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_READ_FILE_ERROR; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_INSTANCE_ID_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_PARAM_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_BODY_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_ID_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_SEARCH_CRITERIA; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_MULT_SEARCH_CRITERIA; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_BODY_EMPTY; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_CONTENT_TYPE_INVALID; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_OPEN_ECOMP_INSTANCE_ID_INVALID; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_OPEN_ECOMP_REQUEST_ID_INVALID; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_FILTER_PARAM_INVALID; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_GENERIC_CODE; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_NAME; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_MISSING_MANDATORY_PARAM; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UNSUPPORTED_OPERATION; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE; -import static org.openecomp.sdc.action.util.ActionUtil.actionErrorLogProcessor; -import static org.openecomp.sdc.action.util.ActionUtil.actionLogPostProcessor; -import static org.openecomp.sdc.action.util.ActionUtil.getUtcDateStringFromTimestamp; - import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.action.ActionConstants; @@ -108,11 +31,9 @@ import org.openecomp.sdc.action.errors.ActionErrorConstants; import org.openecomp.sdc.action.errors.ActionException; import org.openecomp.sdc.action.logging.CategoryLogLevel; import org.openecomp.sdc.action.logging.StatusCode; -import org.openecomp.sdc.action.types.Action; -import org.openecomp.sdc.action.types.ActionArtifact; -import org.openecomp.sdc.action.types.ActionArtifactProtection; -import org.openecomp.sdc.action.types.ActionRequest; -import org.openecomp.sdc.action.types.OpenEcompComponent; +import org.openecomp.sdc.action.types.*; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdcrests.action.rest.Actions; import org.openecomp.sdcrests.action.rest.mapping.MapActionToActionResponseDto; import org.openecomp.sdcrests.action.types.ActionResponseDto; @@ -125,18 +46,18 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import javax.inject.Named; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import javax.inject.Named; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; +import java.util.*; + +import static org.openecomp.sdc.action.ActionConstants.*; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.*; +import static org.openecomp.sdc.action.util.ActionUtil.*; /** * Implements various CRUD API that can be performed on Action @@ -148,7 +69,7 @@ import javax.ws.rs.core.Response; @Validated public class ActionsImpl implements Actions { - private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName()); + private static final Logger LOGGER = (Logger) LoggerFactory.getLogger(ActionsImpl.class); @Autowired private ActionManager actionManager; private String whitespaceCharacters = "\\s" /* dummy empty string for homogeneity */ @@ -203,7 +124,7 @@ public class ActionsImpl implements Actions { ListResponseWrapper responseList = new ListResponseWrapper(); try { - log.debug(" entering getActionsByActionInvariantUuId "); + LOGGER.debug(" entering getActionsByActionInvariantUuId "); initializeRequestMDC(servletRequest, invariantID, ActionRequest.GET_ACTIONS_INVARIANT_ID); MDC.put(SERVICE_INSTANCE_ID, invariantID); @@ -217,26 +138,26 @@ public class ActionsImpl implements Actions { } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(""); + LOGGER.error(""); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(""); + LOGGER.error(""); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.GET_ACTIONS_INVARIANT_ID.name()); } - log.debug(" exit getActionsByActionInvariantUuId "); + LOGGER.debug(" exit getActionsByActionInvariantUuId "); actionLogPostProcessor(StatusCode.COMPLETE, true); return Response.ok(responseList).build(); } private ListResponseWrapper getActionsByInvId(HttpServletRequest servletRequest, String invariantID) { - log.debug(" entering getActionsByInvId with invariantID= " + invariantID); + LOGGER.debug(" entering getActionsByInvId with invariantID= " + invariantID); ListResponseWrapper responseList = new ListResponseWrapper(); if (StringUtils.isEmpty(servletRequest.getQueryString())) { Map<String, String> errorMap = validateRequestHeaders(servletRequest); @@ -244,7 +165,7 @@ public class ActionsImpl implements Actions { errorMap.putAll(queryParamErrors); if (errorMap.isEmpty()) { List<Action> actions = actionManager.getActionsByActionInvariantUuId(invariantID); - List<ActionResponseDto> versionList = new ArrayList<ActionResponseDto>(); + List<ActionResponseDto> versionList = new ArrayList<>(); for (Action action : actions) { ActionResponseDto responseDTO = createResponseDTO(action); versionList.add(responseDTO); @@ -256,7 +177,7 @@ public class ActionsImpl implements Actions { checkAndThrowError(errorMap); } } - log.debug(" exit getActionsByInvId with invariantID= " + invariantID); + LOGGER.debug(" exit getActionsByInvId with invariantID= " + invariantID); return responseList; } @@ -264,7 +185,7 @@ public class ActionsImpl implements Actions { String actionUUID) throws ActionException { int noOfFilterParams = 0; Response response = null; - log.debug(" entering getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + + LOGGER.debug(" entering getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + actionUUID); if (!StringUtils.isEmpty(actionUUID)) { noOfFilterParams++; @@ -275,7 +196,7 @@ public class ActionsImpl implements Actions { ACTION_REQUEST_FILTER_PARAM_INVALID); } - log.debug(" exit getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + + LOGGER.debug(" exit getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + actionUUID); return response; } @@ -283,7 +204,7 @@ public class ActionsImpl implements Actions { @Override public Response getOpenEcompComponents(HttpServletRequest servletRequest) { try { - log.debug(" entering getOpenEcompComponents "); + LOGGER.debug(" entering getEcompComponents "); initializeRequestMDC(servletRequest, "", ActionRequest.GET_OPEN_ECOMP_COMPONENTS); //Validate request syntax before passing to the manager Map<String, String> errorMap = validateRequestHeaders(servletRequest); @@ -292,19 +213,19 @@ public class ActionsImpl implements Actions { List<OpenEcompComponent> openEcompComponents = actionManager.getOpenEcompComponents(); response.setActionList(null); response.setComponentList(openEcompComponents); - log.debug(" exit getOpenEcompComponents "); + LOGGER.debug(" exit getEcompComponents "); actionLogPostProcessor(StatusCode.COMPLETE, true); return Response.ok(response).build(); } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(""); + LOGGER.error(""); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(""); + LOGGER.error(""); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.GET_OPEN_ECOMP_COMPONENTS.name()); @@ -315,40 +236,17 @@ public class ActionsImpl implements Actions { public Response getFilteredActions(String vendor, String category, String name, String modelID, String componentID, HttpServletRequest servletRequest) { try { - log.debug(" entering getFilteredActions "); - Response response = null; + LOGGER.debug(" entering getFilteredActions "); + Response response; initializeRequestMDC(servletRequest, "", ActionRequest.GET_FILTERED_ACTIONS); - int noOfFilterParams = 0; - if (!StringUtils.isEmpty(vendor)) { - noOfFilterParams++; - } - if (!StringUtils.isEmpty(category)) { - noOfFilterParams++; - } - if (!StringUtils.isEmpty(name)) { - noOfFilterParams++; - } - if (!StringUtils.isEmpty(modelID)) { - noOfFilterParams++; - } - if (!StringUtils.isEmpty(componentID)) { - noOfFilterParams++; - } + int noOfFilterParams = getNoOfFilterParams(vendor, category, name, modelID, componentID); if (StringUtils.isEmpty(servletRequest.getQueryString())) { response = getAllActions(servletRequest); - log.debug(" exit getFilteredActions "); + LOGGER.debug(" exit getFilteredActions "); actionLogPostProcessor(StatusCode.COMPLETE, true); return response; } - if (noOfFilterParams > 1) { - throw new ActionException(ACTION_MULT_SEARCH_CRITERIA, - ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED); - } - if (noOfFilterParams == 0) { - throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, - ACTION_REQUEST_FILTER_PARAM_INVALID); - } - ListResponseWrapper responseList = null; + validateNoOfFilterParamsExactly1(noOfFilterParams); if (!StringUtils.isEmpty(vendor)) { response = getActionsByVendor(vendor, servletRequest); } else if (!StringUtils.isEmpty(category)) { @@ -363,30 +261,61 @@ public class ActionsImpl implements Actions { throw new ActionException(ACTION_INVALID_PARAM_CODE, ACTION_REQUEST_FILTER_PARAM_INVALID); } - log.debug(" exit getFilteredActions "); + LOGGER.debug(" exit getFilteredActions "); actionLogPostProcessor(StatusCode.COMPLETE, true); return response; } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(""); + LOGGER.error(""); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(""); + LOGGER.error(""); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.GET_FILTERED_ACTIONS.name()); } } + private void validateNoOfFilterParamsExactly1(int noOfFilterParams) { + if (noOfFilterParams > 1) { + throw new ActionException(ACTION_MULT_SEARCH_CRITERIA, + ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED); + } + if (noOfFilterParams == 0) { + throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, + ACTION_REQUEST_FILTER_PARAM_INVALID); + } + } + + private int getNoOfFilterParams(String vendor, String category, String name, String modelID, String componentID) { + int noOfFilterParams = 0; + if (!StringUtils.isEmpty(vendor)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(category)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(name)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(modelID)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(componentID)) { + noOfFilterParams++; + } + return noOfFilterParams; + } + @Override public Response createAction(String requestJSON, HttpServletRequest servletRequest) { try { initializeRequestMDC(servletRequest, null, ActionRequest.CREATE_ACTION); - log.debug(" entering API createAction "); + LOGGER.debug(" entering API createAction "); Map<String, String> errorMap = validateRequestHeaders(servletRequest); Map<String, String> requestBodyErrors = validateRequestBody(REQUEST_TYPE_CREATE_ACTION, requestJSON); @@ -403,18 +332,18 @@ public class ActionsImpl implements Actions { checkAndThrowError(errorMap); } actionLogPostProcessor(StatusCode.COMPLETE, true); - log.debug(" exit API createAction with ActionInvariantUUID= " + MDC.get(SERVICE_INSTANCE_ID)); + LOGGER.debug(" exit API createAction with ActionInvariantUUID= " + MDC.get(SERVICE_INSTANCE_ID)); return Response.ok(actionResponseDTO).build(); } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(""); + LOGGER.error(""); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(exception.getMessage()); + LOGGER.error(exception.getMessage()); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.CREATE_ACTION.name()); @@ -447,13 +376,13 @@ public class ActionsImpl implements Actions { } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(""); + LOGGER.error(""); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(exception.getMessage()); + LOGGER.error(exception.getMessage()); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.UPDATE_ACTION.name()); @@ -479,13 +408,13 @@ public class ActionsImpl implements Actions { } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(MDC.get(ERROR_DESCRIPTION)); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(exception.getMessage()); + LOGGER.error(exception.getMessage()); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.DELETE_ACTION.name()); @@ -498,7 +427,7 @@ public class ActionsImpl implements Actions { Response response = null; try { initializeRequestMDC(servletRequest, invariantUUID, ActionRequest.ACTION_VERSIONING); - log.debug("entering actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + + LOGGER.debug("entering actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + requestJSON); Map<String, String> errorMap = validateRequestHeaders(servletRequest); Map<String, String> requestBodyErrors = @@ -542,17 +471,17 @@ public class ActionsImpl implements Actions { } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(MDC.get(ERROR_DESCRIPTION)); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(exception.getMessage()); + LOGGER.error(exception.getMessage()); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.ACTION_VERSIONING.name()); - log.debug("exit actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + + LOGGER.debug("exit actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + requestJSON); } return response; @@ -571,29 +500,29 @@ public class ActionsImpl implements Actions { Response response = null; try { initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.UPLOAD_ARTIFACT); - log.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + + LOGGER.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + "artifactName= " + artifactName); response = uploadArtifactInternal(actionInvariantUUID, artifactName, artifactLabel, artifactCategory, artifactDescription, artifactProtection, checksum, artifactToUpload, servletRequest); actionLogPostProcessor(StatusCode.COMPLETE, true); - log.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + + LOGGER.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + "artifactName= " + artifactName); } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(MDC.get(ERROR_DESCRIPTION)); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(exception.getMessage()); + LOGGER.error(exception.getMessage()); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.UPLOAD_ARTIFACT.name()); } - log.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + + LOGGER.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + "artifactName= " + artifactName); return response; } @@ -632,6 +561,7 @@ public class ActionsImpl implements Actions { try { artifactInputStream = artifactToUpload.getDataHandler().getInputStream(); } catch (IOException exception) { + LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception); throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); } @@ -680,7 +610,7 @@ public class ActionsImpl implements Actions { Response response = null; try { initializeRequestMDC(servletRequest, "", ActionRequest.DOWNLOAD_ARTIFACT); - log.debug( + LOGGER.debug( " entering downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + artifactUUID); response = downloadArtifactInternal(actionUUID, artifactUUID, servletRequest); @@ -688,18 +618,18 @@ public class ActionsImpl implements Actions { } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(MDC.get(ERROR_DESCRIPTION)); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(exception.getMessage()); + LOGGER.error(exception.getMessage()); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.DOWNLOAD_ARTIFACT.name()); } - log.debug(" exit downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + + LOGGER.debug(" exit downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + artifactUUID); return response; } @@ -728,22 +658,22 @@ public class ActionsImpl implements Actions { Response response = null; try { initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.DELETE_ARTIFACT); - log.debug(" entering deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + + LOGGER.debug(" entering deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + " and artifactUUID= " + artifactUUID); response = deleteArtifactInternal(actionInvariantUUID, artifactUUID, servletRequest); - log.debug(" exit deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + + LOGGER.debug(" exit deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + " and artifactUUID= " + artifactUUID); actionLogPostProcessor(StatusCode.COMPLETE, true); } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(MDC.get(ERROR_DESCRIPTION)); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(exception.getMessage()); + LOGGER.error(exception.getMessage()); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.DELETE_ARTIFACT.name()); @@ -774,7 +704,7 @@ public class ActionsImpl implements Actions { String checksum, Attachment artifactToUpdate, HttpServletRequest servletRequest) { Response response = null; - log.debug(" entering updateArtifact with actionInvariantUuId= " + actionInvariantUUID + + LOGGER.debug(" entering updateArtifact with actionInvariantUuId= " + actionInvariantUUID + " and artifactUUID= " + artifactUUID + " and artifactName= " + artifactName + " and artifactLabel= " + artifactLabel + " and artifactCategory= " + artifactCategory + " and artifactDescription= " + artifactDescription + " and artifactProtection= " + @@ -789,18 +719,18 @@ public class ActionsImpl implements Actions { } catch (ActionException exception) { actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - log.error(MDC.get(ERROR_DESCRIPTION)); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); throw exception; } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(exception.getMessage()); + LOGGER.error(exception.getMessage()); throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.UPDATE_ARTIFACT.name()); } - log.debug(" exit updateArtifact with actionInvariantUuId= " + actionInvariantUUID + + LOGGER.debug(" exit updateArtifact with actionInvariantUuId= " + actionInvariantUUID + " and artifactUUID= " + artifactUUID + " and artifactName= " + artifactName + " and artifactLabel= " + artifactLabel + " and artifactCategory= " + artifactCategory + " and artifactDescription= " + artifactDescription + " and artifactProtection= " + @@ -811,8 +741,8 @@ public class ActionsImpl implements Actions { private void finalAuditMetricsLogProcessor(String targetServiceName) { MDC.put(TARGET_SERVICE_NAME, targetServiceName); MDC.put(TARGET_ENTITY, TARGET_ENTITY_API); - log.metrics(""); - log.audit(""); + LOGGER.metrics(""); + LOGGER.audit(""); } private Response updateArtifactInternal(String actionInvariantUUID, String artifactUUID, @@ -835,6 +765,7 @@ public class ActionsImpl implements Actions { try { artifactInputStream = artifactToUpdate.getDataHandler().getInputStream(); } catch (IOException exception) { + LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception); throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); } @@ -951,7 +882,7 @@ public class ActionsImpl implements Actions { */ private Response getActionsByUniqueID(String actionUUID, HttpServletRequest servletRequest, String actionInvariantUUID) { - log.debug( + LOGGER.debug( " entering getActionByUUID with invariantID= " + actionInvariantUUID + " and actionUUID= " + actionUUID); Map<String, Object> responseDTO = new LinkedHashMap<>(); @@ -972,7 +903,7 @@ public class ActionsImpl implements Actions { } else { checkAndThrowError(errorMap); } - log.debug( + LOGGER.debug( " exit getActionByUUID with invariantID= " + actionInvariantUUID + " and actionUUID= " + actionUUID); return Response.ok(responseDTO).build(); @@ -1175,11 +1106,11 @@ public class ActionsImpl implements Actions { if (actionartifact != null && actionartifact.getArtifact() != null) { byte[] artifactsBytes = actionartifact.getArtifact(); File artifactFile = new File(actionartifact.getArtifactName()); - try { - FileOutputStream fos = new FileOutputStream(artifactFile); + try (FileOutputStream fos = new FileOutputStream(artifactFile)) { fos.write(artifactsBytes); fos.close(); } catch (IOException exception) { + LOGGER.error(ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, exception); throw new ActionException(ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE, ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); } @@ -1215,13 +1146,13 @@ public class ActionsImpl implements Actions { MDC.put(LOCAL_ADDR, MDC.get("ServerIPAddress")); MDC.put(BE_FQDN, MDC.get("ServerFQDN")); - if (log.isDebugEnabled()) { + if (LOGGER.isDebugEnabled()) { MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.DEBUG.name()); - } else if (log.isInfoEnabled()) { + } else if (LOGGER.isInfoEnabled()) { MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.INFO.name()); - } else if (log.isWarnEnabled()) { + } else if (LOGGER.isWarnEnabled()) { MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.WARN.name()); - } else if (log.isErrorEnabled()) { + } else if (LOGGER.isErrorEnabled()) { MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.ERROR.name()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java index 991a286a48..271ff45097 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java @@ -21,14 +21,6 @@ package org.openecomp.server.interceptors; -import java.io.Serializable; -import java.lang.annotation.Annotation; -import java.net.URI; -import java.util.Date; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - import javax.ws.rs.core.EntityTag; import javax.ws.rs.core.GenericType; import javax.ws.rs.core.Link; @@ -36,13 +28,20 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.NewCookie; import javax.ws.rs.core.Response; +import java.io.Serializable; +import java.lang.annotation.Annotation; +import java.net.URI; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.Set; public class DefaultOutput extends Response implements Serializable { private static final long serialVersionUID = 8061802931931401706L; private final int status; - private final Object entity; + private final transient Object entity; private MultivaluedMap<String, Object> metadata; public DefaultOutput(int s0, Object e0) { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml index c83ae4471a..126f7814d7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml @@ -30,7 +30,6 @@ <bean id="outEmptyResponseInterceptor" class="org.openecomp.server.interceptors.EmptyOutputOutInterceptor"/> <!-- ASDC --> - <bean id="vendorLicenseManager" class="org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl"/> <bean id="uploadValidationManager" class="org.openecomp.sdc.validation.impl.UploadValidationManagerImpl"/> <bean id="actionManager" class="org.openecomp.sdc.action.impl.ActionManagerImpl"/> <bean id="applicationConfigManager" class="org.openecomp.sdc.applicationconfig.impl.ApplicationConfigManagerImpl"/> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml index 824c6775bc..70581079ff 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml @@ -13,6 +13,12 @@ <dependencies> <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-core</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> <groupId>org.openecomp.sdc.core</groupId> <artifactId>openecomp-utilities-lib</artifactId> <version>${project.version}</version> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java index e8a6c7e7db..d399469745 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java @@ -54,9 +54,10 @@ import javax.ws.rs.ext.ExceptionMapper; public class DefaultExceptionMapper implements ExceptionMapper<Exception> { private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE = "errorCodesToResponseStatusMapping.json"; - private static Map<String, String> errorCodeToResponseStatus = JsonUtil - .json2Object(FileUtils.getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE), - Map.class); + @SuppressWarnings("unchecked") + private static Map<String, String> errorCodeToResponseStatus = + JsonUtil.json2Object(FileUtils + .getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE), Map.class); private static Logger logger = (Logger) LoggerFactory.getLogger(DefaultExceptionMapper.class); @Override @@ -74,11 +75,6 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { response = transform(exception); } - try { - writeStackTraceToFile(exception); - } catch (IOException ex) { - ex.printStackTrace(); - } List<Object> contentTypes = new ArrayList<>(); contentTypes.add(MediaType.APPLICATION_JSON); response.getMetadata().put("Content-Type", contentTypes); @@ -169,17 +165,4 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { private Object toEntity(Response.Status status, ErrorCode code) { return new ErrorCodeAndMessage(status, code); } - - private void writeStackTraceToFile(Exception exception) throws IOException { - File file = new File("stack_trace.txt"); - if (!file.exists()) { - file.createNewFile(); - } - OutputStream outputStream = new FileOutputStream(file); - PrintWriter printWriter = new PrintWriter(file); - exception.printStackTrace(printWriter); - printWriter.close(); - outputStream.close(); - } - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java index 6573485db7..91f2656f16 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java @@ -20,6 +20,15 @@ package org.openecomp.sdcrests.mapping; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerServiceName; + /** * Base class for all mapping classes. Mapping classes will perform data mapping from source object * to target object Base class provides following<br> <ol> <li>provides life cycle of @@ -93,8 +102,19 @@ public abstract class MappingBase<S, T> { try { object = clazz.newInstance(); - } catch (InstantiationException | IllegalAccessException exception) { + } catch (InstantiationException | IllegalAccessException exception ) { //TODO: what what? + MdcDataErrorMessage.createErrorMessageAndUpdateMdc( + LoggerConstants.TARGET_ENTITY, + LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(), + exception.getMessage(), exception.getMessage()); + + throw new CoreException((new ErrorCode.ErrorCodeBuilder()) + .withMessage(exception.getMessage()) + .withId(exception.getMessage()) + .withCategory(ErrorCategory.APPLICATION).build()); + + } return object; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java index 22ce0a4e45..ea69249944 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java @@ -27,7 +27,7 @@ import java.util.List; public class GenericCollectionWrapper<T> implements Serializable { private static final long serialVersionUID = 1L; - private List<T> results; + private transient List<T> results; private int listCount; public GenericCollectionWrapper() { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java index 9678f927b0..1152cc1eb3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java @@ -12,10 +12,10 @@ public class MapLimitEntityToLimitDto extends MappingBase<LimitEntity, LimitEnti target.setId(source.getId()); target.setName(source.getName()); target.setDescription(source.getDescription()); - target.setMetric(source.getMetric() != null ? source.getMetric().name() : null); + target.setMetric(source.getMetric()); target.setAggregationFunction(source.getAggregationFunction() != null ? source .getAggregationFunction().name() : null); - target.setTime(source.getTime() != null ? source.getTime().name() : null); + target.setTime(source.getTime()); target.setType(source.getType() != null ? source.getType().name() : null); target.setUnit(source.getUnit()); target.setValue(source.getValue()); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java index 7f48ece1cf..d123924ec3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java @@ -3,73 +3,60 @@ package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; import org.openecomp.sdc.logging.types.LoggerConstants; import org.openecomp.sdc.logging.types.LoggerServiceName; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction; -import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric; -import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime; import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LimitType; import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder; import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes; -import org.openecomp.sdc.vendorsoftwareproduct.errors.ImageErrorBuilder; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; -import org.openecomp.sdc.vendorlicense.dao.types.LimitType; public class MapLimitRequestDtoToLimitEntity extends MappingBase<LimitRequestDto, LimitEntity> { - @Override - public void doMapping(LimitRequestDto source, LimitEntity target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - try { - LimitType type = LimitType.valueOf(source.getType()); - target.setType(type); - } - catch (IllegalArgumentException exception) { - throwInvalidValueError("type", VendorLicenseErrorCodes.LIMIT_INVALID_TYPE); - } - - try { - EntitlementMetric metric = EntitlementMetric.valueOf(source.getMetric()); - target.setMetric(metric); - } - catch (IllegalArgumentException exception) { - throwInvalidValueError("metric", VendorLicenseErrorCodes.LIMIT_INVALID_METRIC); - } - try { - AggregationFunction function = source.getAggregationFunction() != null ? - AggregationFunction.valueOf(source.getAggregationFunction()) : null; - target.setAggregationFunction(function); + private static final Logger logger = + LoggerFactory.getLogger(MapLimitRequestDtoToLimitEntity.class); + + @Override + public void doMapping(LimitRequestDto source, LimitEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + try { + LimitType type = LimitType.valueOf(source.getType()); + target.setType(type); + } catch (IllegalArgumentException exception) { + logger.error(exception.getMessage(), exception); + throwInvalidValueError("type", VendorLicenseErrorCodes.LIMIT_INVALID_TYPE); + } + + try { + AggregationFunction function = source.getAggregationFunction() != null ? + AggregationFunction.valueOf(source.getAggregationFunction()) : null; + target.setAggregationFunction(function); + } catch (IllegalArgumentException exception) { + logger.error(exception.getMessage(), exception); + throwInvalidValueError("aggregationFunction", + VendorLicenseErrorCodes.LIMIT_INVALID_AGGREGATIONFUNCTION); + } + + target.setTime(source.getTime()); + target.setMetric(source.getMetric()); + target.setValue(source.getValue()); + target.setUnit(source.getUnit()); + + } + + private void throwInvalidValueError(String attribute, String vendorLicenseErrorCode) { + ErrorCode errorCode = LimitErrorBuilder.getInvalidValueErrorBuilder(attribute, + vendorLicenseErrorCode); + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(), + errorCode.id(), errorCode.message()); + throw new CoreException(errorCode); } - catch (IllegalArgumentException exception) { - throwInvalidValueError("aggregationFunction", - VendorLicenseErrorCodes.LIMIT_INVALID_AGGREGATIONFUNCTION); - } - - try { - EntitlementTime time = source.getTime() != null ? - EntitlementTime.valueOf(source.getTime()) : null; - target.setTime(time); - } - catch (IllegalArgumentException exception) { - throwInvalidValueError("time", VendorLicenseErrorCodes.LIMIT_INVALID_TIME); - } - - target.setValue(source.getValue()); - target.setUnit(source.getUnit()); - - } - - private void throwInvalidValueError(String attribute, String vendorLicenseErrorCode) { - ErrorCode errorCode = LimitErrorBuilder.getInvalidValueErrorBuilder(attribute, - vendorLicenseErrorCode); - MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, - LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(), - errorCode.id(), errorCode.message() ); - throw new CoreException(errorCode); - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java index 3a08822048..36e25e0f2e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java @@ -5,6 +5,7 @@ import org.openecomp.sdc.logging.context.MdcUtil; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; import org.openecomp.sdc.versioning.dao.types.Version; @@ -30,8 +31,8 @@ import javax.ws.rs.core.Response; @Scope(value = "prototype") public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); - @Autowired - private VendorLicenseManager vendorLicenseManager; + private VendorLicenseManager vendorLicenseManager = + VendorLicenseManagerFactory.getInstance().createInterface(); @Override public Response createLimit(LimitRequestDto request, diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java index 63576c95bd..120bb3d6a0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java @@ -24,6 +24,7 @@ import org.openecomp.sdc.logging.context.MdcUtil; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorlicense.rest.EntitlementPools; @@ -47,8 +48,8 @@ import java.util.Collection; public class EntitlementPoolsImpl implements EntitlementPools { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); - @Autowired - private VendorLicenseManager vendorLicenseManager; + private VendorLicenseManager vendorLicenseManager = + VendorLicenseManagerFactory.getInstance().createInterface(); /** * List entitlement pools response. diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java index 99ac3cdb70..593ed1939f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java @@ -25,6 +25,7 @@ import org.openecomp.sdc.logging.context.MdcUtil; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; @@ -58,8 +59,8 @@ import java.util.HashSet; public class FeatureGroupsImpl implements FeatureGroups { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); - @Autowired - private VendorLicenseManager vendorLicenseManager; + private VendorLicenseManager vendorLicenseManager = + VendorLicenseManagerFactory.getInstance().createInterface(); @Override public Response listFeatureGroups(String vlmId, String versionId, String user) { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java index ac242422e4..60a2d684d2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java @@ -25,6 +25,7 @@ import org.openecomp.sdc.logging.context.MdcUtil; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel; @@ -55,8 +56,8 @@ import javax.ws.rs.core.Response; public class LicenseAgreementsImpl implements LicenseAgreements { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); - @Autowired - private VendorLicenseManager vendorLicenseManager; + private VendorLicenseManager vendorLicenseManager = + VendorLicenseManagerFactory.getInstance().createInterface(); /** * List license agreements response. diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java index aabba71a5c..4c85cfa45f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java @@ -4,6 +4,7 @@ import org.openecomp.sdc.logging.context.MdcUtil; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; import org.openecomp.sdc.versioning.dao.types.Version; @@ -30,8 +31,8 @@ import javax.ws.rs.core.Response; public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); - @Autowired - private VendorLicenseManager vendorLicenseManager; + private VendorLicenseManager vendorLicenseManager = + VendorLicenseManagerFactory.getInstance().createInterface(); @Override public Response createLimit(LimitRequestDto request, diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java index 2aac474123..4c4bf134fd 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java @@ -24,6 +24,7 @@ import org.openecomp.sdc.logging.context.MdcUtil; import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorlicense.rest.LicenseKeyGroups; @@ -49,8 +50,8 @@ import java.util.Collection; public class LicenseKeyGroupsImpl implements LicenseKeyGroups { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); - @Autowired - private VendorLicenseManager vendorLicenseManager; + private VendorLicenseManager vendorLicenseManager = + VendorLicenseManagerFactory.getInstance().createInterface(); /** * List license key groups response. diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java index 9e72170e04..6d88e4cacb 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java @@ -28,8 +28,11 @@ import org.openecomp.sdc.logging.messages.AuditMessages; import org.openecomp.sdc.logging.types.LoggerConstants; import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; +import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorlicense.rest.VendorLicenseModels; import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity; @@ -56,8 +59,10 @@ import java.util.Collection; public class VendorLicenseModelsImpl implements VendorLicenseModels { private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); - @Autowired - private VendorLicenseManager vendorLicenseManager; + + private VendorLicenseManager vendorLicenseManager = + VendorLicenseManagerFactory.getInstance().createInterface(); + private static final Logger logger = LoggerFactory.getLogger(VendorLicenseModelsImpl.class); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java index 0cc18949d8..a4dc361c57 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java @@ -7,8 +7,8 @@ public class LimitEntityDto { private String type; private String description; private String metric; - private Integer value; - private Integer unit; + private String value; + private String unit; private String aggregationFunction; private String time; @@ -52,11 +52,11 @@ public class LimitEntityDto { this.metric = metric; } - public Integer getUnit() { + public String getUnit() { return unit; } - public void setUnit(Integer unit) { + public void setUnit(String unit) { this.unit = unit; } @@ -76,11 +76,11 @@ public class LimitEntityDto { this.time = time; } - public Integer getValue() { + public String getValue() { return value; } - public void setValue(Integer value) { + public void setValue(String value) { this.value = value; } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java index 61f30916f8..defff137d8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java @@ -20,11 +20,9 @@ public class LimitRequestDto { private String description; @NotBlank(message = "is mandatory and should not be empty") private String metric; - @NotNull(message = "is mandatory and should not be empty") - @Min(value = 1, message = "should be integer and > 0") - private Integer value; - @Min(value = 1, message = "should be integer and > 0") - private Integer unit; + @NotBlank(message = "is mandatory and should not be empty") + private String value; + private String unit; private String aggregationFunction; private String time; @@ -77,19 +75,19 @@ public class LimitRequestDto { this.time = time; } - public Integer getUnit() { + public String getUnit() { return unit; } - public void setUnit(Integer unit) { + public void setUnit(String unit) { this.unit = unit; } - public Integer getValue() { + public String getValue() { return value; } - public void setValue(Integer value) { + public void setValue(String value) { this.value = value; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java index e51ccbd937..baaa664938 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java @@ -4,6 +4,8 @@ package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; import org.openecomp.sdc.logging.types.LoggerConstants; import org.openecomp.sdc.logging.types.LoggerTragetServiceName; @@ -15,6 +17,8 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRelationType public class MapComponentDependencyModelRequestToEntity extends MappingBase<ComponentDependencyModel, ComponentDependencyModelEntity> { + private static final Logger logger = + LoggerFactory.getLogger(MapComponentDependencyModelRequestToEntity.class); @Override public void doMapping(ComponentDependencyModel source, @@ -30,6 +34,7 @@ public class MapComponentDependencyModelRequestToEntity extends MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, LoggerTragetServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL, ErrorLevel.ERROR.name(), errorCode.id(), errorCode.message() ); + logger.error(errorCode.message(), exception); throw new CoreException(errorCode); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java index 9c642eb862..8f2e73bff6 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java @@ -165,7 +165,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { VersionableEntityAction.Read), user); versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user); } catch (Exception e) { - //to do + logger.error(e.getMessage(), e); } } } |