private void mapToContext(Person person, DirContextAdapter context) { context.setAttributeValues("objectclass", new String[] {"top", "person"}); context.setAttributeValue("cn", person.getFullName()); context.setAttributeValue("sn", person.getLastName()); context.setAttributeValue("description", person.getDescription()); context.setAttributeValue("telephoneNumber", person.getPhone()); }
@Override public Person doMapFromContext(DirContextOperations context) { Person person = new Person(); LdapName dn = LdapUtils.newLdapName(context.getDn()); person.setCountry(LdapUtils.getStringValue(dn, 0)); person.setCompany(LdapUtils.getStringValue(dn, 1)); person.setFullName(context.getStringAttribute("cn")); person.setLastName(context.getStringAttribute("sn")); person.setDescription(context.getStringAttribute("description")); person.setPhone(context.getStringAttribute("telephoneNumber")); return person; }
private LdapName buildDn(Person person) { return buildDn(person.getCountry(), person.getCompany(), person.getFullName()); }