⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysconfig.java

📁 java论坛
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.laoer.bbscs.service.config;

import java.util.*;

import org.apache.commons.lang.*;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.logging.*;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.exception.*;
import com.laoer.bbscs.service.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import org.apache.struts.util.LabelValueBean;
import org.apache.commons.io.FilenameUtils;

/**
 * <p>Title: Tianyi BBS</p>
 *
 * <p>Description: BBSCS</p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: Laoer.com</p>
 *
 * @author Gong Tianyi
 * @version 7.0
 */
public class SysConfig {

  private static final Log logger = LogFactory.getLog(SysConfig.class);

  private HashMap configs;

  private ConfigService configService;

  private boolean isLoad = false;

  public SysConfig(ConfigService configService) {
    this.configs = new HashMap();
    this.configService = configService;
    this.loadConfigs();
  }

  public void loadConfigs() {
    logger.info("Load sys config...");
    List l = this.getConfigService().findConfigs();
    for (int i = 0; i < l.size(); i++) {
      Config config = (Config) l.get(i);
      //logger.info(config.getId() + " " + config.getConfContext());
      //this.configs.put(config.getId(), config.getConfContext());
      this.configs.put(config.getId(), config);
    }
    logger.info("Load sys config complete," + l.size() + " items is loaded.");
  }

  public Config getConfigContext(String key) {
    return (Config)this.configs.get(key);
  }

  public void setConfigContext(String key, String confContext) {
    /*
         Config config = new Config();
         config.setId(key);
         config.setConfContext(confContext);
         this.getConfigService().updateConfig(config);
         this.configs.put(key, confContext);*/
    Config config = this.getConfigContext(key);
    config.setConfContext(confContext);
    this.configs.put(key, config);
  }

  public void saveConfigs() throws SysConfigException {
    try {
      this.getConfigService().updateAllConfigs(this.configs);
    }
    catch (BbscsException ex) {
      logger.error(ex);
      throw new SysConfigException(ex);
    }
  }

  public int getIntValue(String key, int defaultValue) {
    Config config = this.getConfigContext(key);
    return NumberUtils.toInt(config.getConfContext(), defaultValue);
  }

  public String getStringValue(String key) {
    Config config = this.getConfigContext(key);
    return StringUtils.trimToEmpty(config.getConfContext());
  }

  public float getFloatValue(String key, float defaultValue) {
    Config config = this.getConfigContext(key);
    return NumberUtils.toFloat(config.getConfContext(), defaultValue);
  }

  public int getIsOpen() {
    return this.getIntValue("IsOpen", 1);
  }

  public void setIsOpen(int isOpen) {
    this.setConfigContext("IsOpen", String.valueOf(isOpen));
  }

  public String getCloseReson() {
    return this.getStringValue("CloseReson");
  }

  public void setCloseReson(String closeReson) {
    this.setConfigContext("CloseReson", closeReson);
  }

  public String getForumName() {
    return this.getStringValue("ForumName");
  }

  public void setForumName(String forumName) {
    this.setConfigContext("ForumName", forumName);
  }

  public String getForumUrl() {
    return this.getStringValue("ForumUrl");
  }

  public void setForumUrl(String forumUrl) {
    this.setConfigContext("ForumUrl", forumUrl);
  }

  public String getWebName() {
    return this.getStringValue("WebName");
  }

  public void setWebName(String webName) {
    this.setConfigContext("WebName", webName);
  }

  public String getWebUrl() {
    return this.getStringValue("WebUrl");
  }

  public void setWebUrl(String webUrl) {
    this.setConfigContext("WebUrl", webUrl);
  }

  public String getWebmasterEmail() {
    return this.getStringValue("WebmasterEmail");
  }

  public void setWebmasterEmail(String webmasterEmail) {
    this.setConfigContext("WebmasterEmail", webmasterEmail);
  }

  public String getPrivacyUrl() {
    return this.getStringValue("PrivacyUrl");
  }

  public void setPrivacyUrl(String privacyUrl) {
    this.setConfigContext("PrivacyUrl", privacyUrl);
  }

  public String getCopyRightMsg() {
    return this.getStringValue("CopyRightMsg");
  }

  public void setCopyRightMsg(String copyRightMsg) {
    this.setConfigContext("CopyRightMsg", copyRightMsg);
  }

  public String getMetaKeywords() {
    return this.getStringValue("MetaKeywords");
  }

  public void setMetaKeywords(String metaKeywords) {
    this.setConfigContext("MetaKeywords", metaKeywords);
  }

  public String getMetaDescription() {
    return this.getStringValue("MetaDescription");
  }

  public void setMetaDescription(String metaDescription) {
    this.setConfigContext("MetaDescription", metaDescription);
  }

  public int getCanSeePageNum() {
    return this.getIntValue("CanSeePageNum", 10);
  }

  public void setCanSeePageNum(int canSeePageNum) {
    this.setConfigContext("CanSeePageNum", String.valueOf(canSeePageNum));
  }

  public int getUseSafeLogin() {
    return this.getIntValue("UseSafeLogin", 0);
  }

  public void setUseSafeLogin(int useSafeLogin) {
    this.setConfigContext("UseSafeLogin", String.valueOf(useSafeLogin));
  }

  public boolean isUseSafeLogin() {
    return (getUseSafeLogin() == 1);
  }

  public String getLogoutUrl() {
    return this.getStringValue("LogoutUrl");
  }

  public void setLogoutUrl(String logoutUrl) {
    this.setConfigContext("LogoutUrl", logoutUrl);
  }

  public int getDateShowType() {
    return this.getIntValue("DateShowType", 0);
  }

  public void setDateShowType(int dateShowType) {
    this.setConfigContext("DateShowType", String.valueOf(dateShowType));
  }

  public int getDefaultTimeZone() {
    return this.getIntValue("DefaultTimeZone", 0);
  }

  public void setDefaultTimeZone(int defaultTimeZone) {
    this.setConfigContext("DefaultTimeZone", String.valueOf(defaultTimeZone));
  }

  public String getForumDateTimeFormat() {
    return this.getStringValue("ForumDateTimeFormat");
  }

  public void setForumDateTimeFormat(String forumDateTimeFormat) {
    this.setConfigContext("ForumDateTimeFormat", forumDateTimeFormat);
  }

  public String getPostDateTimeFormat() {
    return this.getStringValue("PostDateTimeFormat");
  }

  public void setPostDateTimeFormat(String postDateTimeFormat) {
    this.setConfigContext("PostDateTimeFormat", postDateTimeFormat);
  }

  public String getOtherDateTimeFormat() {
    return this.getStringValue("OtherDateTimeFormat");
  }

  public void setOtherDateTimeFormat(String otherDateTimeFormat) {
    this.setConfigContext("OtherDateTimeFormat", otherDateTimeFormat);
  }

  public String getRegDateTimeFormat() {
    return this.getStringValue("RegDateTimeFormat");
  }

  public void setRegDateTimeFormat(String regDateTimeFormat) {
    this.setConfigContext("RegDateTimeFormat", regDateTimeFormat);
  }

  public String getBirthDateTimeFormat() {
    return this.getStringValue("BirthDateTimeFormat");
  }

  public void setBirthDateTimeFormat(String birthDateTimeFormat) {
    this.setConfigContext("BirthDateTimeFormat", birthDateTimeFormat);
  }

  public String getTimeFormat() {
    return this.getStringValue("TimeFormat");
  }

  public void setTimeFormat(String timeFormat) {
    this.setConfigContext("TimeFormat", timeFormat);
  }

  public String getCookiePath() {
    return this.getStringValue("CookiePath");
  }

  public void setCookiePath(String cookiePath) {
    this.setConfigContext("CookiePath", cookiePath);
  }

  public String getCookieDomain() {
    return this.getStringValue("CookieDomain");
  }

  public void setCookieDomain(String cookieDomain) {
    this.setConfigContext("CookieDomain", cookieDomain);
  }

  public String getCookieKey() {
    return this.getStringValue("CookieKey");
  }

  public void setCookieKey(String cookieKey) {
    this.setConfigContext("CookieKey", cookieKey);
  }

  public int getUsePass() {
    return this.getIntValue("UsePass", 0);
  }

  public void setUsePass(int usePass) {
    this.setConfigContext("UsePass", String.valueOf(usePass));
  }

  public boolean isUsePass() {
    return (getUsePass() == 1);
  }

  public String getPassUrl() {
    return this.getStringValue("PassUrl");
  }

  public void setPassUrl(String passUrl) {
    this.setConfigContext("PassUrl", passUrl);
  }

  public String getPassRegUrl() {
    return this.getStringValue("PassRegUrl");
  }

  public void setPassRegUrl(String passRegUrl) {
    this.setConfigContext("PassRegUrl", passRegUrl);
  }

  public String getPassChangeUrl() {
    return this.getStringValue("PassChangeUrl");
  }

  public void setPassChangeUrl(String passChangeUrl) {
    this.setConfigContext("PassChangeUrl", passChangeUrl);
  }

  public int getUseScreen() {
    return this.getIntValue("UseScreen", 1);
  }

  public void setUseScreen(int useScreen) {
    this.setConfigContext("UseScreen", String.valueOf(useScreen));
  }

  public String getBestrowScreen() {
    return this.getStringValue("BestrowScreen");
  }

  public void setBestrowScreen(String bestrowScreen) {
    this.setConfigContext("BestrowScreen", bestrowScreen);
  }

  public String getScreenWord() {
    return this.getStringValue("ScreenWord");
  }

  public void setScreenWord(String screenWord) {
    this.setConfigContext("ScreenWord", screenWord);
  }

  public int getUseEmail() {
    return this.getIntValue("UseEmail", 1);
  }

  public void setUseEmail(int useEmail) {
    this.setConfigContext("UseEmail", String.valueOf(useEmail));
  }

  public int getSmtpAuth() {
    return this.getIntValue("SmtpAuth", 1);
  }

  public void setSmtpAuth(int smtpAuth) {
    this.setConfigContext("SmtpAuth", String.valueOf(smtpAuth));
  }

  public String getSenderEmail() {
    return this.getStringValue("SenderEmail");
  }

  public void setSenderEmail(String senderEmail) {
    this.setConfigContext("SenderEmail", senderEmail);
  }

  public String getSmtpServer() {
    return this.getStringValue("SmtpServer");
  }

  public void setSmtpServer(String smtpServer) {
    this.setConfigContext("SmtpServer", smtpServer);
  }

  public int getSmtpPort() {
    return this.getIntValue("SmtpPort", 25);
  }

  public void setSmtpPort(int smtpPort) {
    this.setConfigContext("SmtpPort", String.valueOf(smtpPort));
  }

  public String getSmtpUser() {
    return this.getStringValue("SmtpUser");
  }

  public void setSmtpUser(String smtpUser) {
    this.setConfigContext("SmtpUser", smtpUser);
  }

  public String getSmtpPasswd() {
    return this.getStringValue("SmtpPasswd");
  }

  public void setSmtpPasswd(String smtpPasswd) {
    this.setConfigContext("SmtpPasswd", smtpPasswd);
  }

  public int getOpenUserReg() {
    return this.getIntValue("OpenUserReg", 1);
  }

  public void setOpenUserReg(int openUserReg) {
    this.setConfigContext("OpenUserReg", String.valueOf(openUserReg));
  }

  public int getCheckRegUser() {
    return this.getIntValue("CheckRegUser", 0);
  }

  public boolean isCheckRegUser() {
    return (this.getCheckRegUser() == 1);
  }

  public void setCheckRegUser(int checkRegUser) {
    this.setConfigContext("CheckRegUser", String.valueOf(checkRegUser));
  }

  public int getCheckRegUserEmail() {
    return this.getIntValue("CheckRegUserEmail", 0);
  }

  public void setCheckRegUserEmail(int checkRegUserEmail) {
    this.setConfigContext("CheckRegUserEmail", String.valueOf(checkRegUserEmail));
  }

  public String getCanNotRegUserName() {
    return this.getStringValue("CanNotRegUserName");
  }

  public void setCanNotRegUserName(String canNotRegUserName) {
    this.setConfigContext("CanNotRegUserName", canNotRegUserName);
  }

  public String getCanNotUseNickName() {
    return this.getStringValue("CanNotUseNickName");
  }

  public void setCanNotUseNickName(String canNotUseNickName) {
    this.setConfigContext("CanNotUseNickName", canNotUseNickName);
  }

  public int getUseSign() {
    return this.getIntValue("UseSign", 1);
  }

  public void setUseSign(int useSign) {
    this.setConfigContext("UseSign", String.valueOf(useSign));
  }

  public int getSignMaxLen() {
    return this.getIntValue("SignMaxLen", 300);
  }

  public void setSignMaxLen(int signMaxLen) {
    this.setConfigContext("SignMaxLen", String.valueOf(signMaxLen));
  }

  public int getSignUseHtml() {
    return this.getIntValue("SignUseHtml", 0);
  }

  public void setSignUseHtml(int signUseHtml) {
    this.setConfigContext("SignUseHtml", String.valueOf(signUseHtml));
  }

  public boolean isSignUseHtml() {
    return (this.getSignUseHtml() == 1);
  }

  public int getSignUseUBB() {
    return this.getIntValue("SignUseUBB", 0);
  }

  public void setSignUseUBB(int signUseUBB) {
    this.setConfigContext("SignUseUBB", String.valueOf(signUseUBB));
  }

  public boolean isSignUseUBB() {
    return (this.getSignUseUBB() == 1);
  }

  public int getSignUseSmile() {
    return this.getIntValue("SignUseSmile", 1);
  }

  public void setSignUseSmile(int signUseSmile) {
    this.setConfigContext("SignUseSmile", String.valueOf(signUseSmile));
  }

  public boolean isSignUseSmile() {
    return (this.getSignUseSmile() == 1);
  }

  public int getUseFace() {
    return this.getIntValue("UseFace", 1);
  }

  public void setUseFace(int useFace) {
    this.setConfigContext("UseFace", String.valueOf(useFace));
  }

  public int getFaceHigh() {
    return this.getIntValue("FaceHigh", 100);
  }

  public void setFaceHigh(int faceHigh) {
    this.setConfigContext("FaceHigh", String.valueOf(faceHigh));
  }

  public int getFaceWidth() {
    return this.getIntValue("FaceWidth", 100);
  }

  public void setFaceWidth(int faceWidth) {
    this.setConfigContext("FaceWidth", String.valueOf(faceWidth));
  }

  public int getFaceSize() {
    return this.getIntValue("FaceSize", 50);
  }

  public void setFaceSize(int faceSize) {
    this.setConfigContext("FaceSize", String.valueOf(faceSize));
  }

  public int getUseForbid() {
    return this.getIntValue("UseForbid", 1);
  }

  public void setUseForbid(int useForbid) {
    this.setConfigContext("UseForbid", String.valueOf(useForbid));
  }

  public String getForbidIP() {
    return this.getStringValue("ForbidIP");
  }

  public void setForbidIP(String forbidIP) {
    this.setConfigContext("ForbidIP", forbidIP);
  }

  public String getForbidEmail() {
    return this.getStringValue("ForbidEmail");
  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -