projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
afc39ea
)
Only store IDs of Sones in replies.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Tue, 22 Jan 2013 09:31:48 +0000
(10:31 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Tue, 22 Jan 2013 09:31:48 +0000
(10:31 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/PostReplyBuilder.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/ReplyBuilder.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/impl/AbstractReplyBuilder.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/core/Core.java
b/src/main/java/net/pterodactylus/sone/core/Core.java
index
8faad72
..
c3276a3
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/Core.java
+++ b/
src/main/java/net/pterodactylus/sone/core/Core.java
@@
-1330,7
+1330,7
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
return;
}
PostReplyBuilder postReplyBuilder = postReplyBuilderFactory.newPostReplyBuilder();
return;
}
PostReplyBuilder postReplyBuilder = postReplyBuilderFactory.newPostReplyBuilder();
- postReplyBuilder.withId(replyId).from(sone).to(postId).withTime(replyTime).withText(replyText);
+ postReplyBuilder.withId(replyId).from(sone
.getId()
).to(postId).withTime(replyTime).withText(replyText);
replies.add(postReplyBuilder.build());
}
replies.add(postReplyBuilder.build());
}
@@
-1663,7
+1663,7
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
return null;
}
PostReplyBuilder postReplyBuilder = postReplyBuilderFactory.newPostReplyBuilder();
return null;
}
PostReplyBuilder postReplyBuilder = postReplyBuilderFactory.newPostReplyBuilder();
- postReplyBuilder.randomId().from(sone).to(post.getId()).currentTime().withText(text.trim());
+ postReplyBuilder.randomId().from(sone
.getId()
).to(post.getId()).currentTime().withText(text.trim());
final PostReply reply = postReplyBuilder.build();
synchronized (replies) {
replies.put(reply.getId(), reply);
final PostReply reply = postReplyBuilder.build();
synchronized (replies) {
replies.put(reply.getId(), reply);
diff --git
a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
index
6c61fd8
..
388d804
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
+++ b/
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
@@
-409,7
+409,7
@@
public class SoneDownloader extends AbstractService {
try {
PostReplyBuilder postReplyBuilder = core.postReplyBuilder();
/* TODO - parse time correctly. */
try {
PostReplyBuilder postReplyBuilder = core.postReplyBuilder();
/* TODO - parse time correctly. */
- postReplyBuilder.withId(replyId).from(sone).to(replyPostId).withTime(Long.parseLong(replyTime)).withText(replyText);
+ postReplyBuilder.withId(replyId).from(sone
.getId()
).to(replyPostId).withTime(Long.parseLong(replyTime)).withText(replyText);
replies.add(postReplyBuilder.build());
} catch (NumberFormatException nfe1) {
/* TODO - mark Sone as bad. */
replies.add(postReplyBuilder.build());
} catch (NumberFormatException nfe1) {
/* TODO - mark Sone as bad. */
diff --git
a/src/main/java/net/pterodactylus/sone/data/PostReplyBuilder.java
b/src/main/java/net/pterodactylus/sone/data/PostReplyBuilder.java
index
1ba7fd5
..
09eb98a
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/PostReplyBuilder.java
+++ b/
src/main/java/net/pterodactylus/sone/data/PostReplyBuilder.java
@@
-42,7
+42,7
@@
public interface PostReplyBuilder extends ReplyBuilder<PostReplyBuilder> {
* <ul>
* <li>Exactly one of {@link #randomId()} or {@link #withId(String)} must
* have been called.</li>
* <ul>
* <li>Exactly one of {@link #randomId()} or {@link #withId(String)} must
* have been called.</li>
- * <li>The {@link #from(S
one
) sender} must not be {@code null}.</li>
+ * <li>The {@link #from(S
tring
) 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
* <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
diff --git
a/src/main/java/net/pterodactylus/sone/data/ReplyBuilder.java
b/src/main/java/net/pterodactylus/sone/data/ReplyBuilder.java
index
53f3153
..
fa0aac8
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/ReplyBuilder.java
+++ b/
src/main/java/net/pterodactylus/sone/data/ReplyBuilder.java
@@
-46,14
+46,14
@@
public interface ReplyBuilder<B extends ReplyBuilder<B>> {
public B withId(String id);
/**
public B withId(String id);
/**
- * Configures this builder to use the
given {@link Sone} as sender of the
- * reply.
+ * Configures this builder to use the
ID of the given {@link Sone} as sender
+ *
of the
reply.
*
*
- * @param sender
- * The sender of the reply
+ * @param sender
Id
+ * The
ID of the
sender of the reply
* @return This builder
*/
* @return This builder
*/
- public B from(S
one sender
);
+ public B from(S
tring senderId
);
/**
* Configures this builder to use the current time when creating the reply.
/**
* Configures this builder to use the current time when creating the reply.
diff --git
a/src/main/java/net/pterodactylus/sone/data/impl/AbstractReplyBuilder.java
b/src/main/java/net/pterodactylus/sone/data/impl/AbstractReplyBuilder.java
index
e04e854
..
25dd1e1
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/impl/AbstractReplyBuilder.java
+++ b/
src/main/java/net/pterodactylus/sone/data/impl/AbstractReplyBuilder.java
@@
-18,7
+18,6
@@
package net.pterodactylus.sone.data.impl;
import net.pterodactylus.sone.data.ReplyBuilder;
package net.pterodactylus.sone.data.impl;
import net.pterodactylus.sone.data.ReplyBuilder;
-import net.pterodactylus.sone.data.Sone;
/**
* Abstract implementation of a {@link ReplyBuilder}.
/**
* Abstract implementation of a {@link ReplyBuilder}.
@@
-36,7
+35,7
@@
public class AbstractReplyBuilder<B extends ReplyBuilder<B>> implements ReplyBui
protected String id;
/** The sender of the reply. */
protected String id;
/** The sender of the reply. */
- protected S
one sender
;
+ protected S
tring senderId
;
/** Whether to use the current time when creating the reply. */
protected boolean currentTime;
/** Whether to use the current time when creating the reply. */
protected boolean currentTime;
@@
-72,8
+71,8
@@
public class AbstractReplyBuilder<B extends ReplyBuilder<B>> implements ReplyBui
*/
@Override
@SuppressWarnings("unchecked")
*/
@Override
@SuppressWarnings("unchecked")
- public B from(S
one sender
) {
- this.sender
= sender
;
+ public B from(S
tring senderId
) {
+ this.sender
Id = senderId
;
return (B) this;
}
return (B) this;
}
diff --git
a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java
b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java
index
80bc3c7
..
5005e5e
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java
+++ b/
src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java
@@
-18,6
+18,7
@@
package net.pterodactylus.sone.data.impl;
import net.pterodactylus.sone.core.PostProvider;
package net.pterodactylus.sone.data.impl;
import net.pterodactylus.sone.core.PostProvider;
+import net.pterodactylus.sone.core.SoneProvider;
import net.pterodactylus.sone.data.PostReplyBuilder;
import net.pterodactylus.sone.data.PostReplyBuilderFactory;
import net.pterodactylus.sone.data.PostReplyBuilder;
import net.pterodactylus.sone.data.PostReplyBuilderFactory;
@@
-30,17
+31,23
@@
import com.google.inject.Inject;
*/
public class DefaultPostReplyBuilderFactory implements PostReplyBuilderFactory {
*/
public class DefaultPostReplyBuilderFactory implements PostReplyBuilderFactory {
+ /** The Sone provider. */
+ private final SoneProvider soneProvider;
+
/** The post provider. */
private final PostProvider postProvider;
/**
* Creates a new default post reply builder factory.
*
/** The post provider. */
private final PostProvider postProvider;
/**
* Creates a new default post reply builder factory.
*
+ * @param soneProvider
+ * The Sone provider
* @param postProvider
* The post provider
*/
@Inject
* @param postProvider
* The post provider
*/
@Inject
- public DefaultPostReplyBuilderFactory(PostProvider postProvider) {
+ public DefaultPostReplyBuilderFactory(SoneProvider soneProvider, PostProvider postProvider) {
+ this.soneProvider = soneProvider;
this.postProvider = postProvider;
}
this.postProvider = postProvider;
}
@@
-49,7
+56,7
@@
public class DefaultPostReplyBuilderFactory implements PostReplyBuilderFactory {
*/
@Override
public PostReplyBuilder newPostReplyBuilder() {
*/
@Override
public PostReplyBuilder newPostReplyBuilder() {
- return new PostReplyBuilderImpl(postProvider);
+ return new PostReplyBuilderImpl(
soneProvider,
postProvider);
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java
b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java
index
c4e6bff
..
1709b6e
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java
+++ b/
src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java
@@
-22,6
+22,7
@@
import static com.google.common.base.Preconditions.checkState;
import java.util.UUID;
import net.pterodactylus.sone.core.PostProvider;
import java.util.UUID;
import net.pterodactylus.sone.core.PostProvider;
+import net.pterodactylus.sone.core.SoneProvider;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.PostReplyBuilder;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.PostReplyBuilder;
@@
-35,7
+36,10
@@
import org.apache.commons.lang.StringUtils;
*/
public class PostReplyBuilderImpl extends AbstractReplyBuilder<PostReplyBuilder> implements PostReplyBuilder {
*/
public class PostReplyBuilderImpl extends AbstractReplyBuilder<PostReplyBuilder> implements PostReplyBuilder {
- /** The post builder. */
+ /** The Sone provider. */
+ private final SoneProvider soneProvider;
+
+ /** The post provider. */
private final PostProvider postProvider;
/** The ID of the post the created reply refers to. */
private final PostProvider postProvider;
/** The ID of the post the created reply refers to. */
@@
-44,10
+48,13
@@
public class PostReplyBuilderImpl extends AbstractReplyBuilder<PostReplyBuilder>
/**
* Creates a new post reply builder.
*
/**
* Creates a new post reply builder.
*
+ * @param soneProvider
+ * The Sone provider
* @param postProvider
* The post provider
*/
* @param postProvider
* The post provider
*/
- public PostReplyBuilderImpl(PostProvider postProvider) {
+ public PostReplyBuilderImpl(SoneProvider soneProvider, PostProvider postProvider) {
+ this.soneProvider = soneProvider;
this.postProvider = postProvider;
}
this.postProvider = postProvider;
}
@@
-66,12
+73,12
@@
public class PostReplyBuilderImpl extends AbstractReplyBuilder<PostReplyBuilder>
@Override
public PostReply build() {
checkState((randomId && (id == null)) || (!randomId && (id != null)), "either random ID nor custom ID must be set");
@Override
public PostReply build() {
checkState((randomId && (id == null)) || (!randomId && (id != null)), "either random ID nor custom ID must be set");
- checkState(sender != null, "sender must not be null");
+ checkState(sender
Id
!= null, "sender must not be null");
checkState((currentTime && (time == 0)) || (!currentTime && (time >= 0)), "either current time or custom time must be set");
checkState(!StringUtils.isBlank(text), "text must not be empty");
checkState(postId != null, "post must not be null");
/* create new post reply. */
checkState((currentTime && (time == 0)) || (!currentTime && (time >= 0)), "either current time or custom time must be set");
checkState(!StringUtils.isBlank(text), "text must not be empty");
checkState(postId != null, "post must not be null");
/* create new post reply. */
- return new PostReplyImpl(
postProvider, randomId ? UUID.randomUUID().toString() : id, sender
, currentTime ? System.currentTimeMillis() : time, text, postId);
+ return new PostReplyImpl(
soneProvider, postProvider, randomId ? UUID.randomUUID().toString() : id, senderId
, currentTime ? System.currentTimeMillis() : time, text, postId);
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java
b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java
index
e7b6626
..
97c84e4
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java
+++ b/
src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java
@@
-18,9
+18,9
@@
package net.pterodactylus.sone.data.impl;
import net.pterodactylus.sone.core.PostProvider;
package net.pterodactylus.sone.data.impl;
import net.pterodactylus.sone.core.PostProvider;
+import net.pterodactylus.sone.core.SoneProvider;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
-import net.pterodactylus.sone.data.Sone;
/**
* Simple {@link PostReply} implementation.
/**
* Simple {@link PostReply} implementation.
@@
-38,12
+38,14
@@
public class PostReplyImpl extends ReplyImpl<PostReply> implements PostReply {
/**
* Creates a new reply.
*
/**
* Creates a new reply.
*
+ * @param soneProvider
+ * The Sone provider
* @param postProvider
* The post provider
* @param id
* The ID of the reply
* @param postProvider
* The post provider
* @param id
* The ID of the reply
- * @param sone
- * The Sone of the reply
+ * @param sone
Id
+ * The
ID of the
Sone of the reply
* @param time
* The time of the reply
* @param text
* @param time
* The time of the reply
* @param text
@@
-51,8
+53,8
@@
public class PostReplyImpl extends ReplyImpl<PostReply> implements PostReply {
* @param postId
* The ID of the post this reply refers to
*/
* @param postId
* The ID of the post this reply refers to
*/
- public PostReplyImpl(
PostProvider postProvider, String id, Sone sone
, long time, String text, String postId) {
- super(
id, sone
, time, text);
+ public PostReplyImpl(
SoneProvider soneProvider, PostProvider postProvider, String id, String soneId
, long time, String text, String postId) {
+ super(
soneProvider, id, soneId
, time, text);
this.postProvider = postProvider;
this.postId = postId;
}
this.postProvider = postProvider;
this.postId = postId;
}
diff --git
a/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java
b/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java
index
ee8c01e
..
5590c7e
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java
+++ b/
src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java
@@
-17,6
+17,7
@@
package net.pterodactylus.sone.data.impl;
package net.pterodactylus.sone.data.impl;
+import net.pterodactylus.sone.core.SoneProvider;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
@@
-29,11
+30,14
@@
import net.pterodactylus.sone.data.Sone;
*/
public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
*/
public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
+ /** The Sone provider. */
+ private final SoneProvider soneProvider;
+
/** The ID of the reply. */
private final String id;
/** The Sone that created this reply. */
/** The ID of the reply. */
private final String id;
/** The Sone that created this reply. */
- private final S
one sone
;
+ private final S
tring soneId
;
/** The time of the reply. */
private final long time;
/** The time of the reply. */
private final long time;
@@
-47,18
+51,21
@@
public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
/**
* Creates a new reply.
*
/**
* Creates a new reply.
*
+ * @param soneProvider
+ * The Sone provider
* @param id
* The ID of the reply
* @param id
* The ID of the reply
- * @param sone
- * The Sone of the reply
+ * @param sone
Id
+ * The
ID of the
Sone of the reply
* @param time
* The time of the reply
* @param text
* The text of the reply
*/
* @param time
* The time of the reply
* @param text
* The text of the reply
*/
- protected ReplyImpl(String id, Sone sone, long time, String text) {
+ protected ReplyImpl(SoneProvider soneProvider, String id, String soneId, long time, String text) {
+ this.soneProvider = soneProvider;
this.id = id;
this.id = id;
- this.sone
= sone
;
+ this.sone
Id = soneId
;
this.time = time;
this.text = text;
}
this.time = time;
this.text = text;
}
@@
-76,7
+83,7
@@
public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
*/
@Override
public Sone getSone() {
*/
@Override
public Sone getSone() {
- return sone;
+ return sone
Provider.getSone(soneId, false)
;
}
/**
}
/**
@@
-142,7
+149,7
@@
public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
*/
@Override
public String toString() {
*/
@Override
public String toString() {
- return
getClass().getName() + "[id=" + id + ",sone=" + sone + ",time=" + time + ",text=" + text + "]"
;
+ return
String.format("%s[id=%s,sone=%s,time=%d,text=%s]", getClass().getName(), id, soneId, time, text)
;
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java
b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java
index
1114c42
..
04b0de4
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
+++ b/
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
@@
-25,6
+25,7
@@
import java.util.logging.Logger;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.core.FreenetInterface;
import net.pterodactylus.sone.core.PostProvider;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.core.FreenetInterface;
import net.pterodactylus.sone.core.PostProvider;
+import net.pterodactylus.sone.core.SoneProvider;
import net.pterodactylus.sone.core.WebOfTrustUpdater;
import net.pterodactylus.sone.data.PostBuilderFactory;
import net.pterodactylus.sone.data.PostReplyBuilderFactory;
import net.pterodactylus.sone.core.WebOfTrustUpdater;
import net.pterodactylus.sone.data.PostBuilderFactory;
import net.pterodactylus.sone.data.PostReplyBuilderFactory;
@@
-224,6
+225,7
@@
public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
bind(FcpInterface.class).in(Singleton.class);
bind(PostBuilderFactory.class).to(DefaultPostBuilderFactory.class).in(Singleton.class);
bind(PostReplyBuilderFactory.class).to(DefaultPostReplyBuilderFactory.class).in(Singleton.class);
bind(FcpInterface.class).in(Singleton.class);
bind(PostBuilderFactory.class).to(DefaultPostBuilderFactory.class).in(Singleton.class);
bind(PostReplyBuilderFactory.class).to(DefaultPostReplyBuilderFactory.class).in(Singleton.class);
+ bind(SoneProvider.class).to(Core.class).in(Singleton.class);
bind(PostProvider.class).to(Core.class).in(Singleton.class);
bindListener(Matchers.any(), new TypeListener() {
bind(PostProvider.class).to(Core.class).in(Singleton.class);
bindListener(Matchers.any(), new TypeListener() {