Class Application

    • Field Detail

      • tempLogFile

        protected TempLogFile tempLogFile
        Temporary log file where messages will be logged, once openTempLogFile() has asked for it. It stays null until then: creating it costs a file - and the directory it lives in - that nothing removes unless the operation succeeds, so the roads which attempt nothing must not create one (issue #1030).
    • Constructor Detail

      • Application

        public Application()
    • Method Detail

      • create

        public static GuiApplication create()
                                     throws RuntimeException
        Creates an application by instantiating the Application class denoted by the System property org.opends.quicksetup.Application.class.
        Returns:
        Application object that was newly instantiated
        Throws:
        RuntimeException - if there was a problem creating the new Application object
      • setUserData

        public void setUserData​(UserData userData)
        Sets this instances user data.
        Parameters:
        userData - UserData this application will use when executing
      • createUserData

        public UserData createUserData()
        Creates a set of user data with default values.
        Returns:
        UserData empty set of UserData
      • getInstallation

        public Installation getInstallation()
        Gets the OpenDJ installation associated with the execution of this command.
        Returns:
        Installation object representing the current OpenDS installation
      • setInstallation

        public void setInstallation​(Installation installation)
        Sets the application's installation.
        Parameters:
        installation - describing the application's OpenDS installation
      • getUserData

        public UserData getUserData()
        Returns the UserData object representing the parameters provided by the user to do the installation.
        Returns:
        the UserData object representing the parameters provided by the user to do the installation.
      • notifyListenersDone

        public void notifyListenersDone​(Integer ratio)
        This method notifies the ProgressUpdateListeners that there was an update in the installation progress.
        Parameters:
        ratio - the integer that specifies which percentage of the whole installation has been completed.
      • notifyListenersRatioChange

        public void notifyListenersRatioChange​(Integer ratio)
        This method notifies the ProgressUpdateListeners that there was an update in the installation progress.
        Parameters:
        ratio - the integer that specifies which percentage of the whole installation has been completed.
      • notifyListeners

        public void notifyListeners​(Integer ratio,
                                    org.forgerock.i18n.LocalizableMessage currentPhaseSummary,
                                    org.forgerock.i18n.LocalizableMessage newLogDetail)
        This method notifies the ProgressUpdateListeners that there was an update in the installation progress.
        Specified by:
        notifyListeners in interface ProgressNotifier
        Parameters:
        ratio - the integer that specifies which percentage of the whole installation has been completed.
        currentPhaseSummary - the localized summary message for the current installation progress in formatted form.
        newLogDetail - the new log messages that we have for the installation in formatted form.
      • notifyListenersWithPoints

        public void notifyListenersWithPoints​(Integer ratio,
                                              org.forgerock.i18n.LocalizableMessage newLogDetail)
        This method notifies the ProgressUpdateListeners that there was an update in the installation progress.
        Parameters:
        ratio - the integer that specifies which percentage of the whole installation has been completed.
        newLogDetail - the localized additional log message.
      • setProgressMessageFormatter

        public void setProgressMessageFormatter​(ProgressMessageFormatter formatter)
        Sets the formatter this instance should use to used to format progress messages.
        Parameters:
        formatter - ProgressMessageFormatter for formatting progress messages
      • getProgressMessageFormatter

        public ProgressMessageFormatter getProgressMessageFormatter()
        Gets the formatter this instance is currently using.
        Returns:
        the progress message formatter currently used by this application
      • getFormattedSummary

        protected org.forgerock.i18n.LocalizableMessage getFormattedSummary​(org.forgerock.i18n.LocalizableMessage text)
        Returns the formatted representation of the text that is the summary of the installation process (the one that goes in the UI next to the progress bar).
        Parameters:
        text - the source text from which we want to get the formatted representation
        Returns:
        the formatted representation of an error for the given text.
      • getFormattedError

        protected org.forgerock.i18n.LocalizableMessage getFormattedError​(org.forgerock.i18n.LocalizableMessage text)
        Returns the formatted representation of an error for a given text.
        Parameters:
        text - the source text from which we want to get the formatted representation
        Returns:
        the formatted representation of an error for the given text.
      • getFormattedWarning

        public org.forgerock.i18n.LocalizableMessage getFormattedWarning​(org.forgerock.i18n.LocalizableMessage text)
        Returns the formatted representation of an warning for a given text.
        Parameters:
        text - the source text from which we want to get the formatted representation
        Returns:
        the formatted representation of an warning for the given text.
      • getFormattedSuccess

        protected org.forgerock.i18n.LocalizableMessage getFormattedSuccess​(org.forgerock.i18n.LocalizableMessage text)
        Returns the formatted representation of a success message for a given text.
        Parameters:
        text - the source text from which we want to get the formatted representation
        Returns:
        the formatted representation of an success message for the given text.
      • getFormattedLogError

        public org.forgerock.i18n.LocalizableMessage getFormattedLogError​(org.forgerock.i18n.LocalizableMessage text)
        Returns the formatted representation of a log error message for a given text.
        Parameters:
        text - the source text from which we want to get the formatted representation
        Returns:
        the formatted representation of a log error message for the given text.
      • getFormattedLog

        public org.forgerock.i18n.LocalizableMessage getFormattedLog​(org.forgerock.i18n.LocalizableMessage text)
        Returns the formatted representation of a log message for a given text.
        Parameters:
        text - the source text from which we want to get the formatted representation
        Returns:
        the formatted representation of a log message for the given text.
      • getFormattedDone

        public org.forgerock.i18n.LocalizableMessage getFormattedDone()
        Returns the formatted representation of the 'Done' text string.
        Returns:
        the formatted representation of the 'Done' text string.
      • getFormattedDoneWithLineBreak

        public org.forgerock.i18n.LocalizableMessage getFormattedDoneWithLineBreak()
        Returns the formatted representation of the 'Done' text string with a line break at the end.
        Returns:
        the formatted representation of the 'Done' text string.
      • getFormattedWithPoints

        public org.forgerock.i18n.LocalizableMessage getFormattedWithPoints​(org.forgerock.i18n.LocalizableMessage text)
        Returns the formatted representation of the argument text to which we add points. For instance if we pass as argument 'Configuring Server' the return value will be 'Configuring Server .....'.
        Parameters:
        text - the String to which add points.
        Returns:
        the formatted representation of the '.....' text string.
      • getFormattedProgress

        public org.forgerock.i18n.LocalizableMessage getFormattedProgress​(org.forgerock.i18n.LocalizableMessage text)
        Returns the formatted representation of a progress message for a given text.
        Parameters:
        text - the source text from which we want to get the formatted representation
        Returns:
        the formatted representation of a progress message for the given text.
      • getFormattedProgressWithLineBreak

        public org.forgerock.i18n.LocalizableMessage getFormattedProgressWithLineBreak​(org.forgerock.i18n.LocalizableMessage text)
        Returns the formatted representation of a progress message for a given text with a line break.
        Parameters:
        text - the source text from which we want to get the formatted representation
        Returns:
        the formatted representation of a progress message for the given text.
      • getFormattedError

        protected org.forgerock.i18n.LocalizableMessage getFormattedError​(Throwable t,
                                                                          boolean applyMargin)
        Returns the formatted representation of an error message for a given exception. This method applies a margin if the applyMargin parameter is true.
        Parameters:
        t - the exception.
        applyMargin - specifies whether we apply a margin or not to the resulting formatted text.
        Returns:
        the formatted representation of an error message for the given exception.
      • getLineBreak

        public org.forgerock.i18n.LocalizableMessage getLineBreak()
        Returns the line break formatted.
        Returns:
        the line break formatted.
      • getTaskSeparator

        protected org.forgerock.i18n.LocalizableMessage getTaskSeparator()
        Returns the task separator formatted.
        Returns:
        the task separator formatted.
      • notifyListeners

        public void notifyListeners​(org.forgerock.i18n.LocalizableMessage newLogDetail)
        This method is called when a new log message has been received. It will notify the ProgressUpdateListeners of this fact.
        Parameters:
        newLogDetail - the new log detail.
      • getInstallationPath

        public abstract String getInstallationPath()
        Returns the installation path.
        Returns:
        the installation path.
      • getInstancePath

        public abstract String getInstancePath()
        Returns the instance path.
        Returns:
        the instance path.
      • getCurrentProgressStep

        public abstract ProgressStep getCurrentProgressStep()
        Gets the current step.
        Returns:
        ProgressStep representing the current step
      • getRatio

        public abstract Integer getRatio​(ProgressStep step)
        Gets an integer representing the amount of processing this application still needs to perform as a ratio out of 100.
        Parameters:
        step - ProgressStop for which a summary is needed
        Returns:
        ProgressStep representing the current step
      • getSummary

        public abstract org.forgerock.i18n.LocalizableMessage getSummary​(ProgressStep step)
        Gets an i18n'd string representing the summary of a give ProgressStep.
        Parameters:
        step - ProgressStop for which a summary is needed
        Returns:
        String representing the summary
      • setCurrentInstallStatus

        public void setCurrentInstallStatus​(CurrentInstallStatus installStatus)
        Sets the current install status for this application.
        Parameters:
        installStatus - for the current installation.
      • isFinished

        public abstract boolean isFinished()
        Returns whether the installer has finished or not.
        Returns:
        true if the install is finished or false if not.
      • getTrustManager

        public ApplicationTrustManager getTrustManager()
        Returns the trust manager that can be used to establish secure connections.
        Returns:
        the trust manager that can be used to establish secure connections.
      • isCancellable

        public abstract boolean isCancellable()
        Indicates whether this application is capable of cancelling the operation performed in the run method. A cancellable operation should leave its environment in the same state as it was prior to running the operation (files deleted, changes backed out etc.). Marking an Application as cancellable may control UI elements like the presense of a cancel button while the operation is being performed. Applications marked as cancellable should override the cancel method in such a way as to undo whatever actions have taken place in the run method up to that point.
        Returns:
        boolean where true inidcates that the operation is cancellable
      • cancel

        public abstract void cancel()
        Signals that the application should cancel a currently running operation as soon as possible and return the environment to the state prior to running the operation. When finished backing out changes the application should make sure that isFinished returns true so that the application can complete.
      • checkAbort

        public void checkAbort()
                        throws ApplicationException
        Checks whether the operation has been aborted. If it has throws an ApplicationException. All the applications that support abort must provide their implementation as the default implementation is empty.
        Throws:
        ApplicationException - thrown if the application was aborted.
      • getMessage

        protected org.forgerock.i18n.LocalizableMessage getMessage​(TopologyCacheException e)
        Returns a localized representation of a TopologyCacheException object.
        Parameters:
        e - the exception we want to obtain the representation from.
        Returns:
        a localized representation of a TopologyCacheException object.
      • getRemoteConnection

        protected ConnectionWrapper getRemoteConnection​(ServerDescriptor server,
                                                        DN dn,
                                                        String pwd,
                                                        int timeout,
                                                        Set<PreferredConnection> cnx)
                                                 throws ApplicationException
        Gets a connection based on the information that appears on the provided ServerDescriptor object. Note that the server is assumed to be registered and that contains a Map with ADSContext.ServerProperty keys.
        Parameters:
        server - the object describing the server.
        dn - the dn to be used to authenticate.
        pwd - the pwd to be used to authenticate.
        timeout - the timeout to establish the connection in milliseconds. Use 0 to express no timeout.
        cnx - the ordered list of preferred connections to connect to the server.
        Returns:
        the connection to the remote server.
        Throws:
        ApplicationException - if something goes wrong.
      • isVerbose

        public boolean isVerbose()
        Returns true if the application is running in verbose mode and false otherwise.
        Returns:
        true if the application is running in verbose mode and false otherwise.
      • getApplicationErrorStream

        public Application.ErrorPrintStream getApplicationErrorStream()
        Returns the error stream to be used by the application when launching command lines.
        Returns:
        the error stream to be used by the application when launching command lines.
      • getApplicationOutputStream

        public Application.OutputPrintStream getApplicationOutputStream()
        Returns the output stream to be used by the application when launching command lines.
        Returns:
        the output stream to be used by the application when launching command lines.
      • setNotifyListeners

        public void setNotifyListeners​(boolean notifyListeners)
        Tells whether we must notify the listeners or not of the message received.
        Parameters:
        notifyListeners - the boolean that informs of whether we have to notify the listeners or not.
      • applicationPrintStreamReceived

        protected void applicationPrintStreamReceived​(String message)
        Method that is invoked by the printstreams with the messages received on operations such as start or import. This is done so that the application can parse this messages and display them.
        Parameters:
        message - the message that has been received
      • setTempLogFile

        public void setTempLogFile​(Supplier<TempLogFile> tempLogFile)
        Sets where the temporary log file of this application comes from, without creating it.

        The wizard and the CLI hand the supplier over as they start: the file itself is created by openTempLogFile(), on the road that runs the operation, so that a run which does nothing - a quit at any step of the wizard, a server which turns out to be installed already - leaves no log behind (issue #1030).

        There is deliberately no setter taking the file itself: a caller holding a supplier could then resolve it on the spot, and the log would be created before anything is attempted again.

        Parameters:
        tempLogFile - supplies the temporary log file where messages will be logged.
      • openTempLogFile

        protected TempLogFile openTempLogFile()
        Creates the temporary log file of this application, unless it has one already.

        Called where the operation begins and not before: from that point on the log is worth keeping, because there is something which can fail and be reported.

        An application nobody handed a supplier to has no log of its own: the command line uninstaller is built that way, and its launcher creates the log before running it.

        Returns:
        the temporary log file of this application, or null if it was given none.