1 23 24 29 30 package com.sun.enterprise.tools.upgrade.miscconfig; 31 32 import java.io.*; 33 import com.sun.enterprise.tools.upgrade.common.*; 34 import com.sun.enterprise.util.i18n.StringManager; 35 import com.sun.enterprise.tools.upgrade.logging.*; 36 import java.util.logging.*; 37 import java.util.*; 38 import java.lang.reflect.*; 39 import javax.xml.parsers.DocumentBuilder ; 40 import javax.xml.parsers.DocumentBuilderFactory ; 41 import javax.xml.parsers.FactoryConfigurationError ; 42 import javax.xml.parsers.ParserConfigurationException ; 43 import org.xml.sax.SAXException ; 44 import org.xml.sax.SAXParseException ; 45 import org.w3c.dom.Document ; 46 import org.w3c.dom.DOMException ; 47 import org.w3c.dom.Element ; 48 import org.w3c.dom.Node ; 49 import org.w3c.dom.NodeList ; 50 import org.w3c.dom.NamedNodeMap ; 51 import javax.xml.transform.Transformer ; 52 import javax.xml.transform.TransformerFactory ; 53 import javax.xml.transform.TransformerException ; 54 import javax.xml.transform.TransformerConfigurationException ; 55 import javax.xml.transform.dom.DOMSource ; 56 import javax.xml.transform.stream.StreamResult ; 57 import javax.xml.transform.OutputKeys ; 58 59 63 public class InitConfTransfer { 64 private CommonInfoModel commonInfo; 65 private StringManager stringManager = StringManager.getManager("com.sun.enterprise.tools.upgrade.miscconfig"); 66 private Logger logger = CommonInfoModel.getDefaultLogger(); 67 68 69 public InitConfTransfer(CommonInfoModel cim) { 70 commonInfo = cim; 71 } 72 73 public void transform() { 74 logger.log(Level.INFO, stringManager.getString("upgrade.configTransfers.initconf.startMessage")); 75 76 String fileName = commonInfo.getSourceInitConfFileName(); 77 BufferedReader reader = null; 78 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 79 factory.setNamespaceAware(true); 81 try { 82 DocumentBuilder builderDomainXml = factory.newDocumentBuilder(); 83 builderDomainXml.setEntityResolver((org.xml.sax.helpers.DefaultHandler )Class.forName 84 ("com.sun.enterprise.config.serverbeans.ServerValidationHandler").newInstance()); 85 Document resultDoc = builderDomainXml.parse( new File(commonInfo.getTargetConfigXMLFile()) ); 86 reader = new BufferedReader(new FileReader(fileName)); 87 while (reader.ready()) { 88 String line = reader.readLine(); 89 String key = null; 90 String value = null; 91 StringTokenizer st = new StringTokenizer(line, " ", false); 92 if ( st.hasMoreTokens() ) { 93 key = st.nextToken(); 94 } else { 95 continue; 96 } 97 if ( st.hasMoreTokens() ) { 98 value = st.nextToken(); 99 } else { 100 continue; 101 } 102 try { 103 Method m = getClass().getMethod("transform" + key, new Class [] { Document .class, String .class }); 104 m.invoke(this, new Object [] { resultDoc, value } ); 105 } catch (NoSuchMethodException nsm) { 106 logger.log(Level.WARNING, stringManager.getString("upgrade.configTransfers.initconf.unsupportedElement") + key); 107 } catch (Exception e) { 108 logger.log(Level.WARNING, stringManager.getString("upgrade.configTransfers.initconf.exception") + e.getLocalizedMessage()); 109 } 110 } 111 TransformerFactory tFactory = TransformerFactory.newInstance(); 114 Transformer transformer = tFactory.newTransformer(); 115 if (resultDoc.getDoctype() != null){ 116 String systemValue = resultDoc.getDoctype().getSystemId(); 117 transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, systemValue); 118 String pubValue = resultDoc.getDoctype().getPublicId(); 119 transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, pubValue); 120 } 121 DOMSource source = new DOMSource (resultDoc); 122 StreamResult result = new StreamResult (new FileOutputStream(commonInfo.getTargetConfigXMLFile())); 123 transformer.transform(source, result); 124 } catch (IOException ioe) { 125 logger.log(Level.WARNING, stringManager.getString("upgrade.configTransfers.initconf.iofailure") + ioe.getLocalizedMessage()); 126 } catch (Exception e) { 127 logger.log(Level.WARNING, stringManager.getString("upgrade.configTransfers.initconf.exception") + e.getLocalizedMessage()); 128 } 129 if (reader != null) { 130 try { 131 reader.close(); 132 } catch (Exception e) { 133 logger.log(Level.WARNING, stringManager.getString("upgrade.configTransfers.initconf.iofailure") + e.getLocalizedMessage()); 134 } 135 } 136 } 137 138 public void transformServerName(Document domainXML, String value) { 139 140 } 141 142 public void transformServerID(Document domainXML, String value) { 143 144 } 145 146 public void transformExtraPath(Document domainXML, String value) { 147 148 } 149 150 public void transformInit(Document domainXML, String value) { 151 } 153 154 public void transformNetsiteRoot(Document domainXML, String value) { 155 156 } 157 158 public void transformDNS(Document domainXML, String value) { 159 logger.finest("DNS = " + value); 160 Element docEle = domainXML.getDocumentElement(); 161 NodeList nodeList = docEle.getElementsByTagName("config"); 162 for (int i=0; i < nodeList.getLength(); i++) { 163 Element configElement = (Element )nodeList.item(i); 164 String attrValue = configElement.getAttribute("name"); 165 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 166 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 167 Element httpServiceElement = (Element )httpServiceNodes.item(0); 169 NodeList httpList = httpServiceElement.getElementsByTagName("http-protocol"); 170 Element element = (Element )httpList.item(0); 172 if (element != null) { 174 if (value.equalsIgnoreCase("off")) { 175 element.setAttribute("dns-lookup-enabled", "false"); 176 } else { 177 element.setAttribute("dns-lookup-enabled", "true"); 178 } 179 } 180 } 181 } 182 } 183 184 public void transformAsyncDNS(Document domainXML, String value) { 185 } 187 188 public void transformConnQueueSize(Document domainXML, String value) { 189 logger.finest("ConnQueueSize = " + value); 191 Element docEle = domainXML.getDocumentElement(); 192 NodeList nodeList = docEle.getElementsByTagName("config"); 193 for (int i=0; i < nodeList.getLength(); i++) { 194 Element configElement = (Element )nodeList.item(i); 195 String attrValue = configElement.getAttribute("name"); 196 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 197 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 198 Element httpServiceElement = (Element )httpServiceNodes.item(0); 200 NodeList subList = httpServiceElement.getElementsByTagName("connection-pool"); 201 Element element = (Element )subList.item(0); 203 if (element != null) { 205 element.setAttribute("queue-size-bytes", value); 206 } 207 } 208 } 209 } 210 211 public void transformHeaderBufferSize(Document domainXML, String value) { 212 logger.finest("HeaderBufferSize = " + value); 214 Element docEle = domainXML.getDocumentElement(); 215 NodeList nodeList = docEle.getElementsByTagName("config"); 216 for (int i=0; i < nodeList.getLength(); i++) { 217 Element configElement = (Element )nodeList.item(i); 218 String attrValue = configElement.getAttribute("name"); 219 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 220 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 221 Element httpServiceElement = (Element )httpServiceNodes.item(0); 223 NodeList subList = httpServiceElement.getElementsByTagName("request-processing"); 224 Element element = (Element )subList.item(0); 226 if (element != null) { 228 element.setAttribute("header-buffer-size-bytes", value); 229 } 230 } 231 } 232 } 233 234 public void transformIOTimeout(Document domainXML, String value) { 235 logger.finest("IOTimeout = " + value); 237 Element docEle = domainXML.getDocumentElement(); 238 NodeList nodeList = docEle.getElementsByTagName("config"); 239 for (int i=0; i < nodeList.getLength(); i++) { 240 Element configElement = (Element )nodeList.item(i); 241 String attrValue = configElement.getAttribute("name"); 242 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 243 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 244 Element httpServiceElement = (Element )httpServiceNodes.item(0); 246 NodeList subList = httpServiceElement.getElementsByTagName("request-processing"); 247 Element element = (Element )subList.item(0); 249 if (element != null) { 251 element.setAttribute("request-timeout-in-seconds", value); 252 } 253 } 254 } 255 } 256 257 public void transformKeepAliveThreads(Document domainXML, String value) { 258 logger.finest("KeepAliveThreads = " + value); 260 Element docEle = domainXML.getDocumentElement(); 261 NodeList nodeList = docEle.getElementsByTagName("config"); 262 for (int i=0; i < nodeList.getLength(); i++) { 263 Element configElement = (Element )nodeList.item(i); 264 String attrValue = configElement.getAttribute("name"); 265 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 266 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 267 Element httpServiceElement = (Element )httpServiceNodes.item(0); 269 NodeList subList = httpServiceElement.getElementsByTagName("keep-alive"); 270 Element element = (Element )subList.item(0); 272 if (element != null) { 274 element.setAttribute("keep-alive-thread-count", value); 275 } 276 } 277 } 278 } 279 280 public void transformKeepAliveTimeout(Document domainXML, String value) { 281 logger.finest("KeepAliveTimeout = " + value); 283 Element docEle = domainXML.getDocumentElement(); 284 NodeList nodeList = docEle.getElementsByTagName("config"); 285 for (int i=0; i < nodeList.getLength(); i++) { 286 Element configElement = (Element )nodeList.item(i); 287 String attrValue = configElement.getAttribute("name"); 288 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 289 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 290 Element httpServiceElement = (Element )httpServiceNodes.item(0); 292 NodeList subList = httpServiceElement.getElementsByTagName("keep-alive"); 293 Element element = (Element )subList.item(0); 295 if (element != null) { 297 element.setAttribute("timeout-in-seconds", value); 298 } 299 } 300 } 301 } 302 303 public void transformKernelThreads(Document domainXML, String value) { 304 } 306 307 public void transformListenQ(Document domainXML, String value) { 308 logger.finest("ListenQ = " + value); 310 Element docEle = domainXML.getDocumentElement(); 311 NodeList nodeList = docEle.getElementsByTagName("config"); 312 for (int i=0; i < nodeList.getLength(); i++) { 313 Element configElement = (Element )nodeList.item(i); 314 String attrValue = configElement.getAttribute("name"); 315 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 316 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 317 Element httpServiceElement = (Element )httpServiceNodes.item(0); 319 NodeList subList = httpServiceElement.getElementsByTagName("connection-pool"); 320 Element element = (Element )subList.item(0); 322 if (element != null) { 324 element.setAttribute("max-pending-count", value); 325 } 326 } 327 } 328 } 329 330 public void transformRcvBufSize(Document domainXML, String value) { 331 logger.finest("RcvBufSize = " + value); 333 Element docEle = domainXML.getDocumentElement(); 334 NodeList nodeList = docEle.getElementsByTagName("config"); 335 for (int i=0; i < nodeList.getLength(); i++) { 336 Element configElement = (Element )nodeList.item(i); 337 String attrValue = configElement.getAttribute("name"); 338 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 339 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 340 Element httpServiceElement = (Element )httpServiceNodes.item(0); 342 NodeList subList = httpServiceElement.getElementsByTagName("connection-pool"); 343 Element element = (Element )subList.item(0); 345 if (element != null) { 347 element.setAttribute("receive-buffer-size-bytes", value); 348 } 349 } 350 } 351 } 352 353 public void transformMaxKeepAliveConnections(Document domainXML, String value) { 354 logger.finest("MaxKeepAliveConnections = " + value); 356 Element docEle = domainXML.getDocumentElement(); 357 NodeList nodeList = docEle.getElementsByTagName("config"); 358 for (int i=0; i < nodeList.getLength(); i++) { 359 Element configElement = (Element )nodeList.item(i); 360 String attrValue = configElement.getAttribute("name"); 361 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 362 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 363 Element httpServiceElement = (Element )httpServiceNodes.item(0); 365 NodeList subList = httpServiceElement.getElementsByTagName("keep-alive"); 366 Element element = (Element )subList.item(0); 368 if (element != null) { 370 element.setAttribute("max-keep-alive-connections", value); 371 } 372 } 373 } 374 } 375 376 public void transformRqThrottle(Document domainXML, String value) { 377 logger.finest("RqThrottle = " + value); 379 Element docEle = domainXML.getDocumentElement(); 380 NodeList nodeList = docEle.getElementsByTagName("config"); 381 for (int i=0; i < nodeList.getLength(); i++) { 382 Element configElement = (Element )nodeList.item(i); 383 String attrValue = configElement.getAttribute("name"); 384 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 385 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 386 Element httpServiceElement = (Element )httpServiceNodes.item(0); 388 NodeList subList = httpServiceElement.getElementsByTagName("request-processing"); 389 Element element = (Element )subList.item(0); 391 if (element != null) { 393 element.setAttribute("thread-count", value); 394 } 395 } 396 } 397 } 398 399 public void transformRqThrottleMin(Document domainXML, String value) { 400 logger.finest("RqThrottleMin = " + value); 402 Element docEle = domainXML.getDocumentElement(); 403 NodeList nodeList = docEle.getElementsByTagName("config"); 404 for (int i=0; i < nodeList.getLength(); i++) { 405 Element configElement = (Element )nodeList.item(i); 406 String attrValue = configElement.getAttribute("name"); 407 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 408 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 409 Element httpServiceElement = (Element )httpServiceNodes.item(0); 411 NodeList subList = httpServiceElement.getElementsByTagName("request-processing"); 412 Element element = (Element )subList.item(0); 414 if (element != null) { 416 element.setAttribute("initial-thread-count", value); 417 } 418 } 419 } 420 } 421 422 public void transformSndBufSize(Document domainXML, String value) { 423 logger.finest("SndBufSize = " + value); 425 Element docEle = domainXML.getDocumentElement(); 426 NodeList nodeList = docEle.getElementsByTagName("config"); 427 for (int i=0; i < nodeList.getLength(); i++) { 428 Element configElement = (Element )nodeList.item(i); 429 String attrValue = configElement.getAttribute("name"); 430 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 431 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 432 Element httpServiceElement = (Element )httpServiceNodes.item(0); 434 NodeList subList = httpServiceElement.getElementsByTagName("connection-pool"); 435 Element element = (Element )subList.item(0); 437 if (element != null) { 439 element.setAttribute("send-buffer-size-bytes", value); 440 } 441 } 442 } 443 } 444 445 public void transformStackSize(Document domainXML, String value) { 446 String name = "stack-size"; 450 logger.finest("StackSize = " + value); 451 Element docEle = domainXML.getDocumentElement(); 452 NodeList nodeList = docEle.getElementsByTagName("config"); 453 for (int i=0; i < nodeList.getLength(); i++) { 454 Element configElement = (Element )nodeList.item(i); 455 String attrValue = configElement.getAttribute("name"); 456 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 457 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 458 Element httpServiceElement = (Element )httpServiceNodes.item(0); 460 NodeList resultProperties = httpServiceElement.getElementsByTagName("property"); 461 Element resultProperty = null; 462 if(resultProperties != null){ 463 for(int index=0; index < resultProperties.getLength(); index++){ 464 if(((Element )resultProperties.item(index)).getAttribute("name").equals(name)){ 465 resultProperty = (Element )resultProperties.item(index); 466 resultProperty.getAttributeNode("value").setValue(value); 467 break; 469 } 470 } 471 } 472 if(resultProperty == null){ 473 resultProperty = httpServiceElement.getOwnerDocument().createElement("property"); 474 resultProperty.setAttribute("name", name); 475 resultProperty.setAttribute("value", value); 476 httpServiceElement.appendChild(resultProperty); 477 } 478 } 479 } 480 } 481 482 public void transformStrictHttpHeaders(Document domainXML, String value) { 483 } 485 486 public void transformTerminateTimeout(Document domainXML, String value) { 487 } 489 490 public void transformUser(Document domainXML, String value) { 491 } 493 494 public void transformTempDir(Document domainXML, String value) { 495 } 497 498 public void transformThreadIncrement(Document domainXML, String value) { 499 logger.finest("ThreadIncrement = " + value); 501 Element docEle = domainXML.getDocumentElement(); 502 NodeList nodeList = docEle.getElementsByTagName("config"); 503 for (int i=0; i < nodeList.getLength(); i++) { 504 Element configElement = (Element )nodeList.item(i); 505 String attrValue = configElement.getAttribute("name"); 506 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 507 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 508 Element httpServiceElement = (Element )httpServiceNodes.item(0); 510 NodeList subList = httpServiceElement.getElementsByTagName("request-processing"); 511 Element element = (Element )subList.item(0); 513 if (element != null) { 515 element.setAttribute("thread-increment", value); 516 } 517 } 518 } 519 } 520 521 public void transformNativePoolStackSize(Document domainXML, String value) { 522 } 523 524 public void transformNativePoolMaxThreads(Document domainXML, String value) { 525 } 526 527 public void transformNativePoolMinThreads(Document domainXML, String value) { 528 } 529 530 public void transformNativePoolQueueSize(Document domainXML, String value) { 531 } 532 533 public void transformErrorLogDateFormat(Document domainXML, String value) { 534 } 535 536 public void transformLogFlushInterval(Document domainXML, String value) { 537 } 538 539 public void transformPidLog(Document domainXML, String value) { 540 } 541 542 public void transformSecurity(Document domainXML, String value) { 543 logger.finest("Security = " + value); 545 Element docEle = domainXML.getDocumentElement(); 546 NodeList nodeList = docEle.getElementsByTagName("config"); 547 for (int i=0; i < nodeList.getLength(); i++) { 548 Element configElement = (Element )nodeList.item(i); 549 String attrValue = configElement.getAttribute("name"); 550 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 551 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 552 Element httpServiceElement = (Element )httpServiceNodes.item(0); 554 NodeList httpList = httpServiceElement.getElementsByTagName("http-protocol"); 555 Element element = (Element )httpList.item(0); 557 if (element != null) { 559 if (value.equalsIgnoreCase("off")) { 560 element.setAttribute("ssl-enabled", "false"); 561 } else { 562 element.setAttribute("ssl-enabled", "true"); 563 } 564 } 565 } 566 } 567 } 568 569 public void transformSSLCacheEntries(Document domainXML, String value) { 570 String name = "ssl-cache-entries"; 574 logger.finest("SSLCacheEntries = " + value); 575 Element docEle = domainXML.getDocumentElement(); 576 NodeList nodeList = docEle.getElementsByTagName("config"); 577 for (int i=0; i < nodeList.getLength(); i++) { 578 Element configElement = (Element )nodeList.item(i); 579 String attrValue = configElement.getAttribute("name"); 580 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 581 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 582 Element httpServiceElement = (Element )httpServiceNodes.item(0); 584 NodeList resultProperties = httpServiceElement.getElementsByTagName("property"); 585 Element resultProperty = null; 586 if(resultProperties != null){ 587 for(int index=0; index < resultProperties.getLength(); index++){ 588 if(((Element )resultProperties.item(index)).getAttribute("name").equals(name)){ 589 resultProperty = (Element )resultProperties.item(index); 590 resultProperty.getAttributeNode("value").setValue(value); 591 break; 593 } 594 } 595 } 596 if(resultProperty == null){ 597 resultProperty = httpServiceElement.getOwnerDocument().createElement("property"); 598 resultProperty.setAttribute("name", name); 599 resultProperty.setAttribute("value", value); 600 httpServiceElement.appendChild(resultProperty); 601 } 602 } 603 } 604 } 605 606 public void transformSSLClientAuthDataLimit(Document domainXML, String value) { 607 String name = "ssl-client-auth-data-limit"; 611 logger.finest("SSLClientAuthDataLimit = " + value); 612 Element docEle = domainXML.getDocumentElement(); 613 NodeList nodeList = docEle.getElementsByTagName("config"); 614 for (int i=0; i < nodeList.getLength(); i++) { 615 Element configElement = (Element )nodeList.item(i); 616 String attrValue = configElement.getAttribute("name"); 617 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 618 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 619 Element httpServiceElement = (Element )httpServiceNodes.item(0); 621 NodeList resultProperties = httpServiceElement.getElementsByTagName("property"); 622 Element resultProperty = null; 623 if(resultProperties != null){ 624 for(int index=0; index < resultProperties.getLength(); index++){ 625 if(((Element )resultProperties.item(index)).getAttribute("name").equals(name)){ 626 resultProperty = (Element )resultProperties.item(index); 627 resultProperty.getAttributeNode("value").setValue(value); 628 break; 630 } 631 } 632 } 633 if(resultProperty == null){ 634 resultProperty = httpServiceElement.getOwnerDocument().createElement("property"); 635 resultProperty.setAttribute("name", name); 636 resultProperty.setAttribute("value", value); 637 httpServiceElement.appendChild(resultProperty); 638 } 639 } 640 } 641 } 642 643 public void transformSSLClientAuthTimeout(Document domainXML, String value) { 644 String name = "ssl-client-auth-timeout"; 648 logger.finest("SSLClientAuthTimeout = " + value); 649 Element docEle = domainXML.getDocumentElement(); 650 NodeList nodeList = docEle.getElementsByTagName("config"); 651 for (int i=0; i < nodeList.getLength(); i++) { 652 Element configElement = (Element )nodeList.item(i); 653 String attrValue = configElement.getAttribute("name"); 654 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 655 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 656 Element httpServiceElement = (Element )httpServiceNodes.item(0); 658 NodeList resultProperties = httpServiceElement.getElementsByTagName("property"); 659 Element resultProperty = null; 660 if(resultProperties != null){ 661 for(int index=0; index < resultProperties.getLength(); index++){ 662 if(((Element )resultProperties.item(index)).getAttribute("name").equals(name)){ 663 resultProperty = (Element )resultProperties.item(index); 664 resultProperty.getAttributeNode("value").setValue(value); 665 break; 667 } 668 } 669 } 670 if(resultProperty == null){ 671 resultProperty = httpServiceElement.getOwnerDocument().createElement("property"); 672 resultProperty.setAttribute("name", name); 673 resultProperty.setAttribute("value", value); 674 httpServiceElement.appendChild(resultProperty); 675 } 676 } 677 } 678 } 679 680 public void transformSSLSessionTimeout(Document domainXML, String value) { 681 String name = "ssl-session-timeout"; 685 logger.finest("SSLSessionTimeout = " + value); 686 Element docEle = domainXML.getDocumentElement(); 687 NodeList nodeList = docEle.getElementsByTagName("config"); 688 for (int i=0; i < nodeList.getLength(); i++) { 689 Element configElement = (Element )nodeList.item(i); 690 String attrValue = configElement.getAttribute("name"); 691 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 692 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 693 Element httpServiceElement = (Element )httpServiceNodes.item(0); 695 NodeList resultProperties = httpServiceElement.getElementsByTagName("property"); 696 Element resultProperty = null; 697 if(resultProperties != null){ 698 for(int index=0; index < resultProperties.getLength(); index++){ 699 if(((Element )resultProperties.item(index)).getAttribute("name").equals(name)){ 700 resultProperty = (Element )resultProperties.item(index); 701 resultProperty.getAttributeNode("value").setValue(value); 702 break; 704 } 705 } 706 } 707 if(resultProperty == null){ 708 resultProperty = httpServiceElement.getOwnerDocument().createElement("property"); 709 resultProperty.setAttribute("name", name); 710 resultProperty.setAttribute("value", value); 711 httpServiceElement.appendChild(resultProperty); 712 } 713 } 714 } 715 } 716 717 public void transformSSL3SessionTimeout(Document domainXML, String value) { 718 String name = "ssl3-session-timeout"; 722 logger.finest("SSL3SessionTimeout = " + value); 723 Element docEle = domainXML.getDocumentElement(); 724 NodeList nodeList = docEle.getElementsByTagName("config"); 725 for (int i=0; i < nodeList.getLength(); i++) { 726 Element configElement = (Element )nodeList.item(i); 727 String attrValue = configElement.getAttribute("name"); 728 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 729 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 730 Element httpServiceElement = (Element )httpServiceNodes.item(0); 732 NodeList resultProperties = httpServiceElement.getElementsByTagName("property"); 733 Element resultProperty = null; 734 if(resultProperties != null){ 735 for(int index=0; index < resultProperties.getLength(); index++){ 736 if(((Element )resultProperties.item(index)).getAttribute("name").equals(name)){ 737 resultProperty = (Element )resultProperties.item(index); 738 resultProperty.getAttributeNode("value").setValue(value); 739 break; 741 } 742 } 743 } 744 if(resultProperty == null){ 745 resultProperty = httpServiceElement.getOwnerDocument().createElement("property"); 746 resultProperty.setAttribute("name", name); 747 resultProperty.setAttribute("value", value); 748 httpServiceElement.appendChild(resultProperty); 749 } 750 } 751 } 752 } 753 754 public void transformHTTPVersion(Document domainXML, String value) { 755 logger.finest("HTTPVersion = " + value); 757 Element docEle = domainXML.getDocumentElement(); 758 NodeList nodeList = docEle.getElementsByTagName("config"); 759 for (int i=0; i < nodeList.getLength(); i++) { 760 Element configElement = (Element )nodeList.item(i); 761 String attrValue = configElement.getAttribute("name"); 762 if (attrValue.equals(commonInfo.getCurrentSourceInstance() + "-config")) { 763 NodeList httpServiceNodes = configElement.getElementsByTagName("http-service"); 764 Element httpServiceElement = (Element )httpServiceNodes.item(0); 766 NodeList httpList = httpServiceElement.getElementsByTagName("http-protocol"); 767 Element element = (Element )httpList.item(0); 769 if (element != null) { 771 element.setAttribute("http-version", value); 772 } 773 } 774 } 775 } 776 777 799 800 } 801 | Popular Tags |