r7260 - in dumbhippo/trunk/server/src/com/dumbhippo/server: blocks impl
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7260 - in dumbhippo/trunk/server/src/com/dumbhippo/server: blocks impl
- Date: Fri, 25 Jan 2008 14:25:23 -0600 (CST)
Author: marinaz
Date: 2008-01-25 14:25:23 -0600 (Fri, 25 Jan 2008)
New Revision: 7260
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/BlockView.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java
Log:
Fix a NullPointerException that happened when a block did not have a link associated
with it. This can be the case with some MUSIC_PERSON blocks for which we didn't find
any information about the track that we can link to.
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/BlockView.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/BlockView.java 2008-01-25 18:53:47 UTC (rev 7259)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/BlockView.java 2008-01-25 20:25:23 UTC (rev 7260)
@@ -424,6 +424,8 @@
// it in some sort of a badge, the block is likely going to be on the
// first page there. Otherwise, we provide a link to the person who was
// the source of the original block.
+ // Note, block summary link can be null, if, for example, we didn't find any
+ // information about a track someone played that we can link to.
public String getSummaryLink() {
if (getUserBlockData() != null && getUserBlockData().getParticipatedReason().equals(StackReason.CHAT_MESSAGE))
return "/person?who=" + getUserBlockData().getUser().getId();
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java 2008-01-25 18:53:47 UTC (rev 7259)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/FacebookTrackerBean.java 2008-01-25 20:25:23 UTC (rev 7260)
@@ -387,7 +387,18 @@
Map<String, CharSequence> titleData = new HashMap<String, CharSequence>();
String action = blockView.getSummaryHeading().toLowerCase();
- String link = "<a target='_blank' href='" + getAbsoluteUrl(blockView.getSummaryLink()) + "'>" + blockView.getSummaryLinkText() + "</a>";
+ String link;
+ if (blockView.getSummaryLink() != null) {
+ link = "<a target='_blank' href='" + getAbsoluteUrl(blockView.getSummaryLink()) + "'>" + blockView.getSummaryLinkText() + "</a>";
+ } else {
+ // This happens when we don't get information about a track someone played that we can link to,
+ // but it should happen rarely or never in other cases. When we have a MUSIC_CHAT block, it should
+ // normally link to the page of the person who chatted on it.
+ if (blockView.getBlockType() != BlockType.MUSIC_PERSON) {
+ logger.warn("Link was null for block {} with block summary text {}", blockView, blockView.getSummaryLinkText());
+ }
+ link = blockView.getSummaryLinkText();
+ }
String where = "";
if (blockView.getBlockType().getExternalAccountSource() != null) {
if (blockView.getSummaryHeading().contains("Chatted about")) {
@@ -829,12 +840,25 @@
}
backgroundColor = (resultsCount % 2 == 0 ? "#FFFFFF" : "#EEEEEE");
resultsCount++;
+ String link;
+ if (blockView.getSummaryLink() != null) {
+ link = "<a target='_blank' href='" + getAbsoluteUrl(blockView.getSummaryLink()) + "'>" + blockView.getSummaryLinkText() + "</a>";
+ } else {
+ // This happens when we don't get information about a track someone played that we can link to,
+ // but it should happen rarely or never in other cases. When we have a MUSIC_CHAT block, it should
+ // normally link to the page of the person who chatted on it.
+ if (blockView.getBlockType() != BlockType.MUSIC_PERSON) {
+ logger.warn("Link was null for block {} with block summary text {}", blockView, blockView.getSummaryLinkText());
+ }
+ link = blockView.getSummaryLinkText();
+ }
+
String updateTable = "<table cellspacing='0' cellpadding='0'>" +
"<tbody><tr><td style='width:18px;padding-left:8px;'>" +
"<img src='http://mugshot.org" + blockView.getIcon() + "' title='" + blockView.getTypeTitle() + "' style='width: 16; height: 16; border: none; margin-right: 3px;'/>" +
"</td><td align='left'>" +
blockView.getSummaryHeading() +
- ": <a target='_blank' href='" + getAbsoluteUrl(blockView.getSummaryLink()) + "'>" + blockView.getSummaryLinkText() + "</a>" +
+ ": " + link +
"</td></tr></table>";
String updateStyle = "background-color: " + backgroundColor + ";margin-left:-8px;padding-top:2px;padding-bottom:2px;";
@@ -879,6 +903,11 @@
}
private String getAbsoluteUrl(String link) {
+ if (link == null) {
+ logger.warn("A null link was passed in to FacebookTrackerBean::getAbsoluteUrl()");
+ return "";
+ }
+
if (link.startsWith("/")) {
String baseurl = config.getBaseUrlMugshot().toExternalForm();
return baseurl + link;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]