diff --git a/src/main/java/org/gcube/portal/ldapexport/LDAPSync.java b/src/main/java/org/gcube/portal/ldapexport/LDAPSync.java index 4a4a327..bd73a57 100644 --- a/src/main/java/org/gcube/portal/ldapexport/LDAPSync.java +++ b/src/main/java/org/gcube/portal/ldapexport/LDAPSync.java @@ -64,7 +64,7 @@ public class LDAPSync implements Runnable { DirContext ctx = new InitialDirContext(env); _log.debug("Initiating LDAP Sync ..."); for (User user : users) { - updateUserInLDAP(user.getScreenName(), user.getFirstName(), user.getLastName(), user.getEmailAddress(), "{SHA}"+user.getPassword(), ctx, filter); + updateUserInLDAP(user.getScreenName(), user.getFirstName(), user.getLastName(), user.getFullName(), user.getEmailAddress(), "{SHA}"+user.getPassword(), ctx, filter); //_log.debug("Updated " + user.getScreenName()); } _log.debug("LDAP Sync cycle done"); @@ -104,19 +104,22 @@ public class LDAPSync implements Runnable { * @param ctx * @throws NamingException */ - private void updateUserInLDAP(String username, String name, String lastName, String email, String passwd, DirContext ctx, String filter) throws NamingException { + private void updateUserInLDAP(String username, String name, String lastName, String fullName, String email, String passwd, DirContext ctx, String filter) throws NamingException { Attributes attributes=new BasicAttributes(); Attribute objectClass=new BasicAttribute("objectClass"); objectClass.add("inetOrgPerson"); attributes.put(objectClass); - Attribute sn = new BasicAttribute("sn"); + //the main ldap server uses 'givenName' for the First name, 'cn' for "first name last name', 'sn' for the last name + Attribute givenName = new BasicAttribute("givenName"); Attribute cn = new BasicAttribute("cn"); + Attribute sn = new BasicAttribute("sn"); Attribute mail = new BasicAttribute("mail"); Attribute userPassword = new BasicAttribute("userPassword"); - - sn.add(name); - cn.add(lastName); + + givenName.add(name); + cn.add(fullName); + sn.add(lastName); mail.add(email); userPassword.add(passwd); diff --git a/src/main/java/org/gcube/portal/socialmail/PeriodicTask.java b/src/main/java/org/gcube/portal/socialmail/PeriodicTask.java index cdc1a5e..8ec46d8 100644 --- a/src/main/java/org/gcube/portal/socialmail/PeriodicTask.java +++ b/src/main/java/org/gcube/portal/socialmail/PeriodicTask.java @@ -105,7 +105,7 @@ public class PeriodicTask implements Runnable { _log.debug("Created fakesession for user " + username + " email="+emailAddress); } catch (PortalException | SystemException e) { - e.printStackTrace(); + _log.error("Exception while trying to get the user from email address: " + e.getMessage()); } @@ -206,6 +206,12 @@ public class PeriodicTask implements Runnable { * @param fakeSession */ private void favoriteFeed(String feedId, ASLSession fakeSession) { + if (feedId == null || feedId.compareTo("") == 0) { + _log.warn("Found email with no feedId from " + fakeSession.getUserEmailAddress() + ". Going to trash it"); + return; + } + + Like like = new Like(UUID.randomUUID().toString(), fakeSession.getUsername(), new Date(), feedId, fakeSession.getUserFullName(), fakeSession.getUserAvatarId());