int postCounter = 0;
for (Post post : sone.getPosts()) {
String postPrefix = sonePrefix + "/Posts/" + postCounter++;
- configuration.getStringValue(postPrefix + "/ID").setValue(post.getId());
+ configuration.getStringValue(postPrefix + "/ID").setValue(post.getInternalId());
configuration.getStringValue(postPrefix + "/Recipient").setValue(post.getRecipientId().orNull());
configuration.getLongValue(postPrefix + "/Time").setValue(post.getTime());
configuration.getStringValue(postPrefix + "/Text").setValue(post.getText());
* @return The ID of the post
*/
public String getId();
+ String getInternalId();
/**
* Returns whether this post has already been loaded.
}
@Override
+ public String getInternalId() {
+ return id;
+ }
+
+ @Override
public boolean isLoaded() {
return false;
}
package net.pterodactylus.sone.data.impl;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.database.SoneProvider;
*/
public class PostImpl implements Post {
+ private final IdBuilder idBuilder = new IdBuilder();
+
/** The Sone provider. */
private final SoneProvider soneProvider;
*/
@Override
public String getId() {
+ return idBuilder.buildId(soneId, id);
+ }
+
+ @Override
+ public String getInternalId() {
return id;
}
import java.util.UUID;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.database.SoneProvider;
*/
class MemoryPost implements Post {
+ private final IdBuilder idBuilder = new IdBuilder();
+
/** The post database. */
private final MemoryDatabase postDatabase;
*/
@Override
public String getId() {
+ return idBuilder.buildId(soneId, id.toString());
+ }
+
+ @Override
+ public String getInternalId() {
return id.toString();
}
package net.pterodactylus.sone.web;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
- String id = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
+ String id = request.getHttpRequest().getPartAsStringFailsafe("post", IdBuilder.ID_STRING_LENGTH);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
Optional<Post> post = webInterface.getCore().getPost(id);
if (post.isPresent()) {
import com.google.common.base.Optional;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.text.TextFilter;
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
- String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
+ String postId = request.getHttpRequest().getPartAsStringFailsafe("post", IdBuilder.ID_STRING_LENGTH);
String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
if (request.getMethod() == Method.POST) {
import com.google.common.base.Optional;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
templateContext.set("post", post.get());
templateContext.set("returnPage", returnPage);
} else if (request.getMethod() == Method.POST) {
- String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
+ String postId = request.getHttpRequest().getPartAsStringFailsafe("post", IdBuilder.ID_STRING_LENGTH);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
Optional<Post> post = webInterface.getCore().getPost(postId);
if (!post.isPresent() || !post.get().getSone().isLocal()) {
package net.pterodactylus.sone.web;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
String type = request.getHttpRequest().getPartAsStringFailsafe("type", 16);
- String id = request.getHttpRequest().getPartAsStringFailsafe(type, 36);
+ String id = request.getHttpRequest().getPartAsStringFailsafe(type, IdBuilder.ID_STRING_LENGTH);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
Sone currentSone = getCurrentSone(request.getToadletContext());
if ("post".equals(type)) {
import java.util.Set;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
- String id = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
+ String id = request.getHttpRequest().getPartAsStringFailsafe("post", IdBuilder.ID_STRING_LENGTH);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
Optional<Post> post = webInterface.getCore().getPost(id);
if (post.isPresent()) {
package net.pterodactylus.sone.web;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
super.processTemplate(request, templateContext);
if (request.getMethod() == Method.POST) {
String type = request.getHttpRequest().getPartAsStringFailsafe("type", 16);
- String id = request.getHttpRequest().getPartAsStringFailsafe(type, 36);
+ String id = request.getHttpRequest().getPartAsStringFailsafe(type, IdBuilder.ID_STRING_LENGTH);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
Sone currentSone = getCurrentSone(request.getToadletContext());
if ("post".equals(type)) {
<posts>
<%foreach currentSone.posts post>
<post>
- <id><% post.id|xml></id>
+ <id><% post.internalId|xml></id>
<recipient><%if post.recipientId.present><% post.recipientId.get|xml><%/if></recipient>
<time><% post.time></time>
<text><% post.text|xml></text>