| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2012-2013 ForgeRock AS. |
| | | * Portions Copyright 2012-2014 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.admin.ads.ServerDescriptor; |
| | |
| | | * @param newLogDetail the new log messages that we have for the |
| | | * installation in formatted form. |
| | | */ |
| | | public void notifyListeners(Integer ratio, Message currentPhaseSummary, |
| | | Message newLogDetail) |
| | | public void notifyListeners(Integer ratio, LocalizableMessage currentPhaseSummary, |
| | | LocalizableMessage newLogDetail) |
| | | { |
| | | if (notifyListeners) |
| | | { |
| | |
| | | * @param newLogDetail the localized additional log message. |
| | | */ |
| | | public void notifyListenersWithPoints(Integer ratio, |
| | | Message newLogDetail) { |
| | | LocalizableMessage newLogDetail) { |
| | | notifyListeners(ratio, getSummary(getCurrentProgressStep()), |
| | | formatter.getFormattedWithPoints(newLogDetail)); |
| | | } |
| | |
| | | * representation |
| | | * @return the formatted representation of an error for the given text. |
| | | */ |
| | | protected Message getFormattedSummary(Message text) |
| | | protected LocalizableMessage getFormattedSummary(LocalizableMessage text) |
| | | { |
| | | return formatter.getFormattedSummary(text); |
| | | } |
| | |
| | | * representation |
| | | * @return the formatted representation of an error for the given text. |
| | | */ |
| | | protected Message getFormattedError(Message text) |
| | | protected LocalizableMessage getFormattedError(LocalizableMessage text) |
| | | { |
| | | return formatter.getFormattedError(text, false); |
| | | } |
| | |
| | | * representation |
| | | * @return the formatted representation of an warning for the given text. |
| | | */ |
| | | public Message getFormattedWarning(Message text) |
| | | public LocalizableMessage getFormattedWarning(LocalizableMessage text) |
| | | { |
| | | return formatter.getFormattedWarning(text, false); |
| | | } |
| | |
| | | * @return the formatted representation of an success message for the given |
| | | * text. |
| | | */ |
| | | protected Message getFormattedSuccess(Message text) |
| | | protected LocalizableMessage getFormattedSuccess(LocalizableMessage text) |
| | | { |
| | | return formatter.getFormattedSuccess(text); |
| | | } |
| | |
| | | * @return the formatted representation of a log error message for the given |
| | | * text. |
| | | */ |
| | | public Message getFormattedLogError(Message text) |
| | | public LocalizableMessage getFormattedLogError(LocalizableMessage text) |
| | | { |
| | | return formatter.getFormattedLogError(text); |
| | | } |
| | |
| | | * representation |
| | | * @return the formatted representation of a log message for the given text. |
| | | */ |
| | | public Message getFormattedLog(Message text) |
| | | public LocalizableMessage getFormattedLog(LocalizableMessage text) |
| | | { |
| | | return formatter.getFormattedLog(text); |
| | | } |
| | |
| | | * Returns the formatted representation of the 'Done' text string. |
| | | * @return the formatted representation of the 'Done' text string. |
| | | */ |
| | | public Message getFormattedDone() |
| | | public LocalizableMessage getFormattedDone() |
| | | { |
| | | return Message.raw(formatter.getFormattedDone()); |
| | | return LocalizableMessage.raw(formatter.getFormattedDone()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * with a line break at the end. |
| | | * @return the formatted representation of the 'Done' text string. |
| | | */ |
| | | public Message getFormattedDoneWithLineBreak() { |
| | | return new MessageBuilder(formatter.getFormattedDone()) |
| | | public LocalizableMessage getFormattedDoneWithLineBreak() { |
| | | return new LocalizableMessageBuilder(formatter.getFormattedDone()) |
| | | .append(formatter.getLineBreak()).toMessage(); |
| | | } |
| | | |
| | |
| | | * @param text the String to which add points. |
| | | * @return the formatted representation of the '.....' text string. |
| | | */ |
| | | public Message getFormattedWithPoints(Message text) |
| | | public LocalizableMessage getFormattedWithPoints(LocalizableMessage text) |
| | | { |
| | | return formatter.getFormattedWithPoints(text); |
| | | } |
| | |
| | | * @return the formatted representation of a progress message for the given |
| | | * text. |
| | | */ |
| | | public Message getFormattedProgress(Message text) |
| | | public LocalizableMessage getFormattedProgress(LocalizableMessage text) |
| | | { |
| | | return formatter.getFormattedProgress(text); |
| | | } |
| | |
| | | * @return the formatted representation of a progress message for the given |
| | | * text. |
| | | */ |
| | | public Message getFormattedProgressWithLineBreak(Message text) |
| | | public LocalizableMessage getFormattedProgressWithLineBreak(LocalizableMessage text) |
| | | { |
| | | return new MessageBuilder(formatter.getFormattedProgress(text)) |
| | | return new LocalizableMessageBuilder(formatter.getFormattedProgress(text)) |
| | | .append(getLineBreak()).toMessage(); |
| | | } |
| | | |
| | |
| | | * @return the formatted representation of an error message for the given |
| | | * exception. |
| | | */ |
| | | protected Message getFormattedError(Throwable t, boolean applyMargin) |
| | | protected LocalizableMessage getFormattedError(Throwable t, boolean applyMargin) |
| | | { |
| | | return formatter.getFormattedError(t, applyMargin); |
| | | } |
| | |
| | | * Returns the line break formatted. |
| | | * @return the line break formatted. |
| | | */ |
| | | public Message getLineBreak() |
| | | public LocalizableMessage getLineBreak() |
| | | { |
| | | return formatter.getLineBreak(); |
| | | } |
| | |
| | | * Returns the task separator formatted. |
| | | * @return the task separator formatted. |
| | | */ |
| | | protected Message getTaskSeparator() |
| | | protected LocalizableMessage getTaskSeparator() |
| | | { |
| | | return formatter.getTaskSeparator(); |
| | | } |
| | |
| | | * notify the ProgressUpdateListeners of this fact. |
| | | * @param newLogDetail the new log detail. |
| | | */ |
| | | public void notifyListeners(Message newLogDetail) |
| | | public void notifyListeners(LocalizableMessage newLogDetail) |
| | | { |
| | | Integer ratio = getRatio(getCurrentProgressStep()); |
| | | Message currentPhaseSummary = getSummary(getCurrentProgressStep()); |
| | | LocalizableMessage currentPhaseSummary = getSummary(getCurrentProgressStep()); |
| | | notifyListeners(ratio, currentPhaseSummary, newLogDetail); |
| | | } |
| | | |
| | |
| | | * @param step ProgressStop for which a summary is needed |
| | | * @return String representing the summary |
| | | */ |
| | | public abstract Message getSummary(ProgressStep step); |
| | | public abstract LocalizableMessage getSummary(ProgressStep step); |
| | | |
| | | /** |
| | | * Sets the current install status for this application. |
| | |
| | | * @param e the exception we want to obtain the representation from. |
| | | * @return a localized representation of a TopologyCacheException object. |
| | | */ |
| | | protected Message getMessage(TopologyCacheException e) |
| | | protected LocalizableMessage getMessage(TopologyCacheException e) |
| | | { |
| | | return Utils.getMessage(e); |
| | | } |
| | |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | Message msg; |
| | | LocalizableMessage msg; |
| | | if (Utils.isCertificateException(ne)) |
| | | { |
| | | msg = INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER.get( |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected Message formatString(String s) { |
| | | return getFormattedLogError(Message.raw(s)); |
| | | protected LocalizableMessage formatString(String s) { |
| | | return getFormattedLogError(LocalizableMessage.raw(s)); |
| | | } |
| | | |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | protected Message formatString(String s) { |
| | | return getFormattedLog(Message.raw(s)); |
| | | protected LocalizableMessage formatString(String s) { |
| | | return getFormattedLog(LocalizableMessage.raw(s)); |
| | | } |
| | | |
| | | } |
| | |
| | | * @param string to format |
| | | * @return formatted message |
| | | */ |
| | | abstract protected Message formatString(String string); |
| | | abstract protected LocalizableMessage formatString(String string); |
| | | |
| | | /** |
| | | * Default constructor. |
| | |
| | | @Override |
| | | public void println(String msg) |
| | | { |
| | | MessageBuilder mb = new MessageBuilder(); |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); |
| | | if (isFirstLine) |
| | | { |
| | | mb.append(formatString(msg)); |
| | |
| | | */ |
| | | public void start() |
| | | { |
| | | MessageBuilder mb = new MessageBuilder(); |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); |
| | | mb.append(formatter.getSpace()); |
| | | for (int i=0; i< 5; i++) |
| | | { |
| | | mb.append(formatter.getFormattedPoint()); |
| | | } |
| | | Integer ratio = getRatio(getCurrentProgressStep()); |
| | | Message currentPhaseSummary = getSummary(getCurrentProgressStep()); |
| | | LocalizableMessage currentPhaseSummary = getSummary(getCurrentProgressStep()); |
| | | listenerDelegate.notifyListeners(getCurrentProgressStep(), |
| | | ratio, currentPhaseSummary, mb.toMessage()); |
| | | t = new Thread(this); |
| | |
| | | { |
| | | Thread.sleep(3000); |
| | | Integer ratio = getRatio(getCurrentProgressStep()); |
| | | Message currentPhaseSummary = getSummary(getCurrentProgressStep()); |
| | | LocalizableMessage currentPhaseSummary = getSummary(getCurrentProgressStep()); |
| | | listenerDelegate.notifyListeners(getCurrentProgressStep(), |
| | | ratio, currentPhaseSummary, formatter.getFormattedPoint()); |
| | | } |
| | |
| | | pointAdderStopped = true; |
| | | |
| | | Integer ratio = getRatio(getCurrentProgressStep()); |
| | | Message currentPhaseSummary = getSummary(getCurrentProgressStep()); |
| | | LocalizableMessage currentPhaseSummary = getSummary(getCurrentProgressStep()); |
| | | listenerDelegate.notifyListeners(getCurrentProgressStep(), |
| | | ratio, currentPhaseSummary, formatter.getSpace()); |
| | | } |