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

📄 authmanageaction.java

📁 《JSP网站开发典型模块与实例精讲》一书光盘源码
💻 JAVA
字号:
package org.appfuse.webapp.action;

import java.util.List;

import org.apache.struts.actions.DispatchAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.appfuse.service.StaffManager;
import org.appfuse.model.Staff;

import org.appfuse.util.ServiceFactory;
import org.appfuse.dao.hibernate.StaffDAOHibernate;
import java.util.ArrayList;
import org.appfuse.service.RoleManager;
import org.appfuse.model.Role;
import org.appfuse.model.*;
import org.appfuse.model.*;
import org.appfuse.service.StaffRoleManager;

import org.appfuse.webapp.form.*;
import org.appfuse.service.*;
import org.appfuse.service.ModuleManager;
import org.appfuse.webapp.form.*;

public class AuthManageAction
    extends BaseAction {

    private static Log log = LogFactory.getLog(AuthManageAction.class);

    public ActionForward createauth(ActionMapping mapping, ActionForm form,
                                        HttpServletRequest request,
                                        HttpServletResponse response) throws
        Exception {
        if (log.isDebugEnabled()) {
            log.debug("entering 'createauth' method...");
        }
        AuthManager authManager = null;
        Auth auth = new Auth();
        AuthForm authForm = (AuthForm) form;
        copyProperties(auth, authForm);
        try {
            authManager = (AuthManager) getBean("authManager");
            authManager.saveAuth(auth);
        }
        catch (Exception es) {
            log.error("in createauth: ", es);
        }
        return list(mapping, form, request, response);
    }

    public ActionForward removeauth(ActionMapping mapping, ActionForm form,
                                        HttpServletRequest request,
                                        HttpServletResponse response) throws
        Exception {
        if (log.isDebugEnabled()) {
            log.debug("entering 'removeauth' method...");
        }
        AuthManager authManager = null;
        Auth auth = new Auth();
        AuthForm authForm = (AuthForm) form;
        copyProperties(auth, authForm);
        try {
            authManager = (AuthManager) getBean("authManager");
            authManager.removeAuth(auth);
        }
        catch (Exception es) {
            log.error("in createauth: ", es);
        }
        return list(mapping, form, request, response);
    }
    public ActionForward list(ActionMapping mapping, ActionForm form,
                                HttpServletRequest request,
                                HttpServletResponse response) throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("entering 'list' method...");
        }
        FunctionManager functionMgr = null;
        ModuleManager moduleMgr = null;
        AuthForm authForm = (AuthForm)form;
        Module module = null;
        List allFunctions = null;
        List auths = null;
        List list = null;
        try {
            moduleMgr = (ModuleManager) getBean("moduleManager");
            module = moduleMgr.getModule(authForm.getModuleid());
            functionMgr = (FunctionManager) getBean("functionManager");
            allFunctions = functionMgr.getFunctions(new Function());
            auths = moduleMgr.getFunctions(authForm.getModuleid());
            list = new ArrayList(allFunctions.size());
            for (int i = 0; i < allFunctions.size(); i++) {
                Function a = (Function) allFunctions.get(i);
                FunctionEx b = new FunctionEx();
                b.setFunction(a);
                list.add(b);
            }
            for (int i = 0; i < auths.size(); i++) {
                Function a = (Function) auths.get(i);
                for (int j = 0; j < list.size(); j++) {
                    FunctionEx b = (FunctionEx) list.get(j);
                    if (a.getFunctionid() == b.getFunctionid()) {
                        b.setIsExist(true);
                    }
                }
            }
        }
        catch (Exception es) {
            log.error("in auth: ", es);
        }
        request.setAttribute("functions", list);
        request.setAttribute("module", module);
        log.debug("out of 'list' method...");
        return mapping.findForward("list");
    }


    public ActionForward unspecified(ActionMapping mapping, ActionForm form,
                                     HttpServletRequest request,
                                     HttpServletResponse response) throws
        Exception {
        return list(mapping, form, request, response);
    }
}

⌨️ 快捷键说明

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