コード例 #1
0
ファイル: UpgradeUtils.java プロジェクト: AbacusHu/OpenDJ
  /**
   * Returns the path of the installation of the directory server. Note that this method assumes
   * that this code is being run locally.
   *
   * @return the path of the installation of the directory server.
   */
  static String getInstallPathFromClasspath() {
    String installPath = DirectoryServer.getServerRoot();
    if (installPath != null) {
      return installPath;
    }

    /* Get the install path from the Class Path */
    final String sep = System.getProperty("path.separator");
    final String[] classPaths = System.getProperty("java.class.path").split(sep);
    String path = getInstallPath(classPaths);
    if (path != null) {
      final File f = new File(path).getAbsoluteFile();
      final File librariesDir = f.getParentFile();

      /*
       * Do a best effort to avoid having a relative representation (for
       * instance to avoid having ../../../).
       */
      try {
        installPath = librariesDir.getParentFile().getCanonicalPath();
      } catch (IOException ioe) {
        // Best effort
        installPath = librariesDir.getParent();
      }
    }
    return installPath;
  }
コード例 #2
0
ファイル: UpgradeUtils.java プロジェクト: AbacusHu/OpenDJ
 private static String[] readLDIFLines(
     final DN dn, final ChangeOperationType changeType, final String... lines) {
   final String[] modifiedLines = new String[lines.length + 2];
   if (changeType == MODIFY) {
     modifiedLines[0] = "dn: " + dn;
     modifiedLines[1] = "changetype: modify";
   }
   System.arraycopy(lines, 0, modifiedLines, 2, lines.length);
   return modifiedLines;
 }
コード例 #3
0
ファイル: UpgradeUtils.java プロジェクト: AbacusHu/OpenDJ
 /**
  * Returns the server's installation path.
  *
  * @return The server's installation path.
  */
 static String getInstallationPath() {
   // The upgrade runs from the bits extracted by BuildExtractor
   // in the staging directory.  However
   // we still want the Installation to point at the build being
   // upgraded so the install path reported in [installroot].
   String installationPath = System.getProperty("INSTALL_ROOT");
   if (installationPath == null) {
     final String path = getInstallPathFromClasspath();
     if (path != null) {
       final File f = new File(path);
       if (f.getParentFile() != null
           && f.getParentFile().getParentFile() != null
           && new File(f.getParentFile().getParentFile(), Installation.LOCKS_PATH_RELATIVE)
               .exists()) {
         installationPath = getPath(f.getParentFile().getParentFile());
       } else {
         installationPath = path;
       }
     }
   }
   return installationPath;
 }