r7048 - in dumbhippo/trunk/server/src/com/dumbhippo/server: impl views
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7048 - in dumbhippo/trunk/server/src/com/dumbhippo/server: impl views
- Date: Wed, 12 Dec 2007 19:02:36 -0600 (CST)
Author: marinaz
Date: 2007-12-12 19:02:36 -0600 (Wed, 12 Dec 2007)
New Revision: 7048
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PersonViewerBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/views/PersonView.java
Log:
Since we set the nickname based on the available resource when we are creating a user
account, we should make the name from Facebook a preferred name in certain cases,
instead of a fallback name.
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PersonViewerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PersonViewerBean.java 2007-12-13 00:27:10 UTC (rev 7047)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/PersonViewerBean.java 2007-12-13 01:02:36 UTC (rev 7048)
@@ -301,7 +301,8 @@
addPersonViewExtra(viewpoint, pv, resources, e);
}
- if (pv.getUser() != null && (pv.getUser().getNickname() == null || pv.getUser().getNickname().length() == 0)) {
+ if (pv.getUser() != null && (pv.getUser().getNickname() == null || pv.getUser().getNickname().length() == 0
+ || pv.getUser().getNickname().contains("Facebook user"))) {
// we need to get the user's name from Facebook if Facebook is the only resource available for
// the user that can provide us with a name
FacebookResource fr = null;
@@ -317,8 +318,11 @@
if (fr != null) {
FacebookWebServices ws = new FacebookWebServices(REQUEST_TIMEOUT, config);
FacebookAccount facebookAccount = facebookTracker.getFacebookAccount(fr.getFacebookUserId());
- String name = ws.getName(facebookAccount);
- pv.setFallbackName(name);
+ if (facebookAccount != null) {
+ String name = ws.getName(facebookAccount);
+ if (name.trim().length() > 0)
+ pv.setPreferredName(name);
+ }
}
}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/views/PersonView.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/views/PersonView.java 2007-12-13 00:27:10 UTC (rev 7047)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/views/PersonView.java 2007-12-13 01:02:36 UTC (rev 7048)
@@ -55,6 +55,7 @@
private Set<Resource> resources;
private EnumSet<PersonViewExtra> extras;
private boolean invited;
+ private String preferredName;
private String fallbackName;
private Guid fallbackIdentifyingGuid;
private String bioAsHtmlCached;
@@ -156,9 +157,9 @@
}
private String getNickname() {
- String name = null;
+ String name = preferredName;
- if (user != null)
+ if ((name == null || name.length() == 0) && user != null)
name = user.getNickname();
// Contacts just should not have a nickname field, unless/until
@@ -877,6 +878,21 @@
}
/**
+ * Sometimes the dafault name we can store for the user is not
+ * that great (e.g. "Facebook user 123456"), and we can only
+ * get the preferred name on the fly.
+ *
+ * @return the preferred name or null
+ */
+ public String getPreferredName() {
+ return preferredName;
+ }
+
+ public void setPreferredName(String preferredName) {
+ this.preferredName = preferredName;
+ }
+
+ /**
* A name we use if we don't have anything else (no contact/user/resources),
* typically null but we set it sometimes when we know we'll need it.
* Specifically this was added when viewing someone else's contact we
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]