Assign image keyname and pubkey at vnf level
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / apps / devicemanager / impl / src / main / java / org / opendaylight / mwtn / config / impl / BaseSubConfig.java
1 package org.opendaylight.mwtn.config.impl;
2
3 import org.opendaylight.mwtn.base.internalTypes.IniConfigurationFile;
4 import org.opendaylight.mwtn.base.internalTypes.IniConfigurationFile.ConversionException;
5 import org.opendaylight.mwtn.base.internalTypes.IniConfigurationFile.Section;
6 import org.opendaylight.mwtn.config.impl.HtDevicemanagerConfiguration.ISubConfigHandler;
7
8 public class BaseSubConfig {
9
10
11         private final Section subconfig;
12         private final ISubConfigHandler configHandler;
13         private final IniConfigurationFile config;
14         protected Section getSubConfig() {
15                 return this.subconfig;
16         }
17         protected ISubConfigHandler getConfigHandler() {
18                 return this.configHandler;
19         }
20         protected IniConfigurationFile getConfig() {
21                 return this.config;
22         }
23         public BaseSubConfig()
24         {
25                 this.config=null;
26                 this.subconfig=null;
27                 this.configHandler=null;
28         }
29         public BaseSubConfig(IniConfigurationFile config, ISubConfigHandler configHandler,String section) {
30                 this.config = config;
31                 this.subconfig = config.subset(section);
32                 this.configHandler = configHandler;
33         }
34         protected boolean hasKey(String key)
35         {
36                 if(this.subconfig==null)
37                         return false;
38                 return this.subconfig.hasKey(key);
39         }
40         protected String getString(String key,String def)
41         {
42                 if(this.subconfig==null)
43                         return def;
44                 String s;
45                 //try
46                 {
47                         s=this.subconfig.getString(key, def);
48                         if(s.isEmpty())
49                                 s=def;
50                 }
51                 /*catch(ConversionException e)
52                 {
53                         s=def;
54                 }
55                 */
56                 return s;
57         }
58         protected boolean getBoolean(String key, boolean def) {
59                 if(this.subconfig==null)
60                         return def;
61                 boolean s;
62                 try {
63                         s=this.subconfig.getBoolean(key, def);
64                 }
65                 catch(ConversionException e)
66                 {
67                         s=def;
68                 }
69                 return s;
70         }
71         protected int getInt(String key, int def) {
72                 if(this.subconfig==null)
73                         return def;
74                 int s;
75                 try {
76                         s=this.subconfig.getInt(key, def);
77                 }
78                 catch(ConversionException e)
79                 {
80                         s=def;
81                 }
82                 return s;
83         }
84         protected void save()
85         {
86                 if(this.configHandler!=null)
87                         this.configHandler.save();
88         }
89
90
91 }