Examples of ArgumentException


Examples of org.nasutekds.server.util.args.ArgumentException

          if (cd == null) {
            // The name must be invalid.
            String typeUsage = getSubTypesUsage(relation.getChildDefinition());
            Message msg = ERR_DSCFG_ERROR_SUB_TYPE_UNRECOGNIZED.get(
                name, relation.getUserFriendlyName(), typeUsage);
            throw new ArgumentException(msg);
          } else {
            childName = cd.getName();
          }
        }
View Full Code Here

Examples of org.nasutekds.server.util.args.ArgumentException

      ServerProperty serverProperty = ADSContext
          .getServerPropFromName(propertyName);
      if (serverProperty == null)
      {
        Message message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
        throw new ArgumentException(message);
      }

      // Check that propName is not hidden.
      if (serverProperties.get(serverProperty).isHidden())
      {
        Message message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
        throw new ArgumentException(message);
      }

      // Check the property Syntax.
      MessageBuilder invalidReason = new MessageBuilder();
      Argument arg = serverProperties.get(serverProperty) ;
      if ( ! arg.valueIsAcceptable(value, invalidReason))
      {
        Message message =
            ERR_CLI_ERROR_INVALID_PROPERTY_VALUE.get(propertyName, value);
        throw new ArgumentException(message);
      }
      serverProperties.get(serverProperty).addValue(value);

      // add to the map.
      map.put(serverProperty, value);
    }

    // Check that all mandatory props are set.
    for (ServerProperty s : ServerProperty.values())
    {
      Argument arg = serverProperties.get(s);
      if (arg.isHidden())
      {
        continue;
      }
      if (map.containsKey(s))
      {
        continue ;
      }
      if ( ! arg.isRequired())
      {
        continue ;
      }

      // If we are here, it means that the argument is required
      // but not yet is the map. Check if we have a default value.
      if (arg.getDefaultValue() == null)
      {
        Message message =
            ERR_CLI_ERROR_MISSING_PROPERTY.get(s.getAttributeName());
        throw new ArgumentException(message);
      }
      else
      {
        map.put(s, arg.getDefaultValue());
      }
View Full Code Here

Examples of org.nasutekds.server.util.args.ArgumentException

      if (errorMessages.size() > 0)
      {
        Message message = ERR_CANNOT_INITIALIZE_ARGS.get(
            Utils.getMessageFromCollection(errorMessages,
                Constants.LINE_SEPARATOR));
        throw new ArgumentException(message);
      }
    }
  }
View Full Code Here

Examples of org.nasutekds.server.util.args.ArgumentException

    if (errorMessages.size() > 0)
    {
      Message message = ERR_CANNOT_INITIALIZE_ARGS.get(
          Utils.getMessageFromCollection(errorMessages,
              Constants.LINE_SEPARATOR));
      throw new ArgumentException(message);
    }
  }
View Full Code Here

Examples of org.nasutekds.server.util.args.ArgumentException

      if (value != null) {
        try {
          return SizeUnit.getUnit(value);
        } catch (IllegalArgumentException e) {
          Message msg = INFO_DSCFG_ERROR_SIZE_UNIT_UNRECOGNIZED.get(value);
          throw new ArgumentException(msg);
        }
      }
    }

    return null;
View Full Code Here

Examples of org.nasutekds.server.util.args.ArgumentException

      if (value != null) {
        try {
          return DurationUnit.getUnit(value);
        } catch (IllegalArgumentException e) {
          Message msg = INFO_DSCFG_ERROR_TIME_UNIT_UNRECOGNIZED.get(value);
          throw new ArgumentException(msg);
        }
      }
    }

    return null;
View Full Code Here

Examples of org.nasutekds.server.util.args.ArgumentException

      if (errorMessages.size() > 0)
      {
        Message message = ERR_CANNOT_INITIALIZE_ARGS.get(
            Utils.getMessageFromCollection(errorMessages,
                Constants.LINE_SEPARATOR));
        throw new ArgumentException(message);
      }
    }
  }
View Full Code Here

Examples of org.nasutekds.server.util.args.ArgumentException

      AdministratorProperty adminUserProperty = ADSContext
          .getAdminUserPropFromName(propertyName);
      if (adminUserProperty == null)
      {
        Message message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
        throw new ArgumentException(message);
      }

      // Check that propName is not hidden.
      if (userAdminProperties.get(adminUserProperty).isHidden())
      {
        Message message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
        throw new ArgumentException(message);
      }

      // Check the property Syntax.
      MessageBuilder invalidReason = new MessageBuilder();
      Argument arg = userAdminProperties.get(adminUserProperty) ;
      if ( ! arg.valueIsAcceptable(value, invalidReason))
      {
        Message message =
            ERR_CLI_ERROR_INVALID_PROPERTY_VALUE.get(propertyName, value);
        throw new ArgumentException(message);
      }
      if (adminUserProperty.equals(AdministratorProperty.PRIVILEGE))
      {
        // Check if 'root' privilege is requested, or
        // if it's a valid privilege
        if (value.equals(arg.getDefaultValue()))
        {
          rootPrivileges = true ;
        }
        else
        {
          String valueToCheck = value ;
          if (value.startsWith("-"))
          {
            valueToCheck = value.substring(1);
          }
          if (Privilege.privilegeForName(valueToCheck) == null)
          {
            Message message = ERR_CLI_ERROR_INVALID_PROPERTY_VALUE.get(
                AdministratorProperty.PRIVILEGE.getAttributeName(),
                valueToCheck);
            throw new ArgumentException(message);
          }
        }
      }

      // Add the value to the argument.
      arg.addValue(value);

      // add to the map.
      if (arg.isMultiValued())
      {
        map.put(adminUserProperty, arg.getValues());
      }
      else
      {
        map.put(adminUserProperty, value);
      }
    }

    // If we are not in the create admin user, just return the
    // provided atributes.
    if (! createCall)
    {
      return map ;
    }

    // Here, we are in the create case.
    // If privileges was not provided by the user, set the default value
    if (! map.containsKey(AdministratorProperty.PRIVILEGE))
    {
      rootPrivileges = true ;
    }

    // If we have root privilege, translate it to the corresponding
    // list of privileges associated to 'root' user.
    if (rootPrivileges)
    {
      LinkedList<String> privilegesList = new LinkedList<String>();
      for (Privilege p : Privilege.getDefaultRootPrivileges())
      {
        privilegesList.add(p.getName());
      }
      map.put(AdministratorProperty.PRIVILEGE,privilegesList);
    }

    for (AdministratorProperty s : AdministratorProperty.values())
    {
      Argument arg = userAdminProperties.get(s);
      if (arg.isHidden())
      {
        continue;
      }
      if (map.containsKey(s))
      {
        continue ;
      }
      if ( ! arg.isRequired())
      {
        continue ;
      }

      // If we are here, it means that the argument is required
      // but not yet is the map. Check if we have a default value.
      if (arg.getDefaultValue() == null)
      {
        Message message =
            ERR_CLI_ERROR_MISSING_PROPERTY.get(s.getAttributeName());
        throw new ArgumentException(message);
      }
      else
      {
        map.put(s, arg.getDefaultValue());
      }
View Full Code Here

Examples of org.nasutekds.server.util.args.ArgumentException

        {
          throw new CLIException(ERR_START_DATETIME_ALREADY_PASSED.get(
              startArg.getValue()));
        }
      } catch (ParseException pe) {
        throw new ArgumentException(ERR_START_DATETIME_FORMAT.get());
      }
    }

    if (recurringArg.isPresent())
    {
      try
      {
        RecurringTask.parseTaskTab(recurringArg.getValue());
      }
      catch (DirectoryException de)
      {
        throw new ArgumentException(ERR_RECURRING_SCHEDULE_FORMAT_ERROR.get(
            de.getMessageObject()), de);
      }
    }

    if (completionNotificationArg.isPresent()) {
      LinkedList<String> addrs = completionNotificationArg.getValues();
      for (String addr : addrs) {
        if (!StaticUtils.isEmailAddress(addr)) {
          throw new ArgumentException(ERR_TASKTOOL_INVALID_EMAIL_ADDRESS.get(
                  addr, completionNotificationArg.getLongIdentifier()));
        }
      }
    }

    if (errorNotificationArg.isPresent()) {
      LinkedList<String> addrs = errorNotificationArg.getValues();
      for (String addr : addrs) {
        if (!StaticUtils.isEmailAddress(addr)) {
          throw new ArgumentException(ERR_TASKTOOL_INVALID_EMAIL_ADDRESS.get(
                  addr, errorNotificationArg.getLongIdentifier()));
        }
      }
    }

    if (failedDependencyActionArg.isPresent()) {

      if (!dependencyArg.isPresent()) {
        throw new ArgumentException(ERR_TASKTOOL_FDA_WITH_NO_DEPENDENCY.get());
      }

      String fda = failedDependencyActionArg.getValue();
      if (null == FailedDependencyAction.fromString(fda)) {
        Set<FailedDependencyAction> fdaValSet =
          EnumSet.allOf(FailedDependencyAction.class);
        throw new ArgumentException(ERR_TASKTOOL_INVALID_FDA.get(fda,
                        StaticUtils.collectionToString(fdaValSet, ",")));
      }
    }
  }
View Full Code Here

Examples of org.nasutekds.server.util.args.ArgumentException

        completionNotificationArg,
        errorNotificationArg, dependencyArg, failedDependencyActionArg};
    for (Argument arg : incompatibleArgs)
    {
      if (arg.isPresent()) {
        throw new ArgumentException(ERR_TASKTOOL_OPTIONS_FOR_TASK_ONLY.get(
                arg.getLongIdentifier()));
      }
    }
    validateArgs();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.