mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
128190 amorarasu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 128171 amukha: MNT-16401: Delete comment notification from Blog or Links is not displayed in Site Activities dashlet - Corrected the comemnts webscript. - Added JUnit tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@128215 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -68,6 +68,24 @@ public class CommentDelete extends AbstractCommentsWebScript
|
|||||||
parentNodeRef = new NodeRef((String) getOrNull(jsonPageParams, JSON_KEY_NODEREF));
|
parentNodeRef = new NodeRef((String) getOrNull(jsonPageParams, JSON_KEY_NODEREF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parentNodeRef == null)
|
||||||
|
{
|
||||||
|
// find the parent content node for the comment
|
||||||
|
// Example would be a blog post which will have the following structure:
|
||||||
|
// blog post -> forum node -> topic node -> the actual comment node
|
||||||
|
NodeRef topicNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
|
||||||
|
if (topicNodeRef == null || !nodeService.getType(topicNodeRef).equals(ForumModel.TYPE_TOPIC))
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("The NodeRef specified is not a child of the topic.");
|
||||||
|
}
|
||||||
|
NodeRef forumNodeRef = nodeService.getPrimaryParent(topicNodeRef).getParentRef();
|
||||||
|
if (forumNodeRef == null || !nodeService.getType(forumNodeRef).equals(ForumModel.TYPE_FORUM))
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("The NodeRef specified doesn't belong to a correct structure of forums.");
|
||||||
|
}
|
||||||
|
parentNodeRef = nodeService.getPrimaryParent(forumNodeRef).getParentRef();
|
||||||
|
}
|
||||||
|
|
||||||
if (parentNodeRef != null)
|
if (parentNodeRef != null)
|
||||||
{
|
{
|
||||||
this.behaviourFilter.disableBehaviour(parentNodeRef, ContentModel.ASPECT_AUDITABLE);
|
this.behaviourFilter.disableBehaviour(parentNodeRef, ContentModel.ASPECT_AUDITABLE);
|
||||||
|
@@ -31,11 +31,15 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.activities.feed.FeedGenerator;
|
||||||
|
import org.alfresco.repo.activities.post.lookup.PostLookup;
|
||||||
|
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
|
||||||
import org.alfresco.repo.node.archive.NodeArchiveService;
|
import org.alfresco.repo.node.archive.NodeArchiveService;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||||
|
import org.alfresco.service.cmr.activities.ActivityService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
@@ -49,6 +53,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONStringer;
|
import org.json.JSONStringer;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
||||||
@@ -71,6 +76,9 @@ public class BlogServiceTest extends BaseWebScriptTest
|
|||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
private NodeArchiveService nodeArchiveService;
|
private NodeArchiveService nodeArchiveService;
|
||||||
|
private ActivityService activityService;
|
||||||
|
private FeedGenerator feedGenerator;
|
||||||
|
private PostLookup postLookup;
|
||||||
|
|
||||||
private static final String USER_ONE = "UserOneSecondToo";
|
private static final String USER_ONE = "UserOneSecondToo";
|
||||||
private static final String USER_TWO = "UserTwoSecondToo";
|
private static final String USER_TWO = "UserTwoSecondToo";
|
||||||
@@ -102,6 +110,11 @@ public class BlogServiceTest extends BaseWebScriptTest
|
|||||||
this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
|
this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
|
||||||
this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService");
|
this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService");
|
||||||
this.nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService");
|
this.nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService");
|
||||||
|
this.activityService = (ActivityService)getServer().getApplicationContext().getBean("activityService");
|
||||||
|
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory)getServer().getApplicationContext().getBean("ActivitiesFeed");
|
||||||
|
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
|
||||||
|
this.feedGenerator = (FeedGenerator)activitiesFeedCtx.getBean("feedGenerator");
|
||||||
|
this.postLookup = (PostLookup)activitiesFeedCtx.getBean("postLookup");
|
||||||
|
|
||||||
// Authenticate as user
|
// Authenticate as user
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
||||||
@@ -281,6 +294,7 @@ public class BlogServiceTest extends BaseWebScriptTest
|
|||||||
JSONObject comment = new JSONObject();
|
JSONObject comment = new JSONObject();
|
||||||
comment.put("title", title);
|
comment.put("title", title);
|
||||||
comment.put("content", content);
|
comment.put("content", content);
|
||||||
|
comment.put("site", SITE_SHORT_NAME_BLOG);
|
||||||
Response response = sendRequest(new PostRequest(getCommentsUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
|
Response response = sendRequest(new PostRequest(getCommentsUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
|
||||||
|
|
||||||
if (expectedStatus != 200)
|
if (expectedStatus != 200)
|
||||||
@@ -729,6 +743,31 @@ public class BlogServiceTest extends BaseWebScriptTest
|
|||||||
assertEquals("new content", commentTwoUpdated.getString("content"));
|
assertEquals("new content", commentTwoUpdated.getString("content"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* REPO-828 (MNT-16401)
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void testDeleteCommentPostActivity() throws Exception
|
||||||
|
{
|
||||||
|
this.authenticationComponent.setCurrentUser(USER_ONE);
|
||||||
|
JSONObject item = createPost("testActivity", "test", null, false, 200);
|
||||||
|
postLookup.execute();
|
||||||
|
feedGenerator.execute();
|
||||||
|
int activityNumStart = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_BLOG).size();
|
||||||
|
String nodeRef = item.getString("nodeRef");
|
||||||
|
JSONObject commentOne = createComment(nodeRef, "comment", "content", 200);
|
||||||
|
postLookup.execute();
|
||||||
|
feedGenerator.execute();
|
||||||
|
int activityNumNext = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_BLOG).size();
|
||||||
|
assertEquals("The activity feeds were not generated after adding a comment", activityNumStart + 1, activityNumNext);
|
||||||
|
|
||||||
|
sendRequest(new DeleteRequest(getCommentUrl(commentOne.getString("nodeRef"))), 200);
|
||||||
|
postLookup.execute();
|
||||||
|
feedGenerator.execute();
|
||||||
|
activityNumNext = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_BLOG).size();
|
||||||
|
assertEquals("The activity feeds were not generated after deleting a comment", activityNumStart + 1, activityNumNext);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can attach information to the blog container relating
|
* You can attach information to the blog container relating
|
||||||
* to integration with external blogs.
|
* to integration with external blogs.
|
||||||
|
@@ -34,7 +34,10 @@ import javax.transaction.UserTransaction;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.activities.feed.FeedGenerator;
|
||||||
|
import org.alfresco.repo.activities.post.lookup.PostLookup;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
|
||||||
import org.alfresco.repo.node.archive.NodeArchiveService;
|
import org.alfresco.repo.node.archive.NodeArchiveService;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
@@ -44,6 +47,7 @@ import org.alfresco.repo.security.permissions.impl.ModelDAO;
|
|||||||
import org.alfresco.repo.security.permissions.impl.SimplePermissionEntry;
|
import org.alfresco.repo.security.permissions.impl.SimplePermissionEntry;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||||
|
import org.alfresco.service.cmr.activities.ActivityService;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -99,6 +103,9 @@ public class CommentsApiTest extends BaseWebScriptTest
|
|||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
protected PermissionServiceSPI permissionService;
|
protected PermissionServiceSPI permissionService;
|
||||||
protected ModelDAO permissionModelDAO;
|
protected ModelDAO permissionModelDAO;
|
||||||
|
private ActivityService activityService;
|
||||||
|
private FeedGenerator feedGenerator;
|
||||||
|
private PostLookup postLookup;
|
||||||
|
|
||||||
private NodeRef rootNodeRef;
|
private NodeRef rootNodeRef;
|
||||||
private NodeRef companyHomeNodeRef;
|
private NodeRef companyHomeNodeRef;
|
||||||
@@ -133,6 +140,11 @@ public class CommentsApiTest extends BaseWebScriptTest
|
|||||||
siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService");
|
siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService");
|
||||||
personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
|
personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
|
||||||
nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService");
|
nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService");
|
||||||
|
activityService = (ActivityService)getServer().getApplicationContext().getBean("activityService");
|
||||||
|
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory)getServer().getApplicationContext().getBean("ActivitiesFeed");
|
||||||
|
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
|
||||||
|
feedGenerator = (FeedGenerator)activitiesFeedCtx.getBean("feedGenerator");
|
||||||
|
postLookup = (PostLookup)activitiesFeedCtx.getBean("postLookup");
|
||||||
|
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||||
|
|
||||||
@@ -421,6 +433,32 @@ public class CommentsApiTest extends BaseWebScriptTest
|
|||||||
assertEquals(modifierBefore, modifierAfter);
|
assertEquals(modifierBefore, modifierAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* REPO-828 (MNT-16401)
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void testDeleteCommentPostActivity() throws Exception
|
||||||
|
{
|
||||||
|
permissionService.setPermission(sitePage, USER_TWO, PermissionService.ALL_PERMISSIONS, true);
|
||||||
|
postLookup.execute();
|
||||||
|
feedGenerator.execute();
|
||||||
|
int activityNumStart = activityService.getSiteFeedEntries(SITE_SHORT_NAME).size();
|
||||||
|
Response response = addComment(sitePage, USER_TWO, 200);
|
||||||
|
postLookup.execute();
|
||||||
|
feedGenerator.execute();
|
||||||
|
int activityNumNext = activityService.getSiteFeedEntries(SITE_SHORT_NAME).size();
|
||||||
|
assertEquals("The activity feeds were not generated after adding a comment", activityNumStart + 1, activityNumNext);
|
||||||
|
JSONObject jsonResponse = parseResponseJSON(response);
|
||||||
|
String nodeRefComment = getOrNull(jsonResponse, JSON_KEY_NODEREF);
|
||||||
|
NodeRef commentNodeRef = new NodeRef(nodeRefComment);
|
||||||
|
deleteComment(commentNodeRef, sitePage, USER_TWO, 200);
|
||||||
|
activityNumStart = activityNumNext;
|
||||||
|
postLookup.execute();
|
||||||
|
feedGenerator.execute();
|
||||||
|
activityNumNext = activityService.getSiteFeedEntries(SITE_SHORT_NAME).size();
|
||||||
|
assertEquals("The activity feeds were not generated after deleting a comment", activityNumStart + 1, activityNumNext);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MNT-12082
|
* MNT-12082
|
||||||
*/
|
*/
|
||||||
|
@@ -33,12 +33,16 @@ import java.util.List;
|
|||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.activities.feed.FeedGenerator;
|
||||||
|
import org.alfresco.repo.activities.post.lookup.PostLookup;
|
||||||
|
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
|
||||||
import org.alfresco.repo.node.archive.NodeArchiveService;
|
import org.alfresco.repo.node.archive.NodeArchiveService;
|
||||||
import org.alfresco.repo.policy.BehaviourFilter;
|
import org.alfresco.repo.policy.BehaviourFilter;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||||
|
import org.alfresco.service.cmr.activities.ActivityService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||||
@@ -54,6 +58,7 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest;
|
||||||
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest;
|
||||||
@@ -81,6 +86,9 @@ public class LinksRestApiTest extends BaseWebScriptTest
|
|||||||
private NodeService internalNodeService;
|
private NodeService internalNodeService;
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
private NodeArchiveService nodeArchiveService;
|
private NodeArchiveService nodeArchiveService;
|
||||||
|
private ActivityService activityService;
|
||||||
|
private FeedGenerator feedGenerator;
|
||||||
|
private PostLookup postLookup;
|
||||||
|
|
||||||
private static final String USER_ONE = "UserOneSecondToo";
|
private static final String USER_ONE = "UserOneSecondToo";
|
||||||
private static final String USER_TWO = "UserTwoSecondToo";
|
private static final String USER_TWO = "UserTwoSecondToo";
|
||||||
@@ -119,6 +127,12 @@ public class LinksRestApiTest extends BaseWebScriptTest
|
|||||||
this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService");
|
this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService");
|
||||||
this.internalNodeService = (NodeService)getServer().getApplicationContext().getBean("nodeService");
|
this.internalNodeService = (NodeService)getServer().getApplicationContext().getBean("nodeService");
|
||||||
this.nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService");
|
this.nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService");
|
||||||
|
this.activityService = (ActivityService)getServer().getApplicationContext().getBean("activityService");
|
||||||
|
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory)getServer().getApplicationContext().getBean("ActivitiesFeed");
|
||||||
|
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
|
||||||
|
this.feedGenerator = (FeedGenerator)activitiesFeedCtx.getBean("feedGenerator");
|
||||||
|
this.postLookup = (PostLookup)activitiesFeedCtx.getBean("postLookup");
|
||||||
|
|
||||||
|
|
||||||
// Authenticate as user
|
// Authenticate as user
|
||||||
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
|
||||||
@@ -767,4 +781,55 @@ public class LinksRestApiTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
assertTrue("The user sould have permission to create a new link.", Boolean.parseBoolean(result.getJSONObject("metadata").getJSONObject("linkPermissions").getString("create")));
|
assertTrue("The user sould have permission to create a new link.", Boolean.parseBoolean(result.getJSONObject("metadata").getJSONObject("linkPermissions").getString("create")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testCommentLink() throws Exception
|
||||||
|
{
|
||||||
|
JSONObject link = createLink(LINK_TITLE_ONE, "commented link", LINK_URL_ONE, false, Status.STATUS_OK);
|
||||||
|
postLookup.execute();
|
||||||
|
feedGenerator.execute();
|
||||||
|
int activityNumStart = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_LINKS).size();
|
||||||
|
String name = getNameFromLink(link);
|
||||||
|
link = getLink(name, Status.STATUS_OK);
|
||||||
|
String nodeRef = link.getString("nodeRef");
|
||||||
|
JSONObject commentOne = createComment(nodeRef, "comment", "content", 200);
|
||||||
|
postLookup.execute();
|
||||||
|
feedGenerator.execute();
|
||||||
|
int activityNumNext = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_LINKS).size();
|
||||||
|
assertEquals("The activity feeds were not generated after adding a comment", activityNumStart + 1, activityNumNext);
|
||||||
|
|
||||||
|
sendRequest(new DeleteRequest(getCommentUrl(commentOne.getString("nodeRef"))), 200);
|
||||||
|
postLookup.execute();
|
||||||
|
feedGenerator.execute();
|
||||||
|
activityNumNext = activityService.getUserFeedEntries(USER_ONE, SITE_SHORT_NAME_LINKS).size();
|
||||||
|
assertEquals("The activity feeds were not generated after deleting a comment", activityNumStart + 1, activityNumNext);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject createComment(String nodeRef, String title, String content, int expectedStatus)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
JSONObject comment = new JSONObject();
|
||||||
|
comment.put("title", title);
|
||||||
|
comment.put("content", content);
|
||||||
|
comment.put("site", SITE_SHORT_NAME_LINKS);
|
||||||
|
Response response = sendRequest(new PostRequest(getCommentsUrl(nodeRef), comment.toString(), "application/json"), expectedStatus);
|
||||||
|
|
||||||
|
if (expectedStatus != 200)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//logger.debug("Comment created: " + response.getContentAsString());
|
||||||
|
JSONObject result = new JSONObject(response.getContentAsString());
|
||||||
|
return result.getJSONObject("item");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCommentsUrl(String nodeRef)
|
||||||
|
{
|
||||||
|
return "/api/node/" + nodeRef.replace("://", "/") + "/comments";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCommentUrl(String nodeRef)
|
||||||
|
{
|
||||||
|
return "/api/comment/node/" + nodeRef.replace("://", "/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user