Package org.nasutekds.messages

Examples of org.nasutekds.messages.Message


  public DN activeValue()
         throws ConfigException
  {
    if ((activeValues == null) || activeValues.isEmpty())
    {
      Message message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName());
      throw new ConfigException(message);
    }

    if (activeValues.size() > 1)
    {
      Message message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName());
      throw new ConfigException(message);
    }

    return activeValues.get(0);
  }
View Full Code Here


      return activeValue();
    }

    if ((pendingValues == null) || pendingValues.isEmpty())
    {
      Message message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName());
      throw new ConfigException(message);
    }

    if (pendingValues.size() > 1)
    {
      Message message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName());
      throw new ConfigException(message);
    }

    return pendingValues.get(0);
  }
View Full Code Here

        // Check for referral entries above the target.
        targetEntryReferrals(txn, entry.getDN(), null);
        long parentID = dn2id.getID(txn, parentDN,
          NdbOperation.LockMode.LM_Read);
        if (parentID == 0) {
          Message message = ERR_NDB_ADD_NO_SUCH_OBJECT.get(
                  entry.getDN().toString());
          DN matchedDN = getMatchedDN(txn, baseDN);
          throw new DirectoryException(ResultCode.NO_SUCH_OBJECT,
              message, matchedDN, null);
        }
      }

      // First time through, assign the next entryID.
      if (entryID == 0)
      {
        entryID = rootContainer.getNextEntryID(txn.getNdb());
      }

      // Insert.
      try {
        dn2id.insert(txn, entry.getDN(), entryID, entry);
        if (!willCommit) {
          txn.execute();
        }
      } catch (NdbApiException ne) {
        if (ne.getErrorObj().getClassification() ==
          NdbError.Classification.ConstraintViolation)
        {
          Message message =
            ERR_NDB_ADD_ENTRY_ALREADY_EXISTS.get(entry.getDN().toString());
          throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS,
            message);
        } else {
          throw ne;
View Full Code Here

  public void setValue(DN value)
         throws ConfigException
  {
    if (value == null)
    {
      Message message = ERR_CONFIG_ATTR_DN_NULL.get(getName());
      throw new ConfigException(message);
    }

    if (requiresAdminAction())
    {
View Full Code Here

    // First check if the set is empty and if that is allowed.
    if ((values == null) || (values.isEmpty()))
    {
      if (isRequired())
      {
        Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(getName());
        throw new ConfigException(message);
      }
      else
      {
        if (requiresAdminAction())
        {
          setPendingValues(new LinkedHashSet<AttributeValue>(0));
          pendingValues = new ArrayList<DN>();
        }
        else
        {
          setActiveValues(new LinkedHashSet<AttributeValue>(0));
          activeValues.clear();
        }
      }
    }


    // Next check if the set contains multiple values and if that is allowed.
    int numValues = values.size();
    if ((! isMultiValued()) && (numValues > 1))
    {
      Message message =
          ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName());
      throw new ConfigException(message);
    }


    // Iterate through all the provided values, make sure that they are
    // acceptable, and build the value set.
    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    for (DN value : values)
    {
      if (value == null)
      {
        Message message = ERR_CONFIG_ATTR_DN_NULL.get(getName());
        throw new ConfigException(message);
      }

      AttributeValue attrValue =
          AttributeValues.create(ByteString.valueOf(value.toString()),
              ByteString.valueOf(value.toNormalizedString()));

      if (valueSet.contains(attrValue))
      {
        Message message =
            ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get(
                    getName(), String.valueOf(value));
        throw new ConfigException(message);
      }
View Full Code Here

  {
    if ((valueStrings == null) || valueStrings.isEmpty())
    {
      if (isRequired())
      {
        Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(getName());
        throw new ConfigException(message);
      }
      else
      {
        return new LinkedHashSet<AttributeValue>();
      }
    }


    int numValues = valueStrings.size();
    if ((! isMultiValued()) && (numValues > 1))
    {
      Message message =
          ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName());
      throw new ConfigException(message);
    }


    LinkedHashSet<AttributeValue> valueSet =
         new LinkedHashSet<AttributeValue>(numValues);
    for (String valueString : valueStrings)
    {
      if (valueString == null)
      {
        Message message = ERR_CONFIG_ATTR_DN_NULL.get(getName());
        if (allowFailures)
        {
          ErrorLogger.logError(message);
          continue;
        }
        else
        {
          throw new ConfigException(message);
        }
      }


      DN dn;
      try
      {
        dn = DN.decode(valueString);
      }
      catch (Exception e)
      {
        if (debugEnabled())
        {
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }

        Message message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
                valueString, getName(),
                String.valueOf(e));

        if (allowFailures)
        {
          ErrorLogger.logError(message);
          continue;
        }
        else
        {
          throw new ConfigException(message);
        }
      }


      valueSet.add(AttributeValues.create(ByteString.valueOf(dn.toString()),
          ByteString.valueOf(dn.toNormalizedString())));
    }


    // If this method was configured to continue on error, then it is possible
    // that we ended up with an empty list.  Check to see if this is a required
    // attribute and if so deal with it accordingly.
    if ((isRequired()) && valueSet.isEmpty())
    {
      Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(getName());
      throw new ConfigException(message);
    }


    return valueSet;
View Full Code Here

        if (a.hasOption(OPTION_PENDING_VALUES))
        {
          if (pendingValues != null)
          {
            // We cannot have multiple pending value sets.
            Message message =
                ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(a.getName());
            throw new ConfigException(message);
          }


          if (a.isEmpty())
          {
            if (isRequired())
            {
              // This is illegal -- it must have a value.
              Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
              throw new ConfigException(message);
            }
            else
            {
              // This is fine.  The pending value set can be empty.
              pendingValues = new ArrayList<DN>(0);
            }
          }
          else
          {
            int numValues = a.size();
            if ((numValues > 1) && (! isMultiValued()))
            {
              // This is illegal -- the attribute is single-valued.
              Message message =
                  ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getName());
              throw new ConfigException(message);
            }

            pendingValues = new ArrayList<DN>(numValues);
            for (AttributeValue v : a)
            {
              DN dn;
              try
              {
                dn = DN.decode(v.getValue().toString());
              }
              catch (Exception e)
              {
                if (debugEnabled())
                {
                  TRACER.debugCaught(DebugLogLevel.ERROR, e);
                }

                Message message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
                    v.getValue().toString(), getName(), String.valueOf(e));
                throw new ConfigException(message, e);
              }

              pendingValues.add(dn);
            }
          }
        }
        else
        {
          // This is illegal -- only the pending option is allowed for
          // configuration attributes.
          Message message =
              ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(a.getName());
          throw new ConfigException(message);
        }
      }
      else
      {
        // This must be the active value.
        if (activeValues!= null)
        {
          // We cannot have multiple active value sets.
          Message message =
              ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(a.getName());
          throw new ConfigException(message);
        }


        if (a.isEmpty())
        {
          if (isRequired())
          {
            // This is illegal -- it must have a value.
            Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
            throw new ConfigException(message);
          }
          else
          {
            // This is fine.  The active value set can be empty.
            activeValues = new ArrayList<DN>(0);
          }
        }
        else
        {
          int numValues = a.size();
          if ((numValues > 1) && (! isMultiValued()))
          {
            // This is illegal -- the attribute is single-valued.
            Message message =
                ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getName());
            throw new ConfigException(message);
          }

          activeValues = new ArrayList<DN>(numValues);
          for (AttributeValue v : a)
          {
            DN dn;
            try
            {
              dn = DN.decode(v.getValue().toString());
            }
            catch (Exception e)
            {
              if (debugEnabled())
              {
                TRACER.debugCaught(DebugLogLevel.ERROR, e);
              }

              Message message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
                  v.getValue().toString(), getName(), String.valueOf(e));
              throw new ConfigException(message, e);
            }

            activeValues.add(dn);
          }
        }
      }
    }

    if (activeValues == null)
    {
      // This is not OK.  The value set must contain an active value.
      Message message = ERR_CONFIG_ATTR_NO_ACTIVE_VALUE_SET.get(getName());
      throw new ConfigException(message);
    }

    if (pendingValues == null)
    {
View Full Code Here

         throws ConfigException
  {
    Object value = jmxAttribute.getValue();
    if (value == null)
    {
      Message message = ERR_CONFIG_ATTR_DN_NULL.get(getName());
      throw new ConfigException(message);
    }
    else if (value instanceof DN)
    {
      setValue((DN) value);
    }
    if (value instanceof String)
    {
      DN dn;
      try
      {
        dn = DN.decode((String) value);
      }
      catch (Exception e)
      {
        if (debugEnabled())
        {
          TRACER.debugCaught(DebugLogLevel.ERROR, e);
        }

        Message message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
            (String) value, getName(), String.valueOf(e));
        throw new ConfigException(message, e);
      }

      setValue(dn);
    }
    else if (value.getClass().isArray())
    {
      String componentType = value.getClass().getComponentType().getName();
      int length = Array.getLength(value);


      if (componentType.equals(DN.class.getName()))
      {
        ArrayList<DN> dnList = new ArrayList<DN>(length);
        for (int i=0; i < length; i++)
        {
          dnList.add((DN) Array.get(value, i));
        }

        setValues(dnList);
      }
      else if (componentType.equals(String.class.getName()))
      {
        try
        {
          ArrayList<DN> values = new ArrayList<DN>(length);
          for (int i=0; i < length; i++)
          {
            String valueStr = (String) Array.get(value, i);

            DN dn;
            try
            {
              dn = DN.decode(valueStr);
            }
            catch (Exception e)
            {
              if (debugEnabled())
              {
                TRACER.debugCaught(DebugLogLevel.ERROR, e);
              }

              Message message = ERR_CONFIG_ATTR_DN_CANNOT_PARSE.get(
                  valueStr, getName(), String.valueOf(e));
              throw new ConfigException(message, e);
            }

            values.add(dn);
          }

          setValues(values);
        }
        catch (ConfigException ce)
        {
          if (debugEnabled())
          {
            TRACER.debugCaught(DebugLogLevel.ERROR, ce);
          }

          throw ce;
        }
        catch (Exception e)
        {
          if (debugEnabled())
          {
            TRACER.debugCaught(DebugLogLevel.ERROR, e);
          }

          Message message = ERR_CONFIG_ATTR_INVALID_DN_VALUE.get(
              getName(), String.valueOf(value), String.valueOf(e));
          throw new ConfigException(message, e);
        }
      }
      else
      {
        Message message =
            ERR_CONFIG_ATTR_DN_INVALID_ARRAY_TYPE.get(
                    String.valueOf(jmxAttribute),
                    String.valueOf(componentType));
        throw new ConfigException(message);
      }
    }
    else
    {
      Message message = ERR_CONFIG_ATTR_DN_INVALID_TYPE.get(
          String.valueOf(value), getName(), value.getClass().getName());
      throw new ConfigException(message);
    }
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void notifyUser() throws ApplicationException {
    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:
View Full Code Here

   * {@inheritDoc}
   */
  protected Message getLocalizedDetailMessage(
          VersionCompatibilityIssue.Cause cause)
  {
    Message msg = cause.getLocalizedReversionMessage();

    // See if we need to supply a generic message
    Set<VersionCompatibilityIssue.Effect> effects = cause.getEffects();

    // If the import/export effect is present, append the detailed
View Full Code Here

TOP

Related Classes of org.nasutekds.messages.Message

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.