mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV to HEAD (4.2)
54389: ALF-15547 : Stack specific:Incorrect work of My Activities dashlet Added a check for siteNetwork to be null in activity feed entry. Added JUnit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54663 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -430,11 +430,11 @@ public class ActivityServiceImpl implements ActivityService, InitializingBean
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
String siteNetwork = activityFeed.getSiteNetwork();
|
||||||
if (siteId == null)
|
if (siteId == null)
|
||||||
{
|
{
|
||||||
// note: pending requirements for THOR-224, for now assume all activities are within context of site and filter by current tenant
|
// note: pending requirements for THOR-224, for now assume all activities are within context of site and filter by current tenant
|
||||||
if (! currentTenantDomain.equals(tenantService.getDomain(activityFeed.getSiteNetwork())))
|
if (siteNetwork != null && !currentTenantDomain.equals(tenantService.getDomain(siteNetwork)))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -478,7 +478,7 @@ public class ActivityServiceImpl implements ActivityService, InitializingBean
|
|||||||
|
|
||||||
activityFeed.setPostUserAvatarNodeRef(avatarNodeRef);
|
activityFeed.setPostUserAvatarNodeRef(avatarNodeRef);
|
||||||
|
|
||||||
activityFeed.setSiteNetwork(tenantService.getBaseName(activityFeed.getSiteNetwork()));
|
activityFeed.setSiteNetwork(tenantService.getBaseName(siteNetwork));
|
||||||
result.add(activityFeed);
|
result.add(activityFeed);
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
|
@@ -18,11 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.activities.feed;
|
package org.alfresco.repo.activities.feed;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.fail;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.activities.post.lookup.PostLookup;
|
import org.alfresco.repo.activities.post.lookup.PostLookup;
|
||||||
|
import org.alfresco.repo.domain.activities.ActivityFeedEntity;
|
||||||
import org.alfresco.repo.domain.activities.ActivityPostDAO;
|
import org.alfresco.repo.domain.activities.ActivityPostDAO;
|
||||||
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
|
import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
@@ -53,6 +55,9 @@ import org.springframework.beans.factory.ObjectFactory;
|
|||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.scheduling.quartz.JobDetailBean;
|
import org.springframework.scheduling.quartz.JobDetailBean;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feed notifier tests.
|
* Feed notifier tests.
|
||||||
*
|
*
|
||||||
@@ -85,6 +90,7 @@ public class FeedNotifierTest
|
|||||||
private NodeRef personNodeRef;
|
private NodeRef personNodeRef;
|
||||||
private String userName1 = "user1." + GUID.generate();
|
private String userName1 = "user1." + GUID.generate();
|
||||||
private String userName2 = "user2." + GUID.generate();
|
private String userName2 = "user2." + GUID.generate();
|
||||||
|
private String userName3 = "user3." + GUID.generate();
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void init()
|
public static void init()
|
||||||
@@ -157,6 +163,13 @@ public class FeedNotifierTest
|
|||||||
personProps.put(ContentModel.PROP_EMAIL, userName2+"@email.com");
|
personProps.put(ContentModel.PROP_EMAIL, userName2+"@email.com");
|
||||||
failingPersonNodeRef = personService.createPerson(personProps);
|
failingPersonNodeRef = personService.createPerson(personProps);
|
||||||
|
|
||||||
|
personProps = new PropertyMap();
|
||||||
|
personProps.put(ContentModel.PROP_USERNAME, userName3);
|
||||||
|
personProps.put(ContentModel.PROP_FIRSTNAME, userName3);
|
||||||
|
personProps.put(ContentModel.PROP_LASTNAME, userName3);
|
||||||
|
personProps.put(ContentModel.PROP_EMAIL, userName3+"@email.com");
|
||||||
|
personService.createPerson(personProps);
|
||||||
|
|
||||||
AuthenticationUtil.popAuthentication();
|
AuthenticationUtil.popAuthentication();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -262,7 +275,60 @@ public class FeedNotifierTest
|
|||||||
// there should not be any more because they have been processed already
|
// there should not be any more because they have been processed already
|
||||||
assertEquals(numSuccessfulNotifications, errorProneActionExecutor.getNumSuccess());
|
assertEquals(numSuccessfulNotifications, errorProneActionExecutor.getNumSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oracle DB specific test, see ALF-15547
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testNullSiteNetworkStatus() throws Exception
|
||||||
|
{
|
||||||
|
final String activityType = "org.alfresco.profile.status-changed";
|
||||||
|
// Intentionally null, required for ALF-15547
|
||||||
|
final String siteId = null;
|
||||||
|
final String appTool = "profile";
|
||||||
|
// Status update
|
||||||
|
final String jsonActivityData = "{\"status\":\"test\"}";
|
||||||
|
|
||||||
|
// and activity for userName3
|
||||||
|
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
||||||
|
{
|
||||||
|
@SuppressWarnings("synthetic-access")
|
||||||
|
public Void execute() throws Throwable
|
||||||
|
{
|
||||||
|
AuthenticationUtil.pushAuthentication();
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(userName3);
|
||||||
|
|
||||||
|
activityService.postActivity(activityType, siteId, appTool, jsonActivityData);
|
||||||
|
|
||||||
|
AuthenticationUtil.popAuthentication();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, false, true);
|
||||||
|
|
||||||
|
generateActivities();
|
||||||
|
|
||||||
|
List<ActivityFeedEntity> feeds = Collections.emptyList();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
feeds = activityService.getUserFeedEntries(userName3, null, false, false, null, null, -1);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
fail("Failed to get user's posts.");
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
for (ActivityFeedEntity feed : feeds)
|
||||||
|
{
|
||||||
|
if (feed.getActivityType().equals(activityType) && feed.getSiteNetwork() == null)
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue("The post should be found.", found);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetup()
|
public void testSetup()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user