package org.onap.music.main;
-import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Properties;
import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.stereotype.Component;
-@PropertySource(value = {"file:/opt/app/music/etc/music.properties", "classpath:/project.properties"})
+@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("${cassandra.password}")
public String cassandraPassword;
- @Value("${aaf.endpoint.url}")
- public String aafEndpointUrl;
-
- @Value("${admin.username}")
- public String adminUsername;
-
- @Value("${admin.password}")
- public String adminPassword;
-
@Value("${cassandra.port}")
public String cassandraPort;
- @Value("${aaf.admin.url}")
- public String aafAdminUrl;
-
- @Value("${music.namespace}")
- public String musicNamespace;
-
- @Value("${admin.aaf.role}")
- public String adminAafRole;
-
- @Value("${notify.interval}")
- public String notifyInterval;
-
- @Value("${notify.timeout}")
- public String notifyTimeout;
-
@Value("${cadi}")
public String isCadi;
private String messageIdPrefix;
@Value("${transId.header.required}")
- private String transIdRequired;
+ private Boolean transIdRequired;
@Value("${conversation.header.required}")
- private String conversationIdRequired;
+ private Boolean conversationIdRequired;
@Value("${clientId.header.required}")
- private String clientIdRequired;
+ private Boolean clientIdRequired;
@Value("${messageId.header.required}")
- private String messageIdRequired;
+ 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);
* .
*/
public void loadProperties() {
- if (aafAdminUrl != null && !aafAdminUrl.equals("${aaf.admin.url}")) {
- MusicUtil.setAafAdminUrl(aafAdminUrl);
- }
- if (aafEndpointUrl != null && !aafEndpointUrl.equals("${aaf.endpoint.url}")) {
- MusicUtil.setAafEndpointUrl(aafEndpointUrl);
+ if(cipherEncKey != null) {
+ MusicUtil.setCipherEncKey(cipherEncKey);
}
- if (adminAafRole != null && !adminAafRole.equals("${admin.aaf.role}")) {
- MusicUtil.setAdminAafRole(adminAafRole);
- }
- if (adminPassword != null && !adminPassword.equals("${admin.password}")) {
- MusicUtil.setAdminPass(adminPassword);
- }
- if (adminUsername != null && !adminUsername.equals("${admin.username}")) {
- MusicUtil.setAdminId(adminUsername);
+ if (musicAafNs != null) {
+ MusicUtil.setMusicAafNs(musicAafNs);
}
if (cassandraPort != null && !cassandraPort.equals("${cassandra.port}")) {
MusicUtil.setCassandraPort(Integer.parseInt(cassandraPort));
if (lockLeasePeriod != null && !lockLeasePeriod.equals("${lock.lease.period}")) {
MusicUtil.setDefaultLockLeasePeriod(Long.parseLong(lockLeasePeriod));
}
- if (musicIp != null && !musicIp.equals("${music.ip}")) {
- MusicUtil.setDefaultMusicIp(musicIp);
- }
- if (musicNamespace != null && !musicNamespace.equals("${music.namespace}")) {
- MusicUtil.setMusicNamespace(musicNamespace);
- }
if (musicProperties != null && !musicProperties.equals("${music.properties}")) {
MusicUtil.setMusicPropertiesFilePath(musicProperties);
}
if (cassandraHost != null && !cassandraHost.equals("${cassandra.host}")) {
MusicUtil.setMyCassaHost(cassandraHost);
}
- if (notifyInterval != null && !notifyInterval.equals("${notify.interval}")) {
- MusicUtil.setNotifyInterval(Integer.parseInt(notifyInterval));
- }
- if (notifyTimeout != null && !notifyTimeout.equals("${notify.timeout}")) {
- MusicUtil.setNotifyTimeOut(Integer.parseInt(notifyTimeout));
- }
if (version != null && !version.equals("${version}")) {
MusicUtil.setVersion(version);
}
if (isKeyspaceActive != null && !isKeyspaceActive.equals("${keyspace.active}")) {
MusicUtil.setKeyspaceActive(Boolean.parseBoolean(isKeyspaceActive));
}
-
-
if(transIdPrefix!=null) {
MusicUtil.setTransIdPrefix(transIdPrefix);
}
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
}
-
+
}