1 16 17 18 package org.apache.webapp.admin.context; 19 20 import javax.servlet.http.HttpServletRequest ; 21 import org.apache.struts.action.ActionError; 22 import org.apache.struts.action.ActionErrors; 23 import org.apache.struts.action.ActionForm; 24 import org.apache.struts.action.ActionMapping; 25 import java.util.List ; 26 27 33 34 public final class ContextForm extends ActionForm { 35 36 38 41 private String adminAction = "Edit"; 42 43 46 private String objectName = null; 47 48 51 private String parentObjectName = null; 52 53 56 private String loaderObjectName = null; 57 58 61 private String managerObjectName = null; 62 63 66 private String nodeLabel = null; 67 68 71 private String cookies = "false"; 72 73 76 private String crossContext = "false"; 77 78 81 private String docBase = null; 82 83 86 private String override = "false"; 87 88 91 private String privileged = "false"; 92 93 96 private String path = null; 97 98 101 private String reloadable = "false"; 102 103 106 private String swallowOutput = "false"; 107 108 111 private String useNaming = "false"; 112 113 116 private String workDir = null; 117 118 121 private String ldrCheckInterval = "15"; 122 123 126 private String ldrReloadable = "false"; 127 128 131 private String mgrCheckInterval = "60"; 132 133 134 137 private String mgrSessionIDInit = ""; 138 139 142 private String mgrMaxSessions = "0"; 143 144 147 private String antiResourceLocking = "false"; 148 149 152 private String antiJarLocking = "false"; 153 154 157 private List booleanVals = null; 158 159 161 164 public String getAdminAction() { 165 166 return this.adminAction; 167 168 } 169 170 171 174 public void setAdminAction(String adminAction) { 175 176 this.adminAction = adminAction; 177 178 } 179 180 183 public String getObjectName() { 184 185 return this.objectName; 186 187 } 188 189 192 public void setObjectName(String objectName) { 193 194 this.objectName = objectName; 195 196 } 197 198 201 public String getParentObjectName() { 202 203 return this.parentObjectName; 204 205 } 206 207 210 public void setParentObjectName(String parentObjectName) { 211 212 this.parentObjectName = parentObjectName; 213 214 } 215 216 219 public String getLoaderObjectName() { 220 221 return this.loaderObjectName; 222 223 } 224 225 228 public void setLoaderObjectName(String loaderObjectName) { 229 230 this.loaderObjectName = loaderObjectName; 231 232 } 233 234 237 public String getManagerObjectName() { 238 239 return this.managerObjectName; 240 241 } 242 243 246 public void setManagerObjectName(String managerObjectName) { 247 248 this.managerObjectName = managerObjectName; 249 250 } 251 252 255 public String getNodeLabel() { 256 257 return this.nodeLabel; 258 259 } 260 261 264 public void setNodeLabel(String nodeLabel) { 265 266 this.nodeLabel = nodeLabel; 267 268 } 269 270 271 274 public List getBooleanVals() { 275 276 return this.booleanVals; 277 278 } 279 280 283 public void setBooleanVals(List booleanVals) { 284 285 this.booleanVals = booleanVals; 286 287 } 288 289 290 293 294 public String getCookies() { 295 296 return this.cookies; 297 298 } 299 300 303 public void setCookies(String cookies) { 304 305 this.cookies = cookies; 306 307 } 308 309 312 313 public String getCrossContext() { 314 315 return this.crossContext; 316 317 } 318 319 322 public void setCrossContext(String crossContext) { 323 324 this.crossContext = crossContext; 325 326 } 327 328 329 332 333 public String getDocBase() { 334 335 return this.docBase; 336 337 } 338 339 342 public void setDocBase(String docBase) { 343 344 this.docBase = docBase; 345 346 } 347 348 349 352 353 public String getOverride() { 354 355 return this.override; 356 357 } 358 359 362 public void setOverride(String override) { 363 364 this.override = override; 365 366 } 367 368 369 372 373 public String getPrivileged() { 374 375 return this.privileged; 376 377 } 378 379 382 public void setPrivileged(String privileged) { 383 384 this.privileged = privileged; 385 386 } 387 388 389 392 393 public String getPath() { 394 395 return this.path; 396 397 } 398 399 402 public void setPath(String path) { 403 404 this.path = path; 405 406 } 407 408 409 412 413 public String getReloadable() { 414 415 return this.reloadable; 416 417 } 418 419 422 public void setReloadable(String reloadable) { 423 424 this.reloadable = reloadable; 425 426 } 427 428 431 432 public String getSwallowOutput() { 433 434 return this.swallowOutput; 435 436 } 437 438 441 public void setSwallowOutput(String swallowOutput) { 442 443 this.swallowOutput = swallowOutput; 444 445 } 446 447 450 451 public String getUseNaming() { 452 453 return this.useNaming; 454 455 } 456 457 460 public void setUseNaming(String useNaming) { 461 462 this.useNaming = useNaming; 463 464 } 465 466 469 public String getWorkDir() { 470 471 return this.workDir; 472 473 } 474 475 478 public void setWorkDir(String workDir) { 479 480 this.workDir = workDir; 481 482 } 483 484 485 488 public String getLdrCheckInterval() { 489 490 return this.ldrCheckInterval; 491 492 } 493 494 497 public void setLdrCheckInterval(String ldrCheckInterval) { 498 499 this.ldrCheckInterval = ldrCheckInterval; 500 501 } 502 503 504 507 public String getLdrReloadable() { 508 509 return this.ldrReloadable; 510 511 } 512 513 516 public void setLdrReloadable(String ldrReloadable) { 517 518 this.ldrReloadable = ldrReloadable; 519 520 } 521 522 525 public String getMgrCheckInterval() { 526 527 return this.mgrCheckInterval; 528 529 } 530 531 534 public void setMgrCheckInterval(String mgrCheckInterval) { 535 536 this.mgrCheckInterval = mgrCheckInterval; 537 538 } 539 540 543 public String getMgrSessionIDInit() { 544 545 return this.mgrSessionIDInit; 546 547 } 548 549 552 public void setMgrSessionIDInit(String mgrSessionIDInit) { 553 554 this.mgrSessionIDInit = mgrSessionIDInit; 555 556 } 557 558 561 562 public String getMgrMaxSessions() { 563 564 return this.mgrMaxSessions; 565 566 } 567 568 571 public void setMgrMaxSessions(String mgrMaxSessions) { 572 573 this.mgrMaxSessions = mgrMaxSessions; 574 575 } 576 577 580 public String getAntiResourceLocking() { 581 return antiResourceLocking; 582 } 583 584 587 public void setAntiResourceLocking(String arl) { 588 antiResourceLocking = arl; 589 } 590 591 592 595 public String getAntiJarLocking() { 596 return antiJarLocking; 597 } 598 599 602 public void setAntiJarLocking(String ajl) { 603 antiJarLocking = ajl; 604 } 605 606 608 614 public void reset(ActionMapping mapping, HttpServletRequest request) { 615 616 this.objectName = null; 617 this.parentObjectName = null; 618 this.loaderObjectName = null; 619 this.managerObjectName = null; 620 621 this.cookies = "false"; 623 this.crossContext = "false"; 624 this.docBase = null; 625 this.override= "false"; 626 this.path = null; 627 this.reloadable = "false"; 628 this.swallowOutput = "false"; 629 this.antiResourceLocking = "false"; 630 this.antiJarLocking = "false"; 631 632 this.ldrCheckInterval = "15"; 634 this.ldrReloadable = "true"; 635 636 this.mgrCheckInterval = "60"; 638 this.mgrSessionIDInit = "0"; 639 this.mgrMaxSessions = "-1"; 640 } 641 642 645 public String toString() { 646 647 StringBuffer sb = new StringBuffer ("ContextForm[adminAction="); 648 sb.append(adminAction); 649 sb.append(",docBase="); 650 sb.append(docBase); 651 sb.append(",path="); 652 sb.append(path); 653 sb.append(",cookies="); 654 sb.append(cookies); 655 sb.append(",crossContext="); 656 sb.append(crossContext); 657 sb.append(",override="); 658 sb.append(override); 659 sb.append(",reloadable="); 660 sb.append(reloadable); 661 sb.append(",swallowOutput="); 662 sb.append(swallowOutput); 663 664 sb.append(",ldrCheckInterval="); 666 sb.append(ldrCheckInterval); 667 sb.append(",ldrReloadable="); 668 sb.append(ldrReloadable); 669 sb.append(",mgrCheckInterval="); 671 sb.append(mgrCheckInterval); 672 sb.append(",mgrSessionIDInit="); 673 sb.append(mgrSessionIDInit); 674 sb.append(",mgrMaxSessions="); 675 sb.append(mgrMaxSessions); 676 sb.append("',objectName='"); 678 sb.append(objectName); 679 sb.append("',parentObjectName="); 680 sb.append(parentObjectName); 681 sb.append("',loaderObjectName="); 682 sb.append(loaderObjectName); 683 sb.append("',managerObjectName="); 684 sb.append(managerObjectName); 685 sb.append("]"); 686 return (sb.toString()); 687 688 } 689 699 700 private ActionErrors errors; 701 702 public ActionErrors validate(ActionMapping mapping, 703 HttpServletRequest request) { 704 705 errors = new ActionErrors(); 706 707 String submit = request.getParameter("submit"); 708 709 712 if ((docBase == null) || (docBase.length() < 1)) { 714 errors.add("docBase", new ActionError("error.docBase.required")); 715 } 716 717 if ("Create".equalsIgnoreCase(adminAction) && !path.startsWith("/")) { 720 errors.add("path", new ActionError("error.path.prefix")); 721 } 722 723 727 numberCheck("ldrCheckInterval", ldrCheckInterval , true, 0, 10000); 730 731 numberCheck("mgrCheckInterval", mgrCheckInterval, true, 0, 10000); 733 numberCheck("mgrMaxSessions", mgrMaxSessions, false, -1, 100); 734 735 740 return errors; 741 } 742 743 755 756 private void numberCheck(String field, String numText, boolean rangeCheck, 757 int min, int max) { 758 759 if ((numText == null) || (numText.length() < 1)) { 761 errors.add(field, new ActionError("error."+field+".required")); 762 } else { 763 764 try { 766 int num = Integer.parseInt(numText); 767 if (rangeCheck) { 769 if ((num < min) || (num > max )) 770 errors.add( field, 771 new ActionError("error."+ field +".range")); 772 } 773 } catch (NumberFormatException e) { 774 errors.add(field, 775 new ActionError("error."+ field + ".format")); 776 } 777 } 778 } 779 780 } 781 | Popular Tags |