507fd80348bd7478bcb30b650585110790c64545.svn-base 5.3 KB
package com.espeed.reading.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.Properties;
/**
 * 程序名称:    	EspeedMail_时速邮箱
 * 程序版本:    	V1.0
 * 作    者:    	深圳市科飞时速网络技术有限公司(0755-88843776)
 * 版权所有:    	深圳市科飞时速网络技术有限公司
 * 技术支持:    	Tech@21gmail.com
 * 单元名称:    读取配置文件工具类
 * 开始时间:    	2013.09.26
 * 程 序 员:    	谢勇
 * 最后修改:    
 * 备    注:		如需修改请通知程序员    
 */
public class ConfigPath {

  static Properties p = loadPropertyFile("config.properties");
  
   /**总控中心请求入口*/
   public static String getControlCentreUrl(){
	   return p.get("controlCentreUrl")+"";
   }
   /**中转站默认跳转链接*/
   public static String getDefaultToUrl(){
	   return p.get("defaultToUrl")+"";
   }
   /**允许获取邮件超链统计数据的ip*/
   public static String getAllowIp(){
	   return p.get("allowIp")+"";
   }
   /**获取token解析密钥*/
	public static String getSecretKey(){
		return p.getProperty("secretkey");
	}
	/**获取token-id*/
	public static String getTokenId(){
		return p.getProperty("tokenid");
	}
	/**获取token-subject*/
	public static String getTokenSubject(){
		return p.getProperty("tokensubject");
	}
	/**邮箱正则表达式*/
	public static String getEmailPattern(){
		return p.getProperty("emailPattern");
	}
	/**邮件官方点读域名*/
	public static String getClickDomain(){
		return p.getProperty("clickDomain");
	}
	/**邮件官方点读url*/
	public static String getClickUrl(){
		return p.getProperty("clickUrl");
	}
	/**日志保存目录*/
	public static String getLogSavePath(){
		return p.getProperty("logSavePath");
	}
	/**云盘分享前端访问入口*/
	public static String getCloudShareUrl(){
		return p.getProperty("cloudShareUrl");
	}
	/**云盘后端访问入口*/
	public static String getCloudServiceUrl(){
		return p.getProperty("cloudServiceUrl");
	}
   
   /**数据库url*/
   public static String getBaseUrl(){
	   return p.get("url")+"";
   }
   /**数据库账号*/
   public static String getBaseUserName(){
	   return p.get("username")+"";
   }
   /**数据库password*/
   public static String getBasePassword(){
	   return p.get("password")+"";
   }
   /**用户中心数据库url*/
   public static String getCentreUrl(){
	   return p.get("centreUrl")+"";
   }
   /**用户中心数据库账号*/
   public static String getCentreUsername(){
	   return p.get("centreUsername")+"";
   }
   /**用户中心数据库password*/
   public static String getCentrePassword(){
	   return p.get("centrePassword")+"";
   }
   /**营销邮数据库url*/
   public static String getYxyUrl(){
	   return p.get("yxyUrl")+"";
   }
   /**营销邮数据库账号*/
   public static String getYxyUsername(){
	   return p.get("yxyUsername")+"";
   }
   /**营销邮数据库password*/
   public static String getYxyPassword(){
	   return p.get("yxyPassword")+"";
   }
   /**易外销WebMail数据库url*/
   public static String getWebmailUrl(){
	   return p.get("webmailUrl")+"";
   }
   /**易外销WebMail数据库账号*/
   public static String getWebmailUsername(){
	   return p.get("webmailUsername")+"";
   }
   /**易外销WebMail数据库password*/
   public static String getWebmailPassword(){
	   return p.get("webmailPassword")+"";
   }
   /**mongodb url*/
   public static String getMongodbUrl(){
	   return p.getProperty("mongodbpath");
   }
   /**mongodb port*/
   public static int getMongodbPort(){
	   return Integer.parseInt(p.getProperty("mongodbport"));
   }
   /**mongodb username*/
   public static String getMongodbUsername(){
	   return p.getProperty("mongodbusername");
   }
   /**mongodb password*/
   public static String getMongodbPassword(){
	   return p.getProperty("mongodbpassword");
   }
   /**mongodb name*/
   public static String getMongodbName(){
	   return p.getProperty("mongodbname");
   }
  
   public static Properties loadPropertyFile(String fullFile) {
       String webRootPath = null;
       if ( fullFile.equals(""))
          throw new IllegalArgumentException("Properties file path can not be null : " + fullFile);
       try {
			webRootPath = ConfigPath.class.getClassLoader().getResource("").toURI().getPath();
		} catch (URISyntaxException e1) {
			e1.printStackTrace();
		}
       webRootPath = new File(webRootPath).getParent();
       InputStream inputStream = null;
       Properties p = null;
       try {
           inputStream = new FileInputStream(new File(webRootPath+ File.separator + fullFile));
           p = new Properties();
           p.load(inputStream);
           
       } catch (FileNotFoundException e) {
           throw new IllegalArgumentException("Properties file not found: "
                   + fullFile);
       } catch (IOException e) {
           throw new IllegalArgumentException(
                   "Properties file can not be loading: " + fullFile);
       } finally {
           try {
               if (inputStream != null)
                   inputStream.close();
           } catch (IOException e) {
               e.printStackTrace();
           }
       }
       return p;
   }  
	
 
   
}