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