1 16 17 package org.apache.webapp.admin.users; 18 19 import java.net.URLDecoder ; 20 import javax.management.MBeanServer ; 21 import javax.servlet.http.HttpServletRequest ; 22 import org.apache.struts.action.ActionError; 23 import org.apache.struts.action.ActionErrors; 24 import org.apache.struts.action.ActionForm; 25 import org.apache.struts.action.ActionMapping; 26 import org.apache.webapp.admin.ApplicationServlet; 27 import org.apache.webapp.admin.TomcatTreeBuilder; 28 29 36 37 public final class GroupForm extends BaseForm { 38 39 40 42 45 private MBeanServer mserver = null; 46 47 48 50 51 54 private String description = null; 55 56 public String getDescription() { 57 return (this.description); 58 } 59 60 public void setDescription(String description) { 61 this.description = description; 62 } 63 64 65 68 private String groupname = null; 69 70 public String getGroupname() { 71 return (this.groupname); 72 } 73 74 public void setGroupname(String groupname) { 75 this.groupname = groupname; 76 } 77 78 79 82 private String roles[] = new String [0]; 83 84 public String [] getRoles() { 85 return (this.roles); 86 } 87 88 public void setRoles(String roles[]) { 89 if (roles == null) { 90 roles = new String [0]; 91 } 92 this.roles = roles; 93 } 94 95 96 98 99 105 public void reset(ActionMapping mapping, HttpServletRequest request) { 106 107 super.reset(mapping, request); 108 description = null; 109 groupname = null; 110 roles = new String [0]; 111 112 } 113 114 115 125 public ActionErrors validate(ActionMapping mapping, 126 HttpServletRequest request) { 127 128 try { 129 if (mserver == null) { 131 mserver = ((ApplicationServlet) getServlet()).getServer(); 132 } 133 134 String databaseName = 136 URLDecoder.decode(request.getParameter("databaseName"),TomcatTreeBuilder.URL_ENCODING); 137 request.setAttribute("rolesForm", 138 UserUtils.getRolesForm(mserver, 139 databaseName)); 140 } catch (Exception e) { 141 } 143 144 ActionErrors errors = new ActionErrors(); 145 146 String submit = request.getParameter("submit"); 147 149 if ((groupname == null) || (groupname.length() < 1)) { 151 errors.add("groupname", 152 new ActionError("users.error.groupname.required")); 153 } 154 155 if ((groupname != null) && (groupname.indexOf('"') >= 0)) { 157 errors.add("groupname", 158 new ActionError("users.error.quotes")); 159 } 160 161 if ((description != null) && (description.indexOf('"') > 0)) { 163 errors.add("description", 164 new ActionError("users.error.quotes")); 165 } 166 167 169 return (errors); 170 171 } 172 173 174 } 175 | Popular Tags |