From 7cf3a6a579482e0a002b0660caa29b1433d48ada Mon Sep 17 00:00:00 2001 From: boncey Date: Sun, 2 Aug 2015 19:09:41 +0100 Subject: [PATCH] Read 'description' from 'flickr.people.getInfo' response. Fix #139 --- .../flickr/people/PeopleInterface.java | 77 ++++++----- .../com/flickr4java/flickr/people/User.java | 126 ++++++++++-------- 2 files changed, 111 insertions(+), 92 deletions(-) diff --git a/Flickr4Java/src/main/java/com/flickr4java/flickr/people/PeopleInterface.java b/Flickr4Java/src/main/java/com/flickr4java/flickr/people/PeopleInterface.java index 52e3c036..c6e0e1e8 100644 --- a/Flickr4Java/src/main/java/com/flickr4java/flickr/people/PeopleInterface.java +++ b/Flickr4Java/src/main/java/com/flickr4java/flickr/people/PeopleInterface.java @@ -3,7 +3,6 @@ */ package com.flickr4java.flickr.people; -import com.flickr4java.flickr.Flickr; import com.flickr4java.flickr.FlickrException; import com.flickr4java.flickr.Response; import com.flickr4java.flickr.Transport; @@ -30,7 +29,7 @@ /** * Interface for finding Flickr users. - * + * * @author Anthony Eden * @version $Id: PeopleInterface.java,v 1.28 2010/09/12 20:13:57 x-mago Exp $ */ @@ -55,7 +54,7 @@ public class PeopleInterface { public static final String METHOD_GET_PHOTOS_OF = "flickr.people.getPhotosOf"; public static final String METHOD_GET_GROUPS = "flickr.people.getGroups"; - + public static final String METHOD_GET_LIMITS = "flickr.people.getLimits"; private final String apiKey; @@ -72,9 +71,9 @@ public PeopleInterface(String apiKey, String sharedSecret, Transport transportAP /** * Find the user by their email address. - * + * * This method does not require authentication. - * + * * @param email * The email address * @return The User @@ -99,9 +98,9 @@ public User findByEmail(String email) throws FlickrException { /** * Find a User by the username. - * + * * This method does not require authentication. - * + * * @param username * The username * @return The User object @@ -110,7 +109,7 @@ public User findByEmail(String email) throws FlickrException { public User findByUsername(String username) throws FlickrException { Map parameters = new HashMap(); parameters.put("method", METHOD_FIND_BY_USERNAME); - + parameters.put("username", username); Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); @@ -126,9 +125,9 @@ public User findByUsername(String username) throws FlickrException { /** * Get info about the specified user. - * + * * This method does not require authentication. - * + * * @param userId * The user ID * @return The User object @@ -137,10 +136,10 @@ public User findByUsername(String username) throws FlickrException { public User getInfo(String userId) throws FlickrException { Map parameters = new HashMap(); parameters.put("method", METHOD_GET_INFO); - + parameters.put("user_id", userId); - Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); + Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } @@ -157,6 +156,7 @@ public User getInfo(String userId) throws FlickrException { String lPathAlias = userElement.getAttribute("path_alias"); user.setPathAlias(lPathAlias == null || "".equals(lPathAlias) ? null : lPathAlias); user.setUsername(XMLUtilities.getChildValue(userElement, "username")); + user.setDescription(XMLUtilities.getChildValue(userElement, "description")); user.setRealName(XMLUtilities.getChildValue(userElement, "realname")); user.setLocation(XMLUtilities.getChildValue(userElement, "location")); user.setMbox_sha1sum(XMLUtilities.getChildValue(userElement, "mbox_sha1sum")); @@ -168,7 +168,7 @@ public User getInfo(String userId) throws FlickrException { user.setPhotosFirstDate(XMLUtilities.getChildValue(photosElement, "firstdate")); user.setPhotosFirstDateTaken(XMLUtilities.getChildValue(photosElement, "firstdatetaken")); user.setPhotosCount(XMLUtilities.getChildValue(photosElement, "count")); - + NodeList tzNodes = userElement.getElementsByTagName("timezone"); for (int i = 0; i < tzNodes.getLength(); i++) { Element tzElement = (Element) tzNodes.item(i); @@ -183,12 +183,12 @@ public User getInfo(String userId) throws FlickrException { /** * Get a collection of public groups for the user. - * + * * The groups will contain only the members nsid, name, admin and eighteenplus. If you want the whole group-information, you have to call * {@link com.flickr4java.flickr.groups.GroupsInterface#getInfo(String)}. - * + * * This method does not require authentication. - * + * * @param userId * The user ID * @return The public groups @@ -202,7 +202,7 @@ public Collection getPublicGroups(String userId) throws FlickrException { parameters.put("user_id", userId); - Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); + Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } @@ -226,9 +226,9 @@ public PhotoList getPublicPhotos(String userId, int perPage, int page) th /** * Get a collection of public photos for the specified user ID. - * + * * This method does not require authentication. - * + * * @see com.flickr4java.flickr.photos.Extras * @param userId * The User ID @@ -260,7 +260,7 @@ public PhotoList getPublicPhotos(String userId, Set extras, int p parameters.put(Extras.KEY_EXTRAS, StringUtilities.join(extras, ",")); } - Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); + Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } @@ -280,9 +280,9 @@ public PhotoList getPublicPhotos(String userId, Set extras, int p /** * Get upload status for the currently authenticated user. - * + * * Requires authentication with 'read' permission using the new authentication API. - * + * * @return A User object with upload status data fields filled * @throws FlickrException */ @@ -290,7 +290,7 @@ public User getUploadStatus() throws FlickrException { Map parameters = new HashMap(); parameters.put("method", METHOD_GET_UPLOAD_STATUS); - Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); + Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } @@ -307,19 +307,18 @@ public User getUploadStatus() throws FlickrException { Element filesizeElement = XMLUtilities.getChild(userElement, "filesize"); user.setFilesizeMax(filesizeElement.getAttribute("max")); - + Element setsElement = XMLUtilities.getChild(userElement, "sets"); user.setSetsCreated(setsElement.getAttribute("created")); user.setSetsRemaining(setsElement.getAttribute("remaining")); - + Element videosElement = XMLUtilities.getChild(userElement, "videos"); user.setVideosUploaded(videosElement.getAttribute("uploaded")); user.setVideosRemaining(videosElement.getAttribute("remaining")); - + Element videoSizeElement = XMLUtilities.getChild(userElement, "videosize"); user.setVideoSizeMax(videoSizeElement.getAttribute("maxbytes")); - return user; } @@ -361,7 +360,7 @@ public PhotoList getPhotos(String userId, String safeSearch, Date minUplo parameters.put(Extras.KEY_EXTRAS, StringUtilities.join(extras, ",")); } - Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); + Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } @@ -400,7 +399,7 @@ public PhotoList getPhotosOf(String userId, String ownerId, Set e parameters.put("page", "" + page); } - Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); + Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } @@ -433,7 +432,7 @@ public PhotoList getPhotosOf(String userId, String ownerId, Set e /** * Add the given person to the photo. Optionally, send in co-ordinates - * + * * @param photoId * @param userId * @param bounds @@ -448,7 +447,7 @@ public void add(String photoId, String userId, Rectangle bounds) throws FlickrEx /** * Delete the person from the photo - * + * * @param photoId * @param userId * @throws FlickrException @@ -462,7 +461,7 @@ public void delete(String photoId, String userId) throws FlickrException { /** * Delete the co-ordinates that the user is shown in - * + * * @param photoId * @param userId * @throws FlickrException @@ -476,7 +475,7 @@ public void deleteCoords(String photoId, String userId) throws FlickrException { /** * Edit the co-ordinates that the user shows in - * + * * @param photoId * @param userId * @param bounds @@ -491,7 +490,7 @@ public void editCoords(String photoId, String userId, Rectangle bounds) throws F /** * Get a list of people in a given photo. - * + * * @param photoId * @throws FlickrException */ @@ -503,7 +502,7 @@ public PersonTagList getList(String photoId) throws FlickrException { } /** - * + * * @param userId * @throws FlickrException */ @@ -514,7 +513,7 @@ public GroupList getGroups(String userId) throws FlickrException { parameters.put("method", METHOD_GET_GROUPS); parameters.put("user_id", userId); - Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); + Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } @@ -537,18 +536,18 @@ public GroupList getGroups(String userId) throws FlickrException { return groupList; } - + /** * Get's the user's current upload limits, User object only contains user_id * * @return Media Limits */ - + public User getLimits() throws FlickrException { Map parameters = new HashMap(); parameters.put("method", METHOD_GET_LIMITS); - Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); + Response response = transportAPI.get(transportAPI.getPath(), parameters, apiKey, sharedSecret); if (response.isError()) { throw new FlickrException(response.getErrorCode(), response.getErrorMessage()); } diff --git a/Flickr4Java/src/main/java/com/flickr4java/flickr/people/User.java b/Flickr4Java/src/main/java/com/flickr4java/flickr/people/User.java index 52cb85f3..f7bc72c0 100644 --- a/Flickr4Java/src/main/java/com/flickr4java/flickr/people/User.java +++ b/Flickr4Java/src/main/java/com/flickr4java/flickr/people/User.java @@ -31,6 +31,8 @@ protected synchronized SimpleDateFormat initialValue() { private String username; + private String description; + private boolean admin; private boolean pro; @@ -44,7 +46,7 @@ protected synchronized SimpleDateFormat initialValue() { private String location; private TimeZone timeZone; - + private Date photosFirstDate; private Date photosFirstDateTaken; @@ -60,17 +62,17 @@ protected synchronized SimpleDateFormat initialValue() { private long bandwidthMax; private long bandwidthUsed; - + private Boolean bandwidthUnlimited; - + private String setsCreated; - + private String setsRemaining; - + private String videosUploaded; - + private String videosRemaining; - + private String videoSizeMax; private long filesizeMax; @@ -90,11 +92,10 @@ protected synchronized SimpleDateFormat initialValue() { private boolean revFamily; private String pathAlias; - + private PhotoLimits photoLimits; - + private VideoLimits videoLimits; - public User() { } @@ -115,6 +116,20 @@ public void setUsername(String username) { this.username = username; } + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + public boolean isAdmin() { return admin; } @@ -131,28 +146,34 @@ public void setPro(boolean pro) { this.pro = pro; } + @Override public int getIconFarm() { return iconFarm; } + @Override public void setIconFarm(int iconFarm) { this.iconFarm = iconFarm; } + @Override public void setIconFarm(String iconFarm) { if (iconFarm != null) { setIconFarm(Integer.parseInt(iconFarm)); } } + @Override public int getIconServer() { return iconServer; } + @Override public void setIconServer(int iconServer) { this.iconServer = iconServer; } + @Override public void setIconServer(String iconServer) { if (iconServer != null) { setIconServer(Integer.parseInt(iconServer)); @@ -167,12 +188,10 @@ public void setRealName(String realName) { this.realName = realName; } - - public TimeZone getTimeZone() { + public TimeZone getTimeZone() { return timeZone; } - - + public TimeZone setTimeZone(TimeZone string) { return this.timeZone = string; } @@ -186,11 +205,12 @@ public TimeZone setTimeZone(TimeZone string) { * @return The BuddyIconUrl * @deprecated use {@link #getSecureBuddyIconUrl() } */ + @Override @Deprecated public String getBuddyIconUrl() { return UrlUtilities.createBuddyIconUrl(iconFarm, iconServer, id); } - + public String getLocation() { return location; } @@ -207,7 +227,6 @@ public String getSecureBuddyIconUrl() { return UrlUtilities.createSecureBuddyIconUrl(iconFarm, iconServer, id); } - public void setLocation(String location) { this.location = location; } @@ -461,6 +480,7 @@ public String getPathAlias() { public void setPathAlias(String pathAlias) { this.pathAlias = pathAlias; } + /** * @return PhotoLimits class instance */ @@ -471,6 +491,7 @@ public PhotoLimits getPhotoLimits() { public void setPhotoLimits(PhotoLimits photoLimits) { this.photoLimits = photoLimits; } + /** * @return VideoLimits class instance */ @@ -481,54 +502,53 @@ public VideoLimits getVideoLimits() { public void setPhotoLimits(VideoLimits videoLimits) { this.videoLimits = videoLimits; } - public Boolean isBandwidthUnlimited(){ - return bandwidthUnlimited; - } - public void setIsBandwidthUnlimited(Boolean bandwidthUnlimited){ - this.bandwidthUnlimited = bandwidthUnlimited; + + public Boolean isBandwidthUnlimited() { + return bandwidthUnlimited; } - public String getSetsCreated() { - return setsCreated; - } + public void setIsBandwidthUnlimited(Boolean bandwidthUnlimited) { + this.bandwidthUnlimited = bandwidthUnlimited; + } - public void setSetsCreated(String setsCreated) { - this.setsCreated = setsCreated; - } + public String getSetsCreated() { + return setsCreated; + } - public String getSetsRemaining() { - return setsRemaining; - } + public void setSetsCreated(String setsCreated) { + this.setsCreated = setsCreated; + } - public void setSetsRemaining(String setsRemaining) { - this.setsRemaining = setsRemaining; - } + public String getSetsRemaining() { + return setsRemaining; + } - public String getVideosUploaded() { - return videosUploaded; - } + public void setSetsRemaining(String setsRemaining) { + this.setsRemaining = setsRemaining; + } - public void setVideosUploaded(String videosUploaded) { - this.videosUploaded = videosUploaded; - } + public String getVideosUploaded() { + return videosUploaded; + } - public String getVideosRemaining() { - return videosRemaining; - } + public void setVideosUploaded(String videosUploaded) { + this.videosUploaded = videosUploaded; + } - public void setVideosRemaining(String videosRemaining) { - this.videosRemaining = videosRemaining; - } + public String getVideosRemaining() { + return videosRemaining; + } - public String getVideosSizeMax() { - return videoSizeMax; - } + public void setVideosRemaining(String videosRemaining) { + this.videosRemaining = videosRemaining; + } - public void setVideoSizeMax(String videoSizeMax) { - this.videoSizeMax = videoSizeMax; - } + public String getVideosSizeMax() { + return videoSizeMax; + } - + public void setVideoSizeMax(String videoSizeMax) { + this.videoSizeMax = videoSizeMax; + } - }