/** * 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; }
/** * The main method for TaskInfo tool. * * @param args The command-line arguments provided to this program. */ public static void main(String[] args) { int retCode = mainTaskInfo(args, System.in, System.out, System.err); if (retCode != 0) { System.exit(filterExitCode(retCode)); } }
/** * The main method for ExportLDIF tool. * * @param args The command-line arguments provided to this program. */ public static void main(String[] args) { int retCode = mainExportLDIF(args, true, System.out, System.err); if (retCode != 0) { System.exit(filterExitCode(retCode)); } }
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; }
/** {@inheritDoc} */ @Override public MenuResult<Void> invoke(ManageTasks app) throws ClientException { MenuResult<TaskEntry> res = new PrintTaskInfo(taskId).invoke(app); TaskEntry taskEntry = res.getValue(); if (taskEntry != null) { while (true) { try { taskEntry = app.getTaskClient().getTaskEntry(taskId); // Show the menu MenuBuilder<TaskEntry> menuBuilder = new MenuBuilder<>(app); menuBuilder.addBackOption(true); menuBuilder.addCharOption( INFO_TASKINFO_CMD_REFRESH_CHAR.get(), INFO_TASKINFO_CMD_REFRESH.get(), new PrintTaskInfo(taskId)); List<LocalizableMessage> logs = taskEntry.getLogMessages(); if (logs != null && !logs.isEmpty()) { menuBuilder.addCharOption( INFO_TASKINFO_CMD_VIEW_LOGS_CHAR.get(), INFO_TASKINFO_CMD_VIEW_LOGS.get(), new ViewTaskLogs(taskId)); } if (taskEntry.isCancelable() && !taskEntry.isDone()) { menuBuilder.addCharOption( INFO_TASKINFO_CMD_CANCEL_CHAR.get(), INFO_TASKINFO_CMD_CANCEL.get(), new CancelTask(taskId)); } menuBuilder.addQuitOption(); Menu<TaskEntry> menu = menuBuilder.toMenu(); MenuResult<TaskEntry> result = menu.run(); if (result.isCancel()) { break; } else if (result.isQuit()) { System.exit(0); } } catch (Exception e) { app.println(LocalizableMessage.raw(StaticUtils.getExceptionMessage(e))); } } } else { app.println(ERR_TASKINFO_UNKNOWN_TASK_ENTRY.get(taskId)); } return MenuResult.success(); }
/** * 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; }
/** * Provides the command-line arguments to the <CODE>configMain</CODE> method for processing. * * @param args The set of command-line arguments provided to this program. */ public static void main(String[] args) { int exitCode = configMain(args, System.out, System.err); if (exitCode != 0) { System.exit(filterExitCode(exitCode)); } }