public Object mapFromAttributes(Attributes attrs) throws NamingException { String sap = getAttribute("employeenumber", attrs); Person p = new Person(); p.setSap(sap); p.setFirstname(getAttribute("givenname", attrs)); p.setLastname(getAttribute("sn", attrs)); p.setMiddlename(getAttribute("initials", attrs)); p.setEmail(getAttribute("mail", attrs)); p.setWorkphone(getAttribute("telephonenumber", attrs)); p.setDepartment(getAttribute("department", attrs)); p.setJobTitle(getAttribute("title", attrs)); p.setStreetAddress(getAttribute("streetAddress", attrs)); p.setState(getAttribute("st", attrs)); p.setZipCode(getAttribute("postalCode", attrs)); return p; }
public Object mapFromAttributes(Attributes attrs) throws NamingException { Person p = null; if (getAttribute("samaccountname", attrs) != null) { try { p = personDao.getPersonByUsername(getAttribute("samaccountname", attrs)); } catch (Exception ex) { } } String username = getAttribute("samaccountname", attrs); String sap = getAttribute("employeenumber", attrs); if (username == null || username .trim() .isEmpty()) { // || sap == null || sap.trim().isEmpty()){ // @NOTE: a lot of students // don't have sap either, might have to check ldap for this... return null; // no point to return this... } if (p == null) { p = new Person(); p.setUsername(username); p.setSap(sap); p.setFirstname(getAttribute("givenname", attrs)); p.setLastname(getAttribute("sn", attrs)); p.setMiddlename(getAttribute("initials", attrs)); p.setEmail(getAttribute("mail", attrs)); p.setWorkphone(getAttribute("telephonenumber", attrs)); p.setDepartment(getAttribute("department", attrs)); p.setJobTitle(getAttribute("title", attrs)); p.setStreetAddress(getAttribute("streetAddress", attrs)); p.setState(getAttribute("st", attrs)); p.setZipCode(getAttribute("postalCode", attrs)); } return p; }