Replace all tab characters in java files with two spaces to remove linter warning
[aai/schema-service.git] / aai-schema-service / src / main / java / org / onap / aai / schemaservice / nodeschema / validation / DefaultVersionValidationModule.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.aai.schemaservice.nodeschema.validation;
21
22 import org.onap.aai.schemaservice.config.ConfigTranslator;
23 import org.onap.aai.schemaservice.nodeschema.SchemaVersion;
24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.stereotype.Component;
26
27 import java.util.List;
28 import java.util.Map;
29
30 /**
31  * By default, A&AI must have schema files for all current
32  * supported Versions in the Version enum
33  *
34  */
35 @Component
36 public class DefaultVersionValidationModule implements VersionValidationModule {
37   private ConfigTranslator config;
38
39   @Autowired
40   public DefaultVersionValidationModule(ConfigTranslator config) {
41     this.config = config;
42   }
43
44   /* (non-Javadoc)
45    * @see org.onap.aai.validation.VersionValidationModule#validate(org.onap.aai.setup.ConfigTranslator)
46    */
47   @Override
48   public String validate() {
49     Map<SchemaVersion, List<String>> nodeConfig = config.getNodeFiles();
50     Map<SchemaVersion, List<String>> edgeConfig = config.getEdgeFiles();
51
52     StringBuilder missingVers = new StringBuilder().append("Missing schema for the following versions: ");
53     boolean isMissing = false;
54     for (SchemaVersion v : config.getSchemaVersions().getVersions()) {
55       if (nodeConfig.get(v) == null) {
56         isMissing = true;
57         missingVers.append(v.toString()).append(" has no OXM configured. ");
58       }
59       if (edgeConfig.get(v) == null) {
60         isMissing = true;
61         missingVers.append(v.toString()).append(" has no edge rules configured. ");
62       }
63     }
64
65     if (isMissing) {
66       return missingVers.toString();
67     } else {
68       return "";
69     }
70   }
71
72 }