【Java开源代码栏目提醒】:网学会员--在 Java开源代码编辑为广大网友搜集整理了:AuthManageAction.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);
}
}
上一篇:
AuthImg.java
下一篇:
心力衰竭的中医证素及常见证型