r7173 - in dumbhippo/trunk/server/src/com/dumbhippo: dm server/dm server/views
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7173 - in dumbhippo/trunk/server/src/com/dumbhippo: dm server/dm server/views
- Date: Thu, 10 Jan 2008 11:00:24 -0600 (CST)
Author: otaylor
Date: 2008-01-10 11:00:22 -0600 (Thu, 10 Jan 2008)
New Revision: 7173
Added:
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FeedDMO.java
Modified:
dumbhippo/trunk/server/src/com/dumbhippo/dm/ReadOnlySession.java
dumbhippo/trunk/server/src/com/dumbhippo/dm/ReadWriteSession.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PostDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/views/Viewpoint.java
Log:
FeedDMO PostDMO DataService Viewpoint: Add FeedDMO object and post.feed property
to get the feed that is the source of a post.
ReadOnlySession ReadWriteSession: Fix problem with null values for filtered
properties.
BlockDMO: Fix a warning
Modified: dumbhippo/trunk/server/src/com/dumbhippo/dm/ReadOnlySession.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/dm/ReadOnlySession.java 2008-01-10 15:33:29 UTC (rev 7172)
+++ dumbhippo/trunk/server/src/com/dumbhippo/dm/ReadOnlySession.java 2008-01-10 17:00:22 UTC (rev 7173)
@@ -47,7 +47,7 @@
// logger.debug("Cached new value for {}.{}", key, property.getName());
}
- if (bypassFilter)
+ if (bypassFilter || value == null)
return value;
else
return property.filter(getViewpoint(), key.getKey(), value);
Modified: dumbhippo/trunk/server/src/com/dumbhippo/dm/ReadWriteSession.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/dm/ReadWriteSession.java 2008-01-10 15:33:29 UTC (rev 7172)
+++ dumbhippo/trunk/server/src/com/dumbhippo/dm/ReadWriteSession.java 2008-01-10 17:00:22 UTC (rev 7173)
@@ -38,7 +38,10 @@
public <K, T extends DMObject<K>> Object storeAndFilter(StoreKey<K,T> key, int propertyIndex, Object value) {
DMPropertyHolder<K,T,?> property = key.getClassHolder().getProperty(propertyIndex);
- return property.filter(getViewpoint(), key.getKey(), value);
+ if (value == null)
+ return null;
+ else
+ return property.filter(getViewpoint(), key.getKey(), value);
}
@Override
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java 2008-01-10 15:33:29 UTC (rev 7172)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/BlockDMO.java 2008-01-10 17:00:22 UTC (rev 7173)
@@ -27,7 +27,6 @@
import com.dumbhippo.persistence.StackReason;
import com.dumbhippo.persistence.User;
import com.dumbhippo.persistence.UserBlockData;
-import com.dumbhippo.persistence.BlockType.BlockVisibility;
import com.dumbhippo.server.ChatSystem;
import com.dumbhippo.server.NotFoundException;
import com.dumbhippo.server.Stacker;
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java 2008-01-10 15:33:29 UTC (rev 7172)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/DataService.java 2008-01-10 17:00:22 UTC (rev 7173)
@@ -117,6 +117,7 @@
model.addDMClass(DesktopSettingDMO.class);
model.addDMClass(ExternalAccountDMO.class);
model.addDMClass(GroupDMO.class);
+ model.addDMClass(FeedDMO.class);
model.addDMClass(PostDMO.class);
model.addDMClass(NetflixMovieDMO.class);
Added: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FeedDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FeedDMO.java 2008-01-10 15:33:29 UTC (rev 7172)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/FeedDMO.java 2008-01-10 17:00:22 UTC (rev 7173)
@@ -0,0 +1,58 @@
+package com.dumbhippo.server.dm;
+
+import javax.persistence.EntityManager;
+
+import com.dumbhippo.dm.DMObject;
+import com.dumbhippo.dm.DMSession;
+import com.dumbhippo.dm.annotations.DMFilter;
+import com.dumbhippo.dm.annotations.DMO;
+import com.dumbhippo.dm.annotations.DMProperty;
+import com.dumbhippo.dm.annotations.Inject;
+import com.dumbhippo.dm.annotations.PropertyType;
+import com.dumbhippo.dm.store.StoreKey;
+import com.dumbhippo.identity20.Guid;
+import com.dumbhippo.persistence.GroupFeed;
+import com.dumbhippo.server.NotFoundException;
+
+ DMO(classId="http://mugshot.org/p/o/feed", resourceBase="/o/feed")
+ DMFilter("viewer.canSeeFeed(this)")
+public abstract class FeedDMO extends DMObject<Guid> {
+ private GroupFeed groupFeed;
+
+ @Inject
+ private EntityManager em;
+
+ @Inject
+ private DMSession session;
+
+ protected FeedDMO(Guid key) {
+ super(key);
+ }
+
+ @Override
+ public void init() throws NotFoundException {
+ groupFeed = em.find(GroupFeed.class, getKey().toString());
+ if (groupFeed == null)
+ throw new NotFoundException("No such group feed");
+ }
+
+ @DMProperty(defaultInclude=true)
+ public String getName() {
+ return groupFeed.getFeed().getTitle();
+ }
+
+ @DMProperty(defaultInclude=true, type=PropertyType.URL)
+ public String getHomeUrl() {
+ return groupFeed.getFeed().getLink().getUrl();
+ }
+
+ @DMProperty(defaultInclude=true, type=PropertyType.URL)
+ public String getPhotoUrl() {
+ return groupFeed.getGroup().getPhotoUrl();
+ }
+
+ @DMProperty
+ public StoreKey<?,?> getVisibilityDelegate() {
+ return session.findUnchecked(GroupDMO.class, groupFeed.getGroup().getGuid()).getStoreKey();
+ }
+}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PostDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PostDMO.java 2008-01-10 15:33:29 UTC (rev 7172)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/PostDMO.java 2008-01-10 17:00:22 UTC (rev 7173)
@@ -16,6 +16,7 @@
import com.dumbhippo.dm.annotations.PropertyType;
import com.dumbhippo.identity20.Guid;
import com.dumbhippo.persistence.AccountClaim;
+import com.dumbhippo.persistence.FeedPost;
import com.dumbhippo.persistence.Post;
import com.dumbhippo.persistence.PostVisibility;
import com.dumbhippo.persistence.Resource;
@@ -48,7 +49,7 @@
post = postingBoard.loadRawPost(SystemViewpoint.getInstance(), getKey());
}
- @DMProperty(defaultInclude=true)
+ @DMProperty(defaultInclude=true, defaultChildren="+")
public UserDMO getPoster() {
User poster = post.getPoster();
if (poster != null)
@@ -57,6 +58,15 @@
return null;
}
+ @DMProperty(defaultInclude=true, defaultChildren="+")
+ public FeedDMO getFeed() {
+ if (post instanceof FeedPost) {
+ return session.findUnchecked(FeedDMO.class, ((FeedPost)post).getFeed().getGuid());
+ } else {
+ return null;
+ }
+ }
+
@DMProperty(defaultInclude=true)
public String getTitle() {
return post.getTitle();
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/views/Viewpoint.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/views/Viewpoint.java 2008-01-10 15:33:29 UTC (rev 7172)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/views/Viewpoint.java 2008-01-10 17:00:22 UTC (rev 7173)
@@ -11,6 +11,7 @@
import com.dumbhippo.server.dm.ChatMessageDMO;
import com.dumbhippo.server.dm.ChatMessageKey;
import com.dumbhippo.server.dm.DataService;
+import com.dumbhippo.server.dm.FeedDMO;
/**
* The Viewpoint class represents the concept of "current user".
@@ -80,4 +81,16 @@
return false;
}
}
+
+ public boolean canSeeFeed(Guid guid) {
+ DMSession session = DataService.getModel().currentSession();
+
+ StoreKey<?, ?> delegateKey;
+ try {
+ delegateKey = (StoreKey<?,?>)session.getRawProperty(FeedDMO.class, guid, "visibilityDelegate");
+ return delegateKey.isVisible(this);
+ } catch (NotFoundException e) {
+ return false;
+ }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]