// Create the message.
  private static Message createMessage(
      ServerManagedObject<?> partialManagedObject, Collection<PropertyException> causes) {
    Validator.ensureNotNull(causes);
    Validator.ensureTrue(!causes.isEmpty());

    ManagedObjectDefinition<?, ?> d = partialManagedObject.getManagedObjectDefinition();
    if (causes.size() == 1) {
      return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_SINGLE.get(
          d.getUserFriendlyName(), causes.iterator().next().getMessageObject());
    } else {
      MessageBuilder builder = new MessageBuilder();

      boolean isFirst = true;
      for (PropertyException cause : causes) {
        if (!isFirst) {
          builder.append("; ");
        }
        builder.append(cause.getMessageObject());
        isFirst = false;
      }

      return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_PLURAL.get(
          d.getUserFriendlyName(), builder.toMessage());
    }
  }
Esempio n. 2
0
  /** {@inheritDoc} */
  @Override
  public void configureBackend(Configuration cfg) throws ConfigException {
    Validator.ensureNotNull(cfg);
    Validator.ensureTrue(cfg instanceof LocalDBBackendCfg);

    this.cfg = (LocalDBBackendCfg) cfg;

    Set<DN> dnSet = this.cfg.getBaseDN();
    baseDNs = new DN[dnSet.size()];
    dnSet.toArray(baseDNs);
  }
 /**
  * Add an attribute which should be part of the add operation.
  *
  * @param expectedName The name of the expected attribute.
  * @param expectedValues The attribute's expected values (never empty).
  */
 public void addExpectedAttribute(String expectedName, String... expectedValues) {
   Validator.ensureNotNull(expectedName);
   Validator.ensureNotNull(expectedValues);
   Validator.ensureTrue(expectedValues.length > 0);
   attributes.put(expectedName, Arrays.asList(expectedValues));
 }