int replyCounter = 0;
for (PostReply reply : sone.getReplies()) {
String replyPrefix = sonePrefix + "/Replies/" + replyCounter++;
- configuration.getStringValue(replyPrefix + "/ID").setValue(reply.getId());
+ configuration.getStringValue(replyPrefix + "/ID").setValue(reply.getInternalId());
configuration.getStringValue(replyPrefix + "/Post/ID").setValue(reply.getPostId());
configuration.getLongValue(replyPrefix + "/Time").setValue(reply.getTime());
configuration.getStringValue(replyPrefix + "/Text").setValue(reply.getText());
* @return The ID of the reply
*/
public String getId();
+ String getInternalId();
/**
* Returns the Sone that posted this reply.
package net.pterodactylus.sone.data.impl;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.database.SoneProvider;
*/
public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
+ 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;
}
package net.pterodactylus.sone.database.memory;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.Sone;
*/
class MemoryPostReply implements PostReply {
+ private final IdBuilder idBuilder = new IdBuilder();
+
/** The database. */
private final MemoryDatabase database;
*/
@Override
public String getId() {
+ return idBuilder.buildId(soneId, id);
+ }
+
+ @Override
+ public String getInternalId() {
return id;
}
package net.pterodactylus.sone.web;
+import net.pterodactylus.sone.data.IdBuilder;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
- String replyId = request.getHttpRequest().getPartAsStringFailsafe("reply", 36);
+ String replyId = request.getHttpRequest().getPartAsStringFailsafe("reply", IdBuilder.ID_STRING_LENGTH);
Optional<PostReply> reply = webInterface.getCore().getPostReply(replyId);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
if (request.getMethod() == Method.POST) {
<replies>
<%foreach currentSone.replies reply>
<reply>
- <id><% reply.id></id>
+ <id><% reply.internalId></id>
<post-id><% reply.postId|xml></post-id>
<time><% reply.time></time>
<text><% reply.text|xml></text>