1 25 26 package org.objectweb.jonas.webapp.jonasadmin.logging; 27 28 import java.util.List ; 29 30 import javax.management.ObjectName ; 31 import javax.servlet.http.HttpServletRequest ; 32 33 import org.apache.struts.action.ActionMessage; 34 import org.apache.struts.action.ActionErrors; 35 import org.apache.struts.action.ActionMapping; 36 import org.objectweb.jonas.jmx.CatalinaObjectName; 37 import org.objectweb.jonas.jmx.JonasManagementRepr; 38 import org.objectweb.jonas.webapp.jonasadmin.Jlists; 39 40 44 45 public final class CatalinaAccessLogValveForm extends CatalinaValveForm { 46 47 49 52 private String directory = null; 53 56 private String pattern = null; 57 60 private String prefix = null; 61 64 private String suffix = null; 65 68 private boolean rotatable = true; 69 73 private boolean resolveHosts = false; 74 77 private List booleanValues = Jlists.getBooleanValues(); 78 81 private String catalinaDomainName = null; 82 83 85 public void reset(ActionMapping mapping, HttpServletRequest request) { 86 super.reset(mapping, request); 87 directory = "logs"; 88 prefix = "access_log."; 89 suffix = ".txt"; 90 pattern = "%h %l %u %t \"%r\" %s %b"; 91 resolveHosts = false; 92 rotatable = true; 93 String [] containerTypes = {"Engine", "Host"}; 94 setContainerTypes(containerTypes); 95 } 96 97 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 98 ActionErrors oErrors = new ActionErrors(); 99 if ((prefix == null) || (prefix.length() < 1)) { 101 oErrors.add("pattern", new ActionMessage("error.logger.catalina.access.prefix.required")); 102 } 103 if ((suffix == null) || (suffix.length() < 1)) { 105 suffix = ""; 106 } 107 if ((pattern == null) || (pattern.length() < 1)) { 109 oErrors.add("pattern", new ActionMessage("error.logger.catalina.access.pattern.required")); 110 } 111 if (getAction().equals("edit")) { 113 return oErrors; 114 } 115 if (getContainerType().equals("Engine")) { 116 ObjectName onEngine = CatalinaObjectName.catalinaEngine(catalinaDomainName); 118 ObjectName [] valveOns = (ObjectName []) JonasManagementRepr.getAttribute(onEngine, "valveObjectNames"); 119 for (int i = 0; i < valveOns.length; i++) { 120 ObjectName valveOn = valveOns[i]; 121 if (valveOn != null) { String valveName = valveOn.getKeyProperty("name"); 123 if (valveName.equals("AccessLogValve")) { 124 oErrors.add("", new ActionMessage("error.logger.catalina.access.log.engine.alreadypresent")); 126 break; 127 } 128 } 129 } 130 } 131 if (getContainerType().equals("Host")) { 132 ObjectName onHost = CatalinaObjectName.catalinaHost(catalinaDomainName, getContainerName()); 134 if (!JonasManagementRepr.isRegistered(onHost)) { 135 oErrors.add("", new ActionMessage("error.logger.catalina.access.log.nohost")); 136 } else { 137 ObjectName [] valveOns = (ObjectName []) JonasManagementRepr.getAttribute(onHost, "valveObjectNames"); 138 for (int i = 0; i < valveOns.length; i++) { 139 ObjectName valveOn = valveOns[i]; 140 if (valveOn != null) { String valveName = valveOn.getKeyProperty("name"); 142 if (valveName.equals("AccessLogValve")) { 143 oErrors.add("", new ActionMessage("error.logger.catalina.access.log.host.alreadypresent")); 145 break; 146 } 147 } 148 } 149 } 150 } 151 return oErrors; 152 } 153 154 156 public List getBooleanValues() { 157 return booleanValues; 158 } 159 160 public void setBooleanValues(List booleanValues) { 161 this.booleanValues = booleanValues; 162 } 163 164 public String getDirectory() { 165 return this.directory; 166 } 167 168 public void setDirectory(String directory) { 169 this.directory = directory; 170 } 171 172 public String getPattern() { 173 return this.pattern; 174 } 175 176 public void setPattern(String pattern) { 177 this.pattern = pattern; 178 } 179 180 public String getPrefix() { 181 return this.prefix; 182 } 183 184 public void setPrefix(String prefix) { 185 this.prefix = prefix; 186 } 187 188 public String getSuffix() { 189 return this.suffix; 190 } 191 192 public void setSuffix(String suffix) { 193 this.suffix = suffix; 194 } 195 196 public boolean isResolveHosts() { 197 return this.resolveHosts; 198 } 199 200 public void setResolveHosts(boolean resolveHosts) { 201 this.resolveHosts = resolveHosts; 202 } 203 204 public boolean isRotatable() { 205 return this.rotatable; 206 } 207 208 public void setRotatable(boolean rotatable) { 209 this.rotatable = rotatable; 210 } 211 212 215 public String getCatalinaDomainName() { 216 return catalinaDomainName; 217 } 218 219 220 223 public void setCatalinaDomainName(String catalinaDomainName) { 224 this.catalinaDomainName = catalinaDomainName; 225 } 226 227 } 228 | Popular Tags |