diff options
5 files changed, 86 insertions, 235 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)); - } - }); - } } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java index 6365b9ef74..4d92ee87c3 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java @@ -16,6 +16,14 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.impl.ToscaConverterImpl; import org.openecomp.core.utilities.file.FileContentHandler; @@ -31,7 +39,6 @@ import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; import org.openecomp.sdc.heat.services.tree.ToscaTreeManager; 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.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; @@ -43,15 +50,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule. import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler { private static final Logger LOGGER = LoggerFactory @@ -63,8 +61,6 @@ public class OrchestrationTemplateProcessCsarHandler @Override public OrchestrationTemplateActionResponse process(VspDetails vspDetails, OrchestrationTemplateCandidateData candidateData) { - LOGGER.audit( - AuditMessages.AUDIT_MSG + AuditMessages.CSAR_VALIDATION_STARTED + vspDetails.getId()); UploadFileResponse uploadFileResponse = new UploadFileResponse(); Optional<FileContentHandler> fileContent = OrchestrationUtil diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java index f155e45c06..cb2921795c 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java @@ -16,6 +16,12 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process; +import java.io.ByteArrayInputStream; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.translator.datatypes.TranslatorOutput; @@ -29,9 +35,6 @@ import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree; import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; -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.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil; import org.openecomp.sdc.validation.util.ValidationManagerUtil; @@ -49,17 +52,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStru import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils; import org.openecomp.sdc.versioning.dao.types.Version; -import java.io.ByteArrayInputStream; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -import static org.openecomp.sdc.logging.messages.AuditMessages.HEAT_VALIDATION_ERROR; - public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemplateProcessHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessZipHandler.class); + private final CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface(); @@ -68,7 +62,6 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp OrchestrationTemplateCandidateData candidateData) { String vspId = vspDetails.getId(); Version version = vspDetails.getVersion(); - LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_STARTED + vspId); OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse(); UploadFileResponse uploadFileResponse = new UploadFileResponse(); Optional<FileContentHandler> fileContent = OrchestrationUtil @@ -76,8 +69,6 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp candidateData.getContentData().array()); if (!fileContent.isPresent()) { response.addStructureErrors(uploadFileResponse.getErrors()); - response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList, vspId, - HEAT_VALIDATION_ERROR)); return response; } @@ -89,8 +80,6 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp if (CollectionUtils.isNotEmpty(structure.getUnassigned())) { response.addErrorMessageToMap(SdcCommon.UPLOAD_FILE, Messages.FOUND_UNASSIGNED_FILES.getErrorMessage(), ErrorLevel.ERROR); - response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList, vspId, - HEAT_VALIDATION_ERROR)); return response; } @@ -102,8 +91,6 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp .fetchZipFileByteArrayInputStream( vspId, candidateData, manifest, OnboardingTypesEnum.ZIP, uploadErrors); if (!zipByteArrayInputStream.isPresent()) { - response.getErrors().values() - .forEach(errorList -> printAuditForErrors(errorList, vspId, HEAT_VALIDATION_ERROR)); return response; } @@ -134,15 +121,6 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp .saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(), fileContentMap, tree); - response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList, vspId, - HEAT_VALIDATION_ERROR)); - if (MapUtils - .isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, response.getErrors()))) { - LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_COMPLETED + vspId); - } - - LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_TRANSLATION_STARTED + vspId); - TranslatorOutput translatorOutput = HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap); @@ -155,7 +133,6 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp orchestrationUtil.updateVspComponentDependencies(vspId, version, vspComponentIdNameInfoBeforeProcess, componentDependenciesBeforeDelete); - LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_TRANSLATION_COMPLETED + vspId); uploadFileResponse.addStructureErrors(uploadErrors); candidateService.deleteOrchestrationTemplateCandidate(vspId, version); return response; @@ -178,14 +155,4 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp return OrchestrationUtil.createHeatTree(fileContentMap, validationErrors); } - - 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)); - } - }); - } } diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java deleted file mode 100644 index 53df3e63f6..0000000000 --- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-api/src/main/java/org/openecomp/sdc/logging/messages/AuditMessages.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2016-2017 European Support Limited - * - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openecomp.sdc.logging.messages; - -public class AuditMessages { - - public static final String AUDIT_MSG = " --Audit-- "; - - public static final String CREATE_VLM = "Create VLM. VLM Name: "; - public static final String CHECK_IN_VLM = "Check in VLM. VLM Id: "; - public static final String CHECK_OUT_VLM = "Check out VLM. VLM Id: "; - public static final String SUBMIT_VLM = "submit VLM. VLM Name: "; - - public static final String CREATE_VSP = "Create VSP. VSP Name: "; - public static final String CHECK_IN_VSP = "Check in VSP. VSP Id: "; - public static final String CHECK_OUT_VSP = "Check out VSP. VSP Id: "; - public static final String RESUBMIT_ALL_FINAL_VSPS = "Check out, check in and submit all " + - "submitted VSPs, see ids below "; - public static final String SUBMIT_VSP = "Submit VSP. VSP Id: "; - public static final String SUBMIT_VSP_FAIL = "Submit VSP failed!. VSP Id: "; - public static final String SUBMIT_VSP_ERROR = "Submit VSP error: %s. VSP Id: %s"; - - public static final String UPLOAD_HEAT = "Upload HEAT. VSP Id: "; - public static final String UPLOAD_PROCESS_ARTIFACT = "Upload Process Artifact. VSP Id: "; - public static final String UPLOAD_MONITORING_FILE = "Upload Monitoring File of type %s " - + ". VSP Id: %s, component id: %s"; - - public static final String IMPORT_SUCCESS = "VSP import to VF success. VSP Id: "; - public static final String IMPORT_FAIL = "VSP import to VF fail. VSP Id: "; - - public static final String HEAT_VALIDATION_STARTED = "HEAT validation started. VSP Id: "; - public static final String HEAT_VALIDATION_COMPLETED = "HEAT validation completed. VSP Id: "; - public static final String HEAT_VALIDATION_ERROR = "HEAT validation error: %s. VSP Id: %s"; - public static final String CSAR_VALIDATION_STARTED = "CSAR validation started. VSP Id: "; - public static final String HEAT_TRANSLATION_STARTED = "HEAT translation started. VSP Id: "; - public static final String HEAT_TRANSLATION_COMPLETED = "HEAT translation completed. VSP Id: "; - public static final String ENRICHMENT_ERROR = "Enrichment error: %s. VSP Id: %s"; - public static final String ENRICHMENT_COMPLETED = "Enrichment completed. VSP Id: "; - public static final String CREATE_PACKAGE = "Created package. VSP Id: "; - private AuditMessages (){ - - } -} |