1 16 17 18 package org.apache.webapp.admin.users; 19 20 21 import java.io.IOException ; 22 import java.net.URLDecoder ; 23 import java.util.Iterator ; 24 import java.util.Locale ; 25 import javax.management.Attribute ; 26 import javax.management.MBeanServer ; 27 import javax.management.MBeanServerFactory ; 28 import javax.management.QueryExp ; 29 import javax.management.Query ; 30 import javax.management.ObjectInstance ; 31 import javax.management.ObjectName ; 32 import javax.management.JMException ; 33 import javax.management.MBeanAttributeInfo ; 34 import javax.management.MBeanOperationInfo ; 35 import javax.management.MBeanInfo ; 36 import javax.servlet.ServletException ; 37 import javax.servlet.http.HttpServletRequest ; 38 import javax.servlet.http.HttpServletResponse ; 39 import javax.servlet.http.HttpSession ; 40 import org.apache.struts.action.Action; 41 import org.apache.struts.action.ActionErrors; 42 import org.apache.struts.action.ActionForm; 43 import org.apache.struts.action.ActionForward; 44 import org.apache.struts.action.ActionMapping; 45 import org.apache.struts.util.MessageResources; 46 import org.apache.webapp.admin.ApplicationServlet; 47 import org.apache.webapp.admin.TomcatTreeBuilder; 48 49 59 60 public final class SetUpRoleAction extends Action { 61 62 63 65 66 69 private MBeanServer mserver = null; 70 71 72 74 75 90 public ActionForward execute(ActionMapping mapping, 91 ActionForm form, 92 HttpServletRequest request, 93 HttpServletResponse response) 94 throws IOException , ServletException { 95 96 if (mserver == null) { 98 mserver = ((ApplicationServlet) getServlet()).getServer(); 99 } 100 MessageResources resources = getResources(request); 101 HttpSession session = request.getSession(); 102 Locale locale = getLocale(request); 103 String databaseName = 104 URLDecoder.decode(request.getParameter("databaseName"),TomcatTreeBuilder.URL_ENCODING); 105 106 String objectName = request.getParameter("objectName"); 108 RoleForm roleForm = new RoleForm(); 109 if (objectName == null) { 110 roleForm.setNodeLabel 111 (resources.getMessage(locale, "users.role.newRole")); 112 roleForm.setObjectName(null); 113 } else { 114 roleForm.setNodeLabel 115 (resources.getMessage(locale, "users.role.oldRole")); 116 roleForm.setObjectName(objectName); 117 String attribute = null; 118 try { 119 ObjectName oname = new ObjectName (objectName); 120 attribute = "rolename"; 121 roleForm.setRolename 122 ((String ) mserver.getAttribute(oname, attribute)); 123 attribute = "description"; 124 roleForm.setDescription 125 ((String ) mserver.getAttribute(oname, attribute)); 126 } catch (Exception e) { 127 getServlet().log 128 (resources.getMessage(locale, 129 "users.error.attribute.get", attribute), e); 130 response.sendError 131 (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 132 resources.getMessage 133 (locale, "users.error.attribute.get", attribute)); 134 return (null); 135 } 136 } 137 roleForm.setDatabaseName(databaseName); 138 139 saveToken(request); 141 request.setAttribute("roleForm", roleForm); 142 return (mapping.findForward("Role")); 143 144 } 145 146 } 147 | Popular Tags |