Merged 5.2.N (5.2.1) to HEAD (5.2)

128215 adavis: 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/HEAD/root@129278 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alexandru Epure
2016-08-09 13:51:28 +00:00
parent 0dffb373fd
commit 9621978d0c
4 changed files with 240 additions and 80 deletions

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Remote API
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.web.scripts.comment;
import java.io.IOException;
@@ -34,7 +34,10 @@ import javax.transaction.UserTransaction;
import org.alfresco.error.AlfrescoRuntimeException;
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.management.subsystems.ChildApplicationContextFactory;
import org.alfresco.repo.node.archive.NodeArchiveService;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
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.site.SiteModel;
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.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -107,6 +111,9 @@ public class CommentsApiTest extends BaseWebScriptTest
private AuthenticationComponent authenticationComponent;
protected PermissionServiceSPI permissionService;
protected ModelDAO permissionModelDAO;
private ActivityService activityService;
private FeedGenerator feedGenerator;
private PostLookup postLookup;
private NodeRef rootNodeRef;
private NodeRef companyHomeNodeRef;
@@ -144,6 +151,11 @@ public class CommentsApiTest extends BaseWebScriptTest
siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService");
personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
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());
@@ -620,7 +632,33 @@ public class CommentsApiTest extends BaseWebScriptTest
assertEquals(modifiedDateBefore.getTime(), modifiedDateAfter.getTime());
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
*/