OPENDJ-2858 Allow first attribute in LDIF change records to be empty
Thanks to Matthew Stevenson for the contribution!
| | |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | * Portions copyright 2016 Matthew Stevenson |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | |
| | | |
| | | /* |
| | | * Look at the character immediately after the colon. If there is none, |
| | | * then no value was specified. Throw an exception |
| | | * then no value was specified. Then return an empty value. |
| | | */ |
| | | final int length = ldifLine.length(); |
| | | if (colonPos == length - 1) { |
| | | pair.key = null; |
| | | pair.value = ""; |
| | | return ldifLine; |
| | | } |
| | | |
| | |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2016 ForgeRock AS. |
| | | * Portions copyright 2016 Matthew Stevenson |
| | | */ |
| | | package org.forgerock.opendj.ldif; |
| | | |
| | |
| | | // Parse the newsuperior if present. |
| | | if (record.iterator.hasNext()) { |
| | | ldifLine = readLDIFRecordKeyValuePair(record, pair, true); |
| | | if (pair.key == null || !"newsuperior".equals(toLowerCase(pair.key))) { |
| | | if (pair.key == null || !"newsuperior".equals(toLowerCase(pair.key)) || "".equals(pair.value)) { |
| | | throw DecodeException.error( |
| | | ERR_LDIF_MALFORMED_NEW_SUPERIOR.get(record.lineNumber, entryDN, ldifLine)); |
| | | } |
| | |
| | | * |
| | | * Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2014 Manuel Gaupp |
| | | * Portions copyright 2016 Matthew Stevenson |
| | | */ |
| | | |
| | | package org.forgerock.opendj.ldif; |
| | |
| | | assertThat(addRequest.getAttributeCount()).isEqualTo(10); |
| | | } |
| | | |
| | | /** |
| | | * Try to read a LDIF record with a empty first attribute |
| | | */ |
| | | @Test |
| | | public void testValueOfLDIFRecordEmptyFirstAttrLDIF() { |
| | | |
| | | // @formatter:off |
| | | LDIFChangeRecordReader.valueOfLDIFChangeRecord( |
| | | "version: 1", |
| | | "# Add a new entry", |
| | | "dn: cn=Fiona Jensen, ou=Marketing, dc=airius, dc=com", |
| | | "description:", |
| | | "objectclass: top", |
| | | "objectclass: person", |
| | | "objectclass: organizationalPerson", |
| | | "cn: Fiona Jensen", |
| | | "sn: Jensen", |
| | | "uid: fiona", |
| | | "telephonenumber: +1 408 555 1212" |
| | | ); |
| | | // @formatter:on |
| | | } |
| | | } |