added skipping email not having feedid

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-mail-servlet@117406 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-07-22 10:41:44 +00:00
parent eb38012be0
commit f62d01ed69
2 changed files with 16 additions and 7 deletions

View File

@ -64,7 +64,7 @@ public class LDAPSync implements Runnable {
DirContext ctx = new InitialDirContext(env); DirContext ctx = new InitialDirContext(env);
_log.debug("Initiating LDAP Sync ..."); _log.debug("Initiating LDAP Sync ...");
for (User user : users) { 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("Updated " + user.getScreenName());
} }
_log.debug("LDAP Sync cycle done"); _log.debug("LDAP Sync cycle done");
@ -104,19 +104,22 @@ public class LDAPSync implements Runnable {
* @param ctx * @param ctx
* @throws NamingException * @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(); Attributes attributes=new BasicAttributes();
Attribute objectClass=new BasicAttribute("objectClass"); Attribute objectClass=new BasicAttribute("objectClass");
objectClass.add("inetOrgPerson"); objectClass.add("inetOrgPerson");
attributes.put(objectClass); 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 cn = new BasicAttribute("cn");
Attribute sn = new BasicAttribute("sn");
Attribute mail = new BasicAttribute("mail"); Attribute mail = new BasicAttribute("mail");
Attribute userPassword = new BasicAttribute("userPassword"); Attribute userPassword = new BasicAttribute("userPassword");
sn.add(name); givenName.add(name);
cn.add(lastName); cn.add(fullName);
sn.add(lastName);
mail.add(email); mail.add(email);
userPassword.add(passwd); userPassword.add(passwd);

View File

@ -105,7 +105,7 @@ public class PeriodicTask implements Runnable {
_log.debug("Created fakesession for user " + username + " email="+emailAddress); _log.debug("Created fakesession for user " + username + " email="+emailAddress);
} catch (PortalException | SystemException e) { } 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 * @param fakeSession
*/ */
private void favoriteFeed(String feedId, ASLSession 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(), Like like = new Like(UUID.randomUUID().toString(), fakeSession.getUsername(),
new Date(), feedId, fakeSession.getUserFullName(), fakeSession.getUserAvatarId()); new Date(), feedId, fakeSession.getUserFullName(), fakeSession.getUserAvatarId());