1 16 17 18 package org.apache.webapp.admin.resources; 19 20 21 import java.io.IOException ; 22 import java.util.ArrayList ; 23 import java.util.Iterator ; 24 import java.util.Locale ; 25 import javax.servlet.ServletException ; 26 import javax.servlet.http.HttpServletRequest ; 27 import javax.servlet.http.HttpServletResponse ; 28 import javax.servlet.http.HttpSession ; 29 import org.apache.struts.action.Action; 30 import org.apache.struts.action.ActionErrors; 31 import org.apache.struts.action.ActionForm; 32 import org.apache.struts.action.ActionForward; 33 import org.apache.struts.action.ActionMapping; 34 import javax.management.Attribute ; 35 import javax.management.MBeanServer ; 36 import javax.management.MBeanServerFactory ; 37 import javax.management.QueryExp ; 38 import javax.management.Query ; 39 import javax.management.ObjectInstance ; 40 import javax.management.ObjectName ; 41 import javax.management.JMException ; 42 import javax.management.MBeanAttributeInfo ; 43 import javax.management.MBeanOperationInfo ; 44 import javax.management.MBeanInfo ; 45 import org.apache.struts.util.MessageResources; 46 import org.apache.webapp.admin.ApplicationServlet; 47 48 49 57 58 public final class DeleteUserDatabasesAction extends Action { 59 60 61 63 64 67 private MBeanServer mserver = null; 68 69 70 72 73 88 public ActionForward execute(ActionMapping mapping, 89 ActionForm form, 90 HttpServletRequest request, 91 HttpServletResponse response) 92 throws IOException , ServletException { 93 94 if (mserver == null) { 96 mserver = ((ApplicationServlet) getServlet()).getServer(); 97 } 98 MessageResources resources = getResources(request); 99 HttpSession session = request.getSession(); 100 Locale locale = getLocale(request); 101 102 if (isCancelled(request)) { 104 return (mapping.findForward("List UserDatabases Setup")); 105 } 106 107 if (!isTokenValid(request)) { 109 response.sendError 110 (HttpServletResponse.SC_BAD_REQUEST, 111 resources.getMessage(locale, "users.error.token")); 112 return (null); 113 } 114 115 UserDatabasesForm userDatabasesForm = (UserDatabasesForm) form; 117 String userDatabases[] = userDatabasesForm.getUserDatabases(); 118 if (userDatabases == null) { 119 userDatabases = new String [0]; 120 } 121 122 try { 124 125 String signature[] = new String [1]; 126 signature[0] = "java.lang.String"; 127 Object params[] = new String [1]; 128 129 for (int i = 0; i < userDatabases.length; i++) { 130 ObjectName oname = new ObjectName (userDatabases[i]); 131 ObjectName dname = new ObjectName (oname.getDomain() + 133 ResourceUtils.NAMINGRESOURCES_TYPE + 134 ResourceUtils.GLOBAL_TYPE); 135 params[0] = oname.getKeyProperty("name"); 136 mserver.invoke(dname, "removeResource", 137 params, signature); 138 } 139 140 } catch (Throwable t) { 141 142 getServlet().log 143 (resources.getMessage(locale, "users.error.invoke", 144 "removeResource"), t); 145 response.sendError 146 (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 147 resources.getMessage(locale, "users.error.invoke", 148 "removeResource")); 149 return (null); 150 151 } 152 153 return (mapping.findForward("UserDatabases List Setup")); 155 156 } 157 158 } 159 | Popular Tags |