When working on discussions objects by noderef rather than name, check to see if it is part of a site so that activity entries can be generated properly if it is

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30192 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2011-09-02 14:08:44 +00:00
parent efedb236b2
commit f8d413d5a0

View File

@@ -209,6 +209,13 @@ public abstract class AbstractDiscussionWebScript extends DeclarativeWebScript
protected void addActivityEntry(String thing, String event, TopicInfo topic, protected void addActivityEntry(String thing, String event, TopicInfo topic,
PostInfo post, SiteInfo site, WebScriptRequest req, JSONObject json) PostInfo post, SiteInfo site, WebScriptRequest req, JSONObject json)
{ {
// We can only add activities against a site
if(site == null)
{
logger.info("Unable to add activity entry for " + thing + " " + event + " as no site given");
return;
}
// What page is this for? // What page is this for?
String page = req.getParameter("page"); String page = req.getParameter("page");
if(page == null && json != null) if(page == null && json != null)
@@ -556,6 +563,21 @@ public abstract class AbstractDiscussionWebScript extends DeclarativeWebScript
topic = objects.getFirst(); topic = objects.getFirst();
post = objects.getSecond(); post = objects.getSecond();
} }
// See if it's actually attached to a site
if(topic != null)
{
NodeRef container = topic.getContainerNodeRef();
if(container != null)
{
NodeRef maybeSite = nodeService.getPrimaryParent(container).getParentRef();
if(maybeSite != null)
{
// Try to make it a site, will return Null if it isn't one
site = siteService.getSite(maybeSite);
}
}
}
} }
else else
{ {