if (user == null) {
// session timed out, return prematurely
return null;
}
WebUserPreferences preferences = user.getWebPreferences();
RecentlyApprovedPortletPreferences recentlyApprovedPreferences = preferences
.getRecentlyApprovedPortletPreferences();
Subject subject = user.getSubject();
// Based on the user preference, generate a timestamp of the oldest resource to display.
long range = recentlyApprovedPreferences.hours;
long ts = 0; // defaults to ANY time in the past
if (range != -1) {
// range encoded as hours (UI shows days)
ts = System.currentTimeMillis() - (range * 60 * 60 * 1000);
}
platformList = DisambiguatedRecentlyAddedResourceComposite.fromResolution(resourceManager.disambiguate(
resourceManager.findRecentlyAddedPlatforms(subject, ts, recentlyApprovedPreferences.range),
RESOURCE_ID_EXTRACTOR, DefaultDisambiguationUpdateStrategies.getDefault()));
Map<Integer, DisambiguatedRecentlyAddedResourceComposite> platformMap;
platformMap = new HashMap<Integer, DisambiguatedRecentlyAddedResourceComposite>();
for (DisambiguatedRecentlyAddedResourceComposite platform : platformList) {
platformMap.put(platform.getOriginal().getId(), platform);
}
// Set the show servers flag on all expanded platforms.
// Find the list of expanded platforms for this user and make it available to the jsp.
List<String> removeExpandedPlatforms = new ArrayList<String>();
for (String expandedPlatform : recentlyApprovedPreferences.expandedPlatforms) {
Integer platformId = null;
try {
platformId = Integer.valueOf(expandedPlatform);
} catch (NumberFormatException nfe) {
removeExpandedPlatforms.add(expandedPlatform);
continue;
}
DisambiguatedRecentlyAddedResourceComposite miniPlatform = platformMap.get(platformId);
if (miniPlatform != null) {
miniPlatform.getOriginal().setShowChildren(true);
miniPlatform.setChildren(DisambiguatedRecentlyAddedResourceComposite.fromResolution(
resourceManager.disambiguate(resourceManager
.findRecentlyAddedServers(subject, ts, platformId.intValue()), RESOURCE_ID_EXTRACTOR,
DefaultDisambiguationUpdateStrategies.getDefault())));
} else {
removeExpandedPlatforms.add(expandedPlatform);
}
}
// we do this just to clean up the preferences for platforms in the filter list which no longer exist
if (removeExpandedPlatforms.size() > 0) {
recentlyApprovedPreferences.expandedPlatforms.removeAll(removeExpandedPlatforms);
preferences.setRecentlyApprovedPortletPreferences(recentlyApprovedPreferences);
}
// Make the list available to the jsp.
} catch (Exception e) {