Skip to content

Commit 7cf3a6a

Browse files
author
boncey
committed
Read 'description' from 'flickr.people.getInfo' response. Fix boncey#139
1 parent 7534591 commit 7cf3a6a

2 files changed

Lines changed: 111 additions & 92 deletions

File tree

Flickr4Java/src/main/java/com/flickr4java/flickr/people/PeopleInterface.java

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44
package com.flickr4java.flickr.people;
55

6-
import com.flickr4java.flickr.Flickr;
76
import com.flickr4java.flickr.FlickrException;
87
import com.flickr4java.flickr.Response;
98
import com.flickr4java.flickr.Transport;
@@ -30,7 +29,7 @@
3029

3130
/**
3231
* Interface for finding Flickr users.
33-
*
32+
*
3433
* @author Anthony Eden
3534
* @version $Id: PeopleInterface.java,v 1.28 2010/09/12 20:13:57 x-mago Exp $
3635
*/
@@ -55,7 +54,7 @@ public class PeopleInterface {
5554
public static final String METHOD_GET_PHOTOS_OF = "flickr.people.getPhotosOf";
5655

5756
public static final String METHOD_GET_GROUPS = "flickr.people.getGroups";
58-
57+
5958
public static final String METHOD_GET_LIMITS = "flickr.people.getLimits";
6059

6160
private final String apiKey;
@@ -72,9 +71,9 @@ public PeopleInterface(String apiKey, String sharedSecret, Transport transportAP
7271

7372
/**
7473
* Find the user by their email address.
75-
*
74+
*
7675
* This method does not require authentication.
77-
*
76+
*
7877
* @param email
7978
* The email address
8079
* @return The User
@@ -99,9 +98,9 @@ public User findByEmail(String email) throws FlickrException {
9998

10099
/**
101100
* Find a User by the username.
102-
*
101+
*
103102
* This method does not require authentication.
104-
*
103+
*
105104
* @param username
106105
* The username
107106
* @return The User object
@@ -110,7 +109,7 @@ public User findByEmail(String email) throws FlickrException {
110109
public User findByUsername(String username) throws FlickrException {
111110
Map<String, Object> parameters = new HashMap<String, Object>();
112111
parameters.put("method", METHOD_FIND_BY_USERNAME);
113-
112+
114113
parameters.put("username", username);
115114

116115
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
@@ -126,9 +125,9 @@ public User findByUsername(String username) throws FlickrException {
126125

127126
/**
128127
* Get info about the specified user.
129-
*
128+
*
130129
* This method does not require authentication.
131-
*
130+
*
132131
* @param userId
133132
* The user ID
134133
* @return The User object
@@ -137,10 +136,10 @@ public User findByUsername(String username) throws FlickrException {
137136
public User getInfo(String userId) throws FlickrException {
138137
Map<String, Object> parameters = new HashMap<String, Object>();
139138
parameters.put("method", METHOD_GET_INFO);
140-
139+
141140
parameters.put("user_id", userId);
142141

143-
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
142+
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
144143
if (response.isError()) {
145144
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
146145
}
@@ -157,6 +156,7 @@ public User getInfo(String userId) throws FlickrException {
157156
String lPathAlias = userElement.getAttribute("path_alias");
158157
user.setPathAlias(lPathAlias == null || "".equals(lPathAlias) ? null : lPathAlias);
159158
user.setUsername(XMLUtilities.getChildValue(userElement, "username"));
159+
user.setDescription(XMLUtilities.getChildValue(userElement, "description"));
160160
user.setRealName(XMLUtilities.getChildValue(userElement, "realname"));
161161
user.setLocation(XMLUtilities.getChildValue(userElement, "location"));
162162
user.setMbox_sha1sum(XMLUtilities.getChildValue(userElement, "mbox_sha1sum"));
@@ -168,7 +168,7 @@ public User getInfo(String userId) throws FlickrException {
168168
user.setPhotosFirstDate(XMLUtilities.getChildValue(photosElement, "firstdate"));
169169
user.setPhotosFirstDateTaken(XMLUtilities.getChildValue(photosElement, "firstdatetaken"));
170170
user.setPhotosCount(XMLUtilities.getChildValue(photosElement, "count"));
171-
171+
172172
NodeList tzNodes = userElement.getElementsByTagName("timezone");
173173
for (int i = 0; i < tzNodes.getLength(); i++) {
174174
Element tzElement = (Element) tzNodes.item(i);
@@ -183,12 +183,12 @@ public User getInfo(String userId) throws FlickrException {
183183

184184
/**
185185
* Get a collection of public groups for the user.
186-
*
186+
*
187187
* The groups will contain only the members nsid, name, admin and eighteenplus. If you want the whole group-information, you have to call
188188
* {@link com.flickr4java.flickr.groups.GroupsInterface#getInfo(String)}.
189-
*
189+
*
190190
* This method does not require authentication.
191-
*
191+
*
192192
* @param userId
193193
* The user ID
194194
* @return The public groups
@@ -202,7 +202,7 @@ public Collection<Group> getPublicGroups(String userId) throws FlickrException {
202202

203203
parameters.put("user_id", userId);
204204

205-
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
205+
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
206206
if (response.isError()) {
207207
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
208208
}
@@ -226,9 +226,9 @@ public PhotoList<Photo> getPublicPhotos(String userId, int perPage, int page) th
226226

227227
/**
228228
* Get a collection of public photos for the specified user ID.
229-
*
229+
*
230230
* This method does not require authentication.
231-
*
231+
*
232232
* @see com.flickr4java.flickr.photos.Extras
233233
* @param userId
234234
* The User ID
@@ -260,7 +260,7 @@ public PhotoList<Photo> getPublicPhotos(String userId, Set<String> extras, int p
260260
parameters.put(Extras.KEY_EXTRAS, StringUtilities.join(extras, ","));
261261
}
262262

263-
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
263+
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
264264
if (response.isError()) {
265265
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
266266
}
@@ -280,17 +280,17 @@ public PhotoList<Photo> getPublicPhotos(String userId, Set<String> extras, int p
280280

281281
/**
282282
* Get upload status for the currently authenticated user.
283-
*
283+
*
284284
* Requires authentication with 'read' permission using the new authentication API.
285-
*
285+
*
286286
* @return A User object with upload status data fields filled
287287
* @throws FlickrException
288288
*/
289289
public User getUploadStatus() throws FlickrException {
290290
Map<String, Object> parameters = new HashMap<String, Object>();
291291
parameters.put("method", METHOD_GET_UPLOAD_STATUS);
292292

293-
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
293+
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
294294
if (response.isError()) {
295295
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
296296
}
@@ -307,19 +307,18 @@ public User getUploadStatus() throws FlickrException {
307307

308308
Element filesizeElement = XMLUtilities.getChild(userElement, "filesize");
309309
user.setFilesizeMax(filesizeElement.getAttribute("max"));
310-
310+
311311
Element setsElement = XMLUtilities.getChild(userElement, "sets");
312312
user.setSetsCreated(setsElement.getAttribute("created"));
313313
user.setSetsRemaining(setsElement.getAttribute("remaining"));
314-
314+
315315
Element videosElement = XMLUtilities.getChild(userElement, "videos");
316316
user.setVideosUploaded(videosElement.getAttribute("uploaded"));
317317
user.setVideosRemaining(videosElement.getAttribute("remaining"));
318-
318+
319319
Element videoSizeElement = XMLUtilities.getChild(userElement, "videosize");
320320
user.setVideoSizeMax(videoSizeElement.getAttribute("maxbytes"));
321321

322-
323322
return user;
324323
}
325324

@@ -361,7 +360,7 @@ public PhotoList<Photo> getPhotos(String userId, String safeSearch, Date minUplo
361360
parameters.put(Extras.KEY_EXTRAS, StringUtilities.join(extras, ","));
362361
}
363362

364-
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
363+
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
365364
if (response.isError()) {
366365
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
367366
}
@@ -400,7 +399,7 @@ public PhotoList<Photo> getPhotosOf(String userId, String ownerId, Set<String> e
400399
parameters.put("page", "" + page);
401400
}
402401

403-
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
402+
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
404403
if (response.isError()) {
405404
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
406405
}
@@ -433,7 +432,7 @@ public PhotoList<Photo> getPhotosOf(String userId, String ownerId, Set<String> e
433432

434433
/**
435434
* Add the given person to the photo. Optionally, send in co-ordinates
436-
*
435+
*
437436
* @param photoId
438437
* @param userId
439438
* @param bounds
@@ -448,7 +447,7 @@ public void add(String photoId, String userId, Rectangle bounds) throws FlickrEx
448447

449448
/**
450449
* Delete the person from the photo
451-
*
450+
*
452451
* @param photoId
453452
* @param userId
454453
* @throws FlickrException
@@ -462,7 +461,7 @@ public void delete(String photoId, String userId) throws FlickrException {
462461

463462
/**
464463
* Delete the co-ordinates that the user is shown in
465-
*
464+
*
466465
* @param photoId
467466
* @param userId
468467
* @throws FlickrException
@@ -476,7 +475,7 @@ public void deleteCoords(String photoId, String userId) throws FlickrException {
476475

477476
/**
478477
* Edit the co-ordinates that the user shows in
479-
*
478+
*
480479
* @param photoId
481480
* @param userId
482481
* @param bounds
@@ -491,7 +490,7 @@ public void editCoords(String photoId, String userId, Rectangle bounds) throws F
491490

492491
/**
493492
* Get a list of people in a given photo.
494-
*
493+
*
495494
* @param photoId
496495
* @throws FlickrException
497496
*/
@@ -503,7 +502,7 @@ public PersonTagList<PersonTag> getList(String photoId) throws FlickrException {
503502
}
504503

505504
/**
506-
*
505+
*
507506
* @param userId
508507
* @throws FlickrException
509508
*/
@@ -514,7 +513,7 @@ public GroupList<Group> getGroups(String userId) throws FlickrException {
514513
parameters.put("method", METHOD_GET_GROUPS);
515514
parameters.put("user_id", userId);
516515

517-
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
516+
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
518517
if (response.isError()) {
519518
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
520519
}
@@ -537,18 +536,18 @@ public GroupList<Group> getGroups(String userId) throws FlickrException {
537536
return groupList;
538537

539538
}
540-
539+
541540
/**
542541
* Get's the user's current upload limits, User object only contains user_id
543542
*
544543
* @return Media Limits
545544
*/
546-
545+
547546
public User getLimits() throws FlickrException {
548547
Map<String, Object> parameters = new HashMap<String, Object>();
549548
parameters.put("method", METHOD_GET_LIMITS);
550549

551-
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
550+
Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret);
552551
if (response.isError()) {
553552
throw new FlickrException(response.getErrorCode(), response.getErrorMessage());
554553
}

0 commit comments

Comments
 (0)