Merge "Update the license for 2017-2018 license"
[aai/aai-common.git] / aai-schema-ingest / src / main / java / org / onap / aai / setup / SchemaLocationsBean.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.setup;
21
22 import org.springframework.beans.factory.annotation.Value;
23 import org.springframework.context.annotation.Bean;
24 import org.springframework.context.annotation.Configuration;
25 import org.springframework.context.annotation.PropertySource;
26 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
27
28 @Configuration
29 @PropertySource(value = "classpath:schemaIngest.properties", ignoreResourceNotFound=true)
30 @PropertySource(value = "file:${schemaIngestPropLoc}", ignoreResourceNotFound=true)
31 public class SchemaLocationsBean {
32         /*
33          * Per Spring documentation, the last PropertySource that works will
34          * be applied. Here, schemaIngestPropLoc will be an environment variable
35          * set on install that tells Spring where to look for the schema
36          * ingest properties file (and the actual filename), but the former
37          * PropertySource gives the default of looking on the classpath for
38          * schemaIngest.properties in case that second one doesn't work.
39          * 
40          * The schemaIngest.properties file (or its equivalent if you choose 
41          * to name it otherwise) must contain the entries the below @Value
42          * annotations are looking for.
43          */
44         
45         @Value("${schemaConfig}")
46         private String schemaConfigLoc;
47         
48         @Value("${nodeDir}")
49         private String nodeDirectory;
50         
51         @Value("${edgeDir}")
52         private String edgeDirectory;
53         
54         /**
55          * @return the file name/location with the list of schema files to be ingested
56          */
57         public String getSchemaConfigLocation() {
58                 return schemaConfigLoc;
59         }
60         
61         /**
62          * Sets the name/location of the file with the list of schema files to ingest
63          * 
64          * @param String schemaConfigLoc - the file name/location 
65          */
66         public void setSchemaConfigLocation(String schemaConfigLoc) {
67                 this.schemaConfigLoc = schemaConfigLoc;
68         }
69         
70         /**
71          * @return the location of the OXM files
72          */
73         public String getNodeDirectory() {
74                 return nodeDirectory;
75         }
76         
77         /**
78          * Sets the location of the OXM files
79          * 
80          * @param String nodeDirectory - the location of the OXM files
81          */
82         public void setNodeDirectory(String nodeDirectory) {
83                 this.nodeDirectory = nodeDirectory;
84         }
85         
86         /**
87          * @return the location of the edge rule json files
88          */
89         public String getEdgeDirectory() {
90                 return edgeDirectory;
91         }
92         
93         /**
94          * Sets the location of the edge rule json files
95          * 
96          * @param String edgeDirectory - the location of the edge rule files
97          */
98         public void setEdgeDirectory(String edgeDirectory) {
99                 this.edgeDirectory = edgeDirectory;
100         }
101         
102         //this allows the code to actually read the value from the config file
103         //without this those strings get set to literally "${edgeDir}" etc
104         @Bean
105         public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
106                 return new PropertySourcesPlaceholderConfigurer();
107         }
108 }