Exemple #1
0
 private static Hashtable<String, String> getManifestAttributes(Manifest manifest) {
   Hashtable<String, String> h = new Hashtable<String, String>();
   try {
     Attributes attrs = manifest.getMainAttributes();
     Iterator it = attrs.keySet().iterator();
     while (it.hasNext()) {
       String key = it.next().toString();
       h.put(key, attrs.getValue(key));
     }
   } catch (Exception ignore) {
   }
   return h;
 }
Exemple #2
0
 /**
  * load from specified JarInputStream
  *
  * @param fis Jar Input Stream
  * @param mnemo the name for the text file
  */
 private void addToCache(JarInputStream fis, String mnemo) {
   String text = "";
   byte[] buf = new byte[4096];
   int i = 0;
   try {
     while ((i = fis.read(buf)) != -1) {
       text += new String(buf, 0, i);
     }
   } catch (IOException ignored) {
   }
   helpcache.put(mnemo, text);
 }
Exemple #3
0
 /**
  * does the same as the constructor
  *
  * @param language relative path. would be "help/en" currently
  */
 public void reInit(String language) {
   System.out.println("HelpLoader reloading...");
   if (this.language == null) {
     System.out.println(
         "language == null! Do you have an empty ~/.jasmin? Delete it!"
             + " And please tell us about this at [email protected]");
   } else if (this.language.equals(language)) {
     System.out.println("but the same language all over again? nope!");
     return;
   }
   helpcache.clear();
   this.language = language;
   this.helpcache = new Hashtable<>();
   init();
   System.out.println("... done\n");
 }
Exemple #4
0
 /**
  * Loads from specified file
  *
  * @param file
  * @param mnemo the name for the text file
  */
 private void addToCache(File file, String mnemo) {
   BufferedInputStream fis;
   try {
     fis = new BufferedInputStream(new FileInputStream(file));
   } catch (FileNotFoundException e) {
     System.out.println("Warning! File '" + file + "' not found!");
     return;
   }
   String text = "";
   byte[] buf = new byte[4096];
   int i = 0;
   try {
     while ((i = fis.read(buf)) != -1) {
       text += new String(buf, 0, i);
     }
     fis.close();
   } catch (IOException ignored) {
   }
   helpcache.put(mnemo, text);
 }
Exemple #5
0
  /**
   * Class constructor; creates a new Installer object, displays a JFrame introducing the program,
   * allows the user to select an install directory, and copies files from the jar into the
   * directory.
   */
  public Installer(String args[]) {
    // Inputs are --install-dir INSTALL_DIR
    for (int k = 0; k < args.length; k = k + 2) {

      switch (args[k]) {
        case "--install-dir":
          directory = new File(args[k + 1]);
          System.out.println(directory);
          break;
        case "--port":
          port = Integer.parseInt(args[k + 1]);
          break;
      }
    }

    cp = new Stream();

    // Find the installer program so we can get to the files.
    installer = getInstallerProgramFile();
    String name = installer.getName();
    programName = (name.substring(0, name.indexOf("-"))).toUpperCase();

    // Get the installation information
    thisJava = System.getProperty("java.version");
    thisJavaBits = System.getProperty("sun.arch.data.model") + " bits";

    // Find the ImageIO Tools and get the version
    String javaHome = System.getProperty("java.home");
    File extDir = new File(javaHome);
    extDir = new File(extDir, "lib");
    extDir = new File(extDir, "ext");
    File clib = getFile(extDir, "clibwrapper_jiio", ".jar");
    File jai = getFile(extDir, "jai_imageio", ".jar");
    imageIOTools = (clib != null) && clib.exists() && (jai != null) && jai.exists();
    if (imageIOTools) {
      Hashtable<String, String> jaiManifest = getManifestAttributes(jai);
      imageIOVersion = jaiManifest.get("Implementation-Version");
    }

    // Get the CTP.jar parameters
    Hashtable<String, String> manifest = getJarManifestAttributes("/CTP/libraries/CTP.jar");
    programDate = manifest.get("Date");
    buildJava = manifest.get("Java-Version");

    // Get the util.jar parameters
    Hashtable<String, String> utilManifest = getJarManifestAttributes("/CTP/libraries/util.jar");
    utilJava = utilManifest.get("Java-Version");

    // Get the MIRC.jar parameters (if the plugin is present)
    Hashtable<String, String> mircManifest = getJarManifestAttributes("/CTP/libraries/MIRC.jar");
    if (mircManifest != null) {
      mircJava = mircManifest.get("Java-Version");
      mircDate = mircManifest.get("Date");
      mircVersion = mircManifest.get("Version");
    }

    // Set up the installation information for display
    if (imageIOVersion.equals("")) {
      imageIOVersion = "<b><font color=\"red\">not installed</font></b>";
    } else if (imageIOVersion.startsWith("1.0")) {
      imageIOVersion = "<b><font color=\"red\">" + imageIOVersion + "</font></b>";
    }
    if (thisJavaBits.startsWith("64")) {
      thisJavaBits = "<b><font color=\"red\">" + thisJavaBits + "</font></b>";
    }
    boolean javaOK = (thisJava.compareTo(buildJava) >= 0);
    javaOK &= (thisJava.compareTo(utilJava) >= 0);
    javaOK &= (thisJava.compareTo(mircJava) >= 0);
    if (!javaOK) {
      thisJava = "<b><font color=\"red\">" + thisJava + "</font></b>";
    }

    if (directory == null) exit();

    // Point to the parent of the directory in which to install the program.
    // so the copy process works correctly for directory trees.
    //
    // If the user has selected a directory named "CTP",
    // then assume that this is the directory in which
    // to install the program.
    //
    // If the directory is not CTP, see if it is called "RSNA" and contains
    // the Launcher program, in which case we can assume that it is an
    // installation that was done with Bill Weadock's all-in-one installer for Windows.
    //
    // If neither of those cases is true, then this is already the parent of the
    // directory in which to install the program
    if (directory.getName().equals("CTP")) {
      directory = directory.getParentFile();
    } else if (directory.getName().equals("RSNA")
        && (new File(directory, "Launcher.jar")).exists()) {
      suppressFirstPathElement = true;
    }

    // Cleanup old releases
    cleanup(directory);

    // Get a port for the server.
    if (port < 0) {
      if (checkServer(-port, false)) {
        System.err.println(
            "CTP appears to be running.\nPlease stop CTP and run the installer again.");
        System.exit(0);
      }
    }

    // Now install the files and report the results.
    int count =
        unpackZipFile(installer, "CTP", directory.getAbsolutePath(), suppressFirstPathElement);
    if (count > 0) {
      // Create the service installer batch files.
      updateWindowsServiceInstaller();
      updateLinuxServiceInstaller();

      // If this was a new installation, set up the config file and set the port
      installConfigFile(port);

      // Make any necessary changes in the config file to reflect schema evolution
      fixConfigSchema();

      System.out.println("Installation complete.");
      System.out.println(programName + " has been installed successfully.");
      System.out.println(count + " files were installed.");
    } else {
      System.err.println("Installation failed.");
      System.err.println(programName + " could not be fully installed.");
    }
    if (!programName.equals("ISN") && startRunner(new File(directory, "CTP"))) System.exit(0);
  }
Exemple #6
0
 /**
  * for debugging.
  *
  * @return a String array containing all mnemos for which help files exist
  */
 public String[] getMnemoList() {
   return helpcache.keySet().toArray(new String[helpcache.size()]);
 }
Exemple #7
0
 /**
  * @param mnemo the mnemo to check on
  * @return if a context help exists for that mnemo
  */
 public boolean exists(String mnemo) {
   return helpcache.containsKey(mnemo.toLowerCase());
 }
Exemple #8
0
 /**
  * @param mnemo the command the context help has to refer to
  * @return the html code for the context help
  */
 public String get(String mnemo) {
   return helpcache.get(mnemo.toLowerCase());
 }