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