aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java')
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java42
1 files changed, 34 insertions, 8 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
index ce0d911082..ddb56ddbfc 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java
@@ -25,17 +25,26 @@ import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.validation.api.ValidationManager;
-import org.openecomp.core.validation.errors.Messages;
+import org.openecomp.sdc.common.errors.Messages;
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.utils.AsdcCommon;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
import org.openecomp.sdc.heat.services.tree.HeatTreeManager;
import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.validation.UploadValidationManager;
import org.openecomp.sdc.validation.types.ValidationFileResponse;
-import org.openecomp.sdc.validation.utils.ValidationManagerUtil;
+import org.openecomp.sdc.validation.util.ValidationManagerUtil;
+import org.slf4j.MDC;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -47,8 +56,15 @@ import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+
+/**
+ * Created by TALIO on 4/20/2016.
+ */
public class UploadValidationManagerImpl implements UploadValidationManager {
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+
private static FileContentHandler getFileContentMapFromZip(byte[] uploadFileData)
throws IOException, CoreException {
ZipEntry zipEntry;
@@ -85,6 +101,7 @@ public class UploadValidationManagerImpl implements UploadValidationManager {
}
if (CollectionUtils.isNotEmpty(folderList)) {
+ MDC.put(LoggerConstants.ERROR_DESCRIPTION, LoggerErrorDescription.INVALID_ZIP);
throw new CoreException((new ErrorCode.ErrorCodeBuilder())
.withMessage(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
.withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
@@ -112,20 +129,25 @@ public class UploadValidationManagerImpl implements UploadValidationManager {
public ValidationFileResponse validateFile(String type, InputStream fileToValidate)
throws IOException {
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
ValidationFileResponse validationFileResponse = new ValidationFileResponse();
HeatTreeManager tree;
ValidationStructureList validationStructureList = new ValidationStructureList();
if (type.toLowerCase().equals("heat")) {
FileContentHandler content = getFileContent(fileToValidate);
- if (!content.containsFile(AsdcCommon.MANIFEST_NAME)) {
+ if (!content.containsFile(SdcCommon.MANIFEST_NAME)) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.VALIDATE_MANIFEST_CONTENT, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_ZIP);
throw new CoreException((new ErrorCode.ErrorCodeBuilder())
.withMessage(Messages.MANIFEST_NOT_EXIST.getErrorMessage())
.withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
.withCategory(ErrorCategory.APPLICATION).build());
}
- Map<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> errors =
- validateHeatUploadData(content);
+ Map<String, List<ErrorMessage>> errors = validateHeatUploadData(content);
tree = HeatTreeManagerUtil.initHeatTreeManager(content);
tree.createTree();
if (MapUtils.isNotEmpty(errors)) {
@@ -138,14 +160,18 @@ public class UploadValidationManagerImpl implements UploadValidationManager {
//validationFileResponse.setStatus(ValidationFileStatus.Success);
}
} else {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.VALIDATE_FILE_TYPE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_FILE_TYPE);
throw new RuntimeException("invalid type:" + type);
}
validationFileResponse.setValidationData(validationStructureList);
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
return validationFileResponse;
}
- private Map<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> validateHeatUploadData(
- FileContentHandler fileContentMap)
+ private Map<String, List<ErrorMessage>> validateHeatUploadData(FileContentHandler fileContentMap)
throws IOException {
ValidationManager validationManager =
ValidationManagerUtil.initValidationManager(fileContentMap);