1 29 30 package org.objectweb.jonas_rar.raconfig; 31 32 import java.io.BufferedReader ; 33 import java.io.File ; 34 import java.io.FileInputStream ; 35 import java.io.FileNotFoundException ; 36 import java.io.FileOutputStream ; 37 import java.io.FileReader ; 38 import java.io.FileWriter ; 39 import java.io.IOException ; 40 import java.io.InputStream ; 41 import java.io.PrintStream ; 42 import java.util.Enumeration ; 43 import java.util.Iterator ; 44 import java.util.Properties ; 45 import java.util.zip.ZipEntry ; 46 import java.util.zip.ZipFile ; 47 import java.util.zip.ZipOutputStream ; 48 49 import org.objectweb.jonas.security.realm.lib.Base64; 50 import org.objectweb.jonas_rar.deployment.xml.Connector; 51 import org.objectweb.jonas_rar.deployment.api.ConfigPropertyDesc; 52 import org.objectweb.jonas_rar.deployment.xml.ConfigProperty; 53 import org.objectweb.jonas_rar.deployment.api.RarDeploymentDesc; 54 import org.objectweb.jonas_rar.deployment.lib.RarDeploymentDescManager; 55 import org.objectweb.jonas_rar.deployment.xml.Activationspec; 56 import org.objectweb.jonas_rar.deployment.xml.Adminobject; 57 import org.objectweb.jonas_rar.deployment.xml.ConnectionDefinition; 58 import org.objectweb.jonas_rar.deployment.xml.InboundResourceadapter; 59 import org.objectweb.jonas_rar.deployment.xml.JdbcConnParams; 60 import org.objectweb.jonas_rar.deployment.xml.JonasActivationspec; 61 import org.objectweb.jonas_rar.deployment.xml.JonasAdminobject; 62 import org.objectweb.jonas_rar.deployment.xml.JonasConfigProperty; 63 import org.objectweb.jonas_rar.deployment.xml.JonasConnectionDefinition; 64 import org.objectweb.jonas_rar.deployment.xml.JonasConnector; 65 import org.objectweb.jonas_rar.deployment.xml.JonasSecurityMapping; 66 import org.objectweb.jonas_rar.deployment.xml.Messageadapter; 67 import org.objectweb.jonas_rar.deployment.xml.Messagelistener; 68 import org.objectweb.jonas_rar.deployment.xml.OutboundResourceadapter; 69 import org.objectweb.jonas_rar.deployment.xml.PoolParams; 70 import org.objectweb.jonas_rar.deployment.xml.RequiredConfigProperty; 71 import org.objectweb.jonas_rar.deployment.xml.Resourceadapter; 72 import org.objectweb.jonas_rar.deployment.xml.SecurityEntry; 73 74 82 public class RAConfig { 83 84 87 private static final int BUFFER_SIZE = 500; 88 89 90 private static final double JCA_1_5 = 1.5; 91 92 private static final double JCA_1_0 = 1.0; 93 94 RarDeploymentDesc rarDD = null; 95 96 99 static boolean validation = true; 100 101 static String outputFile = "META-INF/jonas-ra.xml"; 102 103 private static final String xmlVers = "<?xml version = \"1.0\" encoding = \"UTF-8\"?>\n"; 104 105 public RAConfig(String fileName) throws RAConfigException { 107 ClassLoader curLoader = Thread.currentThread().getContextClassLoader(); 108 109 try { 110 RarDeploymentDescManager.setParsingWithValidation(validation); 111 rarDD = RarDeploymentDescManager.getInstance(fileName, curLoader); 112 } catch (Exception e) { 113 throw new RAConfigException(e); 114 } 115 116 } 117 118 public RarDeploymentDesc getRarDeploymentDesc() { 119 return rarDD; 120 } 121 122 137 private static void buildXML(String fileInputName, String jndiname, String rarlink, Properties dbProps, 138 boolean encrypt, String securityfile, String path, 139 boolean isVerbose) throws RAConfigException { 140 141 RAConfig raxml = new RAConfig(fileInputName); 142 Connector conn = raxml.getRarDeploymentDesc().getConnector(); 143 double specVersion = 0.0; 144 ConfigPropertyDesc[] raProps = raxml.getRarDeploymentDesc().getRaConfigPropTags(); 145 if (raProps == null) { 146 throw new RAConfigException("RAR file doesn't contain ra.xml"); 147 } 148 if (conn.getSpecVersion().equals("1.0")) { 149 specVersion = JCA_1_0; 150 } else if (conn.getSpecVersion().equals("1.5")) { 151 specVersion = JCA_1_5; 152 } else { 153 throw new RAConfigException("ra.xml doesn't correct spec version"); 154 } 155 156 JonasConnector jConn = new JonasConnector(); 157 PoolParams jPool = new PoolParams(); 158 JdbcConnParams jConnParams = new JdbcConnParams(); 159 JonasConfigProperty jCfg = null; 160 161 String val = ""; 162 String str = ""; 163 jPool.setPoolInit("0"); 164 165 val = "0"; 166 if (dbProps.getProperty("jdbc.minconpool") != null && dbProps.getProperty("jdbc.minconpool").length() > 0) { 167 val = dbProps.getProperty("jdbc.minconpool").trim(); 168 } 169 jPool.setPoolMin(val); 170 171 val = "-1"; 172 if (dbProps.getProperty("jdbc.maxconpool") != null && dbProps.getProperty("jdbc.maxconpool").length() > 0) { 173 val = dbProps.getProperty("jdbc.maxconpool").trim(); 174 } 175 jPool.setPoolMax(val); 176 177 val = "0"; 178 if (dbProps.getProperty("jdbc.connmaxage") != null && dbProps.getProperty("jdbc.connmaxage").length() > 0) { 179 val = dbProps.getProperty("jdbc.connmaxage").trim(); 180 } 181 jPool.setPoolMaxAgeMinutes(val); 182 183 jPool.setPstmtMax("10"); 184 185 val = "0"; 186 if (dbProps.getProperty("jdbc.maxopentime") != null && dbProps.getProperty("jdbc.maxopentime").length() > 0) { 187 val = dbProps.getProperty("jdbc.maxopentime").trim(); 188 } 189 jPool.setPoolMaxOpentime(val); 190 191 val = "0"; 192 if (dbProps.getProperty("jdbc.maxwaiters") != null && dbProps.getProperty("jdbc.maxwaiters").length() > 0) { 193 val = dbProps.getProperty("jdbc.maxwaiters").trim(); 194 } 195 jPool.setPoolMaxWaiters(val); 196 197 val = "0"; 198 if (dbProps.getProperty("jdbc.maxwaittime") != null && dbProps.getProperty("jdbc.maxwaittime").length() > 0) { 199 val = dbProps.getProperty("jdbc.maxwaittime").trim(); 200 } 201 jPool.setPoolMaxWaittime(val); 202 203 val = "30"; 204 if (dbProps.getProperty("jdbc.samplingperiod") != null && dbProps.getProperty("jdbc.samplingperiod").length() > 0) { 205 val = dbProps.getProperty("jdbc.samplingperiod").trim(); 206 } 207 jPool.setPoolSamplingPeriod(val); 208 209 210 jConn.setLogEnabled("false"); 211 jConn.setLogTopic(""); 212 jConn.setNativeLib(""); 213 if (jndiname.length() == 0) { 214 jndiname = dbProps.getProperty("datasource.name", "").trim(); 215 } 216 217 val = "0"; 218 if (dbProps.getProperty("jdbc.connchecklevel") != null 219 && dbProps.getProperty("jdbc.connchecklevel").length() > 0) { 220 val = dbProps.getProperty("jdbc.connchecklevel").trim(); 221 } 222 jConnParams.setJdbcCheckLevel(val); 223 224 val = ""; 225 if (dbProps.getProperty("jdbc.connteststmt") != null && dbProps.getProperty("jdbc.connteststmt").length() > 0) { 226 val = dbProps.getProperty("jdbc.connteststmt").trim(); 227 jConnParams.setJdbcTestStatement(val); 228 } 229 230 if (specVersion == 1.0) { 231 jConn.setJndiName(jndiname); 232 } 233 jConn.setRarlink(rarlink); 234 jConn.setPoolParams(jPool); 235 jConn.setJdbcConnParams(jConnParams); 236 237 if (specVersion == JCA_1_0) { 238 val = ""; 239 str = ""; 240 for (int i = 0; i < raProps.length; i++) { 241 jCfg = new JonasConfigProperty(); 242 str = raProps[i].getConfigPropertyName(); 243 jCfg.setJonasConfigPropertyName(str); 244 if (dbProps.size() > 0) { 245 val = getProp(dbProps, str); 246 } else { 247 val = ""; 248 } 249 jCfg.setJonasConfigPropertyValue(val); 250 jConn.addJonasConfigProperty(jCfg); 251 } 252 } else if (specVersion == JCA_1_5) { 253 Resourceadapter rAdapter = conn.getResourceadapter(); 254 ConfigProperty cProperty = null; 255 RequiredConfigProperty rProperty = null; 257 for (Iterator i = rAdapter.getConfigPropertyList().iterator(); i.hasNext();) { 259 cProperty = (ConfigProperty) i.next(); 260 jCfg = new JonasConfigProperty(); 261 str = cProperty.getConfigPropertyName(); 262 jCfg.setJonasConfigPropertyName(str); 263 if (dbProps.size() > 0) { 264 val = getProp(dbProps, str); 265 } else { 266 val = ""; 267 } 268 jCfg.setJonasConfigPropertyValue(val); 269 jConn.addJonasConfigProperty(jCfg); 270 } 271 OutboundResourceadapter oRes = rAdapter.getOutboundResourceadapter(); 273 if (oRes != null) { 274 ConnectionDefinition cDef = null; 275 JonasConnectionDefinition jcDef = null; 276 for (Iterator it = oRes.getConnectionDefinitionList().iterator(); it.hasNext();) { 277 cDef = (ConnectionDefinition) it.next(); 278 jcDef = new JonasConnectionDefinition(); 279 jcDef.setId(cDef.getId()); 280 jcDef.addDescription(cDef.getManagedconnectionfactoryClass()); 281 jcDef.setJndiName(""); 282 for (Iterator i = cDef.getConfigPropertyList().iterator(); i.hasNext();) { 283 cProperty = (ConfigProperty) i.next(); 284 jCfg = new JonasConfigProperty(); 285 str = cProperty.getConfigPropertyName(); 286 jCfg.setJonasConfigPropertyName(str); 287 jCfg.setJonasConfigPropertyValue(""); 288 jcDef.addJonasConfigProperty(jCfg); 289 } 290 jConn.addJonasConnectionDefinition(jcDef); 291 } 292 } 293 InboundResourceadapter iRes = rAdapter.getInboundResourceadapter(); 295 if (iRes != null) { 296 Messageadapter mAdapter = iRes.getMessageadapter(); 297 if (mAdapter != null) { 298 Messagelistener mList = null; 299 JonasActivationspec jaSpec = null; 300 Activationspec aSpec = null; 301 for (Iterator it = mAdapter.getMessagelistenerList().iterator(); it.hasNext();) { 302 mList = (Messagelistener) it.next(); 303 aSpec = mList.getActivationspec(); 304 if (aSpec != null) { 305 jaSpec = new JonasActivationspec(); 306 jaSpec.setId(mList.getId()); 307 jaSpec.addDescription(mList.getMessagelistenerType()); 308 jaSpec.setJndiName(""); 309 jConn.addJonasActivationspec(jaSpec); 310 } 311 } 312 } 313 } 314 for (Iterator it = rAdapter.getAdminobjectList().iterator(); it.hasNext();) { 316 Adminobject aObj = (Adminobject) it.next(); 317 JonasAdminobject jaObj = null; 318 if (aObj != null) { 319 jaObj = new JonasAdminobject(); 320 jaObj.setId(aObj.getId()); 321 jaObj.addDescription(aObj.getAdminobjectClass()); 322 jaObj.setJndiName(""); 323 for (Iterator i = aObj.getConfigPropertyList().iterator(); i.hasNext();) { 325 cProperty = (ConfigProperty) i.next(); 326 jCfg = new JonasConfigProperty(); 327 str = cProperty.getConfigPropertyName(); 328 jCfg.setJonasConfigPropertyName(str); 329 jCfg.setJonasConfigPropertyValue(""); 330 jaObj.addJonasConfigProperty(jCfg); 331 } 332 jConn.addJonasAdminobject(jaObj); 333 } 334 } 335 } 336 337 if (securityfile != null) { 338 Properties secProps = new Properties (); 339 File f = null; 340 try { 341 f = new File (securityfile); 342 FileInputStream is = new FileInputStream (f); 343 secProps.load(is); 344 } catch (FileNotFoundException e) { 345 System.err.println("Cannot find security properties file: " + securityfile); 346 System.err.println("Continuing with creation of jonas-ra.xml"); 347 } catch (IOException e) { 348 System.err.println(e); 349 } 350 351 JonasSecurityMapping jsMap = new JonasSecurityMapping(); 352 String pName = null; 353 String user = null; 354 String pass = null; 355 String tmp = null; 356 int offset = 0; 357 SecurityEntry sEnt = null; 358 for (Enumeration e = secProps.propertyNames(); e.hasMoreElements();) { 359 pName = (String ) e.nextElement(); 360 tmp = secProps.getProperty(pName); 361 offset = tmp.indexOf("::"); 362 if (offset < 0) { 363 System.err.println("Error in format of file: principalName = user::password"); 364 continue; 365 } 366 user = tmp.substring(0, offset); 367 pass = tmp.substring(offset + 2); 368 369 sEnt = new SecurityEntry(); 370 sEnt.setPrincipalName(pName); 371 sEnt.setUser(user); 372 if (encrypt) { 373 try { 374 pass = new String (Base64.encode(pass.getBytes())); 375 sEnt.setEncrypted("" + encrypt); 376 } catch (Exception ex) { 377 System.err.println("Unable to encrypt the password."); 378 } 379 } 380 sEnt.setPassword(pass); 381 jsMap.addSecurityEntry(sEnt); 382 } 383 jConn.setJonasSecurityMapping(jsMap); 384 } 385 386 try { 387 String tmpDir = (path.length() > 0 ? path : System.getProperty("java.io.tmpdir")); 388 String fileName = tmpDir + File.separator + "jonas-ra.xml"; 389 FileWriter fw = new FileWriter (fileName); 390 fw.write(xmlVers); 391 fw.write(jConn.toXML()); 392 fw.close(); 393 if (isVerbose) { 394 System.out.println("Build Jonas Specific DD File '" + fileName + "' OK"); 395 } 396 397 } catch (Exception e) { 398 throw new RAConfigException("Error writing output", e); 399 } 400 } 401 402 409 private static String getProp(Properties prop, String str) { 410 String [][] mapping = {{"connCheckLevel", "jdbc.connchecklevel"}, {"connMaxAge", "jdbc.connmaxage"}, 411 {"connTestStmt", "jdbc.connteststmt"}, {"URL", "datasource.url"}, {"dsClass", "datasource.classname"}, 412 {"user", "datasource.username"}, {"password", "datasource.password"}, 413 {"isolationLevel", "datasource.isolationlevel"}, {"mapperName", "datasource.mapper"}, }; 414 415 String ret = ""; 416 for (int i = 0; i < mapping.length; i++) { 417 if (mapping[i][0].equalsIgnoreCase(str)) { 418 ret = (prop.getProperty(mapping[i][1]) == null ? "" : prop.getProperty(mapping[i][1]).trim()); 419 } 420 } 421 422 return ret; 423 } 424 425 433 private static void updateRAR(String infile, String outfile, String updatename, String rarlink) 434 throws RAConfigException { 435 436 ZipOutputStream zipOutput = null; 437 ZipFile zipFile = null; 438 Enumeration zippedFiles = null; 439 ZipEntry currEntry = null; 440 ZipEntry entry = null; 441 byte[] buffer = new byte[BUFFER_SIZE]; 442 int num = 0; 443 444 String filename = infile; 445 String outfilename = infile; 446 boolean outNew = false; 447 if (outfile != null && outfile.length() != 0) { 448 outfilename = outfile; 449 outNew = true; 450 } 451 452 try { 453 File file = new File (filename); 454 if (file.exists()) { 455 zipFile = new ZipFile (file.getAbsolutePath()); 456 zippedFiles = zipFile.entries(); 458 if (!outNew) { 460 zipOutput = new ZipOutputStream (new FileOutputStream (new File (file.getAbsolutePath() + "NEW"))); 461 } else { 462 File ofile = new File (outfilename); 463 if (ofile.exists()) { 464 ofile.delete(); 465 } 466 467 zipOutput = new ZipOutputStream (new FileOutputStream (new File (outfilename))); 468 } 469 if ((outfile == null || outfile.length() == 0) && rarlink.length() == 0) { 473 while (zippedFiles.hasMoreElements()) { 474 currEntry = (ZipEntry ) zippedFiles.nextElement(); 476 if (currEntry.getName().equalsIgnoreCase(outputFile)) { 477 continue; 478 } 479 zipOutput.putNextEntry(new ZipEntry (currEntry.getName())); 481 InputStream reader = zipFile.getInputStream(currEntry); 482 while ((num = reader.read(buffer)) != -1) { 483 zipOutput.write(buffer, 0, num); 484 } 485 zipOutput.flush(); 487 zipOutput.closeEntry(); 488 } 489 } 490 zipFile.close(); 492 493 entry = new ZipEntry (outputFile); 495 zipOutput.putNextEntry(entry); 496 497 try { 499 BufferedReader reader = new BufferedReader (new FileReader (updatename)); 500 int ch = 0; 501 while ((ch = reader.read()) != -1) { 502 zipOutput.write(ch); 503 } 504 } catch (Exception ex) { 505 System.out.println("Error reading input file: " + updatename + " " + ex); 506 zipOutput.flush(); 508 zipOutput.closeEntry(); 509 zipOutput.finish(); 510 zipOutput.close(); 511 } 512 zipOutput.flush(); 514 zipOutput.closeEntry(); 515 zipOutput.finish(); 516 zipOutput.close(); 517 518 if (!outNew) { 519 File toBeDeleted = new File (file.getAbsolutePath()); 521 toBeDeleted.delete(); 522 File toBeRenamed = new File (file.getAbsolutePath() + "NEW"); 523 toBeRenamed.renameTo(file); 524 } 525 } else { 526 zipOutput = new ZipOutputStream (new FileOutputStream (new File (outfilename))); 528 529 entry = new ZipEntry (outputFile); 531 zipOutput.putNextEntry(entry); 532 BufferedReader reader = new BufferedReader (new FileReader (updatename)); 534 int ch = 0; 535 while ((ch = reader.read()) != -1) { 536 zipOutput.write(ch); 537 } 538 539 zipOutput.flush(); 541 zipOutput.closeEntry(); 542 zipOutput.finish(); 543 zipOutput.close(); 544 } 545 new File (updatename).delete(); 547 } catch (Exception ex) { 548 throw new RAConfigException(ex); 549 } 550 551 } 552 553 558 private static String indent(int count) { 559 String front = ""; 560 String indentChars = " "; 561 for (int i = 0; i < count; i++) { 562 front += indentChars; 563 } 564 return front; 565 } 566 567 571 public static void usage() { 572 System.out.println(""); 573 System.out.println("Usage: java org.objectweb.jonas.resource.RAConfig <Options> <Input_File> [Output_File]"); 574 System.out.println(" to generate the jonas-ra.xml file for a Resource Adapter."); 575 System.out.println(""); 576 System.out.println(" With Options:"); 577 System.out.println(" -? or -help print this help message"); 578 System.out.println(" -DM,-DS,-PC,-XA DriverManager, Datasource, PooledConnection,"); 579 System.out.println(" XAConnection only used with -p"); 580 System.out.println(" -Jndiname <jndiname> specifies the jndiname RA"); 581 System.out.println(" -Property <property file> specifies the database property file"); 582 System.out.println(" to process"); 583 System.out.println(" -Rarlink <rarlink> specifies the rar file to link to"); 584 System.out.println(" -Update <input name> update the input rar with the specified file"); 585 System.out.println(" unless an output_file named is specified"); 586 System.out.println(" -ENcrypt used with -sf to encrypt the passwords "); 587 System.out.println(" -SecurityFile security xml file to add to jonas-ra.xml "); 588 System.out.println(" -Verbose output the contents of the deployment descriptor "); 589 System.out.println(" -NoValidation turn off xml dtd/schema validation "); 590 System.out.println(" -PATH <path> path where jonas-ra.xml should be written to "); 591 System.out.println(" default is System.property('java.io.tmpdir')"); 592 System.out.println(""); 593 System.out.println(" Input_File Resource Adapter RAR file"); 594 System.out.println(" Output_File Resource Adapter RAR file only used with "); 595 System.out.println(" -p(required) or -u(optional)"); 596 System.out.println(""); 597 } 598 599 605 public static void main(String [] args) throws RAConfigException { 606 PrintStream out = null; 607 boolean isHelp = false; 608 boolean isVerbose = false; 609 boolean doProperty = false; 610 boolean doUpdate = false; 611 boolean encrypt = false; 612 String fileInputName = null; 613 String fileOutputName = null; 614 String securityfile = null; 615 String jndiname = ""; 616 String rarlink = ""; 617 String updatename = ""; 618 String jdbcRarLink = ""; 619 String jonasRarStr = "JOnASJDBC_"; 620 String propertyFile = ""; 621 String path = ""; 622 624 Properties dbProps = null; 625 626 if (args.length < 1) { 627 isHelp = true; 628 } 629 for (int argn = 0; argn < args.length; argn++) { 630 String arg = args[argn].toLowerCase(); 631 if (arg.equals("-help") || arg.equals("-?")) { 632 isHelp = true; 633 continue; 634 } 635 if (arg.equals("-verbose") || arg.equals("-v")) { 636 isVerbose = true; 637 continue; 638 } 639 if (arg.equals("-encrypt") || arg.equals("-en")) { 640 encrypt = true; 641 continue; 642 } 643 if (arg.equals("-securityfile") || arg.equals("-sf")) { 644 if (argn + 1 == args.length || args[++argn].startsWith("-")) { 645 usage(); 646 throw new RAConfigException("Error with -sf input"); 647 } 648 securityfile = args[argn]; 649 continue; 650 } 651 if (arg.equals("-novalidation") || arg.equals("-nv")) { 652 validation = false; 653 continue; 654 } 655 if (arg.equals("-update") || arg.equals("-u")) { 656 doUpdate = true; 657 if (argn + 1 == args.length || args[++argn].startsWith("-")) { 658 usage(); 659 throw new RAConfigException("Error with -u input"); 660 } 661 updatename = args[argn]; 662 continue; 663 } 664 if (arg.equals("-jndiname") || arg.equals("-j")) { 665 if (argn + 1 == args.length || args[++argn].startsWith("-")) { 666 usage(); 667 throw new RAConfigException("Error with -j input"); 668 } 669 jndiname = args[argn]; 670 continue; 671 } 672 if (arg.equals("-rarlink") || arg.equals("-r")) { 673 if (argn + 1 == args.length || args[++argn].startsWith("-")) { 674 usage(); 675 throw new RAConfigException("Error with -r input"); 676 } 677 rarlink = args[argn]; 678 continue; 679 } 680 if (arg.equals("-property") || arg.equals("-p")) { 681 doProperty = true; 682 if (argn + 1 == args.length || args[++argn].startsWith("-")) { 683 usage(); 684 throw new RAConfigException("Error with -p input"); 685 } 686 propertyFile = args[argn]; 687 continue; 688 } 689 if (arg.equals("-dm")) { 690 jdbcRarLink = jonasRarStr + "DM"; 691 continue; 692 } 693 if (arg.equals("-ds")) { 694 jdbcRarLink = jonasRarStr + "DS"; 695 continue; 696 } 697 if (arg.equals("-xa")) { 698 jdbcRarLink = jonasRarStr + "XA"; 699 continue; 700 } 701 if (arg.equals("-pc")) { 702 jdbcRarLink = jonasRarStr + "PC"; 703 continue; 704 } 705 if (arg.equals("-path")) { 706 if (argn + 1 == args.length || args[++argn].startsWith("-")) { 707 usage(); 708 throw new RAConfigException("Error with -path"); 709 } 710 path = args[argn]; 711 continue; 712 } 713 if (fileInputName == null) { 714 fileInputName = args[argn]; 715 if (!fileInputName.endsWith(".rar")) { 716 fileInputName += ".rar"; 717 } 718 } else if (doProperty || doUpdate) { 719 if (fileOutputName == null) { 720 fileOutputName = args[argn]; 721 if (!fileOutputName.endsWith(".rar")) { 722 fileOutputName += ".rar"; 723 } 724 } 725 } else { 726 usage(); 727 throw new RAConfigException("Error multiple input files specified without -property or -update"); 728 } 729 } 730 731 if (isHelp) { 733 usage(); 734 System.exit(0); 735 } 736 if (fileInputName == null) { 737 usage(); 738 throw new RAConfigException("Error missing input file"); 739 } 740 if (doProperty && fileOutputName == null) { 741 usage(); 742 throw new RAConfigException("Error missing output file"); 743 } 744 if (fileInputName.equals(fileOutputName)) { 745 throw new RAConfigException("Input and Output filenames cannot be the same"); 746 } 747 748 dbProps = new Properties (); 749 if (doProperty) { 750 if (jdbcRarLink.length() > 0 && rarlink.length() == 0) { 751 rarlink = jdbcRarLink; 752 } 753 try { 754 dbProps.load(new FileInputStream (propertyFile)); 755 } catch (Exception ex) { 756 if (propertyFile.endsWith(".properties")) { 757 System.out.println("Error reading " + propertyFile + " " + ex); 758 } else { 759 try { 760 dbProps.load(new FileInputStream (propertyFile + ".properties")); 761 } catch (Exception ex1) { 762 System.out.println("Error reading " + propertyFile + " " + ex); 763 } 764 } 765 } 766 buildXML(fileInputName, jndiname, rarlink, dbProps, encrypt, securityfile, path, isVerbose); 767 if (updatename.length() == 0) { 768 updatename = System.getProperty("java.io.tmpdir") + File.separator + "jonas-ra.xml"; 769 } 770 updateRAR(fileInputName, fileOutputName, updatename, rarlink); 771 } else if (doUpdate) { 772 updateRAR(fileInputName, fileOutputName, updatename, rarlink); 773 } else { 774 buildXML(fileInputName, jndiname, rarlink, dbProps, encrypt, securityfile, path, isVerbose); 775 } 776 } 777 } 778 | Popular Tags |