001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2014 ForgeRock AS
026 */
027
028package org.opends.quicksetup;
029
030import org.opends.quicksetup.event.ProgressNotifier;
031import org.opends.quicksetup.util.ProgressMessageFormatter;
032
033import com.forgerock.opendj.cli.ClientException;
034
035/**
036 * Represents a quick setup CLI application.
037 */
038public interface CliApplication extends ProgressNotifier, Runnable {
039
040  /**
041   * Creates a set of user data from command line arguments and installation
042   * status.
043   *
044   * @param launcher
045   *          that launched this application
046   * @return UserData object populated to reflect the input args and status
047   * @throws UserDataException
048   *           if something is wrong with the data provided by the user
049   * @throws ApplicationException
050   *           if there is an application specific problem
051   * @throws ClientException
052   *           If an error occurs when creating the data.
053   */
054  UserData createUserData(Launcher launcher)
055          throws UserDataException, ApplicationException, ClientException;
056
057  /**
058   * Gets the user data this application will use when running.
059   * @return UserData to use when running
060   */
061  UserData getUserData();
062
063
064  /**
065   * Sets the user data this application will use when running.
066   * @param userData UserData to use when running
067   */
068  void setUserData(UserData userData);
069
070  /**
071   * Sets the formatter that will be used to format messages.
072   * @param formatter ProgressMessageFormatter used to format messages
073   */
074  void setProgressMessageFormatter(ProgressMessageFormatter formatter);
075
076  /**
077   * Gets any exception that happened while this application was running.
078   * A null value returned from this method indicates that the execution
079   * of the CLI program is not complete or was successful.
080   * @return an exception that happened while the CLI was running
081   */
082  ApplicationException getRunError();
083
084  /**
085   * Gets the return code to return to the console.
086   * @return return code to return;  if null the return code indicated in the
087   *         error returned by <code>getRunError</code> will be used.
088   */
089  ReturnCode getReturnCode();
090}