1 /*************************************************************** 2 * 3 * This program is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU General Public License 5 * as published by the Free Software Foundation; either version 2 6 * of the License, or (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * 17 * @author: Copyright (C) Tim Carver 18 * 19 ***************************************************************/ 20 21 package org.emboss.jemboss; 22 23 import java.util.*; 24 import java.awt.Desktop; 25 import java.io.FileInputStream; 26 import java.io.InputStream; 27 28 29 /** 30 * 31 * Contains all property information about the client 32 * and the server. 33 * 34 */ 35 public class JembossParams 36 { 37 38 /** denotes a server is OK */ 39 static public final int SERVER_OK = 0; 40 /** denotes a server is giving errors */ 41 static public final int SERVER_ERR = 1; 42 /** denotes a server is not responding */ 43 static public final int SERVER_DOWN = 2; 44 45 static final String fs = System.getProperty("file.separator"); 46 47 // these are the things that could be set 48 private boolean useHTTPSProxy = false; 49 private String useHTTPSProxyName = "useHTTPSProxy"; 50 51 private boolean useProxy = false; 52 private String useProxyName = "proxy.use"; 53 54 private String proxyHost = "wwwcache"; 55 private String proxyHostName = "proxy.host"; 56 57 private int proxyPortNum = 8080; 58 private String proxyPortNumName = "proxy.port"; 59 60 //browser proxy 61 62 /** use a separate proxy for browsing the web */ 63 private boolean useBrowserProxy = false; 64 /** property name for using separate proxy for browsing the web */ 65 private String useBrowserProxyName = "browserProxy.use"; 66 /** browser proxy host */ 67 private String browserProxyHost = "wwwcache"; 68 /** property name for browser proxy host */ 69 private String browserProxyHostName = "browserProxy.host"; 70 /** browser proxy port */ 71 private int browserProxyPort = 8080; 72 /** property name for browser proxy port */ 73 private String browserProxyPortName = "browserProxy.port"; 74 75 private boolean useTFM; 76 private String useTFMName = "tfm.use"; 77 78 /** use proxy authentication */ 79 private boolean useProxyAuth = false; 80 /** property name for using proxy authentication */ 81 private String useProxyAuthName = "proxy.auth"; 82 83 private String proxyAuthUser = ""; 84 private String proxyAuthUserName = "proxy.user"; 85 86 private String proxyAuthPasswd = ""; 87 private String proxyAuthPasswdName = "proxy.passwd"; 88 89 private boolean proxyOverride = false; 90 private String proxyOverrideName = "proxy.override"; 91 92 /** use unix authentication to run applications on the server */ 93 private boolean useAuth = true; 94 /** property name for using unix authentication */ 95 private String useAuthName = "user.auth"; 96 97 /** public services URL */ 98 private String publicSoapURL = 99 "https://jemboss.hgmp.mrc.ac.uk:8443/axis/services"; 100 /** property name for public services URL */ 101 private String publicSoapURLName = "server.public"; 102 103 /** private services URL */ 104 private String privateSoapURL = 105 "https://jemboss.hgmp.mrc.ac.uk:8443/axis/services"; 106 /** property name for private services URL */ 107 private String privateSoapURLName = "server.private"; 108 109 /** service name */ 110 private String soapService = "EmbossSoap"; 111 /** property name for service name */ 112 private String soapServiceName = "service.name"; 113 114 /** private service name */ 115 private String privateSoapService = "JembossAuthServer"; 116 /** property name for private service name */ 117 private String privateSoapServiceName = "service.private"; 118 119 /** public service name */ 120 private String publicSoapService = "JembossAuthServer"; 121 /** property name for public service name */ 122 private String publicSoapServiceName = "service.public"; 123 124 //soap options 125 private boolean debug = false; 126 private String debugName = "jemboss.debug"; 127 128 /** batch mode support */ 129 private boolean hasBatchMode = true; 130 /** property name for batch mode support */ 131 private String hasBatchModeName = "jemboss.hasbatchmode"; 132 /** interactive mode support */ 133 private boolean hasInteractiveMode = true; 134 /** property name for interactive mode support */ 135 private String hasInteractiveModeName = "jemboss.hasinteractivemode"; 136 /** current mode for running an application */ 137 private String currentMode = "interactive"; 138 /** property name for current mode */ 139 private String currentModeName = "jemboss.mode"; 140 141 // server lists for redundancy 142 private String serverPublicList = ""; 143 private String serverPublicListName = "server.publiclist"; 144 145 private String serverPrivateList = ""; 146 private String serverPrivateListName = "server.privatelist"; 147 148 // we don't remember these perhaps we should for captive systems 149 private String serviceUserName = ""; 150 private String serviceUserNameName = "user.name"; 151 private char[] servicePasswd = null; 152 /** services password */ 153 private byte[] servicePasswdByte = null; 154 155 Properties jembossSettings; 156 157 // Internal flags to help in the dynamic evaluation of properties 158 private boolean useJavaProxy = false; 159 private String javaProxyPort = ""; 160 private String javaProxyHost = ""; 161 private boolean useJavaNoProxy = false; 162 private String javaNoProxy = ""; 163 private Vector javaNoProxyEntries; 164 private int javaProxyPortNum = 8080; 165 166 // structures for server redundancy 167 private boolean publicServerFailOver = false; 168 private boolean privateServerFailOver = false; 169 private Hashtable serverStatusHash; 170 private Vector publicServers; 171 private Vector privateServers; 172 173 174 /** Jemboss started using the local option */ 175 private static boolean standalone = true; 176 177 /** Jemboss jemboss.server option was true that makes 178 * jemboss running in client mode unless it was not started 179 * using the local option as the first argument to the program */ 180 private static boolean jembossServer = false; 181 /** property name for Jemboss java server */ 182 private String jembossServerName = "jemboss.server"; 183 184 /** cygwin */ 185 private static String cygwin = null; 186 /** property name for Jemboss java server */ 187 private String cygwinName = "cygwin"; 188 189 //EMBOSS directories 190 /** plplot library location */ 191 private String plplot = "/usr/local/share/EMBOSS/"; 192 /** property name for plplot library location */ 193 private String plplotName = "plplot"; 194 /** emboss data location */ 195 private String embossData = "/usr/local/share/EMBOSS/data/"; 196 /** property name for emboss data location */ 197 private String embossDataName = "embossData"; 198 /** emboss binary location */ 199 private String embossBin = "/usr/local/bin/"; 200 /** property name for emboss binary location */ 201 private String embossBinName = "embossBin"; 202 /** emboss path environment variable */ 203 private String embossPath = "/usr/bin/:/bin"; 204 /** property name for emboss path environment variable */ 205 private String embossPathName = "embossPath"; 206 /** emboss environment */ 207 private String embossEnvironment = ""; 208 /** property name for emboss environment */ 209 private String embossEnvironmentName = "embossEnvironment"; 210 /** acd file location */ 211 private String acdDirToParse = "/usr/local/share/EMBOSS/acd/"; 212 /** property name for acd file location */ 213 private String acdDirToParseName = "acdDirToParse"; 214 215 //EMBOSS Application pages 216 /** documentation URL */ 217 private String embURL = "http://www.uk.embnet.org/Software/EMBOSS/Apps/"; 218 /** property name for documentation URL */ 219 private String embossURL = "embossURL"; 220 221 // user properties 222 /** user home directory */ 223 private String userHome = System.getProperty("user.home"); 224 /** property name for user home directory */ 225 private String userHomeName = "user.home"; 226 227 /** standalone results directory */ 228 private String resultsHome = System.getProperty("user.home")+ fs + "jemboss"; 229 private String resultsHomeName = "results.home"; 230 231 /** Specifies whether EMBOSS installation Jemboss configured to use 232 * have PDF support */ 233 private boolean embossHavePDF = true; 234 /** property name for embossHavePDF */ 235 private String embossHavePDFName = "embossHavePDF"; 236 237 boolean desktopOpenActionSupported = false; 238 239 /** 240 * 241 * Loads and holds the properties 242 * 243 */ JembossParams()244 public JembossParams() 245 { 246 Properties defaults = new Properties(); 247 ClassLoader cl = this.getClass().getClassLoader(); 248 249 // initialize data structures 250 serverStatusHash = new Hashtable(); 251 publicServers = new Vector(); 252 privateServers = new Vector(); 253 254 // initialize settings from table above 255 defaults.put(userHomeName,userHome); 256 defaults.put(resultsHomeName,resultsHome); 257 defaults.put(embossURL,embURL); 258 defaults.put(plplotName,plplot); 259 defaults.put(embossDataName,embossData); 260 defaults.put(embossBinName,embossBin); 261 defaults.put(embossPathName,embossPath); 262 defaults.put(embossEnvironmentName,embossEnvironment); 263 defaults.put(acdDirToParseName,acdDirToParse); 264 265 defaults.put(useBrowserProxyName, new Boolean(useBrowserProxy).toString()); 266 defaults.put(browserProxyHostName,browserProxyHost); 267 defaults.put(browserProxyPortName,new Integer(browserProxyPort).toString()); 268 269 defaults.put(useTFMName,new Boolean(useTFM).toString()); 270 271 defaults.put(useProxyName, new Boolean(useProxy).toString()); 272 defaults.put(useHTTPSProxyName, new Boolean(useHTTPSProxy).toString()); 273 defaults.put(proxyHostName,proxyHost); 274 defaults.put(proxyPortNumName, new Integer(proxyPortNum).toString()); 275 defaults.put(useProxyAuthName, new Boolean(useProxyAuth).toString()); 276 defaults.put(proxyAuthUserName, proxyAuthUser); 277 defaults.put(proxyAuthPasswdName, proxyAuthPasswd); 278 defaults.put(proxyOverrideName, new Boolean(proxyOverride).toString()); 279 defaults.put(useAuthName, new Boolean(useAuth).toString()); 280 defaults.put(publicSoapURLName, publicSoapURL); 281 defaults.put(privateSoapURLName, privateSoapURL); 282 defaults.put(privateSoapServiceName, privateSoapService); 283 defaults.put(publicSoapServiceName, publicSoapService); 284 defaults.put(debugName, new Boolean(debug).toString()); 285 defaults.put(hasBatchModeName, new Boolean(hasBatchMode).toString()); 286 defaults.put(hasInteractiveModeName, new Boolean(hasInteractiveMode).toString()); 287 defaults.put(currentModeName, currentMode); 288 defaults.put(serverPublicListName, serverPublicList); 289 defaults.put(serverPrivateListName, serverPrivateList); 290 defaults.put(serviceUserNameName, serviceUserName); 291 292 // load into real settings 293 jembossSettings = new Properties(defaults); 294 295 // try out of the classpath 296 try 297 { 298 InputStream is = cl.getResourceAsStream("resources/jemboss.properties"); 299 if (is!=null) 300 jembossSettings.load(is); 301 } 302 catch (Exception e) 303 { 304 if(debug) 305 System.out.println("Didn't find properties file in classpath."); 306 } 307 308 // override with local system settings 309 loadIn(System.getProperty("user.dir")); 310 311 // override with local user settings 312 loadIn(System.getProperty("user.home")); 313 314 // update our settings 315 updateSettingsFromProperties(); 316 317 if(System.getProperty("useHTTPSProxy") != null) 318 if(System.getProperty("useHTTPSProxy").equalsIgnoreCase("true")) 319 useHTTPSProxy=true; 320 321 // set up for overrides 322 javaNoProxyEntries = new Vector(); 323 if(System.getProperty("proxyPort") != null) 324 { 325 if(System.getProperty("proxyHost") != null) 326 { 327 useJavaProxy = true; 328 useProxy = useJavaProxy; 329 useBrowserProxy = useJavaProxy; 330 331 javaProxyPort = System.getProperty("proxyPort"); 332 javaProxyPortNum = Integer.parseInt(javaProxyPort); 333 javaProxyHost = System.getProperty("proxyHost"); 334 335 browserProxyHost = javaProxyHost; 336 browserProxyPort = javaProxyPortNum; 337 338 if(System.getProperty("http.nonProxyHosts") != null) 339 { 340 useJavaNoProxy = true; 341 javaNoProxy = System.getProperty("http.nonProxyHosts"); 342 StringTokenizer tok = new StringTokenizer(javaNoProxy,"|"); 343 while (tok.hasMoreTokens()) 344 { 345 String toks = tok.nextToken() + "/"; 346 javaNoProxyEntries.add(toks); 347 } 348 } 349 } 350 } 351 352 checkDesktopSupport(); 353 354 } 355 356 /** 357 * 358 * Load a property from the jemboss.property file. 359 * @param folder location of jemboss.property 360 * 361 */ loadIn(String folder)362 private void loadIn(String folder) 363 { 364 FileInputStream in = null; 365 try 366 { 367 in = new FileInputStream(folder + fs + "jemboss.properties"); 368 jembossSettings.load(in); 369 } 370 catch (java.io.FileNotFoundException e) 371 { 372 in = null; 373 if(debug) 374 System.out.println("Can't find properties file in"+folder+"."+ 375 " Using defaults."); 376 } 377 catch (java.io.IOException e) 378 { 379 if(debug) 380 System.out.println("Can't read properties file. " + 381 "Using defaults."); 382 } 383 finally 384 { 385 if (in != null) 386 { 387 try { in.close(); } catch (java.io.IOException e) { } 388 in = null; 389 } 390 } 391 392 } 393 394 /** 395 * 396 * Update the property settings for jembossSettings. 397 * 398 */ updateSettingsFromProperties()399 protected void updateSettingsFromProperties() 400 { 401 402 try 403 { 404 String tmp; 405 406 userHome = jembossSettings.getProperty(userHomeName); 407 resultsHome = jembossSettings.getProperty(resultsHomeName); 408 embURL = jembossSettings.getProperty(embossURL); 409 plplot = jembossSettings.getProperty(plplotName); 410 embossData = jembossSettings.getProperty(embossDataName); 411 embossBin = jembossSettings.getProperty(embossBinName); 412 if (embossBin.length()>0){ 413 if(!embossBin.endsWith(fs)) 414 embossBin += fs; 415 } 416 embossPath = jembossSettings.getProperty(embossPathName); 417 embossEnvironment = jembossSettings.getProperty(embossEnvironmentName); 418 acdDirToParse = jembossSettings.getProperty(acdDirToParseName); 419 tmp = jembossSettings.getProperty(jembossServerName); 420 jembossServer = new Boolean(tmp).booleanValue(); 421 422 cygwin = jembossSettings.getProperty(cygwinName); 423 424 tmp = jembossSettings.getProperty(useHTTPSProxyName); 425 useHTTPSProxy = new Boolean(tmp).booleanValue(); 426 tmp = jembossSettings.getProperty(useProxyName); 427 useProxy = new Boolean(tmp).booleanValue(); 428 proxyHost = jembossSettings.getProperty(proxyHostName); 429 tmp = jembossSettings.getProperty(proxyPortNumName); 430 proxyPortNum = Integer.parseInt(tmp); 431 432 tmp = jembossSettings.getProperty(useBrowserProxyName); 433 useBrowserProxy = new Boolean(tmp).booleanValue(); 434 browserProxyHost = jembossSettings.getProperty(browserProxyHostName); 435 tmp = jembossSettings.getProperty(browserProxyPortName); 436 browserProxyPort = Integer.parseInt(tmp); 437 438 tmp = jembossSettings.getProperty(useTFMName); 439 useTFM = new Boolean(tmp).booleanValue(); 440 441 tmp = jembossSettings.getProperty(useProxyAuthName); 442 useProxyAuth = new Boolean(tmp).booleanValue(); 443 proxyAuthUser = jembossSettings.getProperty(proxyAuthUserName); 444 proxyAuthPasswd = jembossSettings.getProperty(proxyAuthPasswdName); 445 tmp = jembossSettings.getProperty(proxyOverrideName); 446 proxyOverride = new Boolean(tmp).booleanValue(); 447 tmp = jembossSettings.getProperty(useAuthName); 448 useAuth = new Boolean(tmp).booleanValue(); 449 publicSoapURL = jembossSettings.getProperty(publicSoapURLName); 450 privateSoapURL = jembossSettings.getProperty(privateSoapURLName); 451 soapService = jembossSettings.getProperty(soapServiceName); 452 privateSoapService = jembossSettings.getProperty(privateSoapServiceName); 453 publicSoapService = jembossSettings.getProperty(publicSoapServiceName); 454 tmp = jembossSettings.getProperty(debugName); 455 debug = new Boolean(tmp).booleanValue(); 456 tmp = jembossSettings.getProperty(hasBatchModeName); 457 hasBatchMode = new Boolean(tmp).booleanValue(); 458 tmp = jembossSettings.getProperty(hasInteractiveModeName); 459 hasInteractiveMode = new Boolean(tmp).booleanValue(); 460 currentMode = jembossSettings.getProperty(currentModeName); 461 serverPublicList = jembossSettings.getProperty(serverPublicListName); 462 serverPrivateList = jembossSettings.getProperty(serverPrivateListName); 463 464 if(jembossSettings.getProperty(embossHavePDFName)!=null) 465 embossHavePDF = Boolean.getBoolean( 466 jembossSettings.getProperty(embossHavePDFName)); 467 468 } 469 catch (Exception e) { } 470 } 471 472 /** 473 * 474 * Initialize the server redundancy data. This is a separate 475 * method because the server info might not be initialized in 476 * the constructor, but may be imported later from the command line. 477 * 478 */ setupServerRedundancy()479 protected void setupServerRedundancy() 480 { 481 if (!serverPublicList.equals("")) 482 { 483 if(debug) 484 System.out.println("JembossParams: Redundant public servers\n " 485 +serverPublicList); 486 487 publicServerFailOver = true; 488 StringTokenizer tok = new StringTokenizer(serverPublicList,"|"); 489 while (tok.hasMoreTokens()) 490 { 491 String toks = tok.nextToken(); 492 publicServers.add(toks); 493 if(debug) 494 System.out.println(" Entry " + toks); 495 496 serverStatusHash.put(toks, new Integer(SERVER_OK)); 497 } 498 } 499 500 if(!serverPrivateList.equals("")) 501 { 502 if(debug) 503 System.out.println("JembossParams: Redundant private servers\n " 504 +serverPrivateList); 505 506 privateServerFailOver = true; 507 StringTokenizer tok = new StringTokenizer(serverPrivateList,"|"); 508 while (tok.hasMoreTokens()) 509 { 510 String toks = tok.nextToken(); 511 privateServers.add(toks); 512 if(debug) 513 System.out.println(" Entry " + toks); 514 515 serverStatusHash.put(toks,new Integer(SERVER_OK)); 516 } 517 } 518 } 519 520 521 /** 522 * 523 * If using a proxy server 524 * 525 */ getUseProxy()526 public boolean getUseProxy() 527 { 528 return useProxy; 529 } 530 531 532 /** 533 * 534 * If using an https proxy server 535 * 536 */ getUseHTTPSProxy()537 public boolean getUseHTTPSProxy() 538 { 539 return useHTTPSProxy; 540 } 541 542 543 /** 544 * 545 * If using a proxy server for a given URL 546 * @param s the URL we wish to connect to 547 * 548 */ getUseProxy(String s)549 public boolean getUseProxy(String s) 550 { 551 if(proxyOverride) 552 return useProxy; 553 else 554 { 555 if(!useJavaProxy) 556 return useProxy; 557 else 558 { 559 boolean jp = true; 560 if (useJavaNoProxy) 561 { 562 int ip = javaNoProxyEntries.size(); 563 for(int j = 0 ; j<ip ; ++j) 564 if(s.indexOf((String)javaNoProxyEntries.get(j).toString()) != -1) 565 jp = false; 566 } 567 return jp; 568 } 569 } 570 } 571 572 /** 573 * 574 * The name of the proxy server 575 * @return name of the proxy host 576 * 577 */ getProxyHost()578 public String getProxyHost() 579 { 580 if (proxyOverride) 581 return proxyHost; 582 else 583 { 584 if(!useJavaProxy) 585 return proxyHost; 586 else 587 return javaProxyHost; 588 } 589 } 590 591 /** 592 * 593 * The port the proxy server listens on 594 * @return proxy port number 595 * 596 */ getProxyPortNum()597 public int getProxyPortNum() 598 { 599 if(proxyOverride) 600 return proxyPortNum; 601 else 602 { 603 if(!useJavaProxy) 604 return proxyPortNum; 605 else 606 return javaProxyPortNum; 607 } 608 } 609 610 /** 611 * 612 * Determine if the a proxy server is being used for web browsing 613 * @return true if using a proxy server for the browser 614 * 615 */ isBrowserProxy()616 public boolean isBrowserProxy() 617 { 618 return useBrowserProxy; 619 } 620 621 /** 622 * 623 * Get the name of the proxy server for the browser 624 * @return the name of the proxy host 625 * 626 */ getBrowserProxyHost()627 public String getBrowserProxyHost() 628 { 629 return browserProxyHost; 630 } 631 632 633 /** 634 * 635 * The port number of the proxy server for the browser 636 * @return proxy port number 637 * 638 */ getBrowserProxyPort()639 public int getBrowserProxyPort() 640 { 641 return browserProxyPort; 642 } 643 644 isUseTFM()645 public boolean isUseTFM() { return useTFM; } 646 647 648 /** 649 * 650 * If using authenticate with the proxy 651 * @return true if unix authentication used 652 * 653 */ getUseProxyAuth()654 public boolean getUseProxyAuth() 655 { 656 return useProxyAuth; 657 } 658 659 /** 660 * 661 * Username needed to use for the proxy server 662 * 663 */ getProxyAuthUser()664 public String getProxyAuthUser() 665 { 666 return proxyAuthUser; 667 } 668 669 /** 670 * 671 * Password needed to use for the proxy server 672 * 673 */ getProxyAuthPasswd()674 public String getProxyAuthPasswd() 675 { 676 return proxyAuthPasswd; 677 } 678 679 /** 680 * 681 * A description of the proxy settings 682 * @return a description of the proxy settings 683 * 684 */ proxyDescription()685 public String proxyDescription() 686 { 687 String pdesc = ""; 688 if (proxyOverride) 689 { 690 if(useProxy) 691 { 692 String spnum = new Integer(proxyPortNum).toString(); 693 pdesc = "Current Settings: " + "Proxy Host: " + proxyHost + 694 " Proxy Port: " + spnum; 695 } 696 else 697 pdesc = "No proxies, connecting direct."; 698 } 699 else 700 { 701 if (useJavaProxy) 702 { 703 pdesc = "Settings Imported from Java: " + "Proxy Host: " + javaProxyHost 704 + " Proxy Port: " + javaProxyPort; 705 if(useJavaNoProxy) 706 pdesc = pdesc + "\nNo Proxy On: " + javaNoProxy; 707 } 708 else 709 { 710 if(useProxy) 711 { 712 String spnum = new Integer(proxyPortNum).toString(); 713 pdesc = "Current Settings: " + "Proxy Host: " + proxyHost + 714 " Proxy Port: " + spnum; 715 } 716 else 717 pdesc = "No proxies, connecting direct."; 718 } 719 } 720 return pdesc; 721 } 722 723 /** 724 * 725 * Whether the main service requires authentication 726 * @return true if the server is using unix authentication 727 * 728 */ getUseAuth()729 public boolean getUseAuth() 730 { 731 return useAuth; 732 } 733 734 /** 735 * 736 * Returns the URL of the public soap server 737 * @return the public services URL 738 * 739 */ getPublicSoapURL()740 public String getPublicSoapURL() 741 { 742 return publicSoapURL; 743 } 744 745 /** 746 * 747 * @return true if using a Jemboss server 748 * 749 * startup option 'local' overwrites jemboss.server settings 750 * 751 */ isJembossServer()752 public static boolean isJembossServer() 753 { 754 if(standalone) 755 return false; 756 757 return jembossServer; 758 } 759 760 /** 761 * 762 * @return true if using cygwin 763 * 764 */ isCygwin()765 public static boolean isCygwin() 766 { 767 if(cygwin == null || cygwin.equals("")) 768 return false; 769 else 770 return true; 771 } 772 773 774 /** 775 * 776 * Get the cygwin root 777 * @return cygwin root 778 * 779 */ getCygwinRoot()780 public static String getCygwinRoot() 781 { 782 return cygwin; 783 } 784 785 786 787 /** 788 * 789 * Get the location of plplot 790 * @return the location of plplot 791 * 792 */ getPlplot()793 public String getPlplot() 794 { 795 return plplot; 796 } 797 798 /** 799 * 800 * Get the user home directory 801 * @return the user home directory 802 * 803 */ getUserHome()804 public String getUserHome() 805 { 806 return userHome; 807 } 808 809 /** 810 * 811 * Set the user home directory property 812 * @param s the user home directory 813 * 814 */ setUserHome(String s)815 public void setUserHome(String s) 816 { 817 userHome = s; 818 } 819 820 821 /** 822 * 823 * Get the standalone results directory 824 * @return the results directory 825 * 826 */ getResultsHome()827 public String getResultsHome() 828 { 829 if(!resultsHome.endsWith(fs)) 830 resultsHome = resultsHome + fs; 831 return resultsHome; 832 } 833 834 /** 835 * 836 * Set the standalone results directoryproperty 837 * @param s the results directory 838 * 839 */ setResultsHome(String s)840 public void setResultsHome(String s) 841 { 842 resultsHome = s; 843 } 844 845 846 /** 847 * 848 * @return the documentation URL 849 * 850 */ getembURL()851 public String getembURL() 852 { 853 return embURL; 854 } 855 856 /** 857 * 858 * @return the location of the emboss data 859 * 860 */ getEmbossData()861 public String getEmbossData() 862 { 863 return embossData; 864 } 865 866 867 868 869 /** 870 * 871 * @return the location of the emboss data 872 * 873 */ getDesktopSupportsOPENAction()874 public boolean getDesktopSupportsOPENAction() 875 { 876 return desktopOpenActionSupported; 877 } 878 879 880 881 882 /** 883 * 884 * @return the location of the emboss data 885 * 886 */ getEmbossHavePDF()887 public boolean getEmbossHavePDF() 888 { 889 return embossHavePDF; 890 } 891 892 893 894 895 /** 896 * 897 * @return the location of the emboss binaries 898 * 899 */ getEmbossBin()900 public String getEmbossBin() 901 { 902 return embossBin; 903 } 904 905 /** 906 * 907 * Get the path for emboss 908 * @return the path for emboss 909 * 910 */ getEmbossPath()911 public String getEmbossPath() 912 { 913 return embossPath; 914 } 915 916 /** 917 * 918 * Get the environment for emboss 919 * @return the environment for emboss 920 * 921 */ getEmbossEnvironment()922 public String getEmbossEnvironment() 923 { 924 embossEnvironment = embossEnvironment.trim(); 925 embossEnvironment = embossEnvironment.replace(':',' '); 926 embossEnvironment = embossEnvironment.replace(',',' '); 927 return embossEnvironment; 928 } 929 930 /** 931 * 932 * Get the emboss environment as a String array 933 * @return the emboss environment as a String array 934 * 935 */ getEmbossEnvironmentArray(String[] envp)936 public String[] getEmbossEnvironmentArray(String[] envp) 937 { 938 embossEnvironment = embossEnvironment.trim(); 939 embossEnvironment = embossEnvironment.replace(',',' '); 940 941 if(embossEnvironment.equals("")) 942 return envp; 943 944 StringTokenizer st = new StringTokenizer(embossEnvironment," "); 945 int n=0; 946 while(st.hasMoreTokens()) 947 { 948 st.nextToken(); 949 n++; 950 } 951 952 int sizeEnvp = envp.length; 953 String environ[] = new String[n+sizeEnvp]; 954 st = new StringTokenizer(embossEnvironment," "); 955 for(int i=0;i<sizeEnvp;i++) 956 environ[i] = envp[i]; 957 958 n=sizeEnvp; 959 while(st.hasMoreTokens()) 960 { 961 environ[n] = new String(st.nextToken()); 962 n++; 963 } 964 965 return environ; 966 } 967 968 /** 969 * 970 * Acd file location 971 * @return acd file location 972 * 973 */ getAcdDirToParse()974 public String getAcdDirToParse() 975 { 976 return acdDirToParse; 977 } 978 979 /** 980 * 981 * Set the URL of the public soap server 982 * @param s URL of the public services 983 * 984 */ setPublicSoapURL(String s)985 public void setPublicSoapURL(String s) 986 { 987 publicSoapURL = s; 988 } 989 990 /** 991 * 992 * Returns the URL of the private soap server 993 * @return URL of the private services 994 * 995 */ getPrivateSoapURL()996 public String getPrivateSoapURL() 997 { 998 return privateSoapURL; 999 } 1000 1001 /** 1002 * 1003 * Set the URL of the private soap server 1004 * @param s URL of the private services 1005 * 1006 */ setPrivateSoapURL(String s)1007 public void setPrivateSoapURL(String s) 1008 { 1009 privateSoapURL = s; 1010 } 1011 1012 /** 1013 * 1014 * Return whether we have failover on the public server 1015 * 1016 */ getPublicServerFailover()1017 public boolean getPublicServerFailover() 1018 { 1019 return publicServerFailOver; 1020 } 1021 1022 /** 1023 * 1024 * Return whether we have failover on the private server 1025 * 1026 */ getPrivateServerFailover()1027 public boolean getPrivateServerFailover() 1028 { 1029 return privateServerFailOver; 1030 } 1031 1032 /** 1033 * 1034 * Return a vector containing the list of public servers 1035 * 1036 */ getPublicServers()1037 public Vector getPublicServers() 1038 { 1039 return publicServers; 1040 } 1041 1042 /** 1043 * 1044 * Return a vector containing the list of private servers 1045 * 1046 */ getPrivateServers()1047 public Vector getPrivateServers() 1048 { 1049 return privateServers; 1050 } 1051 1052 /** 1053 * 1054 * Mark a server as bad 1055 * 1056 */ setServerStatus(String server, int i)1057 public void setServerStatus(String server, int i) 1058 { 1059 serverStatusHash.put(server, new Integer(i)); 1060 } 1061 1062 1063 /** 1064 * 1065 * Records whether jemboss was started using the 'local' option 1066 * that forces standalone mode. 1067 * 1068 */ setStandaloneMode(boolean local)1069 static public void setStandaloneMode(boolean local) 1070 { 1071 standalone = local; 1072 } 1073 1074 1075 /** 1076 * 1077 * Return the username needed for the remote service 1078 * @return the username 1079 * 1080 */ getServiceUserName()1081 public String getServiceUserName() 1082 { 1083 return serviceUserName; 1084 } 1085 1086 /** 1087 * 1088 * Save the username needed for the remote service 1089 * @param newUserName the username 1090 * 1091 */ setServiceUserName(String newUserName)1092 public void setServiceUserName(String newUserName) 1093 { 1094 serviceUserName = newUserName; 1095 } 1096 1097 /** 1098 * 1099 * Return the password needed for the remote service 1100 * @return password 1101 * 1102 */ getServicePasswd()1103 public char[] getServicePasswd() 1104 { 1105 return servicePasswd; 1106 } 1107 1108 /** 1109 * 1110 * Return the password needed for the remote service 1111 * @return password 1112 * 1113 */ getServicePasswdByte()1114 public byte[] getServicePasswdByte() 1115 { 1116 return servicePasswdByte; 1117 } 1118 1119 /** 1120 * 1121 * Return the password as byte array 1122 * 1123 */ toByteArr(char ch[])1124 private static byte[] toByteArr(char ch[]) 1125 { 1126 int len = ch.length; 1127 byte msb[] = new byte[len]; 1128 1129 for(int i=0;i<len;i++) 1130 msb[i] = (byte)(ch[i]); 1131 return msb; 1132 } 1133 1134 1135 /** 1136 * 1137 * Save the password needed for the remote service 1138 * @param newPasswd the username 1139 * 1140 */ setServicePasswd(char[] newPasswd)1141 public void setServicePasswd(char[] newPasswd) 1142 { 1143 int csize = newPasswd.length; 1144 servicePasswd = new char[csize]; 1145 1146 for(int i=0;i<csize;i++) 1147 servicePasswd[i] = newPasswd[i]; 1148 1149 servicePasswdByte = toByteArr(newPasswd); 1150 } 1151 1152 /** 1153 * 1154 * Get the name of the soap service 1155 * @return soap service name 1156 * 1157 */ getSoapService()1158 public String getSoapService() 1159 { 1160 return soapService; 1161 } 1162 1163 /** 1164 * 1165 * Get the name of the private soap service 1166 * @return private service name 1167 * 1168 */ getPrivateSoapService()1169 public String getPrivateSoapService() 1170 { 1171 return privateSoapService; 1172 } 1173 1174 /** 1175 * 1176 * Set the name of the private soap service 1177 * @param s private service name 1178 * 1179 */ setPrivateSoapService(String s)1180 public void setPrivateSoapService(String s) 1181 { 1182 privateSoapService = s; 1183 } 1184 1185 /** 1186 * 1187 * Get the name of the public soap service we're using 1188 * @return public service name 1189 * 1190 */ getPublicSoapService()1191 public String getPublicSoapService() 1192 { 1193 return publicSoapService; 1194 } 1195 1196 /** 1197 * 1198 * Set the name of the public soap service we're using 1199 * @param s public service name 1200 * 1201 */ setPublicSoapService(String s)1202 public void setPublicSoapService(String s) 1203 { 1204 publicSoapService = s; 1205 } 1206 1207 /** 1208 * 1209 * A description of the server settings 1210 * @return description of the services 1211 * 1212 */ serverDescription()1213 public String serverDescription() 1214 { 1215 String serverdesc = "Current Settings:" 1216 +"\nPublic Server: "+publicSoapURL 1217 +"\nPrivate Server: "+privateSoapURL 1218 +"\nPublic SOAP service: "+publicSoapService 1219 +"\nPrivate SOAP service: "+privateSoapService; 1220 return serverdesc; 1221 } 1222 1223 /** 1224 * 1225 * Whether to show debugging information 1226 * 1227 */ getDebug()1228 public boolean getDebug() 1229 { 1230 return debug; 1231 } 1232 1233 /** 1234 * 1235 * Whether this service supports batch mode 1236 * @return true if batch mode supported 1237 * 1238 */ getHasBatchMode()1239 public boolean getHasBatchMode() 1240 { 1241 return hasBatchMode; 1242 } 1243 1244 /** 1245 * 1246 * Whether this service supports interactive mode 1247 * @return true if interactive mode supported 1248 * 1249 */ getHasInteractiveMode()1250 public boolean getHasInteractiveMode() 1251 { 1252 return hasInteractiveMode; 1253 } 1254 1255 /** 1256 * 1257 * The current mode (interactive or batch). 1258 * @return a String containing the current mode 1259 * 1260 */ getCurrentMode()1261 public String getCurrentMode() 1262 { 1263 if(hasInteractiveMode) 1264 { 1265 if (hasBatchMode) 1266 return currentMode; 1267 else 1268 return "interactive"; 1269 } 1270 else 1271 { 1272 if (hasBatchMode) 1273 return "batch"; 1274 else 1275 return currentMode; 1276 } 1277 } 1278 1279 /** 1280 * 1281 * Set the current mode (interactive or batch). 1282 * @param newMode The new execution mode 1283 * 1284 */ setCurrentMode(String newMode)1285 public void setCurrentMode(String newMode) 1286 { 1287 currentMode = newMode; 1288 } 1289 1290 /** 1291 * 1292 * Return the mode list as a vector, suitable for loading into 1293 * a combobox. 1294 * @return mode list 1295 * 1296 */ modeVector()1297 public Vector modeVector() 1298 { 1299 Vector mv = new Vector(); 1300 if (hasInteractiveMode) 1301 { 1302 if (hasBatchMode) 1303 { 1304 if (currentMode.equals("interactive")) 1305 { 1306 mv.add("interactive"); 1307 mv.add("batch"); 1308 } 1309 else if (currentMode.equals("batch")) 1310 { 1311 mv.add("batch"); 1312 mv.add("interactive"); 1313 } 1314 else 1315 { 1316 mv.add(currentMode); 1317 mv.add("interactive"); 1318 mv.add("batch"); 1319 } 1320 } 1321 else 1322 mv.add("interactive"); 1323 } 1324 else 1325 { 1326 if(hasBatchMode) 1327 mv.add("batch"); 1328 } 1329 return mv; 1330 } 1331 1332 /** 1333 * 1334 * Update the properties structure. 1335 * This doesn't update the actual properties, just the Properties object 1336 * so you must call updateSettingsFromProperties yoursefl 1337 * 1338 * @param name A String naming the property to be updated 1339 * @param newvalue A String containing the new value of the property 1340 * 1341 */ updateJembossProperty(String name, String newvalue)1342 public void updateJembossProperty(String name, String newvalue) 1343 { 1344 if (jembossSettings.getProperty(name) != null) 1345 jembossSettings.setProperty(name,newvalue); 1346 } 1347 1348 /** 1349 * 1350 * Parse a key=value string to update the properties structure 1351 * @param entry String containing a key=value message 1352 * 1353 */ updateJembossPropString(String entry)1354 public void updateJembossPropString(String entry) 1355 { 1356 int isep = entry.indexOf('='); 1357 if(isep != -1) 1358 { 1359 String pkey = entry.substring(0,isep); 1360 String pvalue = entry.substring(isep+1); 1361 updateJembossProperty(pkey, pvalue); 1362 } 1363 } 1364 1365 /** 1366 * 1367 * Parse an array of key=value strings to update the properties structure 1368 * @param entries Array of Strings containing key=value messages 1369 * 1370 */ updateJembossPropStrings(String[] entries)1371 public void updateJembossPropStrings(String[] entries) 1372 { 1373 for (int i=0; i < entries.length; ++i) 1374 updateJembossPropString(entries[i]); 1375 1376 updateSettingsFromProperties(); 1377 setupServerRedundancy(); 1378 } 1379 1380 /** 1381 * 1382 * Update properties from a Hashtable 1383 * @param hash Hashtable containg properties 1384 * 1385 */ updateJembossPropHash(Hashtable hash)1386 public void updateJembossPropHash(Hashtable hash) 1387 { 1388 Enumeration enumer = hash.keys(); 1389 while(enumer.hasMoreElements()) 1390 { 1391 String thiskey = (String)enumer.nextElement().toString(); 1392 String thisval = (String)hash.get(thiskey); 1393 updateJembossProperty(thiskey,thisval); 1394 } 1395 updateSettingsFromProperties(); 1396 } 1397 1398 1399 1400 1401 /* 1402 * Checks whether current JVM supports Desktop OPEN action 1403 */ checkDesktopSupport()1404 private void checkDesktopSupport() 1405 { 1406 String javaVersion = System.getProperty("java.version"); 1407 1408 float ver = Float.parseFloat(javaVersion.substring(0, 1409 javaVersion.lastIndexOf('.'))); 1410 1411 if (ver > 1.6) 1412 { 1413 1414 if(Desktop.isDesktopSupported()){ 1415 Desktop d = Desktop.getDesktop(); 1416 1417 if(d.isSupported(Desktop.Action.OPEN)) 1418 desktopOpenActionSupported = true; 1419 1420 } 1421 } 1422 } 1423 1424 } 1425 1426