mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

neil_a_wilson
11.07.2007 e0a75206da315ac78816dcef9b7a6e44946f6e54
opendj-sdk/opends/src/server/org/opends/server/util/LDIFReader.java
@@ -79,9 +79,6 @@
 */
public final class LDIFReader
{
  // The reader that will be used to read the data.
  private BufferedReader reader;
@@ -243,7 +240,7 @@
        for (StringBuilder line : lines)
        {
          readAttribute(lines, line, entryDN, objectClasses, userAttributes,
                        operationalAttributes);
                        operationalAttributes, checkSchema);
        }
      }
      catch (LDIFException e)
@@ -814,6 +811,8 @@
   *                                for the current entry.
   * @param  operationalAttributes  The set of operational attributes decoded so
   *                                far for the current entry.
   * @param  checkSchema            Indicates whether to perform schema
   *                                validation for the attribute.
   *
   * @throws  LDIFException  If a problem occurs while trying to decode the
   *                         attribute contained in the provided entry.
@@ -822,7 +821,8 @@
       StringBuilder line, DN entryDN,
       HashMap<ObjectClass,String> objectClasses,
       HashMap<AttributeType,List<Attribute>> userAttributes,
       HashMap<AttributeType,List<Attribute>> operationalAttributes)
       HashMap<AttributeType,List<Attribute>> operationalAttributes,
       boolean checkSchema)
          throws LDIFException
  {
    // Parse the attribute type description.
@@ -934,14 +934,40 @@
          LinkedHashSet<AttributeValue> valueSet = a.getValues();
          if (valueSet.contains(attributeValue))
          {
            int    msgID   = MSGID_LDIF_DUPLICATE_ATTR;
            String message = getMessage(msgID, String.valueOf(entryDN),
                                        lastEntryLineNumber, attrName,
                                        value.stringValue());
            logToRejectWriter(lines, message);
            throw new LDIFException(msgID, message, lastEntryLineNumber, true);
            if (! checkSchema)
            {
              // If we're not doing schema checking, then it is possible that
              // the attribute type should use case-sensitive matching and the
              // values differ in capitalization.  Only reject the proposed
              // value if we find another value that is exactly the same as the
              // one that was provided.
              for (AttributeValue v : valueSet)
              {
                if (v.getValue().equals(attributeValue.getValue()))
                {
                  int    msgID   = MSGID_LDIF_DUPLICATE_ATTR;
                  String message = getMessage(msgID, String.valueOf(entryDN),
                                              lastEntryLineNumber, attrName,
                                              value.stringValue());
                  logToRejectWriter(lines, message);
                  throw new LDIFException(msgID, message, lastEntryLineNumber,
                                          true);
                }
              }
            }
            else
            {
              int    msgID   = MSGID_LDIF_DUPLICATE_ATTR;
              String message = getMessage(msgID, String.valueOf(entryDN),
                                          lastEntryLineNumber, attrName,
                                          value.stringValue());
              logToRejectWriter(lines, message);
              throw new LDIFException(msgID, message, lastEntryLineNumber,
                                      true);
            }
          }
          else if (attrType.isSingleValue() && (! valueSet.isEmpty()))
          if (attrType.isSingleValue() && (! valueSet.isEmpty()) && checkSchema)
          {
            int    msgID   = MSGID_LDIF_MULTIPLE_VALUES_FOR_SINGLE_VALUED_ATTR;
            String message = getMessage(msgID, String.valueOf(entryDN),
@@ -949,11 +975,9 @@
            logToRejectWriter(lines, message);
            throw new LDIFException(msgID, message, lastEntryLineNumber, true);
          }
          else
          {
            valueSet.add(attributeValue);
            return;
          }
          valueSet.add(attributeValue);
          return;
        }
      }
@@ -1469,7 +1493,7 @@
    for(StringBuilder line : lines)
    {
      readAttribute(lines, line, entryDN, objectClasses,
          attributes, attributes);
          attributes, attributes, importConfig.validateSchema());
    }
    // Reconstruct the object class attribute.