mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-2166 Update the discussions webscripts for control of the ordering, and switch the "Recent Topics" listing to request newest topics first
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30201 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1008,26 +1008,26 @@ public class DiscussionRestApiTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
|
|
||||||
// Check for recent (new)
|
// Check for recent (new)
|
||||||
// We should get all the topics
|
// We should get all the topics, with the newest one first (rather than last as with others)
|
||||||
result = getPosts("new?numdays=2", Status.STATUS_OK);
|
result = getPosts("new?numdays=2", Status.STATUS_OK);
|
||||||
assertEquals(2, result.getInt("total"));
|
assertEquals(2, result.getInt("total"));
|
||||||
assertEquals(2, result.getInt("itemCount"));
|
assertEquals(2, result.getInt("itemCount"));
|
||||||
assertEquals(2, result.getJSONArray("items").length());
|
assertEquals(2, result.getJSONArray("items").length());
|
||||||
assertEquals("SiteTitle1", result.getJSONArray("items").getJSONObject(0).getString("title"));
|
assertEquals("SiteTitle2", result.getJSONArray("items").getJSONObject(0).getString("title"));
|
||||||
assertEquals("SiteTitle2", result.getJSONArray("items").getJSONObject(1).getString("title"));
|
assertEquals("SiteTitle1", result.getJSONArray("items").getJSONObject(1).getString("title"));
|
||||||
assertEquals(2, result.getJSONArray("items").getJSONObject(0).getInt("replyCount"));
|
assertEquals(3, result.getJSONArray("items").getJSONObject(0).getInt("replyCount"));
|
||||||
assertEquals(3, result.getJSONArray("items").getJSONObject(1).getInt("replyCount"));
|
assertEquals(2, result.getJSONArray("items").getJSONObject(1).getInt("replyCount"));
|
||||||
|
|
||||||
result = getPosts(FORUM_NODE, "new?numdays=2", Status.STATUS_OK);
|
result = getPosts(FORUM_NODE, "new?numdays=2", Status.STATUS_OK);
|
||||||
assertEquals(3, result.getInt("total"));
|
assertEquals(3, result.getInt("total"));
|
||||||
assertEquals(3, result.getInt("itemCount"));
|
assertEquals(3, result.getInt("itemCount"));
|
||||||
assertEquals(3, result.getJSONArray("items").length());
|
assertEquals(3, result.getJSONArray("items").length());
|
||||||
assertEquals("NodeTitle1", result.getJSONArray("items").getJSONObject(0).getString("title"));
|
assertEquals("NodeTitle3", result.getJSONArray("items").getJSONObject(0).getString("title"));
|
||||||
assertEquals("NodeTitle2", result.getJSONArray("items").getJSONObject(1).getString("title"));
|
assertEquals("NodeTitle2", result.getJSONArray("items").getJSONObject(1).getString("title"));
|
||||||
assertEquals("NodeTitle3", result.getJSONArray("items").getJSONObject(2).getString("title"));
|
assertEquals("NodeTitle1", result.getJSONArray("items").getJSONObject(2).getString("title"));
|
||||||
assertEquals(1, result.getJSONArray("items").getJSONObject(0).getInt("replyCount"));
|
assertEquals(0, result.getJSONArray("items").getJSONObject(0).getInt("replyCount"));
|
||||||
assertEquals(0, result.getJSONArray("items").getJSONObject(1).getInt("replyCount"));
|
assertEquals(0, result.getJSONArray("items").getJSONObject(1).getInt("replyCount"));
|
||||||
assertEquals(0, result.getJSONArray("items").getJSONObject(2).getInt("replyCount"));
|
assertEquals(1, result.getJSONArray("items").getJSONObject(2).getInt("replyCount"));
|
||||||
|
|
||||||
|
|
||||||
// Check for hot
|
// Check for hot
|
||||||
@@ -1093,10 +1093,10 @@ public class DiscussionRestApiTest extends BaseWebScriptTest
|
|||||||
assertEquals(2, result.getInt("total"));
|
assertEquals(2, result.getInt("total"));
|
||||||
assertEquals(2, result.getInt("itemCount"));
|
assertEquals(2, result.getInt("itemCount"));
|
||||||
assertEquals(2, result.getJSONArray("items").length());
|
assertEquals(2, result.getJSONArray("items").length());
|
||||||
assertEquals("NodeTitle3", result.getJSONArray("items").getJSONObject(0).getString("title"));
|
assertEquals("NodeTitle1", result.getJSONArray("items").getJSONObject(0).getString("title"));
|
||||||
assertEquals("NodeTitle1", result.getJSONArray("items").getJSONObject(1).getString("title"));
|
assertEquals("NodeTitle3", result.getJSONArray("items").getJSONObject(1).getString("title"));
|
||||||
assertEquals(0, result.getJSONArray("items").getJSONObject(0).getInt("replyCount"));
|
assertEquals(1, result.getJSONArray("items").getJSONObject(0).getInt("replyCount"));
|
||||||
assertEquals(1, result.getJSONArray("items").getJSONObject(1).getInt("replyCount"));
|
assertEquals(0, result.getJSONArray("items").getJSONObject(1).getInt("replyCount"));
|
||||||
|
|
||||||
result = getPosts(FORUM_NODE, "new?numdays=2", Status.STATUS_OK);
|
result = getPosts(FORUM_NODE, "new?numdays=2", Status.STATUS_OK);
|
||||||
assertEquals(1, result.getInt("total"));
|
assertEquals(1, result.getInt("total"));
|
||||||
|
@@ -61,6 +61,7 @@ public class ForumTopicsGet extends AbstractDiscussionWebScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the topics
|
// Get the topics
|
||||||
|
boolean oldestTopicsFirst = true;
|
||||||
PagingResults<TopicInfo> topics = null;
|
PagingResults<TopicInfo> topics = null;
|
||||||
PagingRequest paging = buildPagingRequest(req);
|
PagingRequest paging = buildPagingRequest(req);
|
||||||
if(tagSearch)
|
if(tagSearch)
|
||||||
@@ -68,22 +69,22 @@ public class ForumTopicsGet extends AbstractDiscussionWebScript
|
|||||||
// Tag based is a search rather than a listing
|
// Tag based is a search rather than a listing
|
||||||
if(site != null)
|
if(site != null)
|
||||||
{
|
{
|
||||||
topics = discussionService.findTopics(site.getShortName(), null, tag, paging);
|
topics = discussionService.findTopics(site.getShortName(), null, tag, oldestTopicsFirst, paging);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
topics = discussionService.findTopics(nodeRef, null, tag, paging);
|
topics = discussionService.findTopics(nodeRef, null, tag, oldestTopicsFirst, paging);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(site != null)
|
if(site != null)
|
||||||
{
|
{
|
||||||
topics = discussionService.listTopics(site.getShortName(), paging);
|
topics = discussionService.listTopics(site.getShortName(), oldestTopicsFirst, paging);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
topics = discussionService.listTopics(nodeRef, buildPagingRequest(req));
|
topics = discussionService.listTopics(nodeRef, oldestTopicsFirst, buildPagingRequest(req));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,16 +56,16 @@ public class ForumTopicsMineGet extends AbstractDiscussionWebScript
|
|||||||
// Grab the current user to list for
|
// Grab the current user to list for
|
||||||
String username = AuthenticationUtil.getFullyAuthenticatedUser();
|
String username = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||||
|
|
||||||
// Get the topics for the user
|
// Get the topics for the user, oldest first
|
||||||
PagingResults<TopicInfo> topics = null;
|
PagingResults<TopicInfo> topics = null;
|
||||||
PagingRequest paging = buildPagingRequest(req);
|
PagingRequest paging = buildPagingRequest(req);
|
||||||
if(site != null)
|
if(site != null)
|
||||||
{
|
{
|
||||||
topics = discussionService.listTopics(site.getShortName(), username, paging);
|
topics = discussionService.listTopics(site.getShortName(), username, true, paging);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
topics = discussionService.listTopics(nodeRef, username, paging);
|
topics = discussionService.listTopics(nodeRef, username, true, paging);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -68,16 +68,16 @@ public class ForumTopicsRecentGet extends AbstractDiscussionWebScript
|
|||||||
Date from = new Date(now.getTime() - numDays*ONE_DAY_MS);
|
Date from = new Date(now.getTime() - numDays*ONE_DAY_MS);
|
||||||
Date to = new Date(now.getTime() + ONE_DAY_MS);
|
Date to = new Date(now.getTime() + ONE_DAY_MS);
|
||||||
|
|
||||||
// Get the topics for the user
|
// Get the recent topics, newest first
|
||||||
PagingResults<TopicInfo> topics = null;
|
PagingResults<TopicInfo> topics = null;
|
||||||
PagingRequest paging = buildPagingRequest(req);
|
PagingRequest paging = buildPagingRequest(req);
|
||||||
if(site != null)
|
if(site != null)
|
||||||
{
|
{
|
||||||
topics = discussionService.listTopics(site.getShortName(), from, to, paging);
|
topics = discussionService.listTopics(site.getShortName(), from, to, false, paging);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
topics = discussionService.listTopics(nodeRef, from, to, paging);
|
topics = discussionService.listTopics(nodeRef, from, to, false, paging);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user