projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
67c17c2
)
Add “localOnly” parameter to getSone().
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Mon, 11 Apr 2011 08:05:13 +0000
(10:05 +0200)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Mon, 11 Apr 2011 08:05:13 +0000
(10:05 +0200)
src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.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/LikeReplyCommand.java
patch
|
blob
|
history
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java
index
b183121
..
87a76e2
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java
@@
-79,15
+79,18
@@
public abstract class AbstractSoneCommand extends AbstractCommand {
* @param parameterName
* The name under which the Sone ID is stored in the simple field
* set
* @param parameterName
* The name under which the Sone ID is stored in the simple field
* set
+ * @param localOnly
+ * {@code true} to only return local Sones, {@code false} to
+ * return any Sones
* @return The Sone
* @throws FcpException
* if there is no Sone ID stored under the given parameter name,
* or if the Sone ID is invalid
*/
* @return The Sone
* @throws FcpException
* if there is no Sone ID stored under the given parameter name,
* or if the Sone ID is invalid
*/
- protected Sone getSone(SimpleFieldSet simpleFieldSet, String parameterName) throws FcpException {
+ protected Sone getSone(SimpleFieldSet simpleFieldSet, String parameterName
, boolean localOnly
) throws FcpException {
try {
String soneId = simpleFieldSet.getString(parameterName);
try {
String soneId = simpleFieldSet.getString(parameterName);
- Sone sone = core.getSone(soneId, false);
+ Sone sone =
localOnly ? core.getLocalSone(soneId, false) :
core.getSone(soneId, false);
if (sone == null) {
throw new FcpException("Could not load Sone from “" + soneId + "”.");
}
if (sone == null) {
throw new FcpException("Could not load Sone from “" + soneId + "”.");
}
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
index
3331c4f
..
d4b175c
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java
@@
-54,7
+54,7
@@
public class GetPostFeedCommand 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 {
- Sone sone = getSone(parameters, "Sone");
+ Sone sone = getSone(parameters, "Sone"
, true
);
int startPost = getInt(parameters, "StartPost", 0);
int maxPosts = getInt(parameters, "MaxPosts", -1);
int startPost = getInt(parameters, "StartPost", 0);
int maxPosts = getInt(parameters, "MaxPosts", -1);
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java
index
24362d9
..
6a3b07e
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java
@@
-50,7
+50,7
@@
public class GetPostsCommand 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 {
- Sone sone = getSone(parameters, "Sone");
+ Sone sone = getSone(parameters, "Sone"
, false
);
int startPost = getInt(parameters, "StartPost", 0);
int maxPosts = getInt(parameters, "MaxPosts", -1);
List<Post> posts = sone.getPosts();
int startPost = getInt(parameters, "StartPost", 0);
int maxPosts = getInt(parameters, "MaxPosts", -1);
List<Post> posts = sone.getPosts();
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java
index
2147682
..
34b8516
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java
@@
-48,7
+48,7
@@
public class LikePostCommand extends AbstractSoneCommand {
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Post post = getPost(parameters, "Post");
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Post post = getPost(parameters, "Post");
- Sone sone = getSone(parameters, "Sone");
+ Sone sone = getSone(parameters, "Sone"
, true
);
sone.addLikedPostId(post.getId());
return new Response("PostLiked", new SimpleFieldSetBuilder().put("LikeCount", getCore().getLikes(post).size()).get());
}
sone.addLikedPostId(post.getId());
return new Response("PostLiked", new SimpleFieldSetBuilder().put("LikeCount", getCore().getLikes(post).size()).get());
}
diff --git
a/src/main/java/net/pterodactylus/sone/fcp/LikeReplyCommand.java
b/src/main/java/net/pterodactylus/sone/fcp/LikeReplyCommand.java
index
a9795b2
..
53e4c02
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/fcp/LikeReplyCommand.java
+++ b/
src/main/java/net/pterodactylus/sone/fcp/LikeReplyCommand.java
@@
-48,7
+48,7
@@
public class LikeReplyCommand extends AbstractSoneCommand {
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Reply reply = getReply(parameters, "Reply");
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Reply reply = getReply(parameters, "Reply");
- Sone sone = getSone(parameters, "Sone");
+ Sone sone = getSone(parameters, "Sone"
, true
);
sone.addLikedReplyId(reply.getId());
return new Response("ReplyLiked", new SimpleFieldSetBuilder().put("LikeCount", getCore().getLikes(reply).size()).get());
}
sone.addLikedReplyId(reply.getId());
return new Response("ReplyLiked", new SimpleFieldSetBuilder().put("LikeCount", getCore().getLikes(reply).size()).get());
}