{
log.debug("Deleting activities for groupid:" + groupId);
startTime = System.currentTimeMillis();
}
// Delete comments/activities/starred activity associations
BulkActivityDeleteResponse deleteActivityResponse = deleteGroupActivityDAO.execute(groupId);
if (log.isDebugEnabled())
{
endTime = System.currentTimeMillis();
log.debug("Time to delete activities/comments: " + (endTime - startTime));
log.debug("Removing followers for groupid:" + groupId);
startTime = endTime;
}
// Remove user/group follower associations (reset order indexes) and adjust groupsCount for followers.
List<Long> followerIds = removeGroupFollowersDAO.execute(groupId);
if (log.isDebugEnabled())
{
endTime = System.currentTimeMillis();
log.debug("Time to remove followers from group: " + (endTime - startTime));
log.debug("Removing group subscriptions for groupid:" + groupId);
startTime = endTime;
}
// Remove feed subscriptions for group.
deleteGroupFeedSubscriptions.execute(new DeleteAllFeedSubscriberByEntityTypeAndIdRequest(groupId,
EntityType.GROUP));
if (log.isDebugEnabled())
{
endTime = System.currentTimeMillis();
log.debug("Time to remove group subscriptions: " + (endTime - startTime));
log.debug("Removing group and associated objects for groupid:" + groupId);
startTime = endTime;
}
// Remove the group itself and adjust parent org stats recursively
DeleteGroupResponse deleteGroupResponse = deleteGroupDAO.execute(groupId);
if (log.isDebugEnabled())
{
endTime = System.currentTimeMillis();
log.debug("Time to remove group and associated objects: " + (endTime - startTime));
}
Long endDB = null;
if (log.isInfoEnabled())
{
endDB = System.currentTimeMillis();
}
// ================= Cache update task generation =======================
Long startAsync = null;
if (log.isInfoEnabled())
{
startAsync = System.currentTimeMillis();
}
int startSize = 0;
int endSize = 0;
if (log.isDebugEnabled())
{
startSize = inActionContext.getUserActionRequests().size();
}
// purge fixed set of cache keys.
generateSingleDeleteKeyFromCacheTask(getKeysToPurgeFromCache(deleteGroupResponse), inActionContext);
if (log.isDebugEnabled())
{
endSize = inActionContext.getUserActionRequests().size();
log.debug("Tasks for purge fixed set of cache keys: " + (endSize - startSize));
}
startSize = endSize;
// create tasks (1/key) for removing group id from CacheKeys.GROUPS_FOLLOWED_BY_PERSON lists
generateRemoveIdsFromListTasks(createKeys(CacheKeys.GROUPS_FOLLOWED_BY_PERSON, followerIds), Collections
.singletonList(deleteGroupResponse.getGroupId()), inActionContext);
if (log.isDebugEnabled())
{
endSize = inActionContext.getUserActionRequests().size();
log.debug("Tasks for remove group id from GROUPS_FOLLOWED_BY_PERSON lists: " + (endSize - startSize));
}
startSize = endSize;
// create task for removing activities in group's stream from users' starred activity lists.
generateRemoveIdsFromStarredActivityListTasks(deleteActivityResponse, inActionContext);
if (log.isDebugEnabled())
{
endSize = inActionContext.getUserActionRequests().size();
log.debug("Tasks for remove groups activity ids from starred activity lists: " + (endSize - startSize));
}
// get list of activity ids to remove from cache lists, no need to go beyond maxCacheListSize
List<Long> cachedActivityIds = deleteActivityResponse.getActivityIds().size() > maxCacheListSize // \n
? deleteActivityResponse.getActivityIds().subList(0, maxCacheListSize - 1)
: deleteActivityResponse.getActivityIds();
startSize = endSize;
if (log.isDebugEnabled())
{
endSize = inActionContext.getUserActionRequests().size();
log.debug("Tasks for remove activity ids from parent orgs of the deleted group: " + (endSize - startSize));
}
// create task for removing activities in group's stream from everyone stream
generateRemoveIdsFromListTasks(Collections.singletonList(CacheKeys.EVERYONE_ACTIVITY_IDS), cachedActivityIds,
inActionContext);
startSize = endSize;
// purge group from search index.
generateDeleteFromSearchIndexTasks(DomainGroup.class, Collections.singletonList(deleteGroupResponse
.getGroupId()), inActionContext);
if (log.isDebugEnabled())
{
endSize = inActionContext.getUserActionRequests().size();
log.debug("Tasks for purge group from search index: " + (endSize - startSize));
}
startSize = endSize;
// purge ALL activities from search index.
generateDeleteFromSearchIndexTasks(Activity.class, deleteActivityResponse.getActivityIds(), inActionContext);
if (log.isDebugEnabled())
{
endSize = inActionContext.getUserActionRequests().size();
log.debug("Tasks for purge ALL activities from search index: " + (endSize - startSize));
}
startSize = endSize;
// remove ALL activities from cache (low priority should we even do this?)
generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.ACTIVITY_BY_ID,
deleteActivityResponse.getActivityIds())), inActionContext);
if (log.isDebugEnabled())
{
endSize = inActionContext.getUserActionRequests().size();
log.debug("Tasks for remove ALL activities from cache: " + (endSize - startSize));
}
startSize = endSize;
// remove ALL comments from cache (low priority should we even do this?)
generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.COMMENT_BY_ID,
deleteActivityResponse.getCommentIds())), inActionContext);
if (log.isDebugEnabled())
{
endSize = inActionContext.getUserActionRequests().size();
log.debug("Tasks for remove ALL comments from cache: " + (endSize - startSize));