aboutsummaryrefslogtreecommitdiffstats
path: root/music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java
diff options
context:
space:
mode:
authorArthur Martella <arthur.martella.1@att.com>2019-09-26 16:40:58 -0400
committerArthur Martella <arthur.martella.1@att.com>2019-09-26 17:02:22 -0400
commit11ee6836d6f25a1becdea60a322a72fbffd4b8b6 (patch)
treefc15f181847fa5ae5e26d8ba37cb746feced79d5 /music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java
parenta00014e78f18134f998fb46a7dd543e6ea05a3bd (diff)
Split music src into music-core and music-rest
Separating music into two directories to build with two pom files. Hopefully this should allow both jars to be deployed in nexus. Do not merge without careful review!!! Issue-ID: MUSIC-505 Signed-off-by: Martella, Arthur <arthur.martella.1@att.com> Change-Id: I9dd2074e7f4499216c2bcd00095829dd43e2d0f9
Diffstat (limited to 'music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java')
-rw-r--r--music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java295
1 files changed, 295 insertions, 0 deletions
diff --git a/music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java b/music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java
new file mode 100644
index 00000000..8aac2672
--- /dev/null
+++ b/music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java
@@ -0,0 +1,295 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.onap.music.main;
+
+import java.util.Properties;
+
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.stereotype.Component;
+
+@PropertySource(value = {"file:/opt/app/music/etc/music.properties", "classpath:/project.properties","file:/opt/app/music/etc/key.properties"})
+@Component
+public class PropertiesLoader implements InitializingBean {
+
+ @Value("${cassandra.host}")
+ public String cassandraHost;
+/*
+ @Value("${music.ip}")
+ public String musicIp;
+*/
+ @Value("${debug}")
+ public String debug;
+
+ @Value("${version}")
+ public String version;
+
+ @Value("${build}")
+ public String build;
+
+ @Value("${music.properties}")
+ public String musicProperties;
+
+ @Value("${lock.lease.period}")
+ public String lockLeasePeriod;
+
+ @Value("${cassandra.user}")
+ public String cassandraUser;
+
+ @Value("${cassandra.password}")
+ public String cassandraPassword;
+
+ @Value("${cassandra.port}")
+ public String cassandraPort;
+
+ @Value("${cadi}")
+ public String isCadi;
+
+ @Value("${keyspace.active}")
+ public String isKeyspaceActive;
+
+ @Value("${retry.count}")
+ public String rertryCount;
+
+ @Value("${transId.header.prefix}")
+ private String transIdPrefix;
+
+ @Value("${conversation.header.prefix}")
+ private String conversationIdPrefix;
+
+ @Value("${clientId.header.prefix}")
+ private String clientIdPrefix;
+
+ @Value("${messageId.header.prefix}")
+ private String messageIdPrefix;
+
+ @Value("${transId.header.required}")
+ private Boolean transIdRequired;
+
+ @Value("${conversation.header.required}")
+ private Boolean conversationIdRequired;
+
+ @Value("${clientId.header.required}")
+ private Boolean clientIdRequired;
+
+ @Value("${messageId.header.required}")
+ private Boolean messageIdRequired;
+
+ @Value("${music.aaf.ns}")
+ private String musicAafNs;
+
+ @Value("${cipher.enc.key}")
+ private String cipherEncKey;
+
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PropertiesLoader.class);
+
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer propertyConfigInDev() {
+ //return new PropertySourcesPlaceholderConfigurer();
+ PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
+ pspc.setIgnoreResourceNotFound(true);
+ pspc.setIgnoreUnresolvablePlaceholders(true);
+ return pspc;
+ }
+
+ /**
+ * .
+ */
+ public void loadProperties() {
+ if(cipherEncKey != null) {
+ MusicUtil.setCipherEncKey(cipherEncKey);
+ }
+ if (musicAafNs != null) {
+ MusicUtil.setMusicAafNs(musicAafNs);
+ }
+ if (cassandraPort != null && !cassandraPort.equals("${cassandra.port}")) {
+ MusicUtil.setCassandraPort(Integer.parseInt(cassandraPort));
+ }
+ if (cassandraUser != null && !cassandraUser.equals("${cassandra.user}")) {
+ MusicUtil.setCassName(cassandraUser);
+ }
+ if (cassandraPassword != null && !cassandraPassword.equals("${cassandra.password}")) {
+ MusicUtil.setCassPwd(cassandraPassword);
+ }
+ if (debug != null && !debug.equals("${debug}")) {
+ MusicUtil.setDebug(Boolean.parseBoolean(debug));
+ }
+ if (lockLeasePeriod != null && !lockLeasePeriod.equals("${lock.lease.period}")) {
+ MusicUtil.setDefaultLockLeasePeriod(Long.parseLong(lockLeasePeriod));
+ }
+ if (musicProperties != null && !musicProperties.equals("${music.properties}")) {
+ MusicUtil.setMusicPropertiesFilePath(musicProperties);
+ }
+ if (cassandraHost != null && !cassandraHost.equals("${cassandra.host}")) {
+ MusicUtil.setMyCassaHost(cassandraHost);
+ }
+ if (version != null && !version.equals("${version}")) {
+ MusicUtil.setVersion(version);
+ }
+ if (build != null && !version.equals("${build}")) {
+ MusicUtil.setBuild(build);
+ }
+ if (isCadi != null && !isCadi.equals("${cadi}")) {
+ MusicUtil.setIsCadi(Boolean.parseBoolean(isCadi));
+ }
+ if (rertryCount != null && !rertryCount.equals("${retry.count}")) {
+ MusicUtil.setRetryCount(Integer.parseInt(rertryCount));
+ }
+ if (isKeyspaceActive != null && !isKeyspaceActive.equals("${keyspace.active}")) {
+ MusicUtil.setKeyspaceActive(Boolean.parseBoolean(isKeyspaceActive));
+ }
+ if(transIdPrefix!=null) {
+ MusicUtil.setTransIdPrefix(transIdPrefix);
+ }
+
+ if(conversationIdPrefix!=null) {
+ MusicUtil.setConversationIdPrefix(conversationIdPrefix);
+ }
+
+ if(clientIdPrefix!=null) {
+ MusicUtil.setClientIdPrefix(clientIdPrefix);
+ }
+
+ if(messageIdPrefix!=null) {
+ MusicUtil.setMessageIdPrefix(messageIdPrefix);
+ }
+
+ if(transIdRequired!=null) {
+ MusicUtil.setTransIdRequired(transIdRequired);
+ }
+
+ if(conversationIdRequired!=null) {
+ MusicUtil.setConversationIdRequired(conversationIdRequired);
+ }
+
+ if(clientIdRequired!=null) {
+ MusicUtil.setClientIdRequired(clientIdRequired);
+ }
+
+ if(messageIdRequired!=null) {
+ MusicUtil.setMessageIdRequired(messageIdRequired);
+ }
+ }
+
+ public static void loadProperties(Properties properties) {
+ if (properties.getProperty("cassandra.host")!=null) {
+ MusicUtil.setMyCassaHost(properties.getProperty("cassandra.host"));
+ }
+
+ if (properties.getProperty("cassandra.port")!=null) {
+ MusicUtil.setCassandraPort(Integer.parseInt(properties.getProperty("cassandra.port")));
+ }
+
+ if (properties.getProperty("cassandra.user")!=null) {
+ MusicUtil.setCassName(properties.getProperty("cassandra.user"));
+ }
+
+ if (properties.getProperty("cassandra.password")!=null) {
+ MusicUtil.setCassPwd(properties.getProperty("cassandra.password"));
+ }
+
+ if (properties.getProperty("music.properties")!=null) {
+ MusicUtil.setMusicPropertiesFilePath(properties.getProperty("music.properties"));
+ }
+
+ if (properties.getProperty("debug")!=null) {
+ MusicUtil.setDebug(Boolean.parseBoolean(properties.getProperty("debug")));
+ }
+
+ if (properties.getProperty("version")!=null) {
+ MusicUtil.setVersion(properties.getProperty("version"));
+ }
+
+ if (properties.getProperty("build")!=null) {
+ MusicUtil.setBuild(properties.getProperty("build"));
+ }
+
+ if (properties.getProperty("lock.lease.period")!=null) {
+ MusicUtil.setDefaultLockLeasePeriod(Long.parseLong(properties.getProperty("lock.lease.period")));
+ }
+
+ if (properties.getProperty("cadi")!=null) {
+ MusicUtil.setIsCadi(Boolean.parseBoolean(properties.getProperty("cadi")));
+ }
+
+ if (properties.getProperty("keyspace.active")!=null) {
+ MusicUtil.setKeyspaceActive(Boolean.parseBoolean(properties.getProperty("keyspace.active")));
+ }
+
+ if (properties.getProperty("retry.count")!=null) {
+ MusicUtil.setRetryCount(Integer.parseInt(properties.getProperty("retry.count")));
+ }
+
+ if (properties.getProperty("transId.header.prefix")!=null) {
+ MusicUtil.setTransIdPrefix(properties.getProperty("transId.header.prefix"));
+ }
+
+ if (properties.getProperty("conversation.header.prefix")!=null) {
+ MusicUtil.setConversationIdPrefix(properties.getProperty("conversation.header.prefix"));
+ }
+
+ if (properties.getProperty("clientId.header.prefix")!=null) {
+ MusicUtil.setClientIdPrefix(properties.getProperty("clientId.header.prefix"));
+ }
+
+ if (properties.getProperty("messageId.header.prefix")!=null) {
+ MusicUtil.setMessageIdPrefix(properties.getProperty("messageId.header.prefix"));
+ }
+
+ if (properties.getProperty("transId.header.required")!=null) {
+ MusicUtil.setTransIdRequired(Boolean.parseBoolean(properties.getProperty("transId.header.required")));
+ }
+
+ if (properties.getProperty("conversation.header.required")!=null) {
+ MusicUtil.setConversationIdRequired(Boolean.parseBoolean(properties.getProperty("conversation.header.required")));
+ }
+
+ if (properties.getProperty("clientId.header.required")!=null) {
+ MusicUtil.setClientIdRequired(Boolean.parseBoolean(properties.getProperty("clientId.header.required")));
+ }
+
+ if (properties.getProperty("messageId.header.required")!=null) {
+ MusicUtil.setMessageIdRequired(Boolean.parseBoolean(properties.getProperty("messageId.header.required")));
+ }
+
+ if (properties.getProperty("music.aaf.ns")!=null) {
+ MusicUtil.setMusicAafNs(properties.getProperty("music.aaf.ns"));
+ }
+
+ if (properties.getProperty("cipher.enc.key")!=null) {
+ MusicUtil.setCipherEncKey(properties.getProperty("cipher.enc.key"));
+ }
+
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+}