📄 configaction.java
字号:
package net.meybo.mail.action;
import java.util.List;
import net.meybo.mail.ActiveUser;
import net.meybo.mail.Config;
import net.meybo.mail.MailServer;
import net.meybo.mail.client.UserManage;
import com.easyjf.util.CommUtil;
import com.easyjf.web.ActionContext;
import com.easyjf.web.IWebAction;
import com.easyjf.web.Module;
import com.easyjf.web.Page;
import com.easyjf.web.WebForm;
/**
* 地址管理处理Action
* <p>Title: </p>
* <p>Description: 基于EasyJWeb框架,实现IWebAction接口,处理配置文件信息</p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: 脉博软件</p>
* @author 阚吉彬
* @version 1.0
*/
public class ConfigAction implements IWebAction {
public Page execute(WebForm form, Module module) throws Exception {
String method=CommUtil.null2String(form.get("easyJWebCommand"));
ActiveUser user=(ActiveUser)ActionContext.getContext().getRequest().getSession().getAttribute("user");
if(user==null)
{
form.addResult("msg","您没有登录或者是超时,请重登录!");
return new Page("noLoin","/login.ejf","html");
}
Page forward=null;
if(method.equals("")||"setting".equals(method))
{
forward=doSetting(form,module,user);
}
else if("personal".equals(method))//处理用户登录
{
forward= doPersonal(form,module);
}
else if("refuse".equals(method))
{
forward=doRefuse(form,module,user);
}
else if("filter".equals(method))
{
forward=doFilter(form,module,user);
}
else if("password".equals(method))
{
forward=doPassword(form,module,user);
}
else if("exit".equals(method))
{
ActionContext.getContext().getSession().removeAttribute("user");
forward=new Page("goto","/exit.htm","html");
}
return forward;
}
private Page doSetting(WebForm form, Module module,ActiveUser user)
{
MailServer server=Config.findServerByDomain(user.getServerDomain());
String subCommand=CommUtil.null2String(form.get("subCommand"));
String forwardTo=CommUtil.null2String(form.get("autoForwardTo"));
String autoForward=CommUtil.null2String(form.get("autoForward"));
System.out.println(forwardTo+":"+autoForward+":"+subCommand);
if("change".equals(subCommand))
{
if(((!autoForward.equals("")) && (!forwardTo.equals(""))) || autoForward.equals("")){
if(autoForward.equals(""))forwardTo="null";
if(UserManage.modifyUserInfo(user,"forward",forwardTo,server.getHostIp(),server.getManagePort())==0)
form.addResult("msg","自动转发设置成功!");
else form.addResult("msg","自动转发设置失败!");
}
}
String forward=UserManage.getUserInfo(user,"forward",server.getHostIp(),server.getManagePort());
if(forward!=null && (!forward.equals("")))
{
form.addResult("autoForward","true");
form.addResult("autoForwardTo",forward);
}
return module.findPage("setting");
}
private Page doPersonal(WebForm form, Module module)
{
List list=Config.getDomains();
form.addResult("list",list);
return module.findPage("personal");
}
private Page doRefuse(WebForm form, Module module,ActiveUser user)
{
List list=Config.getDomains();
form.addResult("list",list);
return module.findPage("refuse");
}
private Page doFilter(WebForm form, Module module,ActiveUser user)
{
List list=Config.getDomains();
form.addResult("list",list);
return module.findPage("filter");
}
private Page doPassword(WebForm form, Module module,ActiveUser user)
{
String subCommand=CommUtil.null2String(form.get("subCommand"));
if("change".equals(subCommand))
{
String oldPassword=CommUtil.null2String(form.get("oldPassword"));
String password=CommUtil.null2String(form.get("password"));
String password1=CommUtil.null2String(form.get("password1"));
if(oldPassword.equals(user.getPassword()))
{
if(password.equals(password1))
{
MailServer server=Config.findServerByDomain(user.getServerDomain());
if(UserManage.modifyPassword(user,password,server.getHostIp(),server.getManagePort())==0)
{
user.setPassword(password);
form.addResult("msg","密码修改成功,请注意保存密码!");
}
else
form.addResult("msg","密码修改失败,可能是权限不够!");
}
else
{
form.addResult("msg","两次输入的密码不正确!");
}
}
else
form.addResult("msg","旧密码不正确!");
}
return module.findPage("password");
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -