@Override public void handleRecord(LdapAttributes attributes) { callbackAttributeName = attributes.getName().toString(); } }
LOG.trace("Starting new record."); record = new LdapAttributes(caseInsensitive); builder = new StringBuilder(line); throw new InvalidRecordFormatException("Record [dn: " + record.getDN() + "] does not conform to specification.");
private static void loadLdif(DirContext context, Resource ldifFile) throws IOException { try { DistinguishedName baseDn = (DistinguishedName) context.getEnvironment() .get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY); LdifParser parser = new LdifParser(ldifFile); parser.open(); while (parser.hasMoreRecords()) { LdapAttributes record = parser.getRecord(); DistinguishedName dn = record.getDN(); if (baseDn != null) { dn.removeFirst(baseDn); } context.bind(dn, null, record); } } catch (NamingException e) { throw new RuntimeException("Failed to populate LDIF", e); } }
/** * Returns a {@link java.lang.String String} containing a properly formated LDIF. * * @param item LdapAttributes object to convert to string. * @return string representation of the object LDIF format (in accordance with RFC 2849). */ public String aggregate(LdapAttributes item) { return item.toString(); }
LOG.trace("Starting new record."); record = new LdapAttributes(caseInsensitive); builder = new StringBuilder(line); throw new InvalidRecordFormatException("Record [dn: " + record.getDN() + "] does not conform to specification.");
/** * Returns a {@link java.lang.String String} containing a properly formated LDIF. * * @param item LdapAttributes object to convert to string. * @return string representation of the object LDIF format (in accordance with RFC 2849). */ public String aggregate(LdapAttributes item) { return item.toString(); }
@Override public void handleRecord(LdapAttributes attributes) { callbackAttributeName = attributes.getName().toString(); } }
LOG.trace("Starting new record."); record = new LdapAttributes(caseInsensitive); builder = new StringBuilder(line); throw new InvalidRecordFormatException("Record [dn: " + record.getDN() + "] does not conform to specification.");
@Test public void testBasicRead() throws Exception { this.ldifReader = new LdifReaderBuilder().resource(context.getResource("classpath:/test.ldif")).name("foo").build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the first record did not match expected result", "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", ldapAttributes.getName().toString()); }
@Test public void testCurrentItemCount() throws Exception { this.ldifReader = new LdifReaderBuilder().currentItemCount(3) .resource(context.getResource("classpath:/test.ldif")).name("foo").build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the third record did not match expected result", "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", ldapAttributes.getName().toString()); }