r7160 - in dumbhippo/trunk/server/src/com/dumbhippo: persistence server/impl
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7160 - in dumbhippo/trunk/server/src/com/dumbhippo: persistence server/impl
- Date: Wed, 9 Jan 2008 13:26:58 -0600 (CST)
Author: otaylor
Date: 2008-01-09 13:26:58 -0600 (Wed, 09 Jan 2008)
New Revision: 7160
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/persistence/EmbeddedMessage.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ChatSystemBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java
Log:
EmbeddedMessage: Round the timestamp to seconds to avoid problems when
round-tripping timestamps through the database.
StackerBean ChatSystemBean: Add missing notifications on
BlockDMO.timestamp and BlockDMO.chatMessages.
Modified: dumbhippo/trunk/server/src/com/dumbhippo/persistence/EmbeddedMessage.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/persistence/EmbeddedMessage.java 2008-01-09 18:04:07 UTC (rev 7159)
+++ dumbhippo/trunk/server/src/com/dumbhippo/persistence/EmbeddedMessage.java 2008-01-09 19:26:58 UTC (rev 7160)
@@ -67,8 +67,19 @@
return timestamp;
}
+ // The database only stores timestamps at second-resolution. Things become more reliable
+ // if we round here, rather than rounding when storing into the database. (If we switch
+ // to a database with high-resolution timestamps, this should be removed.)
+ private long roundTimestamp(long timestamp) {
+ // any thing < 0 is just a flag value
+ if (timestamp < 0)
+ return -1000;
+ else
+ return (timestamp / 1000) * 1000;
+ }
+
public void setTimestamp(Date timestamp) {
- this.timestamp = timestamp != null ? timestamp.getTime() : -1;
+ this.timestamp = timestamp != null ? roundTimestamp(timestamp.getTime()) : -1000;
}
@Column(nullable = false)
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ChatSystemBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ChatSystemBean.java 2008-01-09 18:04:07 UTC (rev 7159)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/ChatSystemBean.java 2008-01-09 19:26:58 UTC (rev 7160)
@@ -48,6 +48,9 @@
import com.dumbhippo.server.blocks.GroupChatBlockHandler;
import com.dumbhippo.server.blocks.MusicChatBlockHandler;
import com.dumbhippo.server.blocks.PostBlockHandler;
+import com.dumbhippo.server.dm.BlockDMO;
+import com.dumbhippo.server.dm.BlockDMOKey;
+import com.dumbhippo.server.dm.DataService;
import com.dumbhippo.server.views.ChatMessageView;
import com.dumbhippo.server.views.SystemViewpoint;
import com.dumbhippo.server.views.TrackView;
@@ -581,7 +584,9 @@
throw new RuntimeException("Can't add a chat message to a chat room of unknown kind");
}
- stacker.stack(block, message.getTimestamp().getTime(),
+ DataService.currentSessionRW().feedChanged(BlockDMO.class, new BlockDMOKey(block), "chatMessages", message.getTimestampAsLong());
+
+ stacker.stack(block, message.getTimestampAsLong(),
message.getFromUser(),
block.getBlockType().isChatGroupParticipation(),
StackReason.CHAT_MESSAGE);
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java 2008-01-09 18:04:07 UTC (rev 7159)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java 2008-01-09 19:26:58 UTC (rev 7160)
@@ -706,6 +706,7 @@
// never "roll back" to an earlier timestamp
if (block.getTimestampAsLong() < activity) {
block.setTimestampAsLong(activity);
+ DataService.currentSessionRW().changed(BlockDMO.class, new BlockDMOKey(block), "timestamp");
}
// Now we need to create demand-create user/group block data objects and update the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]