Repository: incubator-wave
Updated Branches:
  refs/heads/master 3682cf914 -> 5e949d0a1


Profile fetcher selection and new initials avatars

Review: https://reviews.apache.org/r/19116/


Project: http://git-wip-us.apache.org/repos/asf/incubator-wave/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-wave/commit/5e949d0a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-wave/tree/5e949d0a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-wave/diff/5e949d0a

Branch: refs/heads/master
Commit: 5e949d0a1f31b81b22e769f17cf8eb6cde317eb0
Parents: 3682cf9
Author: Vicente J. Ruiz Jurado <[email protected]>
Authored: Tue Apr 1 17:45:40 2014 +0200
Committer: Vicente J. Ruiz Jurado <[email protected]>
Committed: Tue Apr 1 17:45:40 2014 +0200

----------------------------------------------------------------------
 .classpath                                      |  3 ++
 build.xml                                       |  3 ++
 server-config.xml                               |  2 +
 server.config.example                           |  4 ++
 .../waveprotocol/box/server/CoreSettings.java   |  5 ++
 src/org/waveprotocol/box/server/ServerMain.java | 11 ++--
 .../box/server/robots/ProfileFetcherModule.java | 57 ++++++++++++++++++++
 .../box/server/robots/RobotApiModule.java       |  3 --
 .../operations/InitialsProfilesFetcher.java     | 49 +++++++++++++++++
 9 files changed, 131 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/5e949d0a/.classpath
----------------------------------------------------------------------
diff --git a/.classpath b/.classpath
index 2b1822f..13b243f 100644
--- a/.classpath
+++ b/.classpath
@@ -83,5 +83,8 @@
        <classpathentry kind="lib" 
path="third_party/codegen/gwt-user-2.5.1.jar"/>
        <classpathentry kind="lib" 
path="third_party/codegen/validation-api-1.1.0.Final-sources.jar"/>
        <classpathentry kind="lib" 
path="third_party/codegen/validation-api-1.1.0.Final.jar"/>
+       <classpathentry kind="lib" 
path="third_party/runtime/gwt-initials-avatars-shared-1.0-20140324.102812-16.jar"/>
+       <classpathentry kind="lib" 
path="third_party/runtime/gwt-initials-avatars-shared-1.0-20140324.102812-16-sources.jar"/>
+       <classpathentry kind="lib" 
path="third_party/runtime/gwt-initials-avatars-server-1.0-20140324.102825-10.jar"/>
        <classpathentry kind="output" path="bin"/>
 </classpath>

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/5e949d0a/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 0681b16..ae3ba88 100644
--- a/build.xml
+++ b/build.xml
@@ -1035,6 +1035,9 @@
       <url 
url="http://central.maven.org/maven2/xpp3/xpp3/1.1.4c/xpp3-1.1.4c.jar"; />
       <url 
url="http://central.maven.org/maven2/xpp3/xpp3_xpath/1.1.4c/xpp3_xpath-1.1.4c.jar";
 />
       <url 
url="http://repo1.maven.org/maven2/org/gnu/inet/libidn/1.15/libidn-1.15.jar"; />
+      <url 
url="http://archiva.comunes.org/repository/comunes-snapshots/cc/kune/gwt-initials-avatars-shared/1.0-SNAPSHOT/gwt-initials-avatars-shared-1.0-20140324.102812-16.jar";
 />
+      <url 
url="http://archiva.comunes.org/repository/comunes-snapshots/cc/kune/gwt-initials-avatars-shared/1.0-SNAPSHOT/gwt-initials-avatars-shared-1.0-20140324.102812-16-sources.jar";
 />
+      <url 
url="http://archiva.comunes.org/repository/comunes-snapshots/cc/kune/gwt-initials-avatars-server/1.0-SNAPSHOT/gwt-initials-avatars-server-1.0-20140324.102825-10.jar";
 />
     </get>
   </target>
 

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/5e949d0a/server-config.xml
----------------------------------------------------------------------
diff --git a/server-config.xml b/server-config.xml
index 1f71757..4f1d94f 100644
--- a/server-config.xml
+++ b/server-config.xml
@@ -56,6 +56,7 @@
   <property name="index_directory" value="_indexes" />
   <property name="thumbnail_patterns_directory" value="thumbnail_patterns" />
   <property name="analytics_account" value="" />
+  <property name="profile_fetcher_type" value="gravatar" />
 
   <!-- Properties for server.federation.config -->
   <property name="xmpp_server_secret" value="opensesame" />
@@ -136,6 +137,7 @@
           <token key="INDEX_DIRECTORY" value="${index_directory}" />
           <token key="ANALYTICS_ACCOUNT" value="${analytics_account}" />
           <token key="THUMBNAIL_PATTERNS_DIRECTORY" 
value="${thumbnail_patterns_directory}" />
+          <token key="PROFILE_FETCHER_TYPE" value="${profile_fetcher_type}" />
         </replacetokens>
       </filterchain>
     </copy>

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/5e949d0a/server.config.example
----------------------------------------------------------------------
diff --git a/server.config.example b/server.config.example
index 795203b..f3feba0 100644
--- a/server.config.example
+++ b/server.config.example
@@ -199,3 +199,7 @@ analytics_account = @ANALYTICS_ACCOUNT@
 # Icon must be in PNG format, and named as MIME type with replacing '/' to '_'.
 # For example thumbnail file for ZIP format (MIME type application/zip) must 
be named application_zip.
 thumbnail_patterns_directory = @THUMBNAIL_PATTERNS_DIRECTORY@
+
+# Currently supported profile fetcher types: gravatar, initials.
+# Default value: gravatar.
+profile_fetcher_type = @PROFILE_FETCHER_TYPE@

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/5e949d0a/src/org/waveprotocol/box/server/CoreSettings.java
----------------------------------------------------------------------
diff --git a/src/org/waveprotocol/box/server/CoreSettings.java 
b/src/org/waveprotocol/box/server/CoreSettings.java
index e61f688..0a6f3fd 100644
--- a/src/org/waveprotocol/box/server/CoreSettings.java
+++ b/src/org/waveprotocol/box/server/CoreSettings.java
@@ -72,6 +72,7 @@ public class CoreSettings {
   public static final String INDEX_DIRECTORY = "index_directory";
   public static final String ANALYTICS_ACCOUNT = "analytics_account";
   public static final String THUMBNAIL_PATTERNS_DIRECTORY = 
"thumbnail_patterns_directory";
+  public static final String PROFILE_FETCHER_TYPE = "profile_fetcher_type";
 
   @Setting(name = WAVE_SERVER_DOMAIN)
   private static String waveServerDomain;
@@ -259,4 +260,8 @@ public class CoreSettings {
       description = "Thumbnail patterns directory",
       defaultValue = "")
   private static String thumbnailPatternsDirectory;
+
+  @Setting(name = PROFILE_FETCHER_TYPE,
+      description = "The wave profile fetcher used", defaultValue = "gravatar")
+  private static String profileFetcherType;
 }

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/5e949d0a/src/org/waveprotocol/box/server/ServerMain.java
----------------------------------------------------------------------
diff --git a/src/org/waveprotocol/box/server/ServerMain.java 
b/src/org/waveprotocol/box/server/ServerMain.java
index 3e885cb..6887bcc 100644
--- a/src/org/waveprotocol/box/server/ServerMain.java
+++ b/src/org/waveprotocol/box/server/ServerMain.java
@@ -19,6 +19,8 @@
 
 package org.waveprotocol.box.server;
 
+import cc.kune.initials.InitialsAvatarsServlet;
+
 import com.google.gwt.logging.server.RemoteLoggingServiceImpl;
 import com.google.inject.Guice;
 import com.google.inject.Inject;
@@ -40,6 +42,7 @@ import org.waveprotocol.box.server.persistence.AccountStore;
 import org.waveprotocol.box.server.persistence.PersistenceException;
 import org.waveprotocol.box.server.persistence.PersistenceModule;
 import org.waveprotocol.box.server.persistence.SignerInfoStore;
+import org.waveprotocol.box.server.robots.ProfileFetcherModule;
 import org.waveprotocol.box.server.robots.RobotApiModule;
 import org.waveprotocol.box.server.robots.RobotRegistrationServlet;
 import org.waveprotocol.box.server.robots.active.ActiveApiServlet;
@@ -81,7 +84,6 @@ import org.waveprotocol.wave.model.wave.ParticipantIdUtil;
 import org.waveprotocol.wave.util.logging.Log;
 import org.waveprotocol.wave.util.settings.SettingsBinder;
 
-
 import java.io.IOException;
 import java.util.Collections;
 import java.util.Map;
@@ -91,6 +93,7 @@ import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServlet;
+
 import org.eclipse.jetty.proxy.ProxyServlet;
 import org.waveprotocol.box.common.comms.WaveClientRpc.ProtocolWaveClientRpc;
 import org.waveprotocol.box.server.rpc.LocaleServlet;
@@ -120,7 +123,7 @@ public class ServerMain {
       LOG.info("Starting GadgetProxyServlet for " + gadgetServerHostname + ":" 
+ gadgetServerPort);
       proxyServlet = new ProxyServlet.Transparent(
           "http://"; + gadgetServerHostname + ":" + gadgetServerPort + 
"/gadgets",
-          "/gadgets");      
+          "/gadgets");
     }
 
     @Override
@@ -175,9 +178,10 @@ public class ServerMain {
     Module federationModule = buildFederationModule(settingsInjector, 
enableFederation);
     PersistenceModule persistenceModule = 
settingsInjector.getInstance(PersistenceModule.class);
     Module searchModule = settingsInjector.getInstance(SearchModule.class);
+    Module profileFetcherModule = 
settingsInjector.getInstance(ProfileFetcherModule.class);
     Injector injector =
         settingsInjector.createChildInjector(new 
ServerModule(enableFederation, listenerCount,
-            waveletLoadCount, deltaPersistCount, storageContinuationCount, 
lookupCount),
+            waveletLoadCount, deltaPersistCount, storageContinuationCount, 
lookupCount), profileFetcherModule,
             new RobotApiModule(), federationModule, persistenceModule, 
searchModule);
 
     ServerRpcProvider server = injector.getInstance(ServerRpcProvider.class);
@@ -252,6 +256,7 @@ public class ServerMain {
     server.addServlet("/robot/rpc", ActiveApiServlet.class);
     server.addServlet("/webclient/remote_logging", 
RemoteLoggingServiceImpl.class);
     server.addServlet("/profile/*", FetchProfilesServlet.class);
+    server.addServlet("/iniavatars/*", InitialsAvatarsServlet.class);
     server.addServlet("/waveref/*", WaveRefServlet.class);
 
     String gadgetHostName =

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/5e949d0a/src/org/waveprotocol/box/server/robots/ProfileFetcherModule.java
----------------------------------------------------------------------
diff --git a/src/org/waveprotocol/box/server/robots/ProfileFetcherModule.java 
b/src/org/waveprotocol/box/server/robots/ProfileFetcherModule.java
new file mode 100644
index 0000000..be8f7ea
--- /dev/null
+++ b/src/org/waveprotocol/box/server/robots/ProfileFetcherModule.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.waveprotocol.box.server.robots;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.name.Named;
+
+import org.waveprotocol.box.server.CoreSettings;
+import 
org.waveprotocol.box.server.robots.operations.FetchProfilesService.ProfilesFetcher;
+import org.waveprotocol.box.server.robots.operations.GravatarProfilesFetcher;
+import org.waveprotocol.box.server.robots.operations.InitialsProfilesFetcher;
+
+/**
+ * Profile Fetcher Module.
+ *
+ * @author [email protected] (Vicente J. Ruiz Jurado)
+ */
+public class ProfileFetcherModule extends AbstractModule {
+
+
+  private String profileFetcherType;
+
+  @Inject
+  public ProfileFetcherModule(@Named(CoreSettings.PROFILE_FETCHER_TYPE) String 
profilerType) {
+    this.profileFetcherType = profilerType;
+  }
+
+  @Override
+  protected void configure() {
+    if ("gravatar".equals(profileFetcherType)) {
+      
bind(ProfilesFetcher.class).to(GravatarProfilesFetcher.class).in(Singleton.class);
+    } else if ("initials".equals(profileFetcherType)) {
+      
bind(ProfilesFetcher.class).to(InitialsProfilesFetcher.class).in(Singleton.class);
+    } else {
+      throw new RuntimeException("Unknown profile fetcher type: " + 
profileFetcherType);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/5e949d0a/src/org/waveprotocol/box/server/robots/RobotApiModule.java
----------------------------------------------------------------------
diff --git a/src/org/waveprotocol/box/server/robots/RobotApiModule.java 
b/src/org/waveprotocol/box/server/robots/RobotApiModule.java
index e3ede28..6bcaadb 100644
--- a/src/org/waveprotocol/box/server/robots/RobotApiModule.java
+++ b/src/org/waveprotocol/box/server/robots/RobotApiModule.java
@@ -42,8 +42,6 @@ import org.waveprotocol.box.server.CoreSettings;
 import 
org.waveprotocol.box.server.robots.active.ActiveApiOperationServiceRegistry;
 import org.waveprotocol.box.server.robots.dataapi.DataApiOAuthServlet;
 import 
org.waveprotocol.box.server.robots.dataapi.DataApiOperationServiceRegistry;
-import 
org.waveprotocol.box.server.robots.operations.FetchProfilesService.ProfilesFetcher;
-import org.waveprotocol.box.server.robots.operations.GravatarProfilesFetcher;
 import org.waveprotocol.box.server.robots.passive.RobotConnector;
 
 import java.util.concurrent.Executor;
@@ -77,7 +75,6 @@ public class RobotApiModule extends AbstractModule {
         ACCESS_TOKEN_PATH);
     
bind(String.class).annotatedWith(Names.named("all_tokens_path")).toInstance(
         ALL_TOKENS_PATH);
-    
bind(ProfilesFetcher.class).to(GravatarProfilesFetcher.class).in(Singleton.class);
   }
 
   @Provides

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/5e949d0a/src/org/waveprotocol/box/server/robots/operations/InitialsProfilesFetcher.java
----------------------------------------------------------------------
diff --git 
a/src/org/waveprotocol/box/server/robots/operations/InitialsProfilesFetcher.java
 
b/src/org/waveprotocol/box/server/robots/operations/InitialsProfilesFetcher.java
new file mode 100644
index 0000000..e14b792
--- /dev/null
+++ 
b/src/org/waveprotocol/box/server/robots/operations/InitialsProfilesFetcher.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.waveprotocol.box.server.robots.operations;
+
+import com.google.wave.api.ParticipantProfile;
+
+import 
org.waveprotocol.box.server.robots.operations.FetchProfilesService.ProfilesFetcher;
+
+/**
+ * A {@link ProfilesFetcher} implementation that assigns a default image URL 
for
+ * the user avatar using it's initial and a random color
+ *
+ * @author [email protected] (Vicente J. Ruiz Jurado)
+ */
+public class InitialsProfilesFetcher implements ProfilesFetcher {
+
+  /**
+   * Returns the avatar URL for the given email address.
+   */
+  public String getImageUrl(String email) {
+    return "/iniavatars/100x100/" + email;
+  }
+
+  @Override
+  public ParticipantProfile fetchProfile(String email) {
+    ParticipantProfile pTemp = null;
+    pTemp = ProfilesFetcher.SIMPLE_PROFILES_FETCHER.fetchProfile(email);
+    ParticipantProfile profile =
+        new ParticipantProfile(email, pTemp.getName(), getImageUrl(email), 
pTemp.getProfileUrl());
+    return profile;
+  }
+}

Reply via email to