diff options
Diffstat (limited to 'openecomp-be/api')
2 files changed, 71 insertions, 126 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 b186852bfd..14c9782fac 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,49 +20,6 @@ package org.openecomp.sdcrests.action.rest.services; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.openecomp.core.utilities.file.FileUtils; -import org.openecomp.core.utilities.json.JsonUtil; -import org.openecomp.sdc.action.ActionConstants; -import org.openecomp.sdc.action.ActionManager; -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.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; -import org.openecomp.sdcrests.action.types.ActionVersionDto; -import org.openecomp.sdcrests.action.types.ListResponseWrapper; -import org.openecomp.sdcrests.wrappers.StringWrapperResponse; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -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 static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_NAME; import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_SUPPORTED_MODELS; import static org.openecomp.sdc.action.ActionConstants.ARTIFACT_FILE; @@ -95,9 +52,6 @@ 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; @@ -137,6 +91,48 @@ 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 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 org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.utilities.json.JsonUtil; +import org.openecomp.sdc.action.ActionConstants; +import org.openecomp.sdc.action.ActionManager; +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.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; +import org.openecomp.sdcrests.action.types.ActionVersionDto; +import org.openecomp.sdcrests.action.types.ListResponseWrapper; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + /** * Implements various CRUD API that can be performed on Action */ @@ -147,7 +143,7 @@ import static org.openecomp.sdc.action.util.ActionUtil.getUtcDateStringFromTimes @Validated public class ActionsImpl implements Actions { - private static final Logger LOGGER = (Logger) LoggerFactory.getLogger(ActionsImpl.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ActionsImpl.class); @Autowired private ActionManager actionManager; private String whitespaceCharacters = "\\s" /* dummy empty string for homogeneity */ @@ -224,8 +220,6 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(""); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.GET_ACTIONS_INVARIANT_ID.name()); } LOGGER.debug(" exit getActionsByActionInvariantUuId "); @@ -305,8 +299,6 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(""); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.GET_OPEN_ECOMP_COMPONENTS.name()); } } @@ -353,8 +345,6 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(""); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.GET_FILTERED_ACTIONS.name()); } } @@ -423,8 +413,6 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(exception.getMessage()); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.CREATE_ACTION.name()); } } @@ -462,8 +450,6 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(exception.getMessage()); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.UPDATE_ACTION.name()); } return Response.ok(actionResponseDTO).build(); @@ -494,8 +480,6 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(exception.getMessage()); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.DELETE_ACTION.name()); } } @@ -558,7 +542,6 @@ public class ActionsImpl implements Actions { LOGGER.error(exception.getMessage()); throw exception; } finally { - finalAuditMetricsLogProcessor(ActionRequest.ACTION_VERSIONING.name()); LOGGER.debug("exit actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + requestJSON); } @@ -597,9 +580,8 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(exception.getMessage()); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.UPLOAD_ARTIFACT.name()); } + LOGGER.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + "artifactName= " + artifactName); return response; @@ -610,7 +592,6 @@ public class ActionsImpl implements Actions { String artifactDescription, String artifactProtection, String checksum, Attachment artifactToUpload, HttpServletRequest servletRequest) { - ListResponseWrapper responseList = null; byte[] payload = null; Map<String, String> errorMap = validateRequestHeaders(servletRequest); //Artifact name empty validation @@ -702,9 +683,8 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(exception.getMessage()); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.DOWNLOAD_ARTIFACT.name()); } + LOGGER.debug(" exit downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + artifactUUID); return response; @@ -751,9 +731,8 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(exception.getMessage()); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.DELETE_ARTIFACT.name()); } + return response; } @@ -803,9 +782,8 @@ public class ActionsImpl implements Actions { ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); LOGGER.error(exception.getMessage()); throw exception; - } finally { - finalAuditMetricsLogProcessor(ActionRequest.UPDATE_ARTIFACT.name()); } + LOGGER.debug(" exit updateArtifact with actionInvariantUuId= " + actionInvariantUUID + " and artifactUUID= " + artifactUUID + " and artifactName= " + artifactName + " and artifactLabel= " + artifactLabel + " and artifactCategory= " + artifactCategory + @@ -814,13 +792,6 @@ public class ActionsImpl implements Actions { return response; } - private void finalAuditMetricsLogProcessor(String targetServiceName) { - MDC.put(TARGET_SERVICE_NAME, targetServiceName); - MDC.put(TARGET_ENTITY, TARGET_ENTITY_API); - LOGGER.metrics(""); - LOGGER.audit(""); - } - private Response updateArtifactInternal(String actionInvariantUUID, String artifactUUID, String artifactName, String artifactLabel, String artifactCategory, String artifactDescription, @@ -1178,7 +1149,6 @@ public class ActionsImpl implements Actions { File artifactFile = new File(actionartifact.getArtifactName()); 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, 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 480b83bf8f..1c8114c2e8 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 @@ -14,9 +14,30 @@ * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; +import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION; +import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.VALIDATION_VSP_NAME; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Predicate; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.util.UniqueValueUtil; @@ -27,7 +48,6 @@ import org.openecomp.sdc.activitylog.dao.type.ActivityType; import org.openecomp.sdc.common.errors.CoreException; 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.datatypes.error.ErrorMessage; import org.openecomp.sdc.datatypes.model.ItemType; import org.openecomp.sdc.healing.factory.HealingManagerFactory; @@ -36,7 +56,6 @@ import org.openecomp.sdc.itempermissions.ItemPermissionsManagerFactory; import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.logging.messages.AuditMessages; import org.openecomp.sdc.notification.dtos.Event; import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory; import org.openecomp.sdc.notification.services.NotificationPropagationManager; @@ -88,30 +107,6 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Predicate; -import javax.inject.Named; -import javax.ws.rs.core.Response; - -import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION; -import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; -import static org.openecomp.sdc.logging.messages.AuditMessages.SUBMIT_VSP_ERROR; -import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; -import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.VALIDATION_VSP_NAME; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME; - @Named @Service("vendorSoftwareProducts") @Scope(value = "prototype") @@ -342,7 +337,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } @Override - public Response getValidationVsp(String user) throws Exception { + public Response getValidationVsp(String user) { if (validationVsp != null) { return Response.ok(validationVsp).build(); } @@ -424,12 +419,10 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { Response.ResponseBuilder response = Response.ok(zipFile); if (zipFile == null) { - LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_FAIL + vspId); return Response.status(Response.Status.NOT_FOUND).build(); } response.header(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + zipFile.getName()); - LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_SUCCESS + vspId); return response.build(); } @@ -500,15 +493,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { Map<String, List<ErrorMessage>> compilationErrors = vendorSoftwareProductManager.compile(vspId, version); if (!validationResponse.isValid() || MapUtils.isNotEmpty(compilationErrors)) { - LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP_FAIL + vspId); - if (validationResponse.getVspErrors() != null) { - validationResponse.getVspErrors().forEach(errorCode -> LOGGER.audit(AuditMessages - .AUDIT_MSG + String.format(SUBMIT_VSP_ERROR, errorCode.message(), vspId))); - } - if (validationResponse.getUploadDataErrors() != null) { - validationResponse.getUploadDataErrors().values().forEach(errorMessages - -> printAuditForErrors(errorMessages, vspId, SUBMIT_VSP_ERROR)); - } + activityLogManager.logActivity( new ActivityLogEntity(vspId, version, ActivityType.Submit, user, false, "Failed on validation before submit", "")); @@ -517,7 +502,6 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { versioningManager.submit(vspId, version, message); - LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP + vspId); activityLogManager.logActivity( new ActivityLogEntity(vspId, version, ActivityType.Submit, user, true, "", message)); return Optional.empty(); @@ -622,13 +606,4 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { return permission != null && permission .matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name()); } - - private void printAuditForErrors(List<ErrorMessage> errorList, String vspId, String auditType) { - errorList.forEach(errorMessage -> { - if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) { - LOGGER.audit( - AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(), vspId)); - } - }); - } } |