try {
List fl = SystemDatabaseFactory.getInstance().getFavorites(frt.getResourceTypeId(), user);
for (Iterator j = fl.iterator(); j.hasNext();) {
Favorite f = (Favorite) j.next();
try {
WrappedFavoriteItem wfi = frt.createWrappedFavoriteItem(f.getFavoriteKey(), request,
AbstractFavoriteItem.USER_FAVORITE);
if (wfi == null) {
SystemDatabaseFactory.getInstance().removeFavorite(f.getType(), f.getFavoriteKey(),
f.getUsername());
}
try {
ResourceUtil.checkResourceAccessRights(wfi.getFavoriteItem().getResource(), info);
getModel().addItem(wfi);
} catch (NoPermissionException npe) {
// Skip
}
} catch (Exception e) {
log.error("Failed to add user favorite " + f.getFavoriteKey() + ".", e);
}
}
} catch (Exception e) {
log.error("Failed to create user favorites for resource type " + frt.getResourceTypeId());
}
try {
for (Iterator iter = ResourceUtil.filterResourceIdsForGlobalFavorites(
PolicyDatabaseFactory.getInstance().getGrantedResourcesOfType(user, frt), rt).iterator(); iter
.hasNext();) {
Integer element = (Integer) iter.next();
try {
WrappedFavoriteItem wfi = frt.createWrappedFavoriteItem(element.intValue(), request,
AbstractFavoriteItem.GLOBAL_FAVORITE);
if (wfi == null) {
// TODO ? sahould we do soemthoing
// here?????????
} else {
if (!getModel().contains(wfi)) {
try {
ResourceUtil.checkResourceAccessRights(wfi.getFavoriteItem().getResource(), info);
getModel().addItem(wfi);
} catch (NoPermissionException npe) {
// Skip
}
}