import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.notify.ListNotificationFilters;
import net.pterodactylus.sone.template.SoneAccessor;
+import net.pterodactylus.sone.utils.Optionals;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.notify.Notification;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
+import com.google.common.collect.FluentIterable;
/**
* The “get status” AJAX handler returns all information that is necessary to
String loadSoneIds = request.getHttpRequest().getParam("soneIds");
if (loadSoneIds.length() > 0) {
String[] soneIds = loadSoneIds.split(",");
- for (String soneId : soneIds) {
- /* just add it, we skip null further down. */
- sones.add(webInterface.getCore().getSone(soneId).orNull());
- }
+ FluentIterable.from(Arrays.asList(soneIds))
+ .transform(webInterface.getCore().soneLoader())
+ .filter(Optionals.isPresent())
+ .transform(Optionals.<Sone>get())
+ .copyInto(sones);
}
ArrayNode jsonSones = new ArrayNode(instance);
for (Sone sone : sones) {
- if (sone == null) {
- continue;
- }
jsonSones.add(createJsonSone(sone));
}
/* load notifications. */