Skip to content

Commit a3bdf5f

Browse files
author
boncey
committed
Fix incorrect mapping of method and map topic methods in completenesstest.properties
1 parent e2e629b commit a3bdf5f

File tree

2 files changed

+49
-48
lines changed

2 files changed

+49
-48
lines changed

Flickr4Java/src/main/java/com/flickr4java/flickr/groups/discuss/GroupDiscussInterface.java

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
package com.flickr4java.flickr.groups.discuss;
22

3-
import java.util.HashMap;
4-
import java.util.Map;
5-
6-
import org.w3c.dom.Element;
7-
import org.w3c.dom.NodeList;
8-
9-
import com.flickr4java.flickr.Flickr;
103
import com.flickr4java.flickr.FlickrException;
114
import com.flickr4java.flickr.Response;
125
import com.flickr4java.flickr.Transport;
136
import com.flickr4java.flickr.util.XMLUtilities;
147

8+
import org.w3c.dom.Element;
9+
import org.w3c.dom.NodeList;
10+
11+
import java.util.HashMap;
12+
import java.util.Map;
1513

1614
public class GroupDiscussInterface {
1715

18-
/**
19-
* Group.Discuss Interface.
20-
*
21-
* @author Jonathan Willis
22-
*/
16+
/**
17+
* Group.Discuss Interface.
18+
*
19+
* @author Jonathan Willis
20+
*/
2321
public static final String METHOD_TOPICS_GET_LIST = "flickr.groups.discuss.topics.getList";
22+
2423
public static final String METHOD_TOPICS_GET_INFO = "flickr.groups.discuss.topics.getInfo";
25-
24+
2625
public static final String METHOD_REPLIES_GET_LIST = "flickr.groups.discuss.replies.getList";
27-
public static final String METHOD_REPLIES_GET_INFO = "flickr.groups.discuss.topics.getInfo";
2826

29-
private String apiKey;
27+
public static final String METHOD_REPLIES_GET_INFO = "flickr.groups.discuss.replies.getInfo";
28+
29+
private final String apiKey;
3030

31-
private String sharedSecret;
31+
private final String sharedSecret;
3232

33-
private Transport transportAPI;
33+
private final Transport transportAPI;
3434

3535
public GroupDiscussInterface(String apiKey, String sharedSecret, Transport transportAPI) {
3636
this.apiKey = apiKey;
@@ -39,7 +39,7 @@ public GroupDiscussInterface(String apiKey, String sharedSecret, Transport trans
3939
}
4040

4141
/**
42-
* Get a list of topics from a group.
42+
* Get a list of topics from a group.
4343
*
4444
* @param groupId
4545
* Unique identifier of a group returns a list of topics for a given group {@link Group}.
@@ -52,7 +52,7 @@ public GroupDiscussInterface(String apiKey, String sharedSecret, Transport trans
5252
* @see <a href="http://www.flickr.com/services/api/flickr.groups.discuss.topics.getList.html">API Documentation</a>
5353
*/
5454
public TopicList<Topic> getTopicsList(String groupId, int perPage, int page) throws FlickrException {
55-
TopicList<Topic> topicList = new TopicList<Topic>();
55+
TopicList<Topic> topicList = new TopicList<Topic>();
5656
Map<String, Object> parameters = new HashMap<String, Object>();
5757
parameters.put("method", METHOD_TOPICS_GET_LIST);
5858

@@ -64,13 +64,12 @@ public TopicList<Topic> getTopicsList(String groupId, int perPage, int page) thr
6464
if (page > 0) {
6565
parameters.put("page", "" + page);
6666
}
67-
6867

6968
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
7069
if (response.isError()) {
7170
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
7271
}
73-
72+
7473
Element topicElements = response.getPayload();
7574
topicList.setPage(topicElements.getAttribute("page"));
7675
topicList.setPages(topicElements.getAttribute("pages"));
@@ -84,17 +83,17 @@ public TopicList<Topic> getTopicsList(String groupId, int perPage, int page) thr
8483
topicList.setPrivacy(Integer.parseInt(topicElements.getAttribute("privacy")));
8584
topicList.setLanguage(topicElements.getAttribute("lang"));
8685
topicList.setIsPoolModerated("1".equals(topicElements.getAttribute("ispoolmoderated")));
87-
86+
8887
NodeList topicNodes = topicElements.getElementsByTagName("topic");
8988
for (int i = 0; i < topicNodes.getLength(); i++) {
9089
Element element = (Element) topicNodes.item(i);
9190
topicList.add(parseTopic(element));
9291
}
9392
return topicList;
9493
}
95-
94+
9695
/**
97-
* Get info for a given topic
96+
* Get info for a given topic
9897
*
9998
* @param topicId
10099
* Unique identifier of a topic for a given group {@link Topic}.
@@ -111,13 +110,12 @@ public Topic getTopicInfo(String topicId) throws FlickrException {
111110
if (response.isError()) {
112111
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
113112
}
114-
113+
115114
Element topicElement = response.getPayload();
116-
115+
117116
return parseTopic(topicElement);
118117
}
119118

120-
121119
/**
122120
* Get list of replies
123121
*
@@ -127,9 +125,9 @@ public Topic getTopicInfo(String topicId) throws FlickrException {
127125
* @throws FlickrException
128126
* @see <a href="http://www.flickr.com/services/api/flickr.groups.discuss.replies.getList.html">API Documentation</a>
129127
*/
130-
public ReplyObject getReplyList(String topicId, int perPage, int page) throws FlickrException {
131-
ReplyList<Reply> reply = new ReplyList<Reply>();
132-
TopicList<Topic> topic = new TopicList<Topic>();
128+
public ReplyObject getReplyList(String topicId, int perPage, int page) throws FlickrException {
129+
ReplyList<Reply> reply = new ReplyList<Reply>();
130+
TopicList<Topic> topic = new TopicList<Topic>();
133131
Map<String, Object> parameters = new HashMap<String, Object>();
134132
parameters.put("method", METHOD_REPLIES_GET_LIST);
135133

@@ -146,31 +144,30 @@ public ReplyObject getReplyList(String topicId, int perPage, int page) throws F
146144
if (response.isError()) {
147145
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
148146
}
149-
147+
150148
Element replyElements = response.getPayload();
151149
ReplyObject ro = new ReplyObject();
152150
NodeList replyNodes = replyElements.getElementsByTagName("reply");
153151
for (int i = 0; i < replyNodes.getLength(); i++) {
154-
Element replyNodeElement = (Element) replyNodes.item(i);
155-
//Element replyElement = XMLUtilities.getChild(replyNodeElement, "reply");
156-
reply.add(parseReply(replyNodeElement));
157-
ro.setReplyList(reply);
158-
152+
Element replyNodeElement = (Element) replyNodes.item(i);
153+
// Element replyElement = XMLUtilities.getChild(replyNodeElement, "reply");
154+
reply.add(parseReply(replyNodeElement));
155+
ro.setReplyList(reply);
156+
159157
}
160158
NodeList topicNodes = replyElements.getElementsByTagName("topic");
161159
for (int i = 0; i < topicNodes.getLength(); i++) {
162-
Element replyNodeElement = (Element) replyNodes.item(i);
163-
//Element topicElement = XMLUtilities.getChild(replyNodeElement, "topic");
160+
Element replyNodeElement = (Element) replyNodes.item(i);
161+
// Element topicElement = XMLUtilities.getChild(replyNodeElement, "topic");
164162
topic.add(parseTopic(replyNodeElement));
165163
ro.setTopicList(topic);
166164
}
167-
165+
168166
return ro;
169167
}
170-
171-
168+
172169
/**
173-
* Get info for a given topic reply
170+
* Get info for a given topic reply
174171
*
175172
* @param topicId
176173
* Unique identifier of a topic for a given group {@link Topic}.
@@ -190,21 +187,21 @@ public Reply getReplyInfo(String topicId, String replyId) throws FlickrException
190187
if (response.isError()) {
191188
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
192189
}
193-
190+
194191
Element replyElement = response.getPayload();
195-
192+
196193
return parseReply(replyElement);
197194
}
198-
195+
199196
private Topic parseTopic(Element tElement) {
200197
Topic topic = new Topic();
201198
topic.setAuthorId(tElement.getAttribute("author"));
202199
topic.setAuthorname(tElement.getAttribute("authorname"));
203200
topic.setIsCanDelete("1".equals(tElement.getAttribute("can_delete")));
204201
topic.setIsCanEdit("1".equals(tElement.getAttribute("can_edit")));
205202
topic.setIsCanReply("1".equals(tElement.getAttribute("can_reply")));
206-
if(!tElement.getAttribute("count_replies").equals("")){
207-
topic.setCountReplies(Integer.parseInt(tElement.getAttribute("count_replies")));
203+
if (!tElement.getAttribute("count_replies").equals("")) {
204+
topic.setCountReplies(Integer.parseInt(tElement.getAttribute("count_replies")));
208205
}
209206
topic.setDatecreate(tElement.getAttribute("datecreate"));
210207
topic.setDatelastpost(tElement.getAttribute("datelastpost"));
@@ -237,5 +234,5 @@ private Reply parseReply(Element rElement) {
237234
reply.setIsPro("1".equals(rElement.getAttribute("is_pro")));
238235
return reply;
239236
}
240-
237+
241238
}

Flickr4Java/src/test/resources/completenesstest.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ flickr.test.null = com.flickr4java.flickr.test.TestInterface.null_
2525
# all methods of flickr.photosets.comments are in PhotosetsComments
2626
flickr.photosets.comments.* = com.flickr4java.flickr.photosets.comments.PhotosetsCommentsInterface.*
2727
flickr.auth.oauth.* = com.flickr4java.flickr.auth.AuthInterface.*
28+
flickr.groups.discuss.topics.getList = com.flickr4java.flickr.groups.discuss.GroupDiscussInterface.getTopicsList
29+
flickr.groups.discuss.topics.getInfo = com.flickr4java.flickr.groups.discuss.GroupDiscussInterface.getTopicInfo
30+
flickr.groups.discuss.replies.getList = com.flickr4java.flickr.groups.discuss.GroupDiscussInterface.getReplyList
31+
flickr.groups.discuss.replies.getInfo = com.flickr4java.flickr.groups.discuss.GroupDiscussInterface.getReplyInfo
2832

0 commit comments

Comments
 (0)