idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
23,200 | @ SuppressWarnings ( "rawtypes" ) private MailInboundChannelAdapterSpec getImapFlowBuilder ( URLName urlName ) { return Mail . imapInboundAdapter ( urlName . toString ( ) ) . shouldMarkMessagesAsRead ( this . properties . isMarkAsRead ( ) ) ; } | Method to build Mail Channel Adapter for IMAP . |
23,201 | protected View postDeclineView ( ) { return new TopLevelWindowRedirect ( ) { protected String getRedirectUrl ( Map < String , ? > model ) { return postDeclineUrl ; } } ; } | View that redirects the top level window to the URL defined in postDeclineUrl property after user declines to authorize application . May be overridden for custom views particularly in the case where the post - decline view should be rendered in - canvas . |
23,202 | @ SuppressWarnings ( "unchecked" ) public Map < String , ? > decodeSignedRequest ( String signedRequest ) throws SignedRequestException { return decodeSignedRequest ( signedRequest , Map . class ) ; } | Decodes a signed request returning the payload of the signed request as a Map |
23,203 | public < T > T decodeSignedRequest ( String signedRequest , Class < T > type ) throws SignedRequestException { String [ ] split = signedRequest . split ( "\\." ) ; String encodedSignature = split [ 0 ] ; String payload = split [ 1 ] ; String decoded = base64DecodeToString ( payload ) ; byte [ ] signature = base64DecodeToBytes ( encodedSignature ) ; try { T data = objectMapper . readValue ( decoded , type ) ; String algorithm = objectMapper . readTree ( decoded ) . get ( "algorithm" ) . textValue ( ) ; if ( algorithm == null || ! algorithm . equals ( "HMAC-SHA256" ) ) { throw new SignedRequestException ( "Unknown encryption algorithm: " + algorithm ) ; } byte [ ] expectedSignature = encrypt ( payload , secret ) ; if ( ! Arrays . equals ( expectedSignature , signature ) ) { throw new SignedRequestException ( "Invalid signature." ) ; } return data ; } catch ( IOException e ) { throw new SignedRequestException ( "Error parsing payload." , e ) ; } } | Decodes a signed request returning the payload of the signed request as a specified type . |
23,204 | public String getString ( String fieldName ) { return hasValue ( fieldName ) ? String . valueOf ( resultMap . get ( fieldName ) ) : null ; } | Returns the value of the identified field as a String . |
23,205 | public Integer getInteger ( String fieldName ) { try { return hasValue ( fieldName ) ? Integer . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) : null ; } catch ( NumberFormatException e ) { throw new FqlException ( "Field '" + fieldName + "' is not a number." , e ) ; } } | Returns the value of the identified field as an Integer . |
23,206 | public Long getLong ( String fieldName ) { try { return hasValue ( fieldName ) ? Long . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) : null ; } catch ( NumberFormatException e ) { throw new FqlException ( "Field '" + fieldName + "' is not a number." , e ) ; } } | Returns the value of the identified field as a Long . |
23,207 | public Float getFloat ( String fieldName ) { try { return hasValue ( fieldName ) ? Float . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) : null ; } catch ( NumberFormatException e ) { throw new FqlException ( "Field '" + fieldName + "' is not a number." , e ) ; } } | Returns the value of the identified field as a Float . |
23,208 | public Boolean getBoolean ( String fieldName ) { return hasValue ( fieldName ) ? Boolean . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) : null ; } | Returns the value of the identified field as a Boolean . |
23,209 | public Date getTime ( String fieldName ) { try { if ( hasValue ( fieldName ) ) { return new Date ( Long . valueOf ( String . valueOf ( resultMap . get ( fieldName ) ) ) * 1000 ) ; } else { return null ; } } catch ( NumberFormatException e ) { throw new FqlException ( "Field '" + fieldName + "' is not a time." , e ) ; } } | Returns the value of the identified field as a Date . Time fields returned from an FQL query are expressed in terms of seconds since midnight January 1 1970 UTC . |
23,210 | public boolean hasValue ( String fieldName ) { return resultMap . containsKey ( fieldName ) && resultMap . get ( fieldName ) != null ; } | Checks that a field exists and contains a non - null value . |
23,211 | public < T > T fetchObject ( String objectId , Class < T > type ) { URI uri = URIBuilder . fromUri ( getBaseGraphApiUrl ( ) + objectId ) . build ( ) ; return getRestTemplate ( ) . getForObject ( uri , type ) ; } | low - level Graph API operations |
23,212 | @ RequestMapping ( value = "/{subscription}" , method = GET , params = "hub.mode=subscribe" ) public String verifySubscription ( @ PathVariable ( "subscription" ) String subscription , @ RequestParam ( "hub.challenge" ) String challenge , @ RequestParam ( "hub.verify_token" ) String verifyToken ) { logger . debug ( "Received subscription verification request for '" + subscription + "'." ) ; return tokens . containsKey ( subscription ) && tokens . get ( subscription ) . equals ( verifyToken ) ? challenge : "" ; } | Handles subscription verification callback from Facebook . |
23,213 | void handleFacebookError ( HttpStatus statusCode , FacebookError error ) { if ( error != null && error . getCode ( ) != null ) { int code = error . getCode ( ) ; if ( code == UNKNOWN ) { throw new UncategorizedApiException ( FACEBOOK_PROVIDER_ID , error . getMessage ( ) , null ) ; } else if ( code == SERVICE ) { throw new ServerException ( FACEBOOK_PROVIDER_ID , error . getMessage ( ) ) ; } else if ( code == TOO_MANY_CALLS || code == USER_TOO_MANY_CALLS || code == EDIT_FEED_TOO_MANY_USER_CALLS || code == EDIT_FEED_TOO_MANY_USER_ACTION_CALLS ) { throw new RateLimitExceededException ( FACEBOOK_PROVIDER_ID ) ; } else if ( code == PERMISSION_DENIED || isUserPermissionError ( code ) ) { throw new InsufficientPermissionException ( FACEBOOK_PROVIDER_ID ) ; } else if ( code == PARAM_SESSION_KEY || code == PARAM_SIGNATURE ) { throw new InvalidAuthorizationException ( FACEBOOK_PROVIDER_ID , error . getMessage ( ) ) ; } else if ( code == PARAM_ACCESS_TOKEN && error . getSubcode ( ) == null ) { throw new InvalidAuthorizationException ( FACEBOOK_PROVIDER_ID , error . getMessage ( ) ) ; } else if ( code == PARAM_ACCESS_TOKEN && error . getSubcode ( ) == 463 ) { throw new ExpiredAuthorizationException ( FACEBOOK_PROVIDER_ID ) ; } else if ( code == PARAM_ACCESS_TOKEN ) { throw new RevokedAuthorizationException ( FACEBOOK_PROVIDER_ID , error . getMessage ( ) ) ; } else if ( code == MESG_DUPLICATE ) { throw new DuplicateStatusException ( FACEBOOK_PROVIDER_ID , error . getMessage ( ) ) ; } else if ( code == DATA_OBJECT_NOT_FOUND || code == PATH_UNKNOWN ) { throw new ResourceNotFoundException ( FACEBOOK_PROVIDER_ID , error . getMessage ( ) ) ; } else { throw new UncategorizedApiException ( FACEBOOK_PROVIDER_ID , error . getMessage ( ) , null ) ; } } } | Examines the error data returned from Facebook and throws the most applicable exception . |
23,214 | private void showGlobalContextActionBar ( ) { ActionBar actionBar = getActionBar ( ) ; actionBar . setDisplayShowTitleEnabled ( true ) ; actionBar . setTitle ( R . string . app_name ) ; } | Per the navigation drawer design guidelines updates the action bar to show the global app context rather than just what s in the current screen . |
23,215 | public String getGroup ( String groupId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_GROUP ) ; parameters . put ( "group_id" , groupId ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element payload = response . getPayload ( ) ; return payload . getAttribute ( "url" ) ; } | Get the group URL for the specified group ID |
23,216 | public String getUserProfile ( String userId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_USER_PROFILE ) ; parameters . put ( "user_id" , userId ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element payload = response . getPayload ( ) ; return payload . getAttribute ( "url" ) ; } | Get the URL for the user s profile . |
23,217 | public Group lookupGroup ( String url ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_LOOKUP_GROUP ) ; parameters . put ( "url" , url ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Group group = new Group ( ) ; Element payload = response . getPayload ( ) ; Element groupnameElement = ( Element ) payload . getElementsByTagName ( "groupname" ) . item ( 0 ) ; group . setId ( payload . getAttribute ( "id" ) ) ; group . setName ( ( ( Text ) groupnameElement . getFirstChild ( ) ) . getData ( ) ) ; return group ; } | Lookup the group for the specified URL . |
23,218 | public String lookupUser ( String url ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_LOOKUP_USER ) ; parameters . put ( "url" , url ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element payload = response . getPayload ( ) ; Element groupnameElement = ( Element ) payload . getElementsByTagName ( "username" ) . item ( 0 ) ; return ( ( Text ) groupnameElement . getFirstChild ( ) ) . getData ( ) ; } | Lookup the username for the specified User URL . |
23,219 | public Gallery lookupGallery ( String galleryId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_LOOKUP_GALLERY ) ; parameters . put ( "url" , galleryId ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element galleryElement = response . getPayload ( ) ; Gallery gallery = new Gallery ( ) ; gallery . setId ( galleryElement . getAttribute ( "id" ) ) ; gallery . setUrl ( galleryElement . getAttribute ( "url" ) ) ; User owner = new User ( ) ; owner . setId ( galleryElement . getAttribute ( "owner" ) ) ; gallery . setOwner ( owner ) ; gallery . setCreateDate ( galleryElement . getAttribute ( "date_create" ) ) ; gallery . setUpdateDate ( galleryElement . getAttribute ( "date_update" ) ) ; gallery . setPrimaryPhotoId ( galleryElement . getAttribute ( "primary_photo_id" ) ) ; gallery . setPrimaryPhotoServer ( galleryElement . getAttribute ( "primary_photo_server" ) ) ; gallery . setVideoCount ( galleryElement . getAttribute ( "count_videos" ) ) ; gallery . setPhotoCount ( galleryElement . getAttribute ( "count_photos" ) ) ; gallery . setPrimaryPhotoFarm ( galleryElement . getAttribute ( "farm" ) ) ; gallery . setPrimaryPhotoSecret ( galleryElement . getAttribute ( "secret" ) ) ; gallery . setTitle ( XMLUtilities . getChildValue ( galleryElement , "title" ) ) ; gallery . setDesc ( XMLUtilities . getChildValue ( galleryElement , "description" ) ) ; return gallery ; } | Lookup the Gallery for the specified ID . |
23,220 | public void add ( String photoId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_ADD ) ; parameters . put ( "photo_id" , photoId ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Add a photo to the user s favorites . |
23,221 | public PhotoContext getContext ( String photoId , String userId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_CONTEXT ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "user_id" , userId ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Collection < Element > payload = response . getPayloadCollection ( ) ; PhotoContext photoContext = new PhotoContext ( ) ; for ( Element element : payload ) { String elementName = element . getTagName ( ) ; if ( elementName . equals ( "prevphoto" ) ) { Photo photo = new Photo ( ) ; photo . setId ( element . getAttribute ( "id" ) ) ; photoContext . setPreviousPhoto ( photo ) ; } else if ( elementName . equals ( "nextphoto" ) ) { Photo photo = new Photo ( ) ; photo . setId ( element . getAttribute ( "id" ) ) ; photoContext . setNextPhoto ( photo ) ; } else { if ( logger . isInfoEnabled ( ) ) { logger . info ( "unsupported element name: " + elementName ) ; } } } return photoContext ; } | Returns next and previous favorites for a photo in a user s favorites |
23,222 | public void editCoords ( String photoId , String userId , Rectangle bounds ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_EDIT_COORDS ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "user_id" , userId ) ; parameters . put ( "person_x" , bounds . x ) ; parameters . put ( "person_y" , bounds . y ) ; parameters . put ( "person_w" , bounds . width ) ; parameters . put ( "person_h" , bounds . height ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Edit the co - ordinates that the user shows in |
23,223 | public AuthInterface getAuthInterface ( ) { if ( authInterface == null ) { authInterface = new AuthInterface ( apiKey , sharedSecret , transport ) ; } return authInterface ; } | Get the AuthInterface . |
23,224 | public ActivityInterface getActivityInterface ( ) { if ( activityInterface == null ) { activityInterface = new ActivityInterface ( apiKey , sharedSecret , transport ) ; } return activityInterface ; } | Get the ActivityInterface . |
23,225 | public TagsInterface getTagsInterface ( ) { if ( tagsInterface == null ) { tagsInterface = new TagsInterface ( apiKey , sharedSecret , transport ) ; } return tagsInterface ; } | Get the TagsInterface for working with Flickr Tags . |
23,226 | public SuggestionsInterface getSuggestionsInterface ( ) { if ( suggestionsInterface == null ) { suggestionsInterface = new SuggestionsInterface ( apiKey , sharedSecret , transport ) ; } return suggestionsInterface ; } | Get the SuggestionsInterface . |
23,227 | public GroupDiscussInterface getDiscussionInterface ( ) { if ( discussionInterface == null ) { discussionInterface = new GroupDiscussInterface ( apiKey , sharedSecret , transport ) ; } return discussionInterface ; } | Get the GroupDiscussInterface . |
23,228 | public Collection < Service > getServices ( ) throws FlickrException { List < Service > list = new ArrayList < Service > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_SERVICES ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element servicesElement = response . getPayload ( ) ; NodeList serviceNodes = servicesElement . getElementsByTagName ( "service" ) ; for ( int i = 0 ; i < serviceNodes . getLength ( ) ; i ++ ) { Element serviceElement = ( Element ) serviceNodes . item ( i ) ; Service srv = new Service ( ) ; srv . setId ( serviceElement . getAttribute ( "id" ) ) ; srv . setName ( XMLUtilities . getValue ( serviceElement ) ) ; list . add ( srv ) ; } return list ; } | Return a list of Flickr supported blogging services . |
23,229 | public void postPhoto ( Photo photo , String blogId , String blogPassword ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_POST_PHOTO ) ; parameters . put ( "blog_id" , blogId ) ; parameters . put ( "photo_id" , photo . getId ( ) ) ; parameters . put ( "title" , photo . getTitle ( ) ) ; parameters . put ( "description" , photo . getDescription ( ) ) ; if ( blogPassword != null ) { parameters . put ( "blog_password" , blogPassword ) ; } Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Post the specified photo to a blog . Note that the Photo . title and Photo . description are used for the blog entry title and body respectively . |
23,230 | public void postPhoto ( Photo photo , String blogId ) throws FlickrException { postPhoto ( photo , blogId , null ) ; } | Post the specified photo to a blog . |
23,231 | public Collection < Blog > getList ( ) throws FlickrException { List < Blog > blogs = new ArrayList < Blog > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_LIST ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element blogsElement = response . getPayload ( ) ; NodeList blogNodes = blogsElement . getElementsByTagName ( "blog" ) ; for ( int i = 0 ; i < blogNodes . getLength ( ) ; i ++ ) { Element blogElement = ( Element ) blogNodes . item ( i ) ; Blog blog = new Blog ( ) ; blog . setId ( blogElement . getAttribute ( "id" ) ) ; blog . setName ( blogElement . getAttribute ( "name" ) ) ; blog . setNeedPassword ( "1" . equals ( blogElement . getAttribute ( "needspassword" ) ) ) ; blog . setUrl ( blogElement . getAttribute ( "url" ) ) ; blogs . add ( blog ) ; } return blogs ; } | Get the collection of configured blogs for the calling user . |
23,232 | private static String getAttribute ( String name , Element firstElement , Element secondElement ) { String val = firstElement . getAttribute ( name ) ; if ( val . length ( ) == 0 && secondElement != null ) { val = secondElement . getAttribute ( name ) ; } return val ; } | Try to get an attribute value from two elements . |
23,233 | public static final PhotoList < Photo > createPhotoList ( Element photosElement ) { PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; photos . setPage ( photosElement . getAttribute ( "page" ) ) ; photos . setPages ( photosElement . getAttribute ( "pages" ) ) ; photos . setPerPage ( photosElement . getAttribute ( "perpage" ) ) ; photos . setTotal ( photosElement . getAttribute ( "total" ) ) ; NodeList photoNodes = photosElement . getElementsByTagName ( "photo" ) ; for ( int i = 0 ; i < photoNodes . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoNodes . item ( i ) ; photos . add ( PhotoUtils . createPhoto ( photoElement ) ) ; } return photos ; } | Parse a list of Photos from given Element . |
23,234 | public OAuth1RequestToken getRequestToken ( String callbackUrl ) { String callback = ( callbackUrl != null ) ? callbackUrl : OUT_OF_BOUND_AUTH_METHOD ; OAuth10aService service = new ServiceBuilder ( apiKey ) . apiSecret ( sharedSecret ) . callback ( callback ) . build ( FlickrApi . instance ( ) ) ; try { return service . getRequestToken ( ) ; } catch ( IOException | InterruptedException | ExecutionException e ) { throw new FlickrRuntimeException ( e ) ; } } | Get the OAuth request token - this is step one of authorization . |
23,235 | public String getAuthorizationUrl ( OAuth1RequestToken oAuthRequestToken , Permission permission ) { OAuth10aService service = new ServiceBuilder ( apiKey ) . apiSecret ( sharedSecret ) . build ( FlickrApi . instance ( ) ) ; String authorizationUrl = service . getAuthorizationUrl ( oAuthRequestToken ) ; return String . format ( "%s&perms=%s" , authorizationUrl , permission . toString ( ) ) ; } | Get the auth URL this is step two of authorization . |
23,236 | @ SuppressWarnings ( "boxing" ) public OAuth1Token getAccessToken ( OAuth1RequestToken oAuthRequestToken , String verifier ) { OAuth10aService service = new ServiceBuilder ( apiKey ) . apiSecret ( sharedSecret ) . build ( FlickrApi . instance ( ) ) ; OAuth1Token accessToken = null ; boolean success = false ; for ( int i = 0 ; i < maxGetTokenRetries && ! success ; i ++ ) { try { accessToken = service . getAccessToken ( oAuthRequestToken , verifier ) ; success = true ; } catch ( OAuthException | IOException | InterruptedException | ExecutionException e ) { if ( i == maxGetTokenRetries - 1 ) { logger . error ( String . format ( "OAuthService.getAccessToken failing after %d tries, re-throwing exception" , i ) , e ) ; throw new FlickrRuntimeException ( e ) ; } else { logger . warn ( String . format ( "OAuthService.getAccessToken failed, try number %d: %s" , i , e . getMessage ( ) ) ) ; try { Thread . sleep ( 500 ) ; } catch ( InterruptedException ie ) { } } } } return accessToken ; } | Trade the request token for an access token this is step three of authorization . |
23,237 | public OAuth1RequestToken exchangeAuthToken ( String authToken ) throws FlickrException { Map < String , String > parameters = new TreeMap < String , String > ( ) ; parameters . put ( "method" , METHOD_EXCHANGE_TOKEN ) ; parameters . put ( Flickr . API_KEY , apiKey ) ; parameters . put ( "api_sig" , getSignature ( sharedSecret , parameters ) ) ; Response response = transportAPI . getNonOAuth ( transportAPI . getPath ( ) , parameters ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } OAuth1RequestToken accessToken = constructToken ( response ) ; return accessToken ; } | Exchange an auth token from the old Authentication API to an OAuth access token . |
23,238 | private OAuth1RequestToken constructToken ( Response response ) { Element authElement = response . getPayload ( ) ; String oauthToken = XMLUtilities . getChildValue ( authElement , "oauth_token" ) ; String oauthTokenSecret = XMLUtilities . getChildValue ( authElement , "oauth_token_secret" ) ; OAuth1RequestToken token = new OAuth1RequestToken ( oauthToken , oauthTokenSecret ) ; return token ; } | Construct a Access Token from a Flickr Response . |
23,239 | private String getSignature ( String sharedSecret , Map < String , String > params ) { StringBuffer buffer = new StringBuffer ( ) ; buffer . append ( sharedSecret ) ; for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { buffer . append ( entry . getKey ( ) ) ; buffer . append ( entry . getValue ( ) ) ; } try { MessageDigest md = MessageDigest . getInstance ( "MD5" ) ; return ByteUtilities . toHexString ( md . digest ( buffer . toString ( ) . getBytes ( "UTF-8" ) ) ) ; } catch ( NoSuchAlgorithmException e ) { throw new RuntimeException ( e ) ; } catch ( UnsupportedEncodingException u ) { throw new RuntimeException ( u ) ; } } | Get a signature for a list of parameters using the given shared secret . |
23,240 | public static URL buildUrl ( String host , int port , String path , Map < String , String > parameters ) throws MalformedURLException { return buildUrl ( "http" , port , path , parameters ) ; } | Build a request URL . |
23,241 | public static URL buildUrl ( String scheme , String host , int port , String path , Map < String , String > parameters ) throws MalformedURLException { checkSchemeAndPort ( scheme , port ) ; StringBuilder buffer = new StringBuilder ( ) ; if ( ! host . startsWith ( scheme + "://" ) ) { buffer . append ( scheme ) . append ( "://" ) ; } buffer . append ( host ) ; if ( port > 0 ) { buffer . append ( ':' ) ; buffer . append ( port ) ; } if ( path == null ) { path = "/" ; } buffer . append ( path ) ; if ( ! parameters . isEmpty ( ) ) { buffer . append ( '?' ) ; } int size = parameters . size ( ) ; for ( Map . Entry < String , String > entry : parameters . entrySet ( ) ) { buffer . append ( entry . getKey ( ) ) ; buffer . append ( '=' ) ; Object value = entry . getValue ( ) ; if ( value != null ) { String string = value . toString ( ) ; try { string = URLEncoder . encode ( string , UTF8 ) ; } catch ( UnsupportedEncodingException e ) { } buffer . append ( string ) ; } if ( -- size != 0 ) { buffer . append ( '&' ) ; } } return new URL ( buffer . toString ( ) ) ; } | Build a request URL using a given scheme . |
23,242 | public String upload ( byte [ ] data , UploadMetaData metaData ) throws FlickrException { Payload payload = new Payload ( data ) ; return sendUploadRequest ( metaData , payload ) ; } | Upload a photo from a byte - array . |
23,243 | public String upload ( File file , UploadMetaData metaData ) throws FlickrException { Payload payload = new Payload ( file ) ; return sendUploadRequest ( metaData , payload ) ; } | Upload a photo from a File . |
23,244 | public String upload ( InputStream in , UploadMetaData metaData ) throws FlickrException { Payload payload = new Payload ( in ) ; return sendUploadRequest ( metaData , payload ) ; } | Upload a photo from an InputStream . |
23,245 | public String replace ( File file , String flickrId , boolean async ) throws FlickrException { Payload payload = new Payload ( file , flickrId ) ; return sendReplaceRequest ( async , payload ) ; } | Replace a photo from a File . |
23,246 | private String getResponseString ( boolean async , UploaderResponse response ) { return async ? response . getTicketId ( ) : response . getPhotoId ( ) ; } | Get the photo or ticket id from the response . |
23,247 | public void setViews ( String views ) { if ( views != null ) { try { setViews ( Integer . parseInt ( views ) ) ; } catch ( NumberFormatException e ) { setViews ( - 1 ) ; } } } | Sets the number of views for this Photo . For un - authenticated calls this value is not available and will be set to - 1 . |
23,248 | public void setRotation ( String rotation ) { if ( rotation != null ) { try { setRotation ( Integer . parseInt ( rotation ) ) ; } catch ( NumberFormatException e ) { setRotation ( - 1 ) ; } } } | Set the degrees of rotation . Value will be set to - 1 if not available . |
23,249 | public InputStream getOriginalAsStream ( ) throws IOException , FlickrException { if ( originalFormat != null ) { return getOriginalImageAsStream ( "_o." + originalFormat ) ; } return getOriginalImageAsStream ( DEFAULT_ORIGINAL_IMAGE_SUFFIX ) ; } | Get an InputStream for the original image . Callers must close the stream upon completion . |
23,250 | public String getOriginalUrl ( ) throws FlickrException { if ( originalSize == null ) { if ( originalFormat != null ) { return getOriginalBaseImageUrl ( ) + "_o." + originalFormat ; } return getOriginalBaseImageUrl ( ) + DEFAULT_ORIGINAL_IMAGE_SUFFIX ; } else { return originalSize . getSource ( ) ; } } | Get the original image URL . |
23,251 | private BufferedImage getImage ( String suffix ) throws IOException { StringBuffer buffer = getBaseImageUrl ( ) ; buffer . append ( suffix ) ; return _getImage ( buffer . toString ( ) ) ; } | Get an image using the specified URL suffix . |
23,252 | private BufferedImage getOriginalImage ( String suffix ) throws IOException , FlickrException { StringBuffer buffer = getOriginalBaseImageUrl ( ) ; buffer . append ( suffix ) ; return _getImage ( buffer . toString ( ) ) ; } | Get the original - image using the specified URL suffix . |
23,253 | private InputStream getImageAsStream ( String suffix ) throws IOException { StringBuffer buffer = getBaseImageUrl ( ) ; buffer . append ( suffix ) ; return _getImageAsStream ( buffer . toString ( ) ) ; } | Get an image as a stream . Callers must be sure to close the stream when they are done with it . |
23,254 | public void setSizes ( Collection < Size > sizes ) { for ( Size size : sizes ) { if ( size . getLabel ( ) == Size . SMALL ) { smallSize = size ; } else if ( size . getLabel ( ) == Size . SQUARE ) { squareSize = size ; } else if ( size . getLabel ( ) == Size . THUMB ) { thumbnailSize = size ; } else if ( size . getLabel ( ) == Size . MEDIUM ) { mediumSize = size ; } else if ( size . getLabel ( ) == Size . LARGE ) { largeSize = size ; } else if ( size . getLabel ( ) == Size . LARGE_1600 ) { large1600Size = size ; } else if ( size . getLabel ( ) == Size . LARGE_2048 ) { large2048Size = size ; } else if ( size . getLabel ( ) == Size . ORIGINAL ) { originalSize = size ; } else if ( size . getLabel ( ) == Size . SQUARE_LARGE ) { squareLargeSize = size ; } else if ( size . getLabel ( ) == Size . SMALL_320 ) { small320Size = size ; } else if ( size . getLabel ( ) == Size . MEDIUM_640 ) { medium640Size = size ; } else if ( size . getLabel ( ) == Size . MEDIUM_800 ) { medium800Size = size ; } else if ( size . getLabel ( ) == Size . VIDEO_PLAYER ) { videoPlayer = size ; } else if ( size . getLabel ( ) == Size . SITE_MP4 ) { siteMP4 = size ; } else if ( size . getLabel ( ) == Size . VIDEO_ORIGINAL ) { videoOriginal = size ; } else if ( size . getLabel ( ) == Size . MOBILE_MP4 ) { mobileMP4 = size ; } else if ( size . getLabel ( ) == Size . HD_MP4 ) { hdMP4 = size ; } } } | Set sizes to override the generated URLs of the different sizes . |
23,255 | public void rotate ( String photoId , int degrees ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_ROTATE ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "degrees" , String . valueOf ( degrees ) ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Rotate the specified photo . The only allowed values for degrees are 90 180 and 270 . |
23,256 | public Map < String , String > getUploadParameters ( ) { Map < String , String > parameters = new TreeMap < > ( ) ; String title = getTitle ( ) ; if ( title != null ) { parameters . put ( "title" , title ) ; } String description = getDescription ( ) ; if ( description != null ) { parameters . put ( "description" , description ) ; } Collection < String > tags = getTags ( ) ; if ( tags != null ) { parameters . put ( "tags" , StringUtilities . join ( tags , " " ) ) ; } if ( isHidden ( ) != null ) { parameters . put ( "hidden" , isHidden ( ) . booleanValue ( ) ? "1" : "0" ) ; } if ( getSafetyLevel ( ) != null ) { parameters . put ( "safety_level" , getSafetyLevel ( ) ) ; } if ( getContentType ( ) != null ) { parameters . put ( "content_type" , getContentType ( ) ) ; } if ( getPhotoId ( ) != null ) { parameters . put ( "photo_id" , getPhotoId ( ) ) ; } parameters . put ( "is_public" , isPublicFlag ( ) ? "1" : "0" ) ; parameters . put ( "is_family" , isFamilyFlag ( ) ? "1" : "0" ) ; parameters . put ( "is_friend" , isFriendFlag ( ) ? "1" : "0" ) ; parameters . put ( "async" , isAsync ( ) ? "1" : "0" ) ; return parameters ; } | Get the upload parameters . |
23,257 | public void deleteComment ( String commentId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_DELETE_COMMENT ) ; parameters . put ( "comment_id" , commentId ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Delete a comment as the currently authenticated user . |
23,258 | public void editComment ( String commentId , String commentText ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_EDIT_COMMENT ) ; parameters . put ( "comment_id" , commentId ) ; parameters . put ( "comment_text" , commentText ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Edit the text of a comment as the currently authenticated user . |
23,259 | public MembersList < Member > getList ( String groupId , Set < String > memberTypes , int perPage , int page ) throws FlickrException { MembersList < Member > members = new MembersList < Member > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_LIST ) ; parameters . put ( "group_id" , groupId ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } if ( memberTypes != null ) { parameters . put ( "membertypes" , StringUtilities . join ( memberTypes , "," ) ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element mElement = response . getPayload ( ) ; members . setPage ( mElement . getAttribute ( "page" ) ) ; members . setPages ( mElement . getAttribute ( "pages" ) ) ; members . setPerPage ( mElement . getAttribute ( "perpage" ) ) ; members . setTotal ( mElement . getAttribute ( "total" ) ) ; NodeList mNodes = mElement . getElementsByTagName ( "member" ) ; for ( int i = 0 ; i < mNodes . getLength ( ) ; i ++ ) { Element element = ( Element ) mNodes . item ( i ) ; members . add ( parseMember ( element ) ) ; } return members ; } | Get a list of the members of a group . The call must be signed on behalf of a Flickr member and the ability to see the group membership will be determined by the Flickr member s group privileges . |
23,260 | public void setLabel ( String label ) { int ix = lstSizes . indexOf ( label ) ; if ( ix != - 1 ) { setLabel ( ix ) ; } } | Set the String - representation of size . |
23,261 | public Photoset create ( String title , String description , String primaryPhotoId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_CREATE ) ; parameters . put ( "title" , title ) ; parameters . put ( "description" , description ) ; parameters . put ( "primary_photo_id" , primaryPhotoId ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosetElement = response . getPayload ( ) ; Photoset photoset = new Photoset ( ) ; photoset . setId ( photosetElement . getAttribute ( "id" ) ) ; photoset . setUrl ( photosetElement . getAttribute ( "url" ) ) ; return photoset ; } | Create a new photoset . |
23,262 | public void editMeta ( String photosetId , String title , String description ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_EDIT_META ) ; parameters . put ( "photoset_id" , photosetId ) ; parameters . put ( "title" , title ) ; if ( description != null ) { parameters . put ( "description" , description ) ; } Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Modify the meta - data for a photoset . |
23,263 | public void editPhotos ( String photosetId , String primaryPhotoId , String [ ] photoIds ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_EDIT_PHOTOS ) ; parameters . put ( "photoset_id" , photosetId ) ; parameters . put ( "primary_photo_id" , primaryPhotoId ) ; parameters . put ( "photo_ids" , StringUtilities . join ( photoIds , "," ) ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Edit which photos are in the photoset . |
23,264 | public Photoset getInfo ( String photosetId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_INFO ) ; parameters . put ( "photoset_id" , photosetId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosetElement = response . getPayload ( ) ; Photoset photoset = new Photoset ( ) ; photoset . setId ( photosetElement . getAttribute ( "id" ) ) ; User owner = new User ( ) ; owner . setId ( photosetElement . getAttribute ( "owner" ) ) ; photoset . setOwner ( owner ) ; Photo primaryPhoto = new Photo ( ) ; primaryPhoto . setId ( photosetElement . getAttribute ( "primary" ) ) ; primaryPhoto . setSecret ( photosetElement . getAttribute ( "secret" ) ) ; primaryPhoto . setServer ( photosetElement . getAttribute ( "server" ) ) ; primaryPhoto . setFarm ( photosetElement . getAttribute ( "farm" ) ) ; photoset . setPrimaryPhoto ( primaryPhoto ) ; photoset . setSecret ( photosetElement . getAttribute ( "secret" ) ) ; photoset . setServer ( photosetElement . getAttribute ( "server" ) ) ; photoset . setFarm ( photosetElement . getAttribute ( "farm" ) ) ; photoset . setPhotoCount ( photosetElement . getAttribute ( "count_photos" ) ) ; photoset . setVideoCount ( Integer . parseInt ( photosetElement . getAttribute ( "count_videos" ) ) ) ; photoset . setViewCount ( Integer . parseInt ( photosetElement . getAttribute ( "count_views" ) ) ) ; photoset . setCommentCount ( Integer . parseInt ( photosetElement . getAttribute ( "count_comments" ) ) ) ; photoset . setDateCreate ( photosetElement . getAttribute ( "date_create" ) ) ; photoset . setDateUpdate ( photosetElement . getAttribute ( "date_update" ) ) ; photoset . setIsCanComment ( "1" . equals ( photosetElement . getAttribute ( "can_comment" ) ) ) ; photoset . setTitle ( XMLUtilities . getChildValue ( photosetElement , "title" ) ) ; photoset . setDescription ( XMLUtilities . getChildValue ( photosetElement , "description" ) ) ; photoset . setPrimaryPhoto ( primaryPhoto ) ; return photoset ; } | Get the information for a specified photoset . |
23,265 | public PhotoList < Photo > getPhotos ( String photosetId , Set < String > extras , int privacy_filter , int perPage , int page ) throws FlickrException { PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_PHOTOS ) ; parameters . put ( "photoset_id" , photosetId ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , String . valueOf ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , String . valueOf ( page ) ) ; } if ( privacy_filter > 0 ) { parameters . put ( "privacy_filter" , "" + privacy_filter ) ; } if ( extras != null && ! extras . isEmpty ( ) ) { parameters . put ( Extras . KEY_EXTRAS , StringUtilities . join ( extras , "," ) ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photoset = response . getPayload ( ) ; NodeList photoElements = photoset . getElementsByTagName ( "photo" ) ; photos . setPage ( photoset . getAttribute ( "page" ) ) ; photos . setPages ( photoset . getAttribute ( "pages" ) ) ; photos . setPerPage ( photoset . getAttribute ( "per_page" ) ) ; photos . setTotal ( photoset . getAttribute ( "total" ) ) ; for ( int i = 0 ; i < photoElements . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoElements . item ( i ) ; photos . add ( PhotoUtils . createPhoto ( photoElement , photoset ) ) ; } return photos ; } | Get a collection of Photo objects for the specified Photoset . |
23,266 | public void orderSets ( String [ ] photosetIds ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_ORDER_SETS ) ; ; parameters . put ( "photoset_ids" , StringUtilities . join ( photosetIds , "," ) ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Set the order in which sets are returned for the user . |
23,267 | public Collection < Contact > getList ( ) throws FlickrException { ContactList < Contact > contacts = new ContactList < Contact > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_LIST ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element contactsElement = response . getPayload ( ) ; contacts . setPage ( contactsElement . getAttribute ( "page" ) ) ; contacts . setPages ( contactsElement . getAttribute ( "pages" ) ) ; contacts . setPerPage ( contactsElement . getAttribute ( "perpage" ) ) ; contacts . setTotal ( contactsElement . getAttribute ( "total" ) ) ; NodeList contactNodes = contactsElement . getElementsByTagName ( "contact" ) ; for ( int i = 0 ; i < contactNodes . getLength ( ) ; i ++ ) { Element contactElement = ( Element ) contactNodes . item ( i ) ; Contact contact = new Contact ( ) ; contact . setId ( contactElement . getAttribute ( "nsid" ) ) ; contact . setUsername ( contactElement . getAttribute ( "username" ) ) ; contact . setRealName ( contactElement . getAttribute ( "realname" ) ) ; contact . setFriend ( "1" . equals ( contactElement . getAttribute ( "friend" ) ) ) ; contact . setFamily ( "1" . equals ( contactElement . getAttribute ( "family" ) ) ) ; contact . setIgnored ( "1" . equals ( contactElement . getAttribute ( "ignored" ) ) ) ; String lPathAlias = contactElement . getAttribute ( "path_alias" ) ; contact . setPathAlias ( lPathAlias == null || "" . equals ( lPathAlias ) ? null : lPathAlias ) ; contact . setOnline ( OnlineStatus . fromType ( contactElement . getAttribute ( "online" ) ) ) ; contact . setIconFarm ( contactElement . getAttribute ( "iconfarm" ) ) ; contact . setIconServer ( contactElement . getAttribute ( "iconserver" ) ) ; if ( contact . getOnline ( ) == OnlineStatus . AWAY ) { contactElement . normalize ( ) ; contact . setAwayMessage ( XMLUtilities . getValue ( contactElement ) ) ; } contacts . add ( contact ) ; } return contacts ; } | Get the collection of contacts for the calling user . |
23,268 | public Collection < Contact > getListRecentlyUploaded ( Date lastUpload , String filter ) throws FlickrException { List < Contact > contacts = new ArrayList < Contact > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_LIST_RECENTLY_UPLOADED ) ; if ( lastUpload != null ) { parameters . put ( "date_lastupload" , String . valueOf ( lastUpload . getTime ( ) / 1000L ) ) ; } if ( filter != null ) { parameters . put ( "filter" , filter ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element contactsElement = response . getPayload ( ) ; NodeList contactNodes = contactsElement . getElementsByTagName ( "contact" ) ; for ( int i = 0 ; i < contactNodes . getLength ( ) ; i ++ ) { Element contactElement = ( Element ) contactNodes . item ( i ) ; Contact contact = new Contact ( ) ; contact . setId ( contactElement . getAttribute ( "nsid" ) ) ; contact . setUsername ( contactElement . getAttribute ( "username" ) ) ; contact . setRealName ( contactElement . getAttribute ( "realname" ) ) ; contact . setFriend ( "1" . equals ( contactElement . getAttribute ( "friend" ) ) ) ; contact . setFamily ( "1" . equals ( contactElement . getAttribute ( "family" ) ) ) ; contact . setIgnored ( "1" . equals ( contactElement . getAttribute ( "ignored" ) ) ) ; contact . setOnline ( OnlineStatus . fromType ( contactElement . getAttribute ( "online" ) ) ) ; contact . setIconFarm ( contactElement . getAttribute ( "iconfarm" ) ) ; contact . setIconServer ( contactElement . getAttribute ( "iconserver" ) ) ; if ( contact . getOnline ( ) == OnlineStatus . AWAY ) { contactElement . normalize ( ) ; contact . setAwayMessage ( XMLUtilities . getValue ( contactElement ) ) ; } contacts . add ( contact ) ; } return contacts ; } | Return a list of contacts for a user who have recently uploaded photos along with the total count of photos uploaded . |
23,269 | public Collection < Contact > getPublicList ( String userId ) throws FlickrException { List < Contact > contacts = new ArrayList < Contact > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_PUBLIC_LIST ) ; parameters . put ( "user_id" , userId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element contactsElement = response . getPayload ( ) ; NodeList contactNodes = contactsElement . getElementsByTagName ( "contact" ) ; for ( int i = 0 ; i < contactNodes . getLength ( ) ; i ++ ) { Element contactElement = ( Element ) contactNodes . item ( i ) ; Contact contact = new Contact ( ) ; contact . setId ( contactElement . getAttribute ( "nsid" ) ) ; contact . setUsername ( contactElement . getAttribute ( "username" ) ) ; contact . setIgnored ( "1" . equals ( contactElement . getAttribute ( "ignored" ) ) ) ; contact . setOnline ( OnlineStatus . fromType ( contactElement . getAttribute ( "online" ) ) ) ; contact . setIconFarm ( contactElement . getAttribute ( "iconfarm" ) ) ; contact . setIconServer ( contactElement . getAttribute ( "iconserver" ) ) ; if ( contact . getOnline ( ) == OnlineStatus . AWAY ) { contactElement . normalize ( ) ; contact . setAwayMessage ( XMLUtilities . getValue ( contactElement ) ) ; } contacts . add ( contact ) ; } return contacts ; } | Get the collection of public contacts for the specified user ID . |
23,270 | public Collection < String > getMethods ( ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_METHODS ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element methodsElement = response . getPayload ( ) ; List < String > methods = new ArrayList < String > ( ) ; NodeList methodElements = methodsElement . getElementsByTagName ( "method" ) ; for ( int i = 0 ; i < methodElements . getLength ( ) ; i ++ ) { Element methodElement = ( Element ) methodElements . item ( i ) ; methods . add ( XMLUtilities . getValue ( methodElement ) ) ; } return methods ; } | Get a list of all methods . |
23,271 | public PhotoContext getContext ( String photoId , String groupId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_CONTEXT ) ; parameters . put ( "photo_id" , photoId ) ; parameters . put ( "group_id" , groupId ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Collection < Element > payload = response . getPayloadCollection ( ) ; PhotoContext photoContext = new PhotoContext ( ) ; for ( Element element : payload ) { String elementName = element . getTagName ( ) ; if ( elementName . equals ( "prevphoto" ) ) { Photo photo = new Photo ( ) ; photo . setId ( element . getAttribute ( "id" ) ) ; photoContext . setPreviousPhoto ( photo ) ; } else if ( elementName . equals ( "nextphoto" ) ) { Photo photo = new Photo ( ) ; photo . setId ( element . getAttribute ( "id" ) ) ; photoContext . setNextPhoto ( photo ) ; } else if ( ! elementName . equals ( "count" ) ) { _log . warn ( "unsupported element name: " + elementName ) ; } } return photoContext ; } | Get the context for a photo in the group pool . |
23,272 | public Collection < Group > getGroups ( ) throws FlickrException { GroupList < Group > groups = new GroupList < Group > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_GROUPS ) ; Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element groupsElement = response . getPayload ( ) ; groups . setPage ( groupsElement . getAttribute ( "page" ) ) ; groups . setPages ( groupsElement . getAttribute ( "pages" ) ) ; groups . setPerPage ( groupsElement . getAttribute ( "perpage" ) ) ; groups . setTotal ( groupsElement . getAttribute ( "total" ) ) ; NodeList groupNodes = groupsElement . getElementsByTagName ( "group" ) ; for ( int i = 0 ; i < groupNodes . getLength ( ) ; i ++ ) { Element groupElement = ( Element ) groupNodes . item ( i ) ; Group group = new Group ( ) ; group . setId ( groupElement . getAttribute ( "id" ) ) ; group . setName ( groupElement . getAttribute ( "name" ) ) ; group . setAdmin ( "1" . equals ( groupElement . getAttribute ( "admin" ) ) ) ; group . setPrivacy ( groupElement . getAttribute ( "privacy" ) ) ; group . setIconServer ( groupElement . getAttribute ( "iconserver" ) ) ; group . setIconFarm ( groupElement . getAttribute ( "iconfarm" ) ) ; group . setPhotoCount ( groupElement . getAttribute ( "photos" ) ) ; groups . add ( group ) ; } return groups ; } | Get a collection of all of the user s groups . |
23,273 | public PhotoList < Photo > getPhotos ( String groupId , String userId , String [ ] tags , Set < String > extras , int perPage , int page ) throws FlickrException { PhotoList < Photo > photos = new PhotoList < Photo > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_PHOTOS ) ; parameters . put ( "group_id" , groupId ) ; if ( userId != null ) { parameters . put ( "user_id" , userId ) ; } if ( tags != null ) { parameters . put ( "tags" , StringUtilities . join ( tags , " " ) ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , String . valueOf ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , String . valueOf ( page ) ) ; } if ( extras != null ) { StringBuffer sb = new StringBuffer ( ) ; Iterator < String > it = extras . iterator ( ) ; for ( int i = 0 ; it . hasNext ( ) ; i ++ ) { if ( i > 0 ) { sb . append ( "," ) ; } sb . append ( it . next ( ) ) ; } parameters . put ( Extras . KEY_EXTRAS , sb . toString ( ) ) ; } Response response = transport . get ( transport . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element photosElement = response . getPayload ( ) ; photos . setPage ( photosElement . getAttribute ( "page" ) ) ; photos . setPages ( photosElement . getAttribute ( "pages" ) ) ; photos . setPerPage ( photosElement . getAttribute ( "perpage" ) ) ; photos . setTotal ( photosElement . getAttribute ( "total" ) ) ; NodeList photoNodes = photosElement . getElementsByTagName ( "photo" ) ; for ( int i = 0 ; i < photoNodes . getLength ( ) ; i ++ ) { Element photoElement = ( Element ) photoNodes . item ( i ) ; photos . add ( PhotoUtils . createPhoto ( photoElement ) ) ; } return photos ; } | Get the photos for the specified group pool optionally filtering by taf . |
23,274 | public int getGeoPerms ( ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_GEO_PERMS ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } int perm = - 1 ; Element personElement = response . getPayload ( ) ; String geoPerms = personElement . getAttribute ( "geoperms" ) ; try { perm = Integer . parseInt ( geoPerms ) ; } catch ( NumberFormatException e ) { throw new FlickrException ( "0" , "Unable to parse geoPermission" ) ; } return perm ; } | Returns the default privacy level for geographic information attached to the user s photos . |
23,275 | public boolean getHidden ( ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_HIDDEN ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element personElement = response . getPayload ( ) ; return personElement . getAttribute ( "hidden" ) . equals ( "1" ) ? true : false ; } | Returns the default hidden preference for the user . |
23,276 | public String getSafetyLevel ( ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_SAFETY_LEVEL ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element personElement = response . getPayload ( ) ; return personElement . getAttribute ( "safety_level" ) ; } | Returns the default safety level preference for the user . |
23,277 | public int getPrivacy ( ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_PRIVACY ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element personElement = response . getPayload ( ) ; return Integer . parseInt ( personElement . getAttribute ( "privacy" ) ) ; } | Returns the default privacy level preference for the user . |
23,278 | public Category browse ( String catId ) throws FlickrException { List < Subcategory > subcategories = new ArrayList < Subcategory > ( ) ; List < Group > groups = new ArrayList < Group > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_BROWSE ) ; if ( catId != null ) { parameters . put ( "cat_id" , catId ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element categoryElement = response . getPayload ( ) ; Category category = new Category ( ) ; category . setName ( categoryElement . getAttribute ( "name" ) ) ; category . setPath ( categoryElement . getAttribute ( "path" ) ) ; category . setPathIds ( categoryElement . getAttribute ( "pathids" ) ) ; NodeList subcatNodes = categoryElement . getElementsByTagName ( "subcat" ) ; for ( int i = 0 ; i < subcatNodes . getLength ( ) ; i ++ ) { Element node = ( Element ) subcatNodes . item ( i ) ; Subcategory subcategory = new Subcategory ( ) ; subcategory . setId ( Integer . parseInt ( node . getAttribute ( "id" ) ) ) ; subcategory . setName ( node . getAttribute ( "name" ) ) ; subcategory . setCount ( Integer . parseInt ( node . getAttribute ( "count" ) ) ) ; subcategories . add ( subcategory ) ; } NodeList groupNodes = categoryElement . getElementsByTagName ( "group" ) ; for ( int i = 0 ; i < groupNodes . getLength ( ) ; i ++ ) { Element node = ( Element ) groupNodes . item ( i ) ; Group group = new Group ( ) ; group . setId ( node . getAttribute ( "nsid" ) ) ; group . setName ( node . getAttribute ( "name" ) ) ; group . setMembers ( node . getAttribute ( "members" ) ) ; groups . add ( group ) ; } category . setGroups ( groups ) ; category . setSubcategories ( subcategories ) ; return category ; } | Browse groups for the given category ID . If a null value is passed for the category then the root category is used . |
23,279 | public Collection < Group > search ( String text , int perPage , int page ) throws FlickrException { GroupList < Group > groupList = new GroupList < Group > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_SEARCH ) ; parameters . put ( "text" , text ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , String . valueOf ( perPage ) ) ; } if ( page > 0 ) { parameters . put ( "page" , String . valueOf ( page ) ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element groupsElement = response . getPayload ( ) ; NodeList groupNodes = groupsElement . getElementsByTagName ( "group" ) ; groupList . setPage ( XMLUtilities . getIntAttribute ( groupsElement , "page" ) ) ; groupList . setPages ( XMLUtilities . getIntAttribute ( groupsElement , "pages" ) ) ; groupList . setPerPage ( XMLUtilities . getIntAttribute ( groupsElement , "perpage" ) ) ; groupList . setTotal ( XMLUtilities . getIntAttribute ( groupsElement , "total" ) ) ; for ( int i = 0 ; i < groupNodes . getLength ( ) ; i ++ ) { Element groupElement = ( Element ) groupNodes . item ( i ) ; Group group = new Group ( ) ; group . setId ( groupElement . getAttribute ( "nsid" ) ) ; group . setName ( groupElement . getAttribute ( "name" ) ) ; groupList . add ( group ) ; } return groupList ; } | Search for groups . 18 + groups will only be returned for authenticated calls where the authenticated user is over 18 . This method does not require authentication . |
23,280 | public void join ( String groupId , Boolean acceptRules ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_JOIN ) ; parameters . put ( "group_id" , groupId ) ; if ( acceptRules != null ) { parameters . put ( "accept_rules" , acceptRules ) ; } Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Join a group as a public member . |
23,281 | public void joinRequest ( String groupId , String message , boolean acceptRules ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_JOIN_REQUEST ) ; parameters . put ( "group_id" , groupId ) ; parameters . put ( "message" , message ) ; parameters . put ( "accept_rules" , acceptRules ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Request to join a group . |
23,282 | public void leave ( String groupId , Boolean deletePhotos ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_LEAVE ) ; parameters . put ( "group_id" , groupId ) ; parameters . put ( "delete_photos" , deletePhotos ) ; Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } } | Leave a group . |
23,283 | private void setNsid ( ) throws FlickrException { if ( username != null && ! username . equals ( "" ) ) { Auth auth = null ; if ( authStore != null ) { auth = authStore . retrieve ( username ) ; if ( auth != null ) { nsid = auth . getUser ( ) . getId ( ) ; } } if ( auth != null ) return ; Auth [ ] allAuths = authStore . retrieveAll ( ) ; for ( int i = 0 ; i < allAuths . length ; i ++ ) { if ( username . equals ( allAuths [ i ] . getUser ( ) . getUsername ( ) ) ) { nsid = allAuths [ i ] . getUser ( ) . getId ( ) ; return ; } } PeopleInterface peopleInterf = flickr . getPeopleInterface ( ) ; User u = peopleInterf . findByUsername ( username ) ; if ( u != null ) { nsid = u . getId ( ) ; } } } | Check local saved copy first ?? . If Auth by username is available then we will not need to make the API call . |
23,284 | private Auth constructAuth ( String authToken , String tokenSecret , String username ) throws IOException { Auth auth = new Auth ( ) ; auth . setToken ( authToken ) ; auth . setTokenSecret ( tokenSecret ) ; auth . setPermission ( Permission . fromString ( "delete" ) ) ; User user = new User ( ) ; user . setId ( nsid ) ; user . setUsername ( ( username ) ) ; user . setRealName ( "" ) ; auth . setUser ( user ) ; this . authStore . store ( auth ) ; return auth ; } | If the Authtoken was already created in a separate program but not saved to file . |
23,285 | public PlacesList < Place > find ( String query ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; PlacesList < Place > placesList = new PlacesList < Place > ( ) ; parameters . put ( "method" , METHOD_FIND ) ; parameters . put ( "query" , query ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element placesElement = response . getPayload ( ) ; NodeList placesNodes = placesElement . getElementsByTagName ( "place" ) ; placesList . setPage ( "1" ) ; placesList . setPages ( "1" ) ; placesList . setPerPage ( "" + placesNodes . getLength ( ) ) ; placesList . setTotal ( "" + placesNodes . getLength ( ) ) ; for ( int i = 0 ; i < placesNodes . getLength ( ) ; i ++ ) { Element placeElement = ( Element ) placesNodes . item ( i ) ; placesList . add ( parsePlace ( placeElement ) ) ; } return placesList ; } | Return a list of place IDs for a query string . |
23,286 | public Location getInfo ( String placeId , String woeId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_GET_INFO ) ; if ( placeId != null ) { parameters . put ( "place_id" , placeId ) ; } if ( woeId != null ) { parameters . put ( "woe_id" , woeId ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element locationElement = response . getPayload ( ) ; return parseLocation ( locationElement ) ; } | Get informations about a place . |
23,287 | public PlacesList < Place > placesForUser ( int placeType , String woeId , String placeId , String threshold , Date minUploadDate , Date maxUploadDate , Date minTakenDate , Date maxTakenDate ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; PlacesList < Place > placesList = new PlacesList < Place > ( ) ; parameters . put ( "method" , METHOD_PLACES_FOR_USER ) ; parameters . put ( "place_type" , intPlaceTypeToString ( placeType ) ) ; if ( placeId != null ) { parameters . put ( "place_id" , placeId ) ; } if ( woeId != null ) { parameters . put ( "woe_id" , woeId ) ; } if ( threshold != null ) { parameters . put ( "threshold" , threshold ) ; } if ( minUploadDate != null ) { parameters . put ( "min_upload_date" , Long . toString ( minUploadDate . getTime ( ) / 1000L ) ) ; } if ( maxUploadDate != null ) { parameters . put ( "max_upload_date" , Long . toString ( maxUploadDate . getTime ( ) / 1000L ) ) ; } if ( minTakenDate != null ) { parameters . put ( "min_taken_date" , ( ( DateFormat ) SearchParameters . MYSQL_DATE_FORMATS . get ( ) ) . format ( minTakenDate ) ) ; } if ( maxTakenDate != null ) { parameters . put ( "max_taken_date" , ( ( DateFormat ) SearchParameters . MYSQL_DATE_FORMATS . get ( ) ) . format ( maxTakenDate ) ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element placesElement = response . getPayload ( ) ; NodeList placesNodes = placesElement . getElementsByTagName ( "place" ) ; placesList . setPage ( "1" ) ; placesList . setPages ( "1" ) ; placesList . setPerPage ( "" + placesNodes . getLength ( ) ) ; placesList . setTotal ( "" + placesNodes . getLength ( ) ) ; for ( int i = 0 ; i < placesNodes . getLength ( ) ; i ++ ) { Element placeElement = ( Element ) placesNodes . item ( i ) ; placesList . add ( parsePlace ( placeElement ) ) ; } return placesList ; } | Return a list of the top 100 unique places clustered by a given placetype for a user . |
23,288 | public Location resolvePlaceId ( String placeId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_RESOLVE_PLACE_ID ) ; parameters . put ( "place_id" , placeId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element locationElement = response . getPayload ( ) ; return parseLocation ( locationElement ) ; } | Find Flickr Places information by Place ID . |
23,289 | public Location resolvePlaceURL ( String flickrPlacesUrl ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_RESOLVE_PLACE_URL ) ; parameters . put ( "url" , flickrPlacesUrl ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element locationElement = response . getPayload ( ) ; return parseLocation ( locationElement ) ; } | Find Flickr Places information by Place URL . |
23,290 | public TopicList < Topic > getTopicsList ( String groupId , int perPage , int page ) throws FlickrException { TopicList < Topic > topicList = new TopicList < Topic > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_TOPICS_GET_LIST ) ; parameters . put ( "group_id" , groupId ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element topicElements = response . getPayload ( ) ; topicList . setPage ( topicElements . getAttribute ( "page" ) ) ; topicList . setPages ( topicElements . getAttribute ( "pages" ) ) ; topicList . setPerPage ( topicElements . getAttribute ( "perpage" ) ) ; topicList . setTotal ( topicElements . getAttribute ( "total" ) ) ; topicList . setGroupId ( topicElements . getAttribute ( "group_id" ) ) ; topicList . setIconServer ( Integer . parseInt ( topicElements . getAttribute ( "iconserver" ) ) ) ; topicList . setIconFarm ( Integer . parseInt ( topicElements . getAttribute ( "iconfarm" ) ) ) ; topicList . setName ( topicElements . getAttribute ( "name" ) ) ; topicList . setMembers ( Integer . parseInt ( topicElements . getAttribute ( "members" ) ) ) ; topicList . setPrivacy ( Integer . parseInt ( topicElements . getAttribute ( "privacy" ) ) ) ; topicList . setLanguage ( topicElements . getAttribute ( "lang" ) ) ; topicList . setIsPoolModerated ( "1" . equals ( topicElements . getAttribute ( "ispoolmoderated" ) ) ) ; NodeList topicNodes = topicElements . getElementsByTagName ( "topic" ) ; for ( int i = 0 ; i < topicNodes . getLength ( ) ; i ++ ) { Element element = ( Element ) topicNodes . item ( i ) ; topicList . add ( parseTopic ( element ) ) ; } return topicList ; } | Get a list of topics from a group . |
23,291 | public Topic getTopicInfo ( String topicId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_TOPICS_GET_INFO ) ; parameters . put ( "topic_id" , topicId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element topicElement = response . getPayload ( ) ; return parseTopic ( topicElement ) ; } | Get info for a given topic |
23,292 | public ReplyObject getReplyList ( String topicId , int perPage , int page ) throws FlickrException { ReplyList < Reply > reply = new ReplyList < Reply > ( ) ; TopicList < Topic > topic = new TopicList < Topic > ( ) ; Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_REPLIES_GET_LIST ) ; parameters . put ( "topic_id" , topicId ) ; if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element replyElements = response . getPayload ( ) ; ReplyObject ro = new ReplyObject ( ) ; NodeList replyNodes = replyElements . getElementsByTagName ( "reply" ) ; for ( int i = 0 ; i < replyNodes . getLength ( ) ; i ++ ) { Element replyNodeElement = ( Element ) replyNodes . item ( i ) ; reply . add ( parseReply ( replyNodeElement ) ) ; ro . setReplyList ( reply ) ; } NodeList topicNodes = replyElements . getElementsByTagName ( "topic" ) ; for ( int i = 0 ; i < topicNodes . getLength ( ) ; i ++ ) { Element replyNodeElement = ( Element ) replyNodes . item ( i ) ; topic . add ( parseTopic ( replyNodeElement ) ) ; ro . setTopicList ( topic ) ; } return ro ; } | Get list of replies |
23,293 | public Reply getReplyInfo ( String topicId , String replyId ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; parameters . put ( "method" , METHOD_REPLIES_GET_INFO ) ; parameters . put ( "topic_id" , topicId ) ; parameters . put ( "reply_id" , replyId ) ; Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element replyElement = response . getPayload ( ) ; return parseReply ( replyElement ) ; } | Get info for a given topic reply |
23,294 | public NamespacesList < Namespace > getNamespaces ( String predicate , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; NamespacesList < Namespace > nsList = new NamespacesList < Namespace > ( ) ; parameters . put ( "method" , METHOD_GET_NAMESPACES ) ; if ( predicate != null ) { parameters . put ( "predicate" , predicate ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element nsElement = response . getPayload ( ) ; NodeList nsNodes = nsElement . getElementsByTagName ( "namespace" ) ; nsList . setPage ( "1" ) ; nsList . setPages ( "1" ) ; nsList . setPerPage ( "" + nsNodes . getLength ( ) ) ; nsList . setTotal ( "" + nsNodes . getLength ( ) ) ; for ( int i = 0 ; i < nsNodes . getLength ( ) ; i ++ ) { Element element = ( Element ) nsNodes . item ( i ) ; nsList . add ( parseNamespace ( element ) ) ; } return nsList ; } | Return a list of unique namespaces optionally limited by a given predicate in alphabetical order . |
23,295 | public NamespacesList < Pair > getPairs ( String namespace , String predicate , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; NamespacesList < Pair > nsList = new NamespacesList < Pair > ( ) ; parameters . put ( "method" , METHOD_GET_PAIRS ) ; if ( namespace != null ) { parameters . put ( "namespace" , namespace ) ; } if ( predicate != null ) { parameters . put ( "predicate" , predicate ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element nsElement = response . getPayload ( ) ; NodeList nsNodes = nsElement . getElementsByTagName ( "pair" ) ; nsList . setPage ( nsElement . getAttribute ( "page" ) ) ; nsList . setPages ( nsElement . getAttribute ( "pages" ) ) ; nsList . setPerPage ( nsElement . getAttribute ( "perPage" ) ) ; nsList . setTotal ( "" + nsNodes . getLength ( ) ) ; for ( int i = 0 ; i < nsNodes . getLength ( ) ; i ++ ) { Element element = ( Element ) nsNodes . item ( i ) ; nsList . add ( parsePair ( element ) ) ; } return nsList ; } | Return a list of unique namespace and predicate pairs optionally limited by predicate or namespace in alphabetical order . |
23,296 | public NamespacesList < Value > getValues ( String namespace , String predicate , int perPage , int page ) throws FlickrException { Map < String , Object > parameters = new HashMap < String , Object > ( ) ; NamespacesList < Value > valuesList = new NamespacesList < Value > ( ) ; parameters . put ( "method" , METHOD_GET_VALUES ) ; if ( namespace != null ) { parameters . put ( "namespace" , namespace ) ; } if ( predicate != null ) { parameters . put ( "predicate" , predicate ) ; } if ( perPage > 0 ) { parameters . put ( "per_page" , "" + perPage ) ; } if ( page > 0 ) { parameters . put ( "page" , "" + page ) ; } Response response = transportAPI . get ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } Element nsElement = response . getPayload ( ) ; NodeList nsNodes = nsElement . getElementsByTagName ( "value" ) ; valuesList . setPage ( nsElement . getAttribute ( "page" ) ) ; valuesList . setPages ( nsElement . getAttribute ( "pages" ) ) ; valuesList . setPerPage ( nsElement . getAttribute ( "perPage" ) ) ; valuesList . setTotal ( "" + nsNodes . getLength ( ) ) ; for ( int i = 0 ; i < nsNodes . getLength ( ) ; i ++ ) { Element element = ( Element ) nsNodes . item ( i ) ; Value value = parseValue ( element ) ; value . setNamespace ( namespace ) ; value . setPredicate ( predicate ) ; valuesList . add ( value ) ; } return valuesList ; } | Return a list of unique values for a namespace and predicate . |
23,297 | public static String join ( Collection < String > s , String delimiter , boolean doQuote ) { StringBuffer buffer = new StringBuffer ( ) ; Iterator < String > iter = s . iterator ( ) ; while ( iter . hasNext ( ) ) { if ( doQuote ) { buffer . append ( "\"" + iter . next ( ) + "\"" ) ; } else { buffer . append ( iter . next ( ) ) ; } if ( iter . hasNext ( ) ) { buffer . append ( delimiter ) ; } } return buffer . toString ( ) ; } | Join the Collection of Strings using the specified delimter and optionally quoting each |
23,298 | public static String join ( Collection < String > s , String delimiter ) { return join ( s , delimiter , false ) ; } | Join the Collection of Strings using the specified delimiter . |
23,299 | public DomainList getCollectionDomains ( Date date , String collectionId , int perPage , int page ) throws FlickrException { return getDomains ( METHOD_GET_COLLECTION_DOMAINS , "collection_id" , collectionId , date , perPage , page ) ; } | Get a list of referring domains for a collection . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.