projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6326513
)
Add a mandatory response message name to Command.Response.
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Mon, 11 Apr 2011 07:29:54 +0000
(09:29 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Mon, 11 Apr 2011 07:29:54 +0000
(09:29 +0200)
src/main/java/net/pterodactylus/sone/fcp/GetLocalSonesCommand.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/fcp/GetPostCommand.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java
patch
|
blob
|
history
src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/GetLocalSonesCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/GetLocalSonesCommand.java
index
718dd89
..
c4206d5
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/GetLocalSonesCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/GetLocalSonesCommand.java
@@
-45,7
+45,7
@@
public class GetLocalSonesCommand extends AbstractSoneCommand {
*/
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
*/
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
- return new Response(encodeSones(getCore().getLocalSones(), "LocalSones."));
+ return new Response(
"ListLocalSones",
encodeSones(getCore().getLocalSones(), "LocalSones."));
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/GetPostCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/GetPostCommand.java
index
391694f
..
b01b8f2
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/GetPostCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/GetPostCommand.java
@@
-48,7
+48,7
@@
public class GetPostCommand extends AbstractSoneCommand {
Post post = getPost(parameters, "Post");
boolean includeReplies = getBoolean(parameters, "IncludeReplies", true);
Post post = getPost(parameters, "Post");
boolean includeReplies = getBoolean(parameters, "IncludeReplies", true);
- return new Response(encodePost(post, "Post.", includeReplies));
+ return new Response(
"Post",
encodePost(post, "Post.", includeReplies));
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
index
895c1c6
..
3331c4f
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
@@
-73,10
+73,10
@@
public class GetPostFeedCommand extends AbstractSoneCommand {
Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
if (sortedPosts.size() < startPost) {
Collections.sort(sortedPosts, Post.TIME_COMPARATOR);
if (sortedPosts.size() < startPost) {
- return new Response(encodePosts(Collections.<Post> emptyList(), "Posts.", false));
+ return new Response(
"PostFeed",
encodePosts(Collections.<Post> emptyList(), "Posts.", false));
}
}
- return new Response(encodePosts(sortedPosts.subList(startPost, (maxPosts == -1) ? sortedPosts.size() : Math.min(startPost + maxPosts, sortedPosts.size())), "Posts.", true));
+ return new Response(
"PostFeed",
encodePosts(sortedPosts.subList(startPost, (maxPosts == -1) ? sortedPosts.size() : Math.min(startPost + maxPosts, sortedPosts.size())), "Posts.", true));
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java
index
0a02a89
..
24362d9
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java
@@
-55,9
+55,9
@@
public class GetPostsCommand extends AbstractSoneCommand {
int maxPosts = getInt(parameters, "MaxPosts", -1);
List<Post> posts = sone.getPosts();
if (posts.size() < startPost) {
int maxPosts = getInt(parameters, "MaxPosts", -1);
List<Post> posts = sone.getPosts();
if (posts.size() < startPost) {
- return new Response(encodePosts(Collections.<Post> emptyList(), "Posts.", false));
+ return new Response(
"Posts",
encodePosts(Collections.<Post> emptyList(), "Posts.", false));
}
}
- return new Response(encodePosts(sone.getPosts().subList(startPost, (maxPosts == -1) ? posts.size() : Math.min(startPost + maxPosts, posts.size())), "Posts.", true));
+ return new Response(
"Posts",
encodePosts(sone.getPosts().subList(startPost, (maxPosts == -1) ? posts.size() : Math.min(startPost + maxPosts, posts.size())), "Posts.", true));
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java
index
42ca409
..
2147682
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java
@@
-50,7
+50,7
@@
public class LikePostCommand extends AbstractSoneCommand {
Post post = getPost(parameters, "Post");
Sone sone = getSone(parameters, "Sone");
sone.addLikedPostId(post.getId());
Post post = getPost(parameters, "Post");
Sone sone = getSone(parameters, "Sone");
sone.addLikedPostId(post.getId());
- return new Response(
new SimpleFieldSetBuilder().put("Message", "PostLiked"
).put("LikeCount", getCore().getLikes(post).size()).get());
+ return new Response(
"PostLiked", new SimpleFieldSetBuilder(
).put("LikeCount", getCore().getLikes(post).size()).get());
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java
index
ff57c40
..
6817476
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java
@@
-35,7
+35,7
@@
public class VersionCommand implements Command {
*/
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) {
*/
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) {
- return new Response(new SimpleFieldSetBuilder().put("Version", SonePlugin.VERSION.toString()).put("ProtocolVersion", 1).get());
+ return new Response(
"Version",
new SimpleFieldSetBuilder().put("Version", SonePlugin.VERSION.toString()).put("ProtocolVersion", 1).get());
}
}
}
}
diff --git
a/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java
b/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java
index
2a083ee
..
46032dd
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java
+++ b/
src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java
@@
-70,6
+70,9
@@
public interface Command {
*/
public static class Response {
*/
public static class Response {
+ /** The message name of the reponse. */
+ private final String messageName;
+
/** The reply parameters. */
private final SimpleFieldSet replyParameters;
/** The reply parameters. */
private final SimpleFieldSet replyParameters;
@@
-82,40
+85,48
@@
public interface Command {
/**
* Creates a new reply with the given parameters.
*
/**
* Creates a new reply with the given parameters.
*
+ * @param messageName
+ * The message name
* @param replyParameters
* The reply parameters
*/
* @param replyParameters
* The reply parameters
*/
- public Response(SimpleFieldSet replyParameters) {
- this(replyParameters, null, null);
+ public Response(S
tring messageName, S
impleFieldSet replyParameters) {
+ this(
messageName,
replyParameters, null, null);
}
/**
* Creates a new reply with the given parameters.
*
}
/**
* Creates a new reply with the given parameters.
*
+ * @param messageName
+ * The message name
* @param replyParameters
* The reply parameters
* @param data
* The data of the reply (may be {@code null})
*/
* @param replyParameters
* The reply parameters
* @param data
* The data of the reply (may be {@code null})
*/
- public Response(SimpleFieldSet replyParameters, byte[] data) {
- this(replyParameters, data, null);
+ public Response(S
tring messageName, S
impleFieldSet replyParameters, byte[] data) {
+ this(
messageName,
replyParameters, data, null);
}
/**
* Creates a new reply with the given parameters.
*
}
/**
* Creates a new reply with the given parameters.
*
+ * @param messageName
+ * The message name
* @param replyParameters
* The reply parameters
* @param bucket
* The bucket of the reply (may be {@code null})
*/
* @param replyParameters
* The reply parameters
* @param bucket
* The bucket of the reply (may be {@code null})
*/
- public Response(SimpleFieldSet replyParameters, Bucket bucket) {
- this(replyParameters, null, bucket);
+ public Response(S
tring messageName, S
impleFieldSet replyParameters, Bucket bucket) {
+ this(
messageName,
replyParameters, null, bucket);
}
/**
* Creates a new reply with the given parameters.
*
}
/**
* Creates a new reply with the given parameters.
*
+ * @param messageName
+ * The message name
* @param replyParameters
* The reply parameters
* @param data
* @param replyParameters
* The reply parameters
* @param data
@@
-123,7
+134,8
@@
public interface Command {
* @param bucket
* The bucket of the reply (may be {@code null})
*/
* @param bucket
* The bucket of the reply (may be {@code null})
*/
- private Response(SimpleFieldSet replyParameters, byte[] data, Bucket bucket) {
+ private Response(String messageName, SimpleFieldSet replyParameters, byte[] data, Bucket bucket) {
+ this.messageName = messageName;
this.replyParameters = replyParameters;
this.data = data;
this.bucket = bucket;
this.replyParameters = replyParameters;
this.data = data;
this.bucket = bucket;
@@
-135,7
+147,7
@@
public interface Command {
* @return The reply parameters
*/
public SimpleFieldSet getReplyParameters() {
* @return The reply parameters
*/
public SimpleFieldSet getReplyParameters() {
- return
replyParameters
;
+ return
new SimpleFieldSetBuilder(replyParameters).put("Message", messageName).get()
;
}
/**
}
/**
@@
-194,7
+206,7
@@
public interface Command {
* The error message
*/
public ErrorResponse(String message) {
* The error message
*/
public ErrorResponse(String message) {
- super(new SimpleFieldSetBuilder().put("ErrorMessage", message).get());
+ super(
"Error",
new SimpleFieldSetBuilder().put("ErrorMessage", message).get());
}
/**
}
/**
@@
-206,7
+218,7
@@
public interface Command {
* The error message
*/
public ErrorResponse(int code, String message) {
* The error message
*/
public ErrorResponse(int code, String message) {
- super(new SimpleFieldSetBuilder().put("ErrorMessage", message).put("ErrorCode", code).get());
+ super(
"Error",
new SimpleFieldSetBuilder().put("ErrorMessage", message).put("ErrorCode", code).get());
}
}
}
}