@@ -150,15 +150,41 @@ public Group lookupGroup(String url) throws FlickrException {
150
150
return group ;
151
151
}
152
152
153
+ /**
154
+ * Lookup the username for the specified User URL.
155
+ *
156
+ * @param url
157
+ * The user profile URL
158
+ * @return The username
159
+ * @throws FlickrException if there was a problem connecting to Flickr
160
+ */
161
+ public String lookupUsernameByURL (String url ) throws FlickrException {
162
+ return lookupUserByURL (url ).getUsername ();
163
+ }
164
+
153
165
/**
154
166
* Lookup the username for the specified User URL.
155
167
*
156
168
* @param url
157
169
* The user profile URL
158
170
* @return The username
159
171
* @throws FlickrException if there was a problem connecting to Flickr
172
+ * @deprecated use {@link #lookupUsernameByURL(String) }
160
173
*/
174
+ @ Deprecated
161
175
public String lookupUser (String url ) throws FlickrException {
176
+ return lookupUsernameByURL (url );
177
+ }
178
+
179
+ /**
180
+ * Lookup the user for the specified User URL.
181
+ *
182
+ * @param url
183
+ * The user profile URL
184
+ * @return The user
185
+ * @throws FlickrException if there was a problem connecting to Flickr
186
+ */
187
+ public User lookupUserByURL (String url ) throws FlickrException {
162
188
Map <String , Object > parameters = new HashMap <String , Object >();
163
189
parameters .put ("method" , METHOD_LOOKUP_USER );
164
190
@@ -171,7 +197,10 @@ public String lookupUser(String url) throws FlickrException {
171
197
172
198
Element payload = response .getPayload ();
173
199
Element groupnameElement = (Element ) payload .getElementsByTagName ("username" ).item (0 );
174
- return ((Text ) groupnameElement .getFirstChild ()).getData ();
200
+ User user = new User ();
201
+ user .setId (payload .getAttribute ("id" ));
202
+ user .setUsername (((Text ) groupnameElement .getFirstChild ()).getData ());
203
+ return user ;
175
204
}
176
205
177
206
/**
0 commit comments