[kune-commits] r1386 - in trunk: . script src/main/java/cc/kune/core/server/manager/impl src/main/java/cc/kune/core/server/xmpp src/main/resources src/test/java/org/ourproject/kune/chat/server/managers

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Fri May 13 12:56:38 CEST 2011


Author: vjrj_
Date: 2011-05-13 12:56:37 +0200 (Fri, 13 May 2011)
New Revision: 1386

Added:
   trunk/src/test/java/org/ourproject/kune/chat/server/managers/XmppManagerDefaultTest.java
Removed:
   trunk/src/test/java/org/ourproject/kune/chat/server/managers/XmppManagerTest.java
Modified:
   trunk/.classpath
   trunk/pom.xml
   trunk/script/css-update.sh
   trunk/script/kune client  -no-server.launch
   trunk/script/mvn-eclipse.sh
   trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
   trunk/src/main/java/cc/kune/core/server/xmpp/XmppManagerDefault.java
   trunk/src/main/resources/wave-server.properties
Log:
Chat welcome fixed, other updates to 0.0.8

Modified: trunk/.classpath
===================================================================
--- trunk/.classpath	2011-05-12 17:15:39 UTC (rev 1385)
+++ trunk/.classpath	2011-05-13 10:56:37 UTC (rev 1386)
@@ -2,7 +2,7 @@
   <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
   <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
   <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
-  <classpathentry kind="output" path="target/kune-0.0.7/WEB-INF/classes"/>
+  <classpathentry kind="output" path="target/kune-0.0.8/WEB-INF/classes"/>
   <classpathentry kind="var" path="M2_REPO/javax/inject/javax.inject/1/javax.inject-1.jar" sourcepath="M2_REPO/javax/inject/javax.inject/1/javax.inject-1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.1/jta-1.1.jar" sourcepath="M2_REPO/javax/transaction/jta/1.1/jta-1.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar" sourcepath="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0-sources.jar"/>
@@ -107,8 +107,8 @@
   <classpathentry kind="var" path="M2_REPO/org/waveprotocol/proto-msg/0.3.0-SNAPSHOT/proto-msg-0.3.0-SNAPSHOT.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jivesoftware/smack/smack/3.0.4/smack-3.0.4.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jivesoftware/smackx/smackx/3.0.4/smackx-3.0.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jivesoftware/smack/3.1.0/smack-3.1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jivesoftware/smackx/3.1.0/smackx-3.1.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/jivesoftware/smackx/debugger/smackx-debugger/3.0.4/smackx-debugger-3.0.4.jar"/>
   <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0.1/stax-api-1.0.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/waveprotocol/util-src/0.3.0-SNAPSHOT/util-src-0.3.0-SNAPSHOT.jar"/>

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2011-05-12 17:15:39 UTC (rev 1385)
+++ trunk/pom.xml	2011-05-13 10:56:37 UTC (rev 1386)
@@ -324,14 +324,14 @@
       <version>r1697</version>
     </dependency>
     <dependency>
-      <groupId>org.jivesoftware.smack</groupId>
+      <groupId>jivesoftware</groupId>
       <artifactId>smack</artifactId>
-      <version>3.0.4</version>
+      <version>3.1.0</version>
     </dependency>
     <dependency>
-      <groupId>org.jivesoftware.smackx</groupId>
+      <groupId>jivesoftware</groupId>
       <artifactId>smackx</artifactId>
-      <version>3.0.4</version>
+      <version>3.1.0</version>
     </dependency>
     <dependency>
       <groupId>org.jivesoftware.smackx.debugger</groupId>

Modified: trunk/script/css-update.sh
===================================================================
--- trunk/script/css-update.sh	2011-05-12 17:15:39 UTC (rev 1385)
+++ trunk/script/css-update.sh	2011-05-13 10:56:37 UTC (rev 1386)
@@ -9,12 +9,14 @@
 #rsync -aC $APPPUB/css/ $WEBAPP/css
 #rsync -aC $APPPUB/images/ $WEBAPP/images
 
-cp src/main/java/cc/kune/chat/public/kune-chat.css target/kune-0.0.7/ws/
-cp src/main/java/cc/kune/chat/public/kune-hablar.css target/kune-0.0.7/ws/
-cp src/main/java/cc/kune/msgs/public/kune-message.css target/kune-0.0.7/ws/
-cp src/main/java/cc/kune/common/public/kune-common.css target/kune-0.0.7/ws/
-cp src/main/java/cc/kune/core/public/ws.css target/kune-0.0.7/ws/
-cp src/main/java/cc/kune/core/public/ws.html target/kune-0.0.7/ws/
-#cp src/main/webapp/templates/basic/basic.css  target/kune-0.0.7/templates/basic/basic.css 
-#cp src/main/webapp/templates/basic/docs.liquid.html  target/kune-0.0.7/templates/basic/
-cp src/main/java/cc/kune/common/public/gxt-custom/css/gxt-op-common.css target/kune-0.0.7/ws/gxt-custom/css/gxt-op-common.css
+VERSION=0.0.8
+
+cp src/main/java/cc/kune/chat/public/kune-chat.css target/kune-$VERSION/ws/
+cp src/main/java/cc/kune/chat/public/kune-hablar.css target/kune-$VERSION/ws/
+cp src/main/java/cc/kune/msgs/public/kune-message.css target/kune-$VERSION/ws/
+cp src/main/java/cc/kune/common/public/kune-common.css target/kune-$VERSION/ws/
+cp src/main/java/cc/kune/core/public/ws.css target/kune-$VERSION/ws/
+cp src/main/java/cc/kune/core/public/ws.html target/kune-$VERSION/ws/
+#cp src/main/webapp/templates/basic/basic.css  target/kune-$VERSION/templates/basic/basic.css 
+#cp src/main/webapp/templates/basic/docs.liquid.html  target/kune-$VERSION/templates/basic/
+cp src/main/java/cc/kune/common/public/gxt-custom/css/gxt-op-common.css target/kune-$VERSION/ws/gxt-custom/css/gxt-op-common.css

Modified: trunk/script/kune client  -no-server.launch
===================================================================
--- trunk/script/kune client  -no-server.launch	2011-05-12 17:15:39 UTC (rev 1385)
+++ trunk/script/kune client  -no-server.launch	2011-05-13 10:56:37 UTC (rev 1386)
@@ -20,7 +20,7 @@
 </listAttribute>
 <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gwt.eclipse.core.moduleClasspathProvider"/>
 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.DevMode"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-war /home/vjrj/proyectos/dev/kune/trunk/target/kune-0.0.7 -startupUrl /ws/?locale=en&amp;log_level=INFO -noserver -remoteUI &quot;${gwt_remote_ui_server_port}:${unique_id}&quot; -logLevel INFO -codeServerPort 9997 cc.kune.Kune"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-war /home/vjrj/proyectos/dev/kune/trunk/target/kune-0.0.8 -startupUrl /ws/?locale=en&amp;log_level=INFO -noserver -remoteUI &quot;${gwt_remote_ui_server_port}:${unique_id}&quot; -logLevel INFO -codeServerPort 9997 cc.kune.Kune"/>
 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="kune"/>
 <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512m"/>
 </launchConfiguration>

Modified: trunk/script/mvn-eclipse.sh
===================================================================
--- trunk/script/mvn-eclipse.sh	2011-05-12 17:15:39 UTC (rev 1385)
+++ trunk/script/mvn-eclipse.sh	2011-05-13 10:56:37 UTC (rev 1386)
@@ -1,4 +1,4 @@
-mvn eclipse:eclipse -o -Dgwt.compiler.skip=true
+mvn eclipse:eclipse -Dgwt.compiler.skip=true
 RESULT=$?
 perl -p -i -e 's/<\/classpath>//g' .classpath
 #perl -p -i -e 's/\/home\/vjrj\/nfsdev\///g' .classpath

Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java	2011-05-12 17:15:39 UTC (rev 1385)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java	2011-05-13 10:56:37 UTC (rev 1386)
@@ -23,6 +23,8 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.TimeZone;
+import java.util.Timer;
+import java.util.TimerTask;
 
 import javax.persistence.EntityManager;
 import javax.persistence.NoResultException;
@@ -64,212 +66,221 @@
 @Singleton
 public class UserManagerDefault extends DefaultManager<User, Long> implements UserManager {
 
-    private final ChatProperties chatProperties;
-    private final I18nCountryManager countryManager;
-    private final DatabaseProperties databaseProperties;
-    private final UserFinder finder;
-    private final I18nTranslationService i18n;
-    private final KuneWaveManager kuneWaveManager;
-    private final I18nLanguageManager languageManager;
-    private final ParticipantUtils participantUtils;
-    private final AccountStore waveAccountStore;
-    // private final PropertiesManager propManager;
-    private final CustomUserRegistrationServlet waveUserRegister;
-    private final XmppManager xmppManager;
+  private final ChatProperties chatProperties;
+  private final I18nCountryManager countryManager;
+  private final DatabaseProperties databaseProperties;
+  private final UserFinder finder;
+  private final I18nTranslationService i18n;
+  private final KuneWaveManager kuneWaveManager;
+  private final I18nLanguageManager languageManager;
+  private final ParticipantUtils participantUtils;
+  private final AccountStore waveAccountStore;
+  // private final PropertiesManager propManager;
+  private final CustomUserRegistrationServlet waveUserRegister;
+  private final XmppManager xmppManager;
 
-    @Inject
-    public UserManagerDefault(final Provider<EntityManager> provider, final UserFinder finder,
-            final I18nLanguageManager languageManager, final I18nCountryManager countryManager,
-            final XmppManager xmppManager, final ChatProperties chatProperties, final I18nTranslationService i18n,
-            final CustomUserRegistrationServlet waveUserRegister, final AccountStore waveAccountStore,
-            final KuneWaveManager kuneWaveManager, final ParticipantUtils participantUtils,
-            final DatabaseProperties databaseProperties) {
-        super(provider, User.class);
-        this.finder = finder;
-        this.languageManager = languageManager;
-        this.countryManager = countryManager;
-        this.xmppManager = xmppManager;
-        this.chatProperties = chatProperties;
-        this.i18n = i18n;
-        this.waveUserRegister = waveUserRegister;
-        this.waveAccountStore = waveAccountStore;
-        this.kuneWaveManager = kuneWaveManager;
-        this.participantUtils = participantUtils;
-        this.databaseProperties = databaseProperties;
-    }
+  @Inject
+  public UserManagerDefault(final Provider<EntityManager> provider, final UserFinder finder,
+      final I18nLanguageManager languageManager, final I18nCountryManager countryManager,
+      final XmppManager xmppManager, final ChatProperties chatProperties,
+      final I18nTranslationService i18n, final CustomUserRegistrationServlet waveUserRegister,
+      final AccountStore waveAccountStore, final KuneWaveManager kuneWaveManager,
+      final ParticipantUtils participantUtils, final DatabaseProperties databaseProperties) {
+    super(provider, User.class);
+    this.finder = finder;
+    this.languageManager = languageManager;
+    this.countryManager = countryManager;
+    this.xmppManager = xmppManager;
+    this.chatProperties = chatProperties;
+    this.i18n = i18n;
+    this.waveUserRegister = waveUserRegister;
+    this.waveAccountStore = waveAccountStore;
+    this.kuneWaveManager = kuneWaveManager;
+    this.participantUtils = participantUtils;
+    this.databaseProperties = databaseProperties;
+  }
 
-    @Override
-    public User createUser(final String shortName, final String longName, final String email, final String passwd,
-            final String langCode, final String countryCode, final String timezone) throws I18nNotFoundException {
-        I18nLanguage language;
-        I18nCountry country;
-        TimeZone tz;
-        try {
-            language = languageManager.findByCode(langCode);
-            country = countryManager.findByCode(countryCode);
-            tz = TimeZone.getTimeZone(timezone);
-        } catch (final NoResultException e) {
-            throw new I18nNotFoundException();
-        }
-        final PasswordDigest passwdDigest = new PasswordDigest(passwd.toCharArray());
-
-        try {
-            createWaveAccount(shortName, passwdDigest);
-        } catch (final UserRegistrationException e) {
-            try {
-                if (finder.getByShortName(shortName) != null) {
-                    throw new GroupNameInUseException();
-                } else {
-                    // Other kind of exception
-                    throw e;
-                }
-            } catch (final NoResultException e2) {
-                // Other kind of exception
-                throw e;
-            }
-        }
-        // if (userPropGroup == null) {
-        // userPropGroup = propGroupManager.find(User.PROPS_ID);
-        // }
-        // final Properties userProp = new Properties(userPropGroup);
-        // propManager.persist(userProp);
-        try {
-            final User user = new User(shortName, longName, email, passwd, passwdDigest.getDigest(),
-                    passwdDigest.getSalt(), language, country, tz);
-            kuneWaveManager.createWave(
-                    ContentConstants.WELCOME_WAVE_CONTENT_TITLE.replaceAll("\\[%s\\]",
-                            databaseProperties.getDefaultSiteName()),
-                    ContentConstants.WELCOME_WAVE_CONTENT.replaceAll("\\[%s\\]",
-                            databaseProperties.getDefaultSiteName()),
-                    participantUtils.of(databaseProperties.getAdminShortName()), participantUtils.of(shortName));
-            return user;
-        } catch (final RuntimeException e) {
-            try {
-                // Try to remove wave account
-                waveAccountStore.removeAccount(participantUtils.of(shortName));
-            } catch (final Exception e2) {
-                throw e;
-            }
-            throw e;
-        }
+  @Override
+  public User createUser(final String shortName, final String longName, final String email,
+      final String passwd, final String langCode, final String countryCode, final String timezone)
+      throws I18nNotFoundException {
+    I18nLanguage language;
+    I18nCountry country;
+    TimeZone tz;
+    try {
+      language = languageManager.findByCode(langCode);
+      country = countryManager.findByCode(countryCode);
+      tz = TimeZone.getTimeZone(timezone);
+    } catch (final NoResultException e) {
+      throw new I18nNotFoundException();
     }
+    final PasswordDigest passwdDigest = new PasswordDigest(passwd.toCharArray());
 
-    @Override
-    public void createWaveAccount(final String shortName, final PasswordDigest passwdDigest) {
-        final String msg = waveUserRegister.tryCreateUser(shortName, passwdDigest);
-        if (msg != null) {
-            throw new UserRegistrationException(msg);
+    try {
+      createWaveAccount(shortName, passwdDigest);
+    } catch (final UserRegistrationException e) {
+      try {
+        if (finder.getByShortName(shortName) != null) {
+          throw new GroupNameInUseException();
+        } else {
+          // Other kind of exception
+          throw e;
         }
+      } catch (final NoResultException e2) {
+        // Other kind of exception
+        throw e;
+      }
     }
-
-    @Override
-    public User find(final Long userId) {
-        try {
-            return finder.getById(userId);
-        } catch (final NoResultException e) {
-            return User.UNKNOWN_USER;
-        }
+    // if (userPropGroup == null) {
+    // userPropGroup = propGroupManager.find(User.PROPS_ID);
+    // }
+    // final Properties userProp = new Properties(userPropGroup);
+    // propManager.persist(userProp);
+    try {
+      final User user = new User(shortName, longName, email, passwd, passwdDigest.getDigest(),
+          passwdDigest.getSalt(), language, country, tz);
+      kuneWaveManager.createWave(
+          ContentConstants.WELCOME_WAVE_CONTENT_TITLE.replaceAll("\\[%s\\]",
+              databaseProperties.getDefaultSiteName()),
+          ContentConstants.WELCOME_WAVE_CONTENT.replaceAll("\\[%s\\]",
+              databaseProperties.getDefaultSiteName()),
+          participantUtils.of(databaseProperties.getAdminShortName()), participantUtils.of(shortName));
+      return user;
+    } catch (final RuntimeException e) {
+      try {
+        // Try to remove wave account
+        waveAccountStore.removeAccount(participantUtils.of(shortName));
+      } catch (final Exception e2) {
+        throw e;
+      }
+      throw e;
     }
+  }
 
-    @Override
-    public User findByShortname(final String shortName) {
-        return finder.getByShortName(shortName);
+  @Override
+  public void createWaveAccount(final String shortName, final PasswordDigest passwdDigest) {
+    final String msg = waveUserRegister.tryCreateUser(shortName, passwdDigest);
+    if (msg != null) {
+      throw new UserRegistrationException(msg);
     }
+  }
 
-    public List<User> getAll() {
-        return finder.getAll();
+  @Override
+  public User find(final Long userId) {
+    try {
+      return finder.getById(userId);
+    } catch (final NoResultException e) {
+      return User.UNKNOWN_USER;
     }
+  }
 
-    @Override
-    @Deprecated
-    public UserBuddiesData getUserBuddies(final String shortName) {
-        // XEP-133 get roster by admin part is not implemented in openfire
-        // also access to the openfire db is not easy with hibernate (the use of
-        // two db at the same time). This compromise solution is server
-        // independent.
-        // In the future cache this.
-        final String domain = "@" + chatProperties.getDomain();
-        final UserBuddiesData buddiesData = new UserBuddiesData();
+  @Override
+  public User findByShortname(final String shortName) {
+    return finder.getByShortName(shortName);
+  }
 
-        final User user = finder.getByShortName(shortName);
-        Collection<RosterEntry> roster;
-        try {
-            final ChatConnection connection = xmppManager.login(user.getShortName() + domain, user.getPassword(),
-                    "kserver");
-            roster = xmppManager.getRoster(connection);
-            xmppManager.disconnect(connection);
-        } catch (final ChatException e) {
-            // Seems that it not possible to get the buddy list, then we follow
-            // with a empty buddy list
-            log.error("Cannot retrieve the buddie list", e);
-            roster = new HashSet<RosterEntry>();
-        }
-        for (final RosterEntry entry : roster) {
-            if (entry.getType().equals(ItemType.both)) {
-                // only show buddies with subscription 'both'
-                final int index = entry.getUser().indexOf(domain);
-                if (index > 0) {
-                    // local user
-                    try {
-                        String username = entry.getUser().substring(0, index);
-                        final User buddie = finder.getByShortName(username);
-                        buddiesData.getBuddies().add(buddie);
-                    } catch (final NoResultException e) {
-                        // No existent buddie, skip
-                    }
-                } else {
-                    // ext user (only count)
-                    buddiesData.setOtherExtBuddies(buddiesData.getOtherExtBuddies() + 1);
-                }
-            }
-        }
-        return buddiesData;
+  public List<User> getAll() {
+    return finder.getAll();
+  }
+
+  @Override
+  @Deprecated
+  public UserBuddiesData getUserBuddies(final String shortName) {
+    // XEP-133 get roster by admin part is not implemented in openfire
+    // also access to the openfire db is not easy with hibernate (the use of
+    // two db at the same time). This compromise solution is server
+    // independent.
+    // In the future cache this.
+    final String domain = "@" + chatProperties.getDomain();
+    final UserBuddiesData buddiesData = new UserBuddiesData();
+
+    final User user = finder.getByShortName(shortName);
+    Collection<RosterEntry> roster;
+    try {
+      final ChatConnection connection = xmppManager.login(user.getShortName() + domain,
+          user.getPassword(), "kserver");
+      roster = xmppManager.getRoster(connection);
+      xmppManager.disconnect(connection);
+    } catch (final ChatException e) {
+      // Seems that it not possible to get the buddy list, then we follow
+      // with a empty buddy list
+      log.error("Cannot retrieve the buddie list", e);
+      roster = new HashSet<RosterEntry>();
     }
-
-    @Override
-    public User login(final String nickOrEmail, final String passwd) {
-        User user;
-        try {
-            user = finder.getByShortName(nickOrEmail);
-        } catch (final NoResultException e) {
-            try {
-                user = finder.getByEmail(nickOrEmail);
-            } catch (final NoResultException e2) {
-                return null;
-            }
-        }
-        if (user.getPassword().equals(passwd)) {
-            if (user.getLastLogin() == null) {
-                xmppManager.sendMessage(
-                        user.getShortName(),
-                        i18n.t("This is the chat window. "
-                                + ""
-                                + "Here you can communicate with other users of this site but also with other users with compatible accounts (like gmail accounts). "
-                                + "" + "Just add some buddie and start to chat."));
-            }
-            user.setLastLogin(System.currentTimeMillis());
-            return user;
+    for (final RosterEntry entry : roster) {
+      if (entry.getType().equals(ItemType.both)) {
+        // only show buddies with subscription 'both'
+        final int index = entry.getUser().indexOf(domain);
+        if (index > 0) {
+          // local user
+          try {
+            final String username = entry.getUser().substring(0, index);
+            final User buddie = finder.getByShortName(username);
+            buddiesData.getBuddies().add(buddie);
+          } catch (final NoResultException e) {
+            // No existent buddie, skip
+          }
         } else {
-            return null;
+          // ext user (only count)
+          buddiesData.setOtherExtBuddies(buddiesData.getOtherExtBuddies() + 1);
         }
+      }
     }
+    return buddiesData;
+  }
 
-    @Override
-    public SearchResult<User> search(final String search) {
-        return this.search(search, null, null);
+  @Override
+  public User login(final String nickOrEmail, final String passwd) {
+    User user;
+    try {
+      user = finder.getByShortName(nickOrEmail);
+    } catch (final NoResultException e) {
+      try {
+        user = finder.getByEmail(nickOrEmail);
+      } catch (final NoResultException e2) {
+        return null;
+      }
     }
+    if (user.getPassword().equals(passwd)) {
+      if (user.getLastLogin() == null) {
+        final String userName = user.getShortName();
+        final Timer timer = new Timer();
+        timer.schedule(new TimerTask() {
+          @Override
+          public void run() {
+            xmppManager.sendMessage(
+                userName,
+                i18n.t("This is the chat window. "
+                    + ""
+                    + "Here you can communicate with other users of this site but also with other users with compatible accounts (like gmail accounts). "
+                    + "" + "Just add some buddie and start to chat."));
+          }
+        }, 5000);
+      }
+      user.setLastLogin(System.currentTimeMillis());
+      return user;
+    } else {
+      return null;
+    }
+  }
 
-    @Override
-    public SearchResult<User> search(final String search, final Integer firstResult, final Integer maxResults) {
-        final MultiFieldQueryParser parser = new MultiFieldQueryParser(new String[] { "name", "shortName" },
-                new StandardAnalyzer());
-        Query query;
-        try {
-            query = parser.parse(search);
-        } catch (final ParseException e) {
-            throw new ServerManagerException("Error parsing search", e);
-        }
-        return super.search(query, firstResult, maxResults);
+  @Override
+  public SearchResult<User> search(final String search) {
+    return this.search(search, null, null);
+  }
+
+  @Override
+  public SearchResult<User> search(final String search, final Integer firstResult,
+      final Integer maxResults) {
+    final MultiFieldQueryParser parser = new MultiFieldQueryParser(new String[] { "name", "shortName" },
+        new StandardAnalyzer());
+    Query query;
+    try {
+      query = parser.parse(search);
+    } catch (final ParseException e) {
+      throw new ServerManagerException("Error parsing search", e);
     }
+    return super.search(query, firstResult, maxResults);
+  }
 
 }

Modified: trunk/src/main/java/cc/kune/core/server/xmpp/XmppManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/xmpp/XmppManagerDefault.java	2011-05-12 17:15:39 UTC (rev 1385)
+++ trunk/src/main/java/cc/kune/core/server/xmpp/XmppManagerDefault.java	2011-05-13 10:56:37 UTC (rev 1386)
@@ -34,6 +34,7 @@
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
 import org.jivesoftware.smack.packet.Message;
+import org.jivesoftware.smack.packet.Message.Type;
 import org.jivesoftware.smackx.Form;
 import org.jivesoftware.smackx.FormField;
 import org.jivesoftware.smackx.muc.MultiUserChat;
@@ -45,150 +46,160 @@
 
 @Singleton
 public class XmppManagerDefault implements XmppManager {
-    public static final Log LOG = LogFactory.getLog(XmppManagerDefault.class);
+  public static final Log LOG = LogFactory.getLog(XmppManagerDefault.class);
 
-    private final ChatProperties chatProperties;
+  private final ChatProperties chatProperties;
 
-    @Inject
-    public XmppManagerDefault(final ChatProperties chatProperties) {
-        this.chatProperties = chatProperties;
-    }
+  @Inject
+  public XmppManagerDefault(final ChatProperties chatProperties) {
+    this.chatProperties = chatProperties;
+  }
 
-    public Room createRoom(final ChatConnection conn, final String roomName, final String alias) {
-        XmppConnection xConn = (XmppConnection) conn;
-        MultiUserChat muc = new MultiUserChat(xConn.getConn(), getRoomName(roomName));
-        try {
-            muc.create(alias);
-            configure(muc);
-            XmppRoom room = new XmppRoom(muc, alias);
-            muc.addMessageListener(room);
-            return room;
-        } catch (XMPPException e) {
-            throw new ChatException(e);
-        }
-    }
+  private void configure(final MultiUserChat muc) throws XMPPException {
+    final Form form = muc.getConfigurationForm();
+    final Form answer = form.createAnswerForm();
 
-    public void destroyRoom(final ChatConnection conn, final String roomName) {
-        XmppConnection xConn = (XmppConnection) conn;
-        MultiUserChat muc = new MultiUserChat(xConn.getConn(), getRoomName(roomName));
-        try {
-            muc.destroy("Room removed by kune server", "");
-        } catch (XMPPException e) {
-            throw new ChatException(e);
+    for (final Iterator<FormField> fields = form.getFields(); fields.hasNext();) {
+      final FormField field = fields.next();
+      final String type = field.getType();
+      if (isVisible(type) && isNotEmpty(field) && isNotList(type)) {
+        final List<String> values = new ArrayList<String>();
+        for (final Iterator<String> it = field.getValues(); it.hasNext();) {
+          values.add(it.next());
         }
+        answer.setAnswer(field.getVariable(), values);
+      }
     }
+    answer.setAnswer("muc#roomconfig_persistentroom", true);
+    muc.sendConfigurationForm(answer);
+  }
 
-    public void disconnect(final ChatConnection connection) {
-        XmppConnection xConn = (XmppConnection) connection;
-        xConn.getConn().disconnect();
-
+  @Override
+  public Room createRoom(final ChatConnection conn, final String roomName, final String alias) {
+    final XmppConnection xConn = (XmppConnection) conn;
+    final MultiUserChat muc = new MultiUserChat(xConn.getConn(), getRoomName(roomName));
+    try {
+      muc.create(alias);
+      configure(muc);
+      final XmppRoom room = new XmppRoom(muc, alias);
+      muc.addMessageListener(room);
+      return room;
+    } catch (final XMPPException e) {
+      throw new ChatException(e);
     }
+  }
 
-    public Collection<RosterEntry> getRoster(final ChatConnection conn) {
-        XmppConnection xConn = (XmppConnection) conn;
-        Roster roster = xConn.getConn().getRoster();
-        return roster.getEntries();
+  @Override
+  public void destroyRoom(final ChatConnection conn, final String roomName) {
+    final XmppConnection xConn = (XmppConnection) conn;
+    final MultiUserChat muc = new MultiUserChat(xConn.getConn(), getRoomName(roomName));
+    try {
+      muc.destroy("Room removed by kune server", "");
+    } catch (final XMPPException e) {
+      throw new ChatException(e);
     }
+  }
 
-    public Room joinRoom(final ChatConnection connection, final String roomName, final String alias) {
-        XmppConnection xConn = (XmppConnection) connection;
-        MultiUserChat muc = new MultiUserChat(xConn.getConn(), getRoomName(roomName));
-        try {
-            muc.join(alias);
-            // configure(muc);
-            XmppRoom room = new XmppRoom(muc, alias);
-            muc.addMessageListener(room);
-            return room;
-        } catch (XMPPException e) {
-            throw new ChatException(e);
-        }
-    }
+  @Override
+  public void disconnect(final ChatConnection connection) {
+    final XmppConnection xConn = (XmppConnection) connection;
+    xConn.getConn().disconnect();
 
-    public ChatConnection login(final String userName, final String password, final String resource) {
-        ConnectionConfiguration config = new ConnectionConfiguration(getServerName(), 5222);
-        XMPPConnection conn = new XMPPConnection(config);
-        try {
-            conn.connect();
-            conn.login(userName, password, resource, true);
-            return new XmppConnection(userName, conn);
-        } catch (XMPPException e) {
-            throw new ChatException(e);
-        }
-    }
+  }
 
-    public void sendMessage(final Room room, final String body) {
-        XmppRoom xAccess = (XmppRoom) room;
-        MultiUserChat muc = xAccess.getMuc();
-        Message message = muc.createMessage();
-        message.setBody(body);
-        message.setFrom(muc.getNickname());
-        try {
-            muc.sendMessage(body);
-        } catch (XMPPException e) {
-            throw new ChatException(e);
-        }
-    }
+  private String getRoomName(final String room) {
+    return room + "@" + chatProperties.getRoomHost();
+  }
 
-    public void sendMessage(final String userName, final String text) {
-        ChatConnection connection = login(chatProperties.getAdminJID(), chatProperties.getAdminPasswd(),
-                "kuneserveradmin" + System.currentTimeMillis());
-        XMPPConnection xmppConn = ((XmppConnection) connection).getConn();
+  @Override
+  public Collection<RosterEntry> getRoster(final ChatConnection conn) {
+    final XmppConnection xConn = (XmppConnection) conn;
+    final Roster roster = xConn.getConn().getRoster();
+    return roster.getEntries();
+  }
 
-        String userJid = userName + "@" + chatProperties.getDomain();
-        Chat newChat = xmppConn.getChatManager().createChat(userJid, new MessageListener() {
-            public void processMessage(final Chat arg0, final Message arg1) {
-                LOG.info("Sended message: " + text);
-            }
-        });
-        try {
-            final Message message = new Message();
-            message.setFrom(chatProperties.getDomain());
-            message.setTo(userJid);
-            message.setBody(text);
-            newChat.sendMessage(message);
-        } catch (Exception e) {
-            LOG.error("Error Delivering xmpp message to " + userName);
-        }
-        xmppConn.disconnect();
-    }
+  private String getServerName() {
+    return chatProperties.getDomain();
+  }
 
-    private void configure(final MultiUserChat muc) throws XMPPException {
-        Form form = muc.getConfigurationForm();
-        Form answer = form.createAnswerForm();
+  private boolean isNotEmpty(final FormField field) {
+    return field.getVariable() != null;
+  }
 
-        for (Iterator<FormField> fields = form.getFields(); fields.hasNext();) {
-            FormField field = fields.next();
-            String type = field.getType();
-            if (isVisible(type) && isNotEmpty(field) && isNotList(type)) {
-                List<String> values = new ArrayList<String>();
-                for (Iterator<String> it = field.getValues(); it.hasNext();) {
-                    values.add(it.next());
-                }
-                answer.setAnswer(field.getVariable(), values);
-            }
-        }
-        answer.setAnswer("muc#roomconfig_persistentroom", true);
-        muc.sendConfigurationForm(answer);
-    }
+  private boolean isNotList(final String type) {
+    return !FormField.TYPE_JID_MULTI.equals(type) && !FormField.TYPE_LIST_MULTI.equals(type)
+        && !FormField.TYPE_LIST_SINGLE.equals(type) && !isVisible(type);
+  }
 
-    private String getRoomName(final String room) {
-        return room + "@" + chatProperties.getRoomHost();
-    }
+  private boolean isVisible(final String type) {
+    return !FormField.TYPE_HIDDEN.equals(type);
+  }
 
-    private String getServerName() {
-        return chatProperties.getDomain();
+  @Override
+  public Room joinRoom(final ChatConnection connection, final String roomName, final String alias) {
+    final XmppConnection xConn = (XmppConnection) connection;
+    final MultiUserChat muc = new MultiUserChat(xConn.getConn(), getRoomName(roomName));
+    try {
+      muc.join(alias);
+      // configure(muc);
+      final XmppRoom room = new XmppRoom(muc, alias);
+      muc.addMessageListener(room);
+      return room;
+    } catch (final XMPPException e) {
+      throw new ChatException(e);
     }
+  }
 
-    private boolean isNotEmpty(final FormField field) {
-        return field.getVariable() != null;
+  @Override
+  public ChatConnection login(final String userName, final String password, final String resource) {
+    final ConnectionConfiguration config = new ConnectionConfiguration(getServerName(), 5222);
+    final XMPPConnection conn = new XMPPConnection(config);
+    try {
+      conn.connect();
+      conn.login(userName, password, resource);
+      return new XmppConnection(userName, conn);
+    } catch (final XMPPException e) {
+      throw new ChatException(e);
     }
+  }
 
-    private boolean isNotList(final String type) {
-        return !FormField.TYPE_JID_MULTI.equals(type) && !FormField.TYPE_LIST_MULTI.equals(type)
-                && !FormField.TYPE_LIST_SINGLE.equals(type) && !isVisible(type);
+  @Override
+  public void sendMessage(final Room room, final String body) {
+    final XmppRoom xAccess = (XmppRoom) room;
+    final MultiUserChat muc = xAccess.getMuc();
+    final Message message = muc.createMessage();
+    message.setBody(body);
+    message.setFrom(muc.getNickname());
+    try {
+      muc.sendMessage(body);
+    } catch (final XMPPException e) {
+      throw new ChatException(e);
     }
+  }
 
-    private boolean isVisible(final String type) {
-        return !FormField.TYPE_HIDDEN.equals(type);
+  @Override
+  public void sendMessage(final String userName, final String text) {
+    final ChatConnection connection = login(chatProperties.getAdminJID(),
+        chatProperties.getAdminPasswd(), "kuneserveradmin" + System.currentTimeMillis());
+    final XMPPConnection xmppConn = ((XmppConnection) connection).getConn();
+    final String userJid = userName + "@" + chatProperties.getDomain();
+    final Chat newChat = xmppConn.getChatManager().createChat(userJid, new MessageListener() {
+      @Override
+      public void processMessage(final Chat arg0, final Message arg1) {
+        LOG.info("Sended message: " + arg1.getBody());
+      }
+    });
+    try {
+      final Message message = new Message();
+      message.setFrom(chatProperties.getDomain());
+      message.setTo(userJid);
+      message.setType(Type.normal);
+      message.setBody(text);
+      message.setSubject("");
+      newChat.sendMessage(message);
+    } catch (final Exception e) {
+      LOG.error("Error Delivering xmpp message to " + userName + ": ", e);
     }
+    xmppConn.disconnect();
+  }
 }

Modified: trunk/src/main/resources/wave-server.properties
===================================================================
--- trunk/src/main/resources/wave-server.properties	2011-05-12 17:15:39 UTC (rev 1385)
+++ trunk/src/main/resources/wave-server.properties	2011-05-13 10:56:37 UTC (rev 1386)
@@ -8,7 +8,7 @@
 # Each address is a comma separated host:port pair.
 http_frontend_public_address = localhost:8888
 http_frontend_addresses = ${http_frontend_public_address}
-resource_bases = target/kune-0.0.7/,src/main/webapp/
+resource_bases = target/kune-0.0.8/,src/main/webapp/
 
 ### Server-specific variables
 ###

Copied: trunk/src/test/java/org/ourproject/kune/chat/server/managers/XmppManagerDefaultTest.java (from rev 1377, trunk/src/test/java/org/ourproject/kune/chat/server/managers/XmppManagerTest.java)
===================================================================
--- trunk/src/test/java/org/ourproject/kune/chat/server/managers/XmppManagerDefaultTest.java	                        (rev 0)
+++ trunk/src/test/java/org/ourproject/kune/chat/server/managers/XmppManagerDefaultTest.java	2011-05-13 10:56:37 UTC (rev 1386)
@@ -0,0 +1,119 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.chat.server.managers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import cc.kune.core.server.integration.IntegrationTestHelper;
+import cc.kune.core.server.xmpp.ChatConnection;
+import cc.kune.core.server.xmpp.ChatException;
+import cc.kune.core.server.xmpp.Room;
+import cc.kune.core.server.xmpp.RoomListener;
+import cc.kune.core.server.xmpp.XmppManager;
+
+import com.google.inject.Inject;
+
+public class XmppManagerDefaultTest {
+  public static class OutputListener implements RoomListener {
+    private int hits;
+    private final String name;
+
+    public OutputListener(final String name) {
+      this.name = name;
+      this.hits = 0;
+    }
+
+    public int getHits() {
+      return hits;
+    }
+
+    @Override
+    public void onMessage(final String from, final String to, final String body) {
+      log.debug("Al listener " + name + "ha llegado: ");
+      log.debug(from + "- " + to + ": " + body);
+      hits++;
+    }
+
+  }
+
+  static Log log = LogFactory.getLog(XmppManagerDefaultTest.class);
+
+  @Inject
+  XmppManager manager;
+
+  @Before
+  public void init() {
+    IntegrationTestHelper.createInjector().injectMembers(this);
+  }
+
+  @Ignore
+  public void testBroadcast() {
+    final String roomName = "roomName";
+    final ChatConnection conn1 = manager.login("testUser1", "easy1", "test");
+    final ChatConnection conn2 = manager.login("testUser2", "easy2", "test");
+    final Room room1 = manager.createRoom(conn1, roomName, "user1Alias");
+    final OutputListener listener1 = new OutputListener("1");
+    room1.setListener(listener1);
+    final Room room2 = manager.joinRoom(conn2, roomName, "user2Alias");
+    final OutputListener listener2 = new OutputListener("2");
+    room2.setListener(listener2);
+
+    manager.sendMessage(room1, "usuario1 dice uno");
+    manager.sendMessage(room2, "usuario2 dice dos");
+    manager.sendMessage(room1, "usuario1 dice tres");
+    manager.sendMessage(room2, "usuario2 dice cuatro");
+    try {
+      Thread.sleep(4000);
+    } catch (final InterruptedException e) {
+      e.printStackTrace();
+    }
+    assertEquals(4, listener1.getHits());
+    assertEquals(4, listener2.getHits());
+  }
+
+  @Test
+  public void testConnection() {
+    final ChatConnection handler1 = manager.login("admin", "easyeasy", "test");
+    assertNotNull(handler1);
+  }
+
+  @Test
+  public void testGetRoster() {
+    final ChatConnection handler = manager.login("admin", "easyeasy", "test");
+    assertNotNull(manager.getRoster(handler));
+  }
+
+  @Test
+  public void testSendMessage() {
+    manager.sendMessage("admin", "test message");
+  }
+
+  @Test(expected = ChatException.class)
+  public void testUserDontExist() {
+    manager.login("user", "password", "test");
+  }
+}

Deleted: trunk/src/test/java/org/ourproject/kune/chat/server/managers/XmppManagerTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/chat/server/managers/XmppManagerTest.java	2011-05-12 17:15:39 UTC (rev 1385)
+++ trunk/src/test/java/org/ourproject/kune/chat/server/managers/XmppManagerTest.java	2011-05-13 10:56:37 UTC (rev 1386)
@@ -1,118 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.chat.server.managers;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import cc.kune.core.server.integration.IntegrationTestHelper;
-import cc.kune.core.server.xmpp.ChatConnection;
-import cc.kune.core.server.xmpp.ChatException;
-import cc.kune.core.server.xmpp.Room;
-import cc.kune.core.server.xmpp.RoomListener;
-import cc.kune.core.server.xmpp.XmppManager;
-
-import com.google.inject.Inject;
-
-public class XmppManagerTest {
-    public static class OutputListener implements RoomListener {
-        private final String name;
-        private int hits;
-
-        public OutputListener(final String name) {
-            this.name = name;
-            this.hits = 0;
-        }
-
-        public int getHits() {
-            return hits;
-        }
-
-        public void onMessage(final String from, final String to, final String body) {
-            log.debug("Al listener " + name + "ha llegado: ");
-            log.debug(from + "- " + to + ": " + body);
-            hits++;
-        }
-
-    }
-
-    static Log log = LogFactory.getLog(XmppManagerTest.class);
-
-    @Inject
-    XmppManager manager;
-
-    @Before
-    public void init() {
-        IntegrationTestHelper.createInjector().injectMembers(this);
-    }
-
-    @Ignore
-    public void testBroadcast() {
-        String roomName = "roomName";
-        ChatConnection conn1 = manager.login("testUser1", "easy1", "test");
-        ChatConnection conn2 = manager.login("testUser2", "easy2", "test");
-        Room room1 = manager.createRoom(conn1, roomName, "user1Alias");
-        OutputListener listener1 = new OutputListener("1");
-        room1.setListener(listener1);
-        Room room2 = manager.joinRoom(conn2, roomName, "user2Alias");
-        OutputListener listener2 = new OutputListener("2");
-        room2.setListener(listener2);
-
-        manager.sendMessage(room1, "usuario1 dice uno");
-        manager.sendMessage(room2, "usuario2 dice dos");
-        manager.sendMessage(room1, "usuario1 dice tres");
-        manager.sendMessage(room2, "usuario2 dice cuatro");
-        try {
-            Thread.sleep(4000);
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-        assertEquals(4, listener1.getHits());
-        assertEquals(4, listener2.getHits());
-    }
-
-    @Test
-    public void testConnection() {
-        ChatConnection handler1 = manager.login("admin", "easyeasy", "test");
-        assertNotNull(handler1);
-    }
-
-    @Test
-    public void testGetRoster() {
-        ChatConnection handler = manager.login("admin", "easyeasy", "test");
-        assertNotNull(manager.getRoster(handler));
-    }
-
-    @Test
-    public void testSendMessage() {
-        manager.sendMessage("admin", "test message");
-    }
-
-    @Test(expected = ChatException.class)
-    public void testUserDontExist() {
-        manager.login("user", "passowrd", "test");
-    }
-}




More information about the kune-commits mailing list