Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)

57055: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3)
      56523: Merged HEAD-BUG-FIX to V4.2-BUG-FIX (4.2.1)
         56443: (MNT-9756) ALF-19225: Made post feeds cleanup to be executed in the unit test tear down method, to clean Pending, Error and etc. feeds.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61689 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-02-11 19:03:22 +00:00
parent 7b0bd9b5dd
commit 5e2c285efd
3 changed files with 18 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2012
* Copyright (C) 2005-2013
Alfresco Software Limited.
*
* This file is part of Alfresco
@@ -20,9 +20,12 @@
package org.alfresco.util.test.junitrules;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.activities.ActivityPostDAO;
import org.alfresco.repo.domain.activities.ActivityPostEntity;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.site.SiteModel;
@@ -70,6 +73,7 @@ public class TemporarySites extends AbstractPersonRule
{
final RetryingTransactionHelper transactionHelper = (RetryingTransactionHelper) appContextRule.getApplicationContext().getBean("retryingTransactionHelper");
final SiteService siteService = appContextRule.getApplicationContext().getBean("siteService", SiteService.class);
final ActivityPostDAO postDAO = appContextRule.getApplicationContext().getBean("postDAO", ActivityPostDAO.class);
// Run as admin to ensure all sites can be deleted irrespective of which user created them.
AuthenticationUtil.runAs(new RunAsWork<Void>()
@@ -96,6 +100,15 @@ public class TemporarySites extends AbstractPersonRule
deletePerson(username);
}
// Clean all the post feeds
int deletedCnt = 0;
Date keepDate = new Date(System.currentTimeMillis() + (120 * 1000L));
for (ActivityPostEntity.STATUS status : ActivityPostEntity.STATUS.values())
{
deletedCnt += postDAO.deletePosts(keepDate, status);
}
log.debug("Deleted " + deletedCnt + " post feeds.");
return null;
}
});