/**
  * Given a file that the preferences are supposedly stored in, this function will try to load the
  * preferences. If the preferences don't exist, or they are incomplete, this will also fill in the
  * missing values, and store the now complete preferences in the file location specified.
  *
  * @param prefFile
  * @throws Exception
  */
 public void init(File prefFile) throws IOException {
   this.prefFile = prefFile;
   if (prefFile.exists()) {
     Properties userProperties = new Properties();
     FileInputStream in = new FileInputStream(prefFile);
     userProperties.load(in);
     in.close();
     for (String key : userProperties.stringPropertyNames()) {
       String val = userProperties.getProperty(key);
       String value = getObject(val, ((Preference) prefs.get(key))).toString();
       Object ovalue = getObject(val, ((Preference) prefs.get(key)));
       Preference p1 = prefs.get(key);
       Preference p2;
       if (p1 != null) {
         p2 = new Preference(p1.name, value, p1.allowed, p1.description);
       } else {
         p2 = new Preference(key, val, Type.STRING, "");
       }
       p2.objectValue = ovalue;
       prefs.put(key, p2);
     }
   }
   save();
 }
Exemple #2
0
 public CDRServer()
 {
     dbpool = new DBPool();
     gateway = new GatewayCDR();
     Preference.loadProperties("gateway.cfg");
     FtpData.loadProperties("ftp2cdrserver.cfg");
     break MISSING_BLOCK_LABEL_51;
     IOException e;
     e;
     Logger.info("CDRServer:", "khong tim thay file cau hinh");
     dbpool;
     DBPool.ConfigDB();
     Logger.setLogWriter("log/cdr${yyyy-MM-dd}.log");
     break MISSING_BLOCK_LABEL_72;
     IOException ex;
     ex;
     Logger.setLogLevel("info,warn,error,crisis");
     return;
 }
 private boolean isValidAddress(String userId, String serviceId) {
   if (userId == null || "".equals(userId) || serviceId == null || "".equals(serviceId)) {
     // System.out.println("Source/dest address NULL --> PDU discarded");
     return false;
   }
   if (!Preference.isValidServiceId(serviceId)) {
     // System.out.println("Invalid dest address:" + serviceId
     // + " --> PDU discarded");
     return false;
   }
   if (userId.startsWith("849") || userId.startsWith("+849") || userId.startsWith("09")) {
     return true;
     // TrungDK EVN -> UNKNOWN
   } else if ("UNKNOWN".equalsIgnoreCase(Preference.mobileOperator)) {
     return true;
   } else {
     // System.out.println("Invalid source address:" + userId + " --> PDU
     // discarded");
     return true;
   }
 }