aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
committerMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
commitf5f13c4f6b6fe3b4d98e349dfd7db59339803436 (patch)
tree72caffc93fab394ffa3b761505775331f1c559b9 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src
parent451a3400b76511393c62a444f588a4ed15f4a549 (diff)
push addional code
Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/api/ValidationManager.java35
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java30
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/Messages.java117
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/factory/ValidationManagerFactory.java32
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/interfaces/Validator.java36
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/FileValidationContext.java53
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java142
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainer.java82
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainerUtil.java64
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/resources/factoryConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/resources/validationConfiguration.json24
11 files changed, 618 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/api/ValidationManager.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/api/ValidationManager.java
new file mode 100644
index 0000000000..d18af3a27b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/api/ValidationManager.java
@@ -0,0 +1,35 @@
+/*-
+ * ============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.core.validation.api;
+
+
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+
+import java.util.List;
+import java.util.Map;
+
+public interface ValidationManager {
+
+ Map<String, List<ErrorMessage>> validate();
+
+ void addFile(String fileName, byte[] validationContent);
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java
new file mode 100644
index 0000000000..210ce76c41
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java
@@ -0,0 +1,30 @@
+/*-
+ * ============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.core.validation.errors;
+
+public class ErrorMessagesFormatBuilder {
+
+ public static String getErrorWithParameters(String error, String... params) {
+ return String.format(error, params);
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/Messages.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/Messages.java
new file mode 100644
index 0000000000..bca4e820a9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/Messages.java
@@ -0,0 +1,117 @@
+/*-
+ * ============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.core.validation.errors;
+
+public enum Messages {
+ INVALID_ZIP_FILE("Invalid zip file"),
+ /* upload errors */
+
+ //NO_ZIP_UPLOADED("No zip file was uploaded or zip file doesn't exist"),
+ ZIP_SHOULD_NOT_CONTAIN_FOLDERS("Zip file should not contain folders"),
+ MANIFEST_NOT_EXIST("Manifest doesn't exist"),
+ NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST("no zip file was uploaded or zip file doesn't exist"),
+
+
+ /* manifest errors*/
+ MISSING_FILE_IN_ZIP("Missing file in zip"),
+ MISSING_FILE_IN_MANIFEST("Missing file in manifest"),
+ MISSING_FILE_NAME_IN_MANIFEST("Missing file name in manifest - %s"),
+ MISSING_NESTED_FILE("Missing nested file - %s"),
+ MISSING_ARTIFACT("Missing artifact - %s"),
+ WRONG_HEAT_FILE_EXTENSION("Wrong HEAT file extension - %s"),
+ WRONG_ENV_FILE_EXTENSION("Wrong ENV file extension - %s"),
+ INVALID_MANIFEST_FILE("invalid manifest file"),
+ INVALID_FILE_TYPE("Missing or Unknown file type in Manifest"),
+ ENV_NOT_ASSOCIATED_TO_HEAT("ENV file must be associated to a HEAT file"),
+
+ /* content errors*/
+ INVALID_YAML_FORMAT("Invalid YAML format - %s"),
+ INVALID_YAML_FORMAT_REASON("Invalid YAML format Problem - [%s]"),
+ EMPTY_YAML_FILE("empty yaml"),
+ GENERAL_YAML_PARSER_ERROR("general parser error"),
+ GENERAL_HEAT_PARSER_ERROR("general parser error"),
+ INVALID_HEAT_FORMAT_REASON("Invalid HEAT format problem - [%s]"),
+ MISSING_RESOURCE_IN_DEPENDS_ON("a Missing resource in depend On Missing Resource ID [%s]"),
+ REFERENCED_PARAMETER_NOT_FOUND("Referenced parameter - %s - not found, used in resource - %s"),
+ GET_ATTR_NOT_FOUND("get_attr attribute not found - %s in resource %s"),
+ MISSING_PARAMETER_IN_NESTED(
+ "Referenced parameter not found in nested file - %s, resource name - %s, "
+ + "parameter name - %s"),
+ NESTED_LOOP("Nested files loop - %s"),
+ MORE_THAN_ONE_BIND_FROM_NOVA_TO_PORT("Resource Port %s exceed allowed relations from NovaServer"),
+ SERVER_NOT_DEFINED_FROM_NOVA("Missing server group definition - %s, %s"),
+ WRONG_POLICY_IN_SERVER_GROUP("Wrong policy in server group - %s"),
+ MISSING_IMAGE_AND_FLAVOR("Missing both Image and Flavor in NOVA Server - %s"),
+ ENV_INCLUDES_PARAMETER_NOT_IN_HEAT("Env file %s includes a parameter not in HEAT - %s"),
+ PARAMETER_ENV_VALUE_NOT_ALIGN_WITH_TYPE("Parameter env value %s not align with type"),
+ PARAMETER_DEFAULT_VALUE_NOT_ALIGN_WITH_TYPE(
+ "Parameter - %s default value not align with type %s"),
+ INVALID_RESOURCE_TYPE("A resource has an invalid or unsupported type - %s, Resource ID [%s]"),
+ ARTIFACT_FILE_NOT_REFERENCED("Artifact file is not referenced."),
+ SERVER_OR_SECURITY_GROUP_NOT_IN_USE("%s not in use, Resource Id [%s]"),
+ PORT_NO_BIND_TO_ANY_NOVA_SERVER("Port not bind to any NOVA Server, Resource Id [%s]"),
+ INVALID_GET_RESOURCE_SYNTAX(
+ "invalid get_resource syntax is in use - %s , get_resource function should"
+ + " get the resource id of the referenced resource"),
+ INVALID_RESOURCE_GROUP_TYPE(
+ "OS::Heat::ResourceGroup resource with resource_def which is not "
+ + "pointing to nested heat file is not supported,"
+ + " Resource ID [%s], resource_def type [%s]"),
+
+ /* warnings */
+ REFERENCED_RESOURCE_NOT_FOUND("Referenced resource - %s not found"),
+ MISSING_GET_PARAM("Missing get_param in %s, Resource Id [%s]"),
+
+ /*Ecomp Guide lines*/
+ MISSING_NOVA_SERVER_METADATA("Missing Nova Server Metadata property Resource id [%s]"),
+ MISSING_NOVA_SERVER_VNF_ID("Missing VNF_ID Resource id [%s]"),
+ MISSING_NOVA_SERVER_VF_MODULE_ID("Missing VF_MODULE_ID, Resource id [%s]"),
+ NETWORK_PARAM_NOT_ALIGNED_WITH_GUIDE_LINE(
+ "Network Parameter Name not aligned with Guidelines Parameter Name [%s] Resource ID [%s]"),
+ MISSIN_BASE_HEAT_FILE(
+ "Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources"),
+ MULTI_BASE_HEAT_FILE("Multi Base HEAT. Expected only one. Files %s."),
+ RESOURCE_NOT_DEFINED_IN_OUTPUT(
+ "Resource is not defined as output and thus cannot be Shared. resource id - %s"),
+ RESOURCE_CONNECTED_TO_TWO_EXTERNAL_NETWORKS_WITH_SAME_ROLE(
+ "A resource is connected twice to the same network role Resource ID [%s] Network Role [%s]."),
+ VOLUME_HEAT_NOT_EXPOSED("Volume is not defined as output and thus cannot be attached %s"),
+ FLOATING_IP_NOT_IN_USE("OS::Neutron::FloatingIP is in use, Resource ID [%s]"),
+ FIXED_IPS_NOT_ALIGNED_WITH_GUIDE_LINES("Fixed_IPS not aligned with Guidelines, Resource ID [%s]"),
+ NOVA_SERVER_NAME_NOT_ALIGNED_WITH_GUIDE_LINES(
+ "Server Name not aligned with Guidelines, Resource ID [%s]"),
+ AVAILABILITY_ZONE_NOT_ALIGNED_WITH_GUIDE_LINES(
+ "Server Availability Zone not aligned with Guidelines, Resource ID [%s]"),
+ WRONG_IMAGE_OR_FLAVOR_NAME_NOVA_SERVER("Wrong %s name format in NOVA Server, Resource ID [%s]");
+
+
+ private String errorMessage;
+
+ Messages(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/factory/ValidationManagerFactory.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/factory/ValidationManagerFactory.java
new file mode 100644
index 0000000000..6031bc14f7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/factory/ValidationManagerFactory.java
@@ -0,0 +1,32 @@
+/*-
+ * ============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.core.validation.factory;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.core.validation.api.ValidationManager;
+
+public abstract class ValidationManagerFactory extends AbstractComponentFactory<ValidationManager> {
+
+ public static ValidationManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ValidationManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/interfaces/Validator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/interfaces/Validator.java
new file mode 100644
index 0000000000..e32dfd72b9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/interfaces/Validator.java
@@ -0,0 +1,36 @@
+/*-
+ * ============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.core.validation.interfaces;
+
+import org.openecomp.core.validation.types.GlobalValidationContext;
+
+public interface Validator {
+
+ //public void validate(String fileName, GlobalValidationContext globalContext);
+ void validate(GlobalValidationContext globalContext);
+ //Object convert(FileValidationContext
+ // fileValidationContext);
+
+ /*default boolean filter(FileValidationContext filecontext,
+ GlobalValidationContext globalValidationContext){
+ return true;
+ }*/
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/FileValidationContext.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/FileValidationContext.java
new file mode 100644
index 0000000000..81e8931dab
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/FileValidationContext.java
@@ -0,0 +1,53 @@
+/*-
+ * ============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.core.validation.types;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+public class FileValidationContext {
+ private String fileName;
+ private MessageContainer messageContainer = new MessageContainer();
+ private byte[] content;
+
+ public FileValidationContext(String fileName, byte[] fileContent) {
+ this.fileName = fileName;
+ this.content = fileContent;
+ }
+
+
+ MessageContainer getMessageContainer() {
+ return this.messageContainer;
+ }
+
+ public InputStream getContent() {
+ return new ByteArrayInputStream(content);
+ }
+
+ public String getFileName() {
+ return this.fileName;
+ }
+
+ public boolean isEmpty() {
+ return content == null || content.length == 0;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java
new file mode 100644
index 0000000000..e6917e84f6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java
@@ -0,0 +1,142 @@
+/*-
+ * ============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.core.validation.types;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.core.validation.interfaces.Validator;
+import org.openecomp.sdc.common.utils.AsdcCommon;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.BiPredicate;
+import java.util.stream.Collectors;
+
+public class GlobalValidationContext {
+
+ private static Logger logger = LoggerFactory.getLogger(Validator.class);
+ private Map<String, FileValidationContext> fileContextMap = new HashMap<>();
+ private Map<String, MessageContainer> messageContainerMap = new HashMap<>();
+
+ /**
+ * Add message.
+ *
+ * @param fileName the file name
+ * @param level the level
+ * @param message the message
+ */
+ public void addMessage(String fileName, ErrorLevel level, String message) {
+
+ printLog(fileName, message, level);
+
+ if (fileContextMap.containsKey(fileName)) {
+ fileContextMap.get(fileName).getMessageContainer().getMessageBuilder().setMessage(message)
+ .setLevel(level).create();
+ } else {
+ if (CommonMethods.isEmpty(fileName)) {
+ fileName = AsdcCommon.UPLOAD_FILE;
+ }
+ MessageContainer messageContainer;
+ synchronized (this) {
+ messageContainer = messageContainerMap.get(fileName);
+ if (messageContainer == null) {
+ messageContainer = new MessageContainer();
+ messageContainerMap.put(fileName, messageContainer);
+ }
+ }
+ messageContainer.getMessageBuilder().setMessage(message).setLevel(level).create();
+ }
+ }
+
+ /**
+ * Gets file content.
+ *
+ * @param fileName the file name
+ * @return the file content
+ */
+ public InputStream getFileContent(String fileName) {
+ FileValidationContext fileContext = fileContextMap.get(fileName);
+ if (fileContext == null || fileContext.isEmpty()) {
+ return null;
+ }
+ return fileContext.getContent();
+ }
+
+ public void addFileContext(String fileName, byte[] fileContent) {
+ fileContextMap.put(fileName, new FileValidationContext(fileName, fileContent));
+ }
+
+ /**
+ * Gets context message containers.
+ *
+ * @return the context message containers
+ */
+ public Map<String, MessageContainer> getContextMessageContainers() {
+
+ Map<String, MessageContainer> contextMessageContainer = new HashMap<>();
+ fileContextMap.entrySet().stream().filter(entry -> CollectionUtils
+ .isNotEmpty(entry.getValue().getMessageContainer().getErrorMessageList())).forEach(
+ entry -> contextMessageContainer.put(
+ entry.getKey(), entry.getValue().getMessageContainer()));
+ messageContainerMap.entrySet().stream()
+ .filter(entry -> CollectionUtils.isNotEmpty(entry.getValue().getErrorMessageList()))
+ .forEach(entry -> contextMessageContainer.put(entry.getKey(), entry.getValue()));
+ return contextMessageContainer;
+ }
+
+ public Map<String, FileValidationContext> getFileContextMap() {
+ return fileContextMap;
+ }
+
+ private void printLog(String fileName, String message, ErrorLevel level) {
+
+ String messageToPrint = message + " in file[" + fileName + "]";
+
+ switch (level) {
+ case ERROR:
+ logger.error(messageToPrint);
+ break;
+ case WARNING:
+ logger.warn(messageToPrint);
+ break;
+ case INFO:
+ logger.info(messageToPrint);
+ break;
+ default:
+ break;
+ }
+ }
+
+ public Collection<String> files(BiPredicate<String, GlobalValidationContext> func) {
+ return fileContextMap.keySet().stream().filter(t -> func.test(t, this))
+ .collect(Collectors.toList());
+ }
+
+ public Collection<String> getFiles() {
+ return this.getFileContextMap().keySet();
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainer.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainer.java
new file mode 100644
index 0000000000..9d37bade67
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainer.java
@@ -0,0 +1,82 @@
+/*-
+ * ============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.core.validation.types;
+
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Predicate;
+
+public class MessageContainer {
+
+ private List<ErrorMessage> errorMessageList = new ArrayList<>();
+
+ public List<ErrorMessage> getErrorMessageList() {
+ return errorMessageList;
+ }
+
+ public MessageBuilder getMessageBuilder() {
+ return new MessageBuilder();
+ }
+
+ /**
+ * Gets error message list by level.
+ *
+ * @param level the level
+ * @return the error message list by level
+ */
+ public List<ErrorMessage> getErrorMessageListByLevel(ErrorLevel level) {
+
+ List<ErrorMessage> errors = new ArrayList<>();
+ errorMessageList.stream().filter(new Predicate<ErrorMessage>() {
+ @Override
+ public boolean test(ErrorMessage errorMessage) {
+ return errorMessage.getLevel().equals(level);
+ }
+ }).forEach(errorMessage -> errors.add(errorMessage));
+ return errors;
+ }
+
+ public class MessageBuilder {
+
+ String message;
+ ErrorLevel level;
+
+ MessageBuilder setMessage(String message) {
+ this.message = message;
+ return this;
+ }
+
+ MessageBuilder setLevel(ErrorLevel level) {
+ this.level = level;
+ return this;
+ }
+
+ void create() {
+ ErrorMessage errorMessage = new ErrorMessage(level, message);
+ if (!errorMessageList.contains(errorMessage)) {
+ errorMessageList.add(errorMessage);
+ }
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainerUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainerUtil.java
new file mode 100644
index 0000000000..c678bb5014
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainerUtil.java
@@ -0,0 +1,64 @@
+/*-
+ * ============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.core.validation.types;
+
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MessageContainerUtil {
+
+ /**
+ * Gets message by level.
+ *
+ * @param level the level
+ * @param messages the messages
+ * @return the message by level
+ */
+ public static Map<String,
+ List<ErrorMessage>> getMessageByLevel(
+ ErrorLevel level,Map<String,List<ErrorMessage>> messages) {
+ if (messages == null) {
+ return null;
+ }
+ Map<String, List<ErrorMessage>> filteredMessages = new HashMap<>();
+ messages.entrySet().stream().forEach(
+ entry -> entry.getValue().stream().filter(message -> message.getLevel().equals(level))
+ .forEach(message -> addMessage(entry.getKey(), message, filteredMessages
+ )));
+ return filteredMessages;
+ }
+
+ private static void addMessage(String fileName, ErrorMessage message,
+ Map<String, List<ErrorMessage>> messages) {
+ List<ErrorMessage> messageList = messages.get(fileName);
+ if (messageList == null) {
+ messageList = new ArrayList<>();
+ messages.put(fileName, messageList);
+ }
+ messageList.add(message);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..42a5583bdf
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.core.validation.factory.ValidationManagerFactory":"org.openecomp.sdc.validation.impl.ValidationManagerFactoryImpl"
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/resources/validationConfiguration.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/resources/validationConfiguration.json
new file mode 100644
index 0000000000..971f4274d9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/resources/validationConfiguration.json
@@ -0,0 +1,24 @@
+{
+ "validatorConfigurationList": [
+ {
+ "name": "yamlValidator",
+ "enableInd": true,
+ "implementationClass": "org.openecomp.sdc.validation.impl.validators.YamlValidator"
+ },
+ {
+ "name": "heatValidator",
+ "enableInd": true,
+ "implementationClass": "org.openecomp.sdc.validation.impl.validators.HeatValidator"
+ },
+ {
+ "name": "manifestValidator",
+ "enableInd": true,
+ "implementationClass": "org.openecomp.sdc.validation.impl.validators.ManifestValidator"
+ },
+ {
+ "name": "ecompGuideLineValidator",
+ "enableInd": true,
+ "implementationClass": "org.openecomp.sdc.validation.impl.validators.EcompGuideLineValidator"
+ }
+ ]
+} \ No newline at end of file