You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2014/03/15 11:32:47 UTC
svn commit: r1577821 -
/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/UserPreferencesStorage.java
Author: manolo
Date: Sat Mar 15 10:32:46 2014
New Revision: 1577821
URL: http://svn.apache.org/r1577821
Log:
Do not repeat contacts
Modified:
james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/UserPreferencesStorage.java
Modified: james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/UserPreferencesStorage.java
URL: http://svn.apache.org/viewvc/james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/UserPreferencesStorage.java?rev=1577821&r1=1577820&r2=1577821&view=diff
==============================================================================
--- james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/UserPreferencesStorage.java (original)
+++ james/hupa/trunk/server/src/main/java/org/apache/hupa/server/preferences/UserPreferencesStorage.java Sat Mar 15 10:32:46 2014
@@ -32,8 +32,6 @@ import java.util.List;
*/
public abstract class UserPreferencesStorage {
- protected static final String CONTACTS_ATTR = "contacts";
-
protected static final String REGEX_OMITTED_EMAILS = "^.*(reply)[A-z0-9._%\\+\\-]*@.*$";
/**
@@ -59,12 +57,26 @@ public abstract class UserPreferencesSto
final public void addContact(List<String> mails) {
if (mails != null) {
for (String mail: mails) {
- if (mail != null && !mail.matches(REGEX_OMITTED_EMAILS)) {
+ if (mail != null && !mail.matches(REGEX_OMITTED_EMAILS)) {
Contact contact = new Contact(mail);
- addContact(contact);
- }
+ if (!exists(contact)) {
+ addContact(contact);
+ }
+ }
+ }
+ }
+ }
+
+ boolean exists (Contact mail) {
+ for (Contact c : getContacts()) {
+ if (c.mail.equals(mail.mail)) {
+ if (c.realname == null || c.realname.isEmpty() || c.realname.equals(c.mail)) {
+ c.realname = mail.realname;
+ }
+ return true;
}
}
+ return false;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org