r7107 - in dumbhippo/trunk/server/src/com/dumbhippo: server/impl web/servlets
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7107 - in dumbhippo/trunk/server/src/com/dumbhippo: server/impl web/servlets
- Date: Thu, 20 Dec 2007 15:20:27 -0600 (CST)
Author: marinaz
Date: 2007-12-20 15:20:26 -0600 (Thu, 20 Dec 2007)
New Revision: 7107
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java
dumbhippo/trunk/server/src/com/dumbhippo/web/servlets/FacebookSigninServlet.java
Log:
Set the full name for the Facebook user when they create a public Mugshot
account, since they no longer go through the process of accepting terms of
use once on the Mugshot site.
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java 2007-12-20 20:40:27 UTC (rev 7106)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/HttpMethodsBean.java 2007-12-20 21:20:26 UTC (rev 7107)
@@ -1238,22 +1238,6 @@
// we would set it to true (possibly when the person visits there Mugshot account
// page for the first time.
viewpoint.getViewer().getAccount().setPublicPage(true);
- // set a better name for a Facebook user, since now the user can edit it, and
- // we won't be needing to get it from Facebook again
- if (viewpoint.getViewer().getNickname().contains("Facebook user")) {
- for (AccountClaim ac : viewpoint.getViewer().getAccountClaims()) {
- if (ac.getResource() instanceof FacebookResource) {
- FacebookResource fr = (FacebookResource)ac.getResource();
- FacebookWebServices ws = new FacebookWebServices(REQUEST_TIMEOUT, config);
- FacebookAccount facebookAccount = facebookTracker.getFacebookAccount(fr.getFacebookUserId());
- if (facebookAccount != null) {
- String name = ws.getName(facebookAccount);
- if (name.trim().length() > 0)
- doRenamePerson(viewpoint, name);
- }
- }
- }
- }
}
public void doSetNeedsDownload(UserViewpoint viewpoint, boolean needsDownload) {
Modified: dumbhippo/trunk/server/src/com/dumbhippo/web/servlets/FacebookSigninServlet.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/web/servlets/FacebookSigninServlet.java 2007-12-20 20:40:27 UTC (rev 7106)
+++ dumbhippo/trunk/server/src/com/dumbhippo/web/servlets/FacebookSigninServlet.java 2007-12-20 21:20:26 UTC (rev 7107)
@@ -1,6 +1,7 @@
package com.dumbhippo.web.servlets;
import java.io.IOException;
+import java.util.Date;
import java.util.Map;
import javax.servlet.ServletException;
@@ -13,14 +14,21 @@
import com.dumbhippo.GlobalSetup;
import com.dumbhippo.persistence.AccountClaim;
import com.dumbhippo.persistence.Client;
+import com.dumbhippo.persistence.FacebookAccount;
import com.dumbhippo.persistence.FacebookResource;
+import com.dumbhippo.persistence.UserNameChangedRevision;
import com.dumbhippo.server.AccountSystem;
import com.dumbhippo.server.Configuration;
+import com.dumbhippo.server.FacebookTracker;
import com.dumbhippo.server.HippoProperty;
import com.dumbhippo.server.HumanVisibleException;
import com.dumbhippo.server.IdentitySpider;
import com.dumbhippo.server.NotFoundException;
+import com.dumbhippo.server.RevisionControl;
import com.dumbhippo.server.Configuration.PropertyNotFoundException;
+import com.dumbhippo.server.dm.DataService;
+import com.dumbhippo.server.dm.UserDMO;
+import com.dumbhippo.services.FacebookWebServices;
import com.dumbhippo.tx.RetryException;
import com.dumbhippo.web.SigninBean;
import com.dumbhippo.web.WebEJBUtil;
@@ -34,6 +42,9 @@
static final long serialVersionUID = 1;
+ // how long to wait on the web services calls
+ static protected final int REQUEST_TIMEOUT = 1000 * 12;
+
private Configuration config;
@Override
@@ -72,7 +83,9 @@
} else {
AccountSystem accounts = WebEJBUtil.defaultLookup(AccountSystem.class);
IdentitySpider identitySpider = WebEJBUtil.defaultLookup(IdentitySpider.class);
- String facebookUserId = facebookParams.get(FacebookParam.USER.toString()).toString();
+ FacebookTracker facebookTracker = WebEJBUtil.defaultLookup(FacebookTracker.class);
+ RevisionControl revisionControl = WebEJBUtil.defaultLookup(RevisionControl.class);
+ String facebookUserId = facebookParams.get(FacebookParam.USER.toString()).toString();
try {
FacebookResource res = identitySpider.lookupFacebook(facebookUserId);
AccountClaim ac = res.getAccountClaim();
@@ -83,6 +96,21 @@
sess.invalidate();
SigninBean.initializeAuthentication(request, response, client);
ac.getOwner().getAccount().setPublicPage(true);
+ // set a better name for a Facebook user, since now the user can edit it, and
+ // we won't be needing to get it from Facebook again
+ if (ac.getOwner().getNickname().contains("Facebook user")) {
+ FacebookWebServices ws = new FacebookWebServices(REQUEST_TIMEOUT, config);
+ FacebookAccount facebookAccount = facebookTracker.getFacebookAccount(facebookUserId);
+ if (facebookAccount != null) {
+ String name = ws.getName(facebookAccount);
+ if (name.trim().length() > 0) {
+ name = name.trim();
+ ac.getOwner().setNickname(name);
+ DataService.currentSessionRW().changed(UserDMO.class, ac.getOwner().getGuid(), "name");
+ revisionControl.persistRevision(new UserNameChangedRevision(ac.getOwner(), new Date(), name));
+ }
+ }
+ }
return redirectToNextPage(request, response, "/account", null);
} else {
errorMessage = "FacebookResource for " + facebookUserId + " was not claimed by any user.";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]