use of org.alfresco.repo.domain.activities.ActivityPostDAO in project alfresco-repository by Alfresco.
the class TemporarySites method after.
@Override
protected void after() {
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);
final NodeArchiveService nodeArchiveService = (NodeArchiveService) appContextRule.getApplicationContext().getBean("nodeArchiveService");
// Run as admin to ensure all sites can be deleted irrespective of which user created them.
AuthenticationUtil.runAs(new RunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
for (SiteInfo site : temporarySites) {
final String shortName = site.getShortName();
if (siteService.getSite(shortName) != null) {
log.debug("Deleting temporary site " + shortName);
siteService.deleteSite(shortName);
}
}
for (String username : temporarySiteUsers) {
log.debug("Deleting temporary site user " + username);
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;
}
});
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
for (SiteInfo site : temporarySites) {
log.debug("Purging temporary site from trashcan: " + site.getShortName());
nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(site.getNodeRef()));
}
return null;
}
});
return null;
}
}, AuthenticationUtil.getAdminUserName());
}
Aggregations