📄 sysconfig.java
字号:
/**************************************************************** * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * * * Copyright 2008 Jun Li(SiChuan University, the School of * * Software Engineering). All rights reserved. * * * * Licensed to the JMS under one or more contributor license * * agreements. See the LICENCE file distributed with this * * work for additional information regarding copyright * * ownership. The JMS licenses this file you may not use this * * file except in compliance with the License. * * * * Unless required by applicable law or agreed to in writing, * * software distributed under the License is distributed on an * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * * KIND, either express or implied. See the License for the * * specific language governing permissions and limitations * * under the License. * ****************************************************************/package org.jpxx.mail.Config;import org.jpxx.mail.Domain.DomainHandler;import java.io.File;import org.jpxx.mail.Constants;/** * This clsss is to manage JMS config. * * @author Jun Li * @version $Revision: 0.0.3 $, $Date: 2008/05/20 $ * @since Version 0.0.1 * */public class SysConfig extends Config { /** * JMS supports one or more SMTP server in one server with diferent ports. * @return the array of smtp server ports */ public int[] getSmtpPort() { String smtpPort = config.getValue("SmtpPort"); if (smtpPort.equals("")) { config.add("SmtpPort", "25"); return getDefaultSmtpPort(); } else { return getDefaultPort(smtpPort); } } /** * JMS supports one or more POP3 server in one server with diferent ports. * @return the array of pop3 server ports */ public int[] getPop3Port() { String pop3Port = config.getValue("Pop3Port"); if (pop3Port.equals("")) { config.add("Pop3Port", "110"); return getDefaultPop3Port(); } else { return getDefaultPort(pop3Port); } } /** * Allow anonymous user to send mail by this server? * * @return anonymous user to send mail by this server return true, * otherwise returnt false. */ public boolean isAllowAnonymousUser() { if (config.getValue("IsAllowAnonymousUser").equals("")) { config.add("IsAllowAnonymousUser", "false"); return false; } else { try { return Boolean.getBoolean(config.getValue("IsAllowAnonymousUser")); } catch (Exception e) { return false; } } } /** * Get current db type * * @return current db type */ public int getDBType() { if (config.getValue("DBType").equals("")) { config.add("DBType", "1"); return 1; } else { return Integer.parseInt(config.getValue("DBType")); } } /** * Get default mailbox size (K) * @return default mailbox size */ public long getDefaltMailBoxSize() { if (config.getValue("DefaltMailBoxSize").equals("")) { config.add("DefaltMailBoxSize", String.valueOf( Constants.DEFAUL_MAILBOX_SIZE)); return 1; } else { return Long.parseLong(config.getValue("DefaltMailBoxSize")); } } /** * * @return User's home directory */ public String getHomeDir(String userName, String domain) { String path = Constants.HOME_DIR + domain + File.separator + userName + File.separator + "MailBox" + File.separator; return path; } /** * Get Server Temp Directory * @return Server Temp Directory */ public String getTempDir() { return Constants.TEMP_DIR; } /** * Get smpt server port * @return smpt server port */ private int[] getDefaultSmtpPort() { return getDefaultPort(Constants.DEFAULT_SMTP_PORT); } /** * Get pop3 server port * @return pop3 server port */ private int[] getDefaultPop3Port() { return getDefaultPort(Constants.DEFAULT_POP3_PORT); } /** * Convert a int to a array. * @param port server port * @return a array of port */ private int[] getDefaultPort(int port) { int _port[] = new int[1]; _port[0] = port; return _port; } /** * Get a email address to send mail back when delivery error * @return a email address */ public String getSystemReplyMail() { DomainHandler dc = new DomainHandler(); String domain = dc.getDefaultDomain(); if (domain == null) { return "MAIL_SEND_ERROR@jpxx.org"; } if (config.getValue("SystemReplyMail").equals("")) { config.add("SystemReplyMail", "MAIL_SEND_ERROR@" + domain); return "MAIL_SEND_ERROR@" + domain; } else { return config.getValue("SystemReplyMail"); } } /** * Get the Console Server port. If not exists, add the default port--8707 * and return. * @since JMS 0.0.3 #2008-10-25# * @return Console Server port. */ public int getConsolePort() { if (config.getValue("ConsolePort").equals("")) { config.add("ConsolePort", "8707"); return 8707; } else { return Integer.parseInt(config.getValue("ConsolePort")); } } /** * Get port from string * @param port * @return an array of ports */ private int[] getDefaultPort(String port) { if (port.lastIndexOf(",") == -1) { return getDefaultPort(Integer.parseInt(port)); } else { String p[] = port.split(","); int _p[] = new int[p.length]; for (int i = 0; i < p.length; i++) { try { _p[i] = Integer.parseInt(p[i]); } catch (Exception e) { throw new UnknownError(_p[i] + " is not a number!"); } } return _p; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -