Package org.nasutekds.messages

Examples of org.nasutekds.messages.MessageBuilder


    Message cont = INFO_ORACLE_ACTION_PROMPT_CONTINUE.get();
    Message cancel = INFO_ORACLE_ACTION_PROMPT_CANCEL.get();
    if (hasIssues()) {
      List<Directive> issues = getIssues();
      if (!isSupported()) {
        MessageBuilder reason = new MessageBuilder();
        if (issues != null) {
          for (Directive directive : issues) {
            LOG.log(Level.INFO, "Unsupported reversion details: " +
                    directive.getMessage());
            reason.append(directive.getMessage());
            reason.append(EOL);
          }
        }
        throw new ApplicationException(
            ReturnCode.APPLICATION_ERROR,
                INFO_REVERSION_ORACLE_UNSUPPORTED.get(
                        currentBuildInfo.toString(),
                        newBuildInfo.toString(),
                        reason.toMessage()),
                null);
      } else {
        if (ui != null) {
          for (Directive directive : issues) {
            Message title;
            Message summary;
            Message details;
            Message defaultAction;
            UserInteraction.MessageType msgType;
            String lineBreak = ui.isCLI() ?
                Constants.LINE_SEPARATOR : Constants.HTML_LINE_BREAK;
            switch (directive.getType()) {
              case ACTION:
                title = INFO_GENERAL_ACTION_REQUIRED.get();
                summary = INFO_REVERSION_ORACLE_ACTION.get();
                details = new MessageBuilder(directive.getMessage())
                        .append(lineBreak)
                        .append(lineBreak)
                        .append(INFO_ORACLE_ACTION_PROMPT.get())
                        .toMessage();
                msgType = UserInteraction.MessageType.WARNING;
                defaultAction = cancel;
                break;
              case INFO:
                title = INFO_GENERAL_INFO.get();
                summary = INFO_REVERSION_ORACLE_INFO.get();
                details = new MessageBuilder(directive.getMessage())
                        .append(lineBreak)
                        .append(lineBreak)
                        .append(INFO_ORACLE_INFO_PROMPT.get())
                        .toMessage();
                msgType = UserInteraction.MessageType.INFORMATION;
                defaultAction = cont;
                break;
              case WARNING:
                title = INFO_GENERAL_WARNING.get();
                summary = INFO_REVERSION_ORACLE_WARNING.get();
                details = new MessageBuilder(directive.getMessage())
                        .append(lineBreak)
                        .append(lineBreak)
                        .append(INFO_ORACLE_INFO_PROMPT.get())
                        .toMessage();
                msgType = UserInteraction.MessageType.WARNING;
View Full Code Here


   * representation
   * @return the HTML representation of the summary for the given text.
   */
  public Message getFormattedSummary(Message text)
  {
    return new MessageBuilder("<html>")
            .append(UIFactory.applyFontToHtml(
                    String.valueOf(text), UIFactory.PROGRESS_FONT))
            .toMessage();
  }
View Full Code Here

  {
    String html = Utils.getHtml(String.valueOf(text));
    String points = SPACE +
            Utils.getHtml(INFO_PROGRESS_POINTS.get().toString()) + SPACE;

    MessageBuilder buf = new MessageBuilder();
    buf.append(UIFactory.applyFontToHtml(html, UIFactory.PROGRESS_FONT))
        .append(
            UIFactory.applyFontToHtml(points, UIFactory.PROGRESS_POINTS_FONT));

    return buf.toMessage();
  }
View Full Code Here

    if (effects.contains(Effect.REVERSION_DATA_EXPORT_AND_REIMPORT_REQUIRED)) {
      if (ui != null)
      {
        String lineBreak = ui.isCLI() ? Constants.LINE_SEPARATOR
            : Constants.HTML_LINE_BREAK;
        msg = new MessageBuilder(msg).append(lineBreak).append(
            ui.createUnorderedList(getExportImportInstructions())).toMessage();
      }
      else
      {
        String lineBreak = Constants.LINE_SEPARATOR;
        msg = new MessageBuilder(msg).append(lineBreak).append(
            createUnorderedList(getExportImportInstructions())).toMessage();
      }
    }
    return msg;
  }
View Full Code Here

            }

            argValue = rawArguments[++i];
          }

          MessageBuilder invalidReason = new MessageBuilder();
          if (! a.valueIsAcceptable(argValue, invalidReason))
          {
            Message message = ERR_ARGPARSER_VALUE_UNACCEPTABLE_FOR_LONG_ID.get(
                argValue, origArgName, invalidReason.toString());
            throw new ArgumentException(message);
          }

          // If the argument already has a value, then make sure it is
          // acceptable to have more than one.
          if (a.hasValue() && (! a.isMultiValued()))
          {
            Message message =
                ERR_ARGPARSER_NOT_MULTIVALUED_FOR_LONG_ID.get(origArgName);
            throw new ArgumentException(message);
          }

          a.addValue(argValue);
        }
        else
        {
          if (argValue != null)
          {
            Message message =
                ERR_ARGPARSER_ARG_FOR_LONG_ID_DOESNT_TAKE_VALUE.get(
                    origArgName);
            throw new ArgumentException(message);
          }
        }
      }
      else if (arg.startsWith("-"))
      {
        // This indicates that we are using the 1-character name to reference
        // the argument.  It may be in any of the following forms:
        // -n
        // -nvalue
        // -n value
        if (arg.equals("-"))
        {
          Message message = ERR_ARGPARSER_INVALID_DASH_AS_ARGUMENT.get();
          throw new ArgumentException(message);
        }

        char argCharacter = arg.charAt(1);
        String argValue;
        if (arg.length() > 2)
        {
          argValue = arg.substring(2);
        }
        else
        {
          argValue = null;
        }


        // Get the argument with the specified short ID.
        Argument a = shortIDMap.get(argCharacter);
        if (a == null)
        {
          if (argCharacter == '?')
          {
            // "-?" will always be interpreted as requesting usage information.
            try
            {
              getUsage(usageOutputStream);
            } catch (Exception e) {}

            return;
          }
          else
          if ( (argCharacter == OPTION_SHORT_PRODUCT_VERSION)
               &&
               ( ! shortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION)))
          {
            // "-V" will always be interpreted as requesting
            // version information except if it's already defined (e.g in
            // ldap tools).
            usageOrVersionDisplayed = true ;
            versionPresent = true;
            try
            {
              DirectoryServer.printVersion(usageOutputStream);
            } catch (Exception e) {}
            return;
          }
          else
          {
            // There is no such argument registered.
            Message message = ERR_ARGPARSER_NO_ARGUMENT_WITH_SHORT_ID.get(
                String.valueOf(argCharacter));
            throw new ArgumentException(message);
          }
        }
        else
        {
          a.setPresent(true);

          // If this is the usage argument, then immediately stop and print
          // usage information.
          if ((usageArgument != null) &&
              usageArgument.getName().equals(a.getName()))
          {
            try
            {
              getUsage(usageOutputStream);
            } catch (Exception e) {}

            return;
          }
        }

        // See if the argument takes a value.  If so, then make sure one was
        // provided.  If not, then make sure none was provided.
        if (a.needsValue())
        {
          if (argValue == null)
          {
            if ((i+1) == numArguments)
            {
              Message message =
                  ERR_ARGPARSER_NO_VALUE_FOR_ARGUMENT_WITH_SHORT_ID.
                    get(String.valueOf(argCharacter));
              throw new ArgumentException(message);
            }

            argValue = rawArguments[++i];
          }

          MessageBuilder invalidReason = new MessageBuilder();
          if (! a.valueIsAcceptable(argValue, invalidReason))
          {
            Message message = ERR_ARGPARSER_VALUE_UNACCEPTABLE_FOR_SHORT_ID.
                get(argValue, String.valueOf(argCharacter),
                    invalidReason.toString());
            throw new ArgumentException(message);
          }

          // If the argument already has a value, then make sure it is
          // acceptable to have more than one.
          if (a.hasValue() && (! a.isMultiValued()))
          {
            Message message = ERR_ARGPARSER_NOT_MULTIVALUED_FOR_SHORT_ID.get(
                String.valueOf(argCharacter));
            throw new ArgumentException(message);
          }

          a.addValue(argValue);
        }
        else
        {
          if (argValue != null)
          {
            // If we've gotten here, then it means that we're in a scenario like
            // "-abc" where "a" is a valid argument that doesn't take a value.
            // However, this could still be valid if all remaining characters in
            // the value are also valid argument characters that don't take
            // values.
            int valueLength = argValue.length();
            for (int j=0; j < valueLength; j++)
            {
              char c = argValue.charAt(j);
              Argument b = shortIDMap.get(c);
              if (b == null)
              {
                // There is no such argument registered.
                Message message = ERR_ARGPARSER_NO_ARGUMENT_WITH_SHORT_ID.get(
                    String.valueOf(argCharacter));
                throw new ArgumentException(message);
              }
              else if (b.needsValue())
              {
                // This means we're in a scenario like "-abc" where b is a
                // valid argument that takes a value.  We don't support that.
                Message message = ERR_ARGPARSER_CANT_MIX_ARGS_WITH_VALUES.get(
                    String.valueOf(argCharacter), argValue, String.valueOf(c));
                throw new ArgumentException(message);
              }
              else
              {
                b.setPresent(true);

                // If this is the usage argument, then immediately stop and
                // print usage information.
                if ((usageArgument != null) &&
                    usageArgument.getName().equals(b.getName()))
                {
                  try
                  {
                    getUsage(usageOutputStream);
                  } catch (Exception e) {}

                  return;
                }
              }
            }
          }
        }
      }
      else if (allowsTrailingArguments)
      {
        // It doesn't start with a dash, so it must be a trailing argument if
        // that is acceptable.
        inTrailingArgs = true;
        trailingArguments.add(arg);
      }
      else
      {
        // It doesn't start with a dash and we don't allow trailing arguments,
        // so this is illegal.
        Message message = ERR_ARGPARSER_DISALLOWED_TRAILING_ARGUMENT.get(arg);
        throw new ArgumentException(message);
      }
    }


    // If we allow trailing arguments and there is a minimum number, then make
    // sure at least that many were provided.
    if (allowsTrailingArguments && (minTrailingArguments > 0))
    {
      if (trailingArguments.size() < minTrailingArguments)
      {
        Message message =
            ERR_ARGPARSER_TOO_FEW_TRAILING_ARGUMENTS.get(minTrailingArguments);
        throw new ArgumentException(message);
      }
    }

    // If we don't have the argumentProperties, try to load a properties file.
    if (argumentProperties == null)
    {
      argumentProperties = checkExternalProperties();
    }

    // Iterate through all of the arguments.  For any that were not provided on
    // the command line, see if there is an alternate default that can be used.
    // For cases where there is not, see that argument is required.
    for (Argument a : argumentList)
    {
      if (! a.isPresent())
      {
        // See if there is a value in the properties that can be used
        if ((argumentProperties != null) && (a.getPropertyName() != null))
        {
          String value = argumentProperties.getProperty(a.getPropertyName()
              .toLowerCase());
          MessageBuilder invalidReason =  new MessageBuilder();
          if (value != null)
          {
            Boolean addValue = true;
            if (!( a instanceof BooleanArgument))
            {
View Full Code Here

  public Message getFormattedError(Message text, boolean applyMargin)
  {
    Message result;
    if (applyMargin)
    {
      result = new MessageBuilder().append(Constants.LINE_SEPARATOR)
              .append(text).toMessage();
    } else
    {
      result = text;
    }
View Full Code Here

  public Message getFormattedWarning(Message text, boolean applyMargin)
  {
    Message result;
    if (applyMargin)
    {
      result = new MessageBuilder(Constants.LINE_SEPARATOR)
              .append(text).toMessage();
    } else
    {
      result = text;
    }
View Full Code Here

   * @param text the String to which add points.
   * @return the plain text representation of the '.....' text string.
   */
  public Message getFormattedWithPoints(Message text)
  {
    return new MessageBuilder(text).append(SPACE)
            .append(INFO_PROGRESS_POINTS.get()).append(SPACE).toMessage();
  }
View Full Code Here

      this.requestControls  = requestControls;
    }

    resultCode                 = ResultCode.UNDEFINED;
    additionalLogMessage       = null;
    errorMessage               = new MessageBuilder();
    attachments                = new HashMap<String,Object>();
    matchedDN                  = null;
    referralURLs               = null;
    cancelResult               = null;
    isInternalOperation        = false;
View Full Code Here

   */
  public final void setErrorMessage(MessageBuilder errorMessage)
  {
    if (errorMessage == null)
    {
      this.errorMessage = new MessageBuilder();
    }
    else
    {
      this.errorMessage = errorMessage;
    }
View Full Code Here

TOP

Related Classes of org.nasutekds.messages.MessageBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.