package com.seeyon.apps.src_automatic.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

import com.seeyon.ctp.common.SystemEnvironment;
//import com.seeyon.ctp.common.file.model.CtpLocalFile;
import com.seeyon.ctp.util.PropertiesUtil;

/**
 * 读取参数
 */

public class PropKit {
	
	private static long lastModify;
	
	private static ConcurrentHashMap<String, String> props;
    
    
    public static final String URL = "url";
    
    public static final String SERVICE_CODE = "serviceCode";
    
    public static final String USER_NAME = "userName";
    
    public static final String USER_PASSWORD = "userPassword";
    
    /**
     * @return
     * @throws IOException 
     * @throws FileNotFoundException 
     */
    public static String getProp(String key) throws FileNotFoundException, IOException {
		File f = new File(SystemEnvironment.getApplicationFolder() + "/WEB-INF/cfgHome/plugin/src_automatic/mobile.properties");
		if(null == props) {
			props = new ConcurrentHashMap<String, String>();
		}
		if(f.lastModified() != lastModify) {
			/**
			 * huangzhengguo
			 * 2022-10-18
			 */
			Properties prop = new Properties();
			prop.load(new FileInputStream(f));
//			Properties prop = PropertiesUtil.getFromFile((CtpLocalFile) f);
			/**
			 * end
			 */
			for(Object propkey : prop.keySet()) {
				props.put(propkey.toString(), prop.getProperty(key));
			}
		}
		return props.get(key);
    }
  
}
