Replace post-specific interfaces with Kotlin versions
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 15 Oct 2017 11:18:12 +0000 (13:18 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 15 Oct 2017 11:18:12 +0000 (13:18 +0200)
17 files changed:
src/main/java/net/pterodactylus/sone/database/PostBuilder.java [deleted file]
src/main/java/net/pterodactylus/sone/database/PostBuilderFactory.java [deleted file]
src/main/java/net/pterodactylus/sone/database/PostDatabase.java [deleted file]
src/main/java/net/pterodactylus/sone/database/PostProvider.java [deleted file]
src/main/java/net/pterodactylus/sone/database/PostStore.java [deleted file]
src/main/kotlin/net/pterodactylus/sone/database/PostBuilder.kt [new file with mode: 0644]
src/main/kotlin/net/pterodactylus/sone/database/PostBuilderFactory.kt [new file with mode: 0644]
src/main/kotlin/net/pterodactylus/sone/database/PostDatabase.kt [new file with mode: 0644]
src/main/kotlin/net/pterodactylus/sone/database/PostProvider.kt [new file with mode: 0644]
src/main/kotlin/net/pterodactylus/sone/database/PostStore.kt [new file with mode: 0644]
src/main/kotlin/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/ajax/LikeAjaxPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/UnbookmarkPage.kt
src/main/kotlin/net/pterodactylus/sone/web/pages/ViewPostPage.kt

diff --git a/src/main/java/net/pterodactylus/sone/database/PostBuilder.java b/src/main/java/net/pterodactylus/sone/database/PostBuilder.java
deleted file mode 100644 (file)
index 45cc062..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Sone - PostBuilder.java - Copyright © 2013–2016 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database;
-
-import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Sone;
-
-/**
- * Builder for {@link Post} objects.
- * <p>
- * A {@link Post} consists of the following elements:
- * <ul>
- * <li>an ID,</li>
- * <li>a {@link Sone sender},</li>
- * <li>an optional {@link Sone recipient},</li>
- * <li>a time,</li>
- * <li>and a text.</li>
- * </ul>
- * Except for the recipient, all this elements have to be configured on this
- * builder. For the ID you have the possibility to configure either a random ID
- * (which should be used for new posts) or a custom ID you specify (for creating
- * an existing post). For the time you can use the current time (again, for
- * creating new posts) or the given time (for loading posts). It is an error to
- * specify both ways for either the ID or the time.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public interface PostBuilder {
-
-       /**
-        * Copies all attributes of the given post to this post builder.
-        *
-        * @param post
-        *            The post whose attributes to copy into this builder
-        * @return This builder
-        * @throws NullPointerException
-        *             if {@code post} is {@code null}
-        */
-       public PostBuilder copyPost(Post post) throws NullPointerException;
-
-       /**
-        * Configures this builder to use the given Sone as sender of the new post.
-        *
-        * @param senderId
-        *            The ID of the sender of the post
-        * @return This post builder
-        */
-       public PostBuilder from(String senderId);
-
-       /**
-        * Configures this builder to use a random ID for the new post. If this
-        * method is used, {@link #withId(String)} must not be used.
-        *
-        * @return This post builder
-        */
-       public PostBuilder randomId();
-
-       /**
-        * Configures this builder to use the given ID as ID for the new post. If
-        * this method is used, {@link #randomId()} must not be used.
-        *
-        * @param id
-        *            The ID to use for the post
-        * @return This post builder
-        */
-       public PostBuilder withId(String id);
-
-       /**
-        * Configures this builder to use the current time when creating the post.
-        * If this method is used, {@link #withTime(long)} must not be used.
-        *
-        * @return This post builder
-        */
-       public PostBuilder currentTime();
-
-       /**
-        * Configures the builder to use the given time as time for the new post. If
-        * this method is used, {@link #currentTime()} must not be used.
-        *
-        * @param time
-        *            The time to use for the post
-        * @return This post builder
-        */
-       public PostBuilder withTime(long time);
-
-       /**
-        * Configures the builder to use the given text for the new post.
-        *
-        * @param text
-        *            The text to use for the post
-        * @return This post builder
-        */
-       public PostBuilder withText(String text);
-
-       /**
-        * Configures the builder to use the given {@link Sone} as recipient for the
-        * post.
-        *
-        * @param recipientId
-        *            The ID of the recipient of the post
-        * @return This post builder
-        */
-       public PostBuilder to(String recipientId);
-
-       /**
-        * Verifies this builder’s configuration and creates a new post.
-        * <p>
-        * The following conditions must be met in order for this builder to be
-        * configured correctly:
-        * <ul>
-        * <li>Exactly one of {@link #randomId()} or {@link #withId(String)} must
-        * have been called.</li>
-        * <li>The {@link #from(String) sender} must not be {@code null}.</li>
-        * <li>Exactly one of {@link #currentTime()} or {@link #withTime(long)} must
-        * have been called.</li>
-        * <li>The {@link #withText(String) text} must not be {@code null} and must
-        * contain something other than whitespace.</li>
-        * <li>The {@link #to(String) recipient} must either not have been set, or
-        * it must have been set to a {@link Sone} other than {@link #from(String)
-        * the sender}.</li>
-        * </ul>
-        *
-        * @return A new post
-        * @throws IllegalStateException
-        *             if this builder’s configuration is not valid
-        */
-       public Post build() throws IllegalStateException;
-
-}
diff --git a/src/main/java/net/pterodactylus/sone/database/PostBuilderFactory.java b/src/main/java/net/pterodactylus/sone/database/PostBuilderFactory.java
deleted file mode 100644 (file)
index e5cee38..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Sone - PostBuilderFactory.java - Copyright © 2013–2016 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database;
-
-import net.pterodactylus.sone.database.memory.MemoryDatabase;
-
-import com.google.inject.ImplementedBy;
-
-/**
- * Factory for {@link PostBuilder}s.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-@ImplementedBy(MemoryDatabase.class)
-public interface PostBuilderFactory {
-
-       /**
-        * Creates a new post builder.
-        *
-        * @return A new post builder
-        */
-       public PostBuilder newPostBuilder();
-
-}
diff --git a/src/main/java/net/pterodactylus/sone/database/PostDatabase.java b/src/main/java/net/pterodactylus/sone/database/PostDatabase.java
deleted file mode 100644 (file)
index 648c77e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Sone - PostDatabase.java - Copyright © 2013–2016 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database;
-
-/**
- * Combines a {@link PostProvider}, a {@link PostBuilderFactory}, and a
- * {@link PostStore} into a complete post database.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public interface PostDatabase extends PostProvider, PostBuilderFactory, PostStore {
-
-       /* nothing here. */
-
-}
diff --git a/src/main/java/net/pterodactylus/sone/database/PostProvider.java b/src/main/java/net/pterodactylus/sone/database/PostProvider.java
deleted file mode 100644 (file)
index bea59b9..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Sone - PostProvider.java - Copyright © 2011–2016 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database;
-
-import java.util.Collection;
-
-import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.database.memory.MemoryDatabase;
-
-import com.google.common.base.Optional;
-import com.google.inject.ImplementedBy;
-
-/**
- * Interface for objects that can provide {@link Post}s by their ID.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-@ImplementedBy(MemoryDatabase.class)
-public interface PostProvider {
-
-       /**
-        * Returns the post with the given ID.
-        *
-        * @param postId
-        *            The ID of the post to return
-        * @return The post with the given ID, or {@code null}
-        */
-       public Optional<Post> getPost(String postId);
-
-       /**
-        * Returns all posts from the given Sone.
-        *
-        * @param soneId
-        *            The ID of the Sone
-        * @return All posts from the given Sone
-        */
-       public Collection<Post> getPosts(String soneId);
-
-       /**
-        * Returns all posts that have the given Sone as recipient.
-        *
-        * @see Post#getRecipient()
-        * @param recipientId
-        *            The ID of the recipient of the posts
-        * @return All posts that have the given Sone as recipient
-        */
-       public Collection<Post> getDirectedPosts(String recipientId);
-
-}
diff --git a/src/main/java/net/pterodactylus/sone/database/PostStore.java b/src/main/java/net/pterodactylus/sone/database/PostStore.java
deleted file mode 100644 (file)
index 7c3e07f..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Sone - PostStore.java - Copyright © 2013–2016 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.database;
-
-import java.util.Collection;
-
-import net.pterodactylus.sone.data.Post;
-import net.pterodactylus.sone.data.Sone;
-
-/**
- * Interface for a store for posts.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public interface PostStore {
-
-       /**
-        * Adds the given post to the store.
-        *
-        * @param post
-        *            The post to store
-        */
-       public void storePost(Post post);
-
-       /**
-        * Removes the given post.
-        *
-        * @param post
-        *            The post to remove
-        */
-       public void removePost(Post post);
-
-}
diff --git a/src/main/kotlin/net/pterodactylus/sone/database/PostBuilder.kt b/src/main/kotlin/net/pterodactylus/sone/database/PostBuilder.kt
new file mode 100644 (file)
index 0000000..c1377ca
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Sone - PostBuilder.java - Copyright © 2013–2016 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.database
+
+import net.pterodactylus.sone.data.Post
+import net.pterodactylus.sone.data.Sone
+
+/**
+ * Builder for [Post] objects.
+ *
+ *
+ * A [Post] consists of the following elements:
+ *
+ *  * an ID,
+ *  * a [sender][Sone],
+ *  * an optional [recipient][Sone],
+ *  * a time,
+ *  * and a text.
+ *
+ * Except for the recipient, all this elements have to be configured on this
+ * builder. For the ID you have the possibility to configure either a random ID
+ * (which should be used for new posts) or a custom ID you specify (for creating
+ * an existing post). For the time you can use the current time (again, for
+ * creating new posts) or the given time (for loading posts). It is an error to
+ * specify both ways for either the ID or the time.
+ */
+interface PostBuilder {
+
+       fun copyPost(post: Post): PostBuilder
+
+       fun from(senderId: String): PostBuilder
+
+       fun randomId(): PostBuilder
+       fun withId(id: String): PostBuilder
+
+       fun currentTime(): PostBuilder
+       fun withTime(time: Long): PostBuilder
+
+       fun withText(text: String): PostBuilder
+
+       fun to(recipientId: String): PostBuilder
+
+       /**
+        * Verifies this builder’s configuration and creates a new post.
+        *
+        * The following conditions must be met in order for this builder to be
+        * configured correctly:
+        *
+        *  * Exactly one of [randomId] or [withId] must have been called.
+        *  * The [sender][from] must not be `null`.
+        *  * Exactly one of [currentTime] or [withTime] must have been called.
+        *  * The [text][withText] must not be `null` and must contain something other than whitespace.
+        *  * The [recipient][to] must either not have been set, or it must have been set to a [Sone] other than [the sender][from].
+        *
+        * @return A new post
+        * @throws IllegalStateException if this builder’s configuration is not valid
+        */
+       fun build(): Post
+
+}
diff --git a/src/main/kotlin/net/pterodactylus/sone/database/PostBuilderFactory.kt b/src/main/kotlin/net/pterodactylus/sone/database/PostBuilderFactory.kt
new file mode 100644 (file)
index 0000000..d7604c3
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Sone - PostBuilderFactory.java - Copyright © 2013–2016 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.database
+
+import net.pterodactylus.sone.database.memory.MemoryDatabase
+
+import com.google.inject.ImplementedBy
+
+/**
+ * Factory for [PostBuilder]s.
+ */
+@ImplementedBy(MemoryDatabase::class)
+interface PostBuilderFactory {
+
+       fun newPostBuilder(): PostBuilder
+
+}
diff --git a/src/main/kotlin/net/pterodactylus/sone/database/PostDatabase.kt b/src/main/kotlin/net/pterodactylus/sone/database/PostDatabase.kt
new file mode 100644 (file)
index 0000000..7b97c6a
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Sone - PostDatabase.java - Copyright © 2013–2016 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.database
+
+/**
+ * Combines a [PostProvider], a [PostBuilderFactory], and a
+ * [PostStore] into a complete post database.
+ */
+interface PostDatabase : PostProvider, PostBuilderFactory, PostStore
diff --git a/src/main/kotlin/net/pterodactylus/sone/database/PostProvider.kt b/src/main/kotlin/net/pterodactylus/sone/database/PostProvider.kt
new file mode 100644 (file)
index 0000000..fba9daf
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Sone - PostProvider.java - Copyright © 2011–2016 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.database
+
+import net.pterodactylus.sone.data.Post
+import net.pterodactylus.sone.database.memory.MemoryDatabase
+
+import com.google.common.base.Optional
+import com.google.inject.ImplementedBy
+
+/**
+ * Interface for objects that can provide [Post]s by their ID.
+ */
+@ImplementedBy(MemoryDatabase::class)
+interface PostProvider {
+
+       fun getPost(postId: String): Optional<Post>
+       fun getPosts(soneId: String): Collection<Post>
+       fun getDirectedPosts(recipientId: String): Collection<Post>
+
+}
diff --git a/src/main/kotlin/net/pterodactylus/sone/database/PostStore.kt b/src/main/kotlin/net/pterodactylus/sone/database/PostStore.kt
new file mode 100644 (file)
index 0000000..3cb5f17
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Sone - PostStore.java - Copyright © 2013–2016 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.database
+
+import net.pterodactylus.sone.data.Post
+import net.pterodactylus.sone.data.Sone
+
+/**
+ * Interface for a store for posts.
+ */
+interface PostStore {
+
+       fun storePost(post: Post)
+       fun removePost(post: Post)
+
+}
index 76d867e..6dcf032 100644 (file)
@@ -14,7 +14,7 @@ class DeletePostAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("deleteP
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["post"]
-                                       .let(core::getPost)
+                                       ?.let(core::getPost)
                                        ?.let { post ->
                                                post.sone.isLocal.ifTrue {
                                                        createSuccessJsonObject().also {
index cff9408..77e2c87 100644 (file)
@@ -20,7 +20,7 @@ class GetLikesAjaxPage(webInterface: WebInterface) : JsonPage("getLikes.ajax", w
        override fun createJsonObject(request: FreenetRequest) =
                        when (request.parameters["type"]) {
                                "post" -> request.parameters["post"]
-                                               .let(core::getPost)
+                                               ?.let(core::getPost)
                                                ?.let(core::getLikes)
                                                ?.toReply()
                                                ?: createErrorJsonObject("invalid-post-id")
index 2d902a6..d91fe90 100644 (file)
@@ -19,8 +19,8 @@ class GetPostAjaxPage(webInterface: WebInterface, private val postTemplate: Temp
 
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        request.parameters["post"]
-                                       .let(core::getPost)
-                                       .let { post ->
+                                       ?.let(core::getPost)
+                                       ?.let { post ->
                                                createSuccessJsonObject().
                                                                put("post", jsonObject(
                                                                                "id" to post.id,
index fb2592e..96fb7e4 100644 (file)
@@ -27,7 +27,7 @@ class GetTimesAjaxPage(webInterface: WebInterface,
 
        override fun createJsonObject(request: FreenetRequest) =
                        createSuccessJsonObject().apply {
-                               put("postTimes", request.parameters["posts"]!!.idsToJson { core.getPost(it)?.let { it.id to it.time } })
+                               put("postTimes", request.parameters["posts"]!!.idsToJson { core.getPost(it).let { it.id to it.time } })
                                put("replyTimes", request.parameters["replies"]!!.idsToJson { core.getPostReply(it)?.let { it.id to it.time } })
                        }
 
index 576bf90..718e6e7 100644 (file)
@@ -14,7 +14,7 @@ class LikeAjaxPage(webInterface: WebInterface) : LoggedInJsonPage("like.ajax", w
        override fun createJsonObject(currentSone: Sone, request: FreenetRequest) =
                        when (request.parameters["type"]) {
                                "post" -> request.parameters["post"]
-                                               .let(core::getPost)
+                                               ?.let(core::getPost)
                                                ?.let { currentSone.addLikedPostId(it.id) }
                                                ?.also { core.touchConfiguration() }
                                                ?.let { createSuccessJsonObject() }
index 01a0fde..c742542 100644 (file)
@@ -26,8 +26,8 @@ class UnbookmarkPage(template: Template, webInterface: WebInterface):
                        }
                        freenetRequest.isPOST -> {
                                freenetRequest.parameters["post", 36]
-                                               .let(webInterface.core::getPost)
-                                               .also(webInterface.core::unbookmarkPost)
+                                               ?.let(webInterface.core::getPost)
+                                               ?.also(webInterface.core::unbookmarkPost)
                                throw RedirectException(freenetRequest.parameters["returnPage", 256])
                        }
                }
index 457e13f..d331417 100644 (file)
@@ -16,14 +16,14 @@ class ViewPostPage(template: Template, webInterface: WebInterface):
                SoneTemplatePage("viewPost.html", template, "Page.ViewPost.Title", webInterface, false) {
 
        override fun handleRequest(freenetRequest: FreenetRequest, templateContext: TemplateContext) {
-               templateContext["post"] = freenetRequest.parameters["post"].let(webInterface.core::getPost).orNull()
+               templateContext["post"] = freenetRequest.parameters["post"]?.let(webInterface.core::getPost)?.orNull()
                templateContext["raw"] = freenetRequest.parameters["raw"] == "true"
        }
 
        override fun isLinkExcepted(link: URI?) = true
 
        public override fun getPageTitle(freenetRequest: FreenetRequest) =
-                       (freenetRequest.parameters["post"].let(webInterface.core::getPost).let {
+                       (freenetRequest.parameters["post"]?.let(webInterface.core::getPost)?.let {
                                if (it.text.length > 20) {
                                        it.text.substring(0..19) + "…"
                                } else {