aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-validation-manager
diff options
context:
space:
mode:
authorAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
committerAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
commit280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch)
tree9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-be/backend/openecomp-sdc-validation-manager
parentfd3821dad11780d33c5373d74c957c442489945e (diff)
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-validation-manager')
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/pom.xml41
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/pom.xml.versionsBackup78
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java3
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationErrorCodes.java3
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationInvalidErrorBuilder.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/impl/UploadValidationManagerImpl.java42
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java1
-rw-r--r--openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java66
8 files changed, 206 insertions, 37 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-validation-manager/pom.xml
index c5ccddf829..f5df7b8f6a 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/pom.xml
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/pom.xml
@@ -4,46 +4,43 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <artifactId>openecomp-sdc-validation-manager</artifactId>
+
<parent>
<groupId>org.openecomp.sdc</groupId>
<artifactId>backend</artifactId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
</parent>
- <artifactId>openecomp-sdc-validation-manager</artifactId>
-
<dependencies>
<dependency>
- <groupId>org.openecomp.sdc</groupId>
+ <groupId>org.openecomp.core</groupId>
<artifactId>openecomp-utilities-lib</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.sdc</groupId>
- <artifactId>openecomp-sdc-validation-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.openecomp.sdc</groupId>
+ <groupId>org.openecomp.core</groupId>
<artifactId>openecomp-heat-lib</artifactId>
<version>${project.version}</version>
</dependency>
-
-
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>6.9.10</version>
+ <version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>RELEASE</version>
+ <version>${junit.version}</version>
<scope>test</scope>
</dependency>
-
-
+ <!--dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-translator-api</artifactId>
+ <version>${project.version}</version>
+ </dependency-->
<dependency>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-translator-core</artifactId>
@@ -52,12 +49,12 @@
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
- <version>2.7.4</version>
+ <version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
- <version>4.4.1</version>
+ <version>${woodstox.version}</version>
</dependency>
<dependency>
<groupId>org.openecomp.sdc</groupId>
@@ -69,10 +66,12 @@
<artifactId>openecomp-sdc-validation-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-common-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
-
-
-
-</project> \ No newline at end of file
+</project>
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/pom.xml.versionsBackup b/openecomp-be/backend/openecomp-sdc-validation-manager/pom.xml.versionsBackup
new file mode 100644
index 0000000000..4d678ad77d
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/pom.xml.versionsBackup
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>openecomp-sdc-validation-manager</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-utilities-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-heat-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>6.9.10</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>RELEASE</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!--dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-translator-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency-->
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-translator-core</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-xml</artifactId>
+ <version>2.7.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>woodstox-core-asl</artifactId>
+ <version>4.4.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-license-core</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-validation-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-common-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>backend</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java
index 734771f909..88aceeb87d 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/UploadValidationManager.java
@@ -25,6 +25,9 @@ import org.openecomp.sdc.validation.types.ValidationFileResponse;
import java.io.IOException;
import java.io.InputStream;
+/**
+ * Created by TALIO on 4/20/2016.
+ */
public interface UploadValidationManager {
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationErrorCodes.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationErrorCodes.java
index 815517cdb8..6a7a010444 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationErrorCodes.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationErrorCodes.java
@@ -20,6 +20,9 @@
package org.openecomp.sdc.validation.errors;
+/**
+ * Created by TALIO on 4/24/2016.
+ */
public class ValidationErrorCodes {
public static final String VALIDATION_INVALID = "VALIDATION_INVALID";
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationInvalidErrorBuilder.java
index 5e4cb59ef3..b8015c0962 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/errors/ValidationInvalidErrorBuilder.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.validation.errors;
-import static org.openecomp.sdc.validation.errors.ValidationErrorCodes.VALIDATION_INVALID;
-
import org.openecomp.sdc.common.errors.BaseErrorBuilder;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
@@ -29,9 +27,6 @@ import org.openecomp.sdc.datatypes.error.ErrorMessage;
import java.util.List;
import java.util.Map;
-/**
- * The type Validation invalid error builder.
- */
public class ValidationInvalidErrorBuilder extends BaseErrorBuilder {
private static final String VALIDATION_INVALID_DETAILED_MSG = "File is invalid: %s";
private static final String VALIDATION_INVALID_MSG = "Validated file is invalid";
@@ -42,7 +37,7 @@ public class ValidationInvalidErrorBuilder extends BaseErrorBuilder {
* @param errors the errors
*/
public ValidationInvalidErrorBuilder(Map<String, List<ErrorMessage>> errors) {
- getErrorCodeBuilder().withId(VALIDATION_INVALID);
+ getErrorCodeBuilder().withId(ValidationErrorCodes.VALIDATION_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder()
.withMessage(String.format(VALIDATION_INVALID_DETAILED_MSG, toString(errors)));
@@ -52,7 +47,7 @@ public class ValidationInvalidErrorBuilder extends BaseErrorBuilder {
* Instantiates a new Validation invalid error builder.
*/
public ValidationInvalidErrorBuilder() {
- getErrorCodeBuilder().withId(VALIDATION_INVALID);
+ getErrorCodeBuilder().withId(ValidationErrorCodes.VALIDATION_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(VALIDATION_INVALID_MSG);
}
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);
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java
index ff7f845252..bf6923d3de 100644
--- a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/types/ValidationFileResponse.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.validation.types;
-
import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
public class ValidationFileResponse {
diff --git a/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
new file mode 100644
index 0000000000..924a956628
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-validation-manager/src/main/java/org/openecomp/sdc/validation/util/ValidationManagerUtil.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.validation.util;
+
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.validation.api.ValidationManager;
+import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.core.validation.factory.ValidationManagerFactory;
+import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+
+public class ValidationManagerUtil {
+
+ /**
+ * Handle missing manifest.
+ *
+ * @param fileContentMap the file content map
+ * @param errors the errors
+ */
+ public static void handleMissingManifest(FileContentHandler fileContentMap,
+ Map<String, List<ErrorMessage>> errors) {
+ InputStream manifest = fileContentMap.getFileContent(SdcCommon.MANIFEST_NAME);
+ if (manifest == null) {
+ ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.MANIFEST_NAME, errors)
+ .add(new ErrorMessage(ErrorLevel.ERROR, Messages.MANIFEST_NOT_EXIST.getErrorMessage()));
+ }
+ }
+
+ /**
+ * Init validation manager validation manager.
+ *
+ * @param fileContentMap the file content map
+ * @return the validation manager
+ */
+ public static ValidationManager initValidationManager(FileContentHandler fileContentMap) {
+ ValidationManager validationManager = ValidationManagerFactory.getInstance().createInterface();
+ fileContentMap.getFileList().forEach(fileName -> validationManager
+ .addFile(fileName, FileUtils.toByteArray(fileContentMap.getFileContent(fileName))));
+ return validationManager;
+ }
+}