import net.pterodactylus.sone.freenet.fcp.FcpException;
import net.pterodactylus.sone.template.SoneAccessor;
+import com.google.common.base.Optional;
import com.google.common.collect.Collections2;
import freenet.node.FSParseException;
protected Post getPost(SimpleFieldSet simpleFieldSet, String parameterName) throws FcpException {
try {
String postId = simpleFieldSet.getString(parameterName);
- Post post = core.getPost(postId);
- if (post == null) {
+ Optional<Post> post = core.getPost(postId);
+ if (!post.isPresent()) {
throw new FcpException("Could not load post from “" + postId + "”.");
}
- return post;
+ return post.get();
} catch (FSParseException fspe1) {
throw new FcpException("Could not post ID from “" + parameterName + "”.", fspe1);
}
protected PostReply getReply(SimpleFieldSet simpleFieldSet, String parameterName) throws FcpException {
try {
String replyId = simpleFieldSet.getString(parameterName);
- PostReply reply = core.getPostReply(replyId, false);
- if (reply == null) {
+ Optional<PostReply> reply = core.getPostReply(replyId);
+ if (!reply.isPresent()) {
throw new FcpException("Could not load reply from “" + replyId + "”.");
}
- return reply;
+ return reply.get();
} catch (FSParseException fspe1) {
throw new FcpException("Could not reply ID from “" + parameterName + "”.", fspe1);
}