use of io.jenkins.blueocean.rest.model.BlueFavorite in project blueocean-plugin by jenkinsci.
the class FavoritesStatePreloader method getFetchData.
@Override
protected FetchData getFetchData(@Nonnull BlueUrlTokenizer blueUrl) {
User jenkinsUser = User.current();
if (jenkinsUser != null) {
UserImpl blueUser = new UserImpl(jenkinsUser);
BlueFavoriteContainer favoritesContainer = blueUser.getFavorites();
if (favoritesContainer != null) {
JSONArray favorites = new JSONArray();
Iterator<BlueFavorite> favoritesIterator = favoritesContainer.iterator();
while (favoritesIterator.hasNext()) {
Reachable favorite = favoritesIterator.next();
try {
favorites.add(JSONObject.fromObject(ModelObjectSerializer.toJson(favorite)));
} catch (IOException e) {
LOGGER.log(Level.FINE, String.format("Unable to preload favorites for User '%s'. Serialization error.", jenkinsUser.getFullName()), e);
return null;
}
}
return new FetchData(favoritesContainer.getLink().getHref(), favorites.toString());
}
}
// Don't preload any data on the page.
return null;
}
use of io.jenkins.blueocean.rest.model.BlueFavorite in project blueocean-plugin by jenkinsci.
the class FavoriteContainerImpl method iterator.
@Override
public Iterator<BlueFavorite> iterator() {
List<BlueFavorite> favorites = new ArrayList<>();
Jenkins j = Jenkins.getInstance();
for (final Item favorite : Favorites.getFavorites(user.user)) {
if (favorite instanceof AbstractFolder) {
continue;
}
BlueFavorite blueFavorite = FavoriteUtil.getFavorite(favorite);
if (blueFavorite != null) {
favorites.add(blueFavorite);
}
}
return favorites.iterator();
}
Aggregations