idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
146,600 | public synchronized HttpServer < Buffer , Buffer > start ( ) throws Exception { if ( server == null ) { server = createProtocolListener ( ) ; } return server ; } | Start a server . | 37 | 4 |
146,601 | public void setSegmentReject ( String reject ) { if ( ! StringUtils . hasText ( reject ) ) { return ; } Integer parsedLimit = null ; try { parsedLimit = Integer . parseInt ( reject ) ; segmentRejectType = SegmentRejectType . ROWS ; } catch ( NumberFormatException e ) { } if ( parsedLimit == null && reject . contains ( "%" ) ) { try { parsedLimit = Integer . parseInt ( reject . replace ( "%" , "" ) . trim ( ) ) ; segmentRejectType = SegmentRejectType . PERCENT ; } catch ( NumberFormatException e ) { } } segmentRejectLimit = parsedLimit ; } | Sets the segment reject as a string . This method is for convenience to be able to set percent reject type just by calling with 3% and otherwise it uses rows . All this assuming that parsing finds % characher and is able to parse a raw reject number . | 147 | 53 |
146,602 | public void setReadTimeout ( int millis ) { // Hack to get round Spring's dynamic loading of http client stuff ClientHttpRequestFactory f = getRequestFactory ( ) ; if ( f instanceof SimpleClientHttpRequestFactory ) { ( ( SimpleClientHttpRequestFactory ) f ) . setReadTimeout ( millis ) ; } else { ( ( HttpComponentsClientHttpRequestFactory ) f ) . setReadTimeout ( millis ) ; } } | The read timeout for the underlying URLConnection to the twitter stream . | 94 | 13 |
146,603 | public void setConnectTimeout ( int millis ) { ClientHttpRequestFactory f = getRequestFactory ( ) ; if ( f instanceof SimpleClientHttpRequestFactory ) { ( ( SimpleClientHttpRequestFactory ) f ) . setConnectTimeout ( millis ) ; } else { ( ( HttpComponentsClientHttpRequestFactory ) f ) . setConnectTimeout ( millis ) ; } } | The connection timeout for making a connection to Twitter . | 81 | 10 |
146,604 | private void handleTextWebSocketFrameInternal ( TextWebSocketFrame frame , ChannelHandlerContext ctx ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( String . format ( "%s received %s" , ctx . channel ( ) , frame . text ( ) ) ) ; } addTraceForFrame ( frame , "text" ) ; ctx . channel ( ) . write ( new TextWebSocketFrame ( "Echo: " + frame . text ( ) ) ) ; } | simple echo implementation | 108 | 3 |
146,605 | private void addTraceForFrame ( WebSocketFrame frame , String type ) { Map < String , Object > trace = new LinkedHashMap <> ( ) ; trace . put ( "type" , type ) ; trace . put ( "direction" , "in" ) ; if ( frame instanceof TextWebSocketFrame ) { trace . put ( "payload" , ( ( TextWebSocketFrame ) frame ) . text ( ) ) ; } if ( traceEnabled ) { websocketTraceRepository . add ( trace ) ; } } | add trace information for received frame | 115 | 6 |
146,606 | @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) private IntegrationFlowBuilder getFlowBuilder ( ) { IntegrationFlowBuilder flowBuilder ; URLName urlName = this . properties . getUrl ( ) ; if ( this . properties . isIdleImap ( ) ) { flowBuilder = getIdleImapFlow ( urlName ) ; } else { MailInboundChannelAdapterSpec adapterSpec ; switch ( urlName . getProtocol ( ) . toUpperCase ( ) ) { case "IMAP" : case "IMAPS" : adapterSpec = getImapFlowBuilder ( urlName ) ; break ; case "POP3" : case "POP3S" : adapterSpec = getPop3FlowBuilder ( urlName ) ; break ; default : throw new IllegalArgumentException ( "Unsupported mail protocol: " + urlName . getProtocol ( ) ) ; } flowBuilder = IntegrationFlows . from ( adapterSpec . javaMailProperties ( getJavaMailProperties ( urlName ) ) . selectorExpression ( this . properties . getExpression ( ) ) . shouldDeleteMessages ( this . properties . isDelete ( ) ) , new Consumer < SourcePollingChannelAdapterSpec > ( ) { @ Override public void accept ( SourcePollingChannelAdapterSpec sourcePollingChannelAdapterSpec ) { sourcePollingChannelAdapterSpec . poller ( MailSourceConfiguration . this . defaultPoller ) ; } } ) ; } return flowBuilder ; } | Method to build Integration Flow for Mail . Suppress Warnings for MailInboundChannelAdapterSpec . | 317 | 20 |
146,607 | private IntegrationFlowBuilder getIdleImapFlow ( URLName urlName ) { return IntegrationFlows . from ( Mail . imapIdleAdapter ( urlName . toString ( ) ) . shouldDeleteMessages ( this . properties . isDelete ( ) ) . javaMailProperties ( getJavaMailProperties ( urlName ) ) . selectorExpression ( this . properties . getExpression ( ) ) . shouldMarkMessagesAsRead ( this . properties . isMarkAsRead ( ) ) ) ; } | Method to build Integration flow for IMAP Idle configuration . | 108 | 11 |
146,608 | @ SuppressWarnings ( "rawtypes" ) private MailInboundChannelAdapterSpec getImapFlowBuilder ( URLName urlName ) { return Mail . imapInboundAdapter ( urlName . toString ( ) ) . shouldMarkMessagesAsRead ( this . properties . isMarkAsRead ( ) ) ; } | Method to build Mail Channel Adapter for IMAP . | 69 | 10 |
146,609 | protected View postDeclineView ( ) { return new TopLevelWindowRedirect ( ) { @ Override 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 . | 48 | 49 |
146,610 | @ 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 | 48 | 15 |
146,611 | 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 . | 243 | 17 |
146,612 | public String getString ( String fieldName ) { return hasValue ( fieldName ) ? String . valueOf ( resultMap . get ( fieldName ) ) : null ; } | Returns the value of the identified field as a String . | 36 | 11 |
146,613 | 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 . | 78 | 11 |
146,614 | 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 . | 78 | 11 |
146,615 | 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 . | 78 | 11 |
146,616 | 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 . | 43 | 11 |
146,617 | 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 . | 92 | 32 |
146,618 | public boolean hasValue ( String fieldName ) { return resultMap . containsKey ( fieldName ) && resultMap . get ( fieldName ) != null ; } | Checks that a field exists and contains a non - null value . | 33 | 14 |
146,619 | 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 | 65 | 6 |
146,620 | @ RequestMapping ( value = "/{subscription}" , method = GET , params = "hub.mode=subscribe" ) public @ ResponseBody 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 . | 128 | 8 |
146,621 | 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 . | 535 | 15 |
146,622 | 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 . | 49 | 26 |
146,623 | 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 | 141 | 9 |
146,624 | 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 . | 145 | 9 |
146,625 | 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 . | 209 | 9 |
146,626 | 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 . | 176 | 10 |
146,627 | 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 . | 419 | 9 |
146,628 | 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 . | 118 | 9 |
146,629 | 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 | 322 | 13 |
146,630 | 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 | 206 | 11 |
146,631 | @ Override public AuthInterface getAuthInterface ( ) { if ( authInterface == null ) { authInterface = new AuthInterface ( apiKey , sharedSecret , transport ) ; } return authInterface ; } | Get the AuthInterface . | 42 | 5 |
146,632 | @ Override public ActivityInterface getActivityInterface ( ) { if ( activityInterface == null ) { activityInterface = new ActivityInterface ( apiKey , sharedSecret , transport ) ; } return activityInterface ; } | Get the ActivityInterface . | 42 | 5 |
146,633 | @ Override public TagsInterface getTagsInterface ( ) { if ( tagsInterface == null ) { tagsInterface = new TagsInterface ( apiKey , sharedSecret , transport ) ; } return tagsInterface ; } | Get the TagsInterface for working with Flickr Tags . | 42 | 10 |
146,634 | @ Override public SuggestionsInterface getSuggestionsInterface ( ) { if ( suggestionsInterface == null ) { suggestionsInterface = new SuggestionsInterface ( apiKey , sharedSecret , transport ) ; } return suggestionsInterface ; } | Get the SuggestionsInterface . | 45 | 6 |
146,635 | @ Override public GroupDiscussInterface getDiscussionInterface ( ) { if ( discussionInterface == null ) { discussionInterface = new GroupDiscussInterface ( apiKey , sharedSecret , transport ) ; } return discussionInterface ; } | Get the GroupDiscussInterface . | 44 | 6 |
146,636 | 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 . | 252 | 9 |
146,637 | 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 . | 202 | 29 |
146,638 | public void postPhoto ( Photo photo , String blogId ) throws FlickrException { postPhoto ( photo , blogId , null ) ; } | Post the specified photo to a blog . | 28 | 8 |
146,639 | 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 . | 291 | 11 |
146,640 | 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 . | 62 | 10 |
146,641 | 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 . | 183 | 10 |
146,642 | 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 . | 115 | 14 |
146,643 | 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 . | 99 | 11 |
146,644 | @ SuppressWarnings ( "boxing" ) public OAuth1Token getAccessToken ( OAuth1RequestToken oAuthRequestToken , String verifier ) { OAuth10aService service = new ServiceBuilder ( apiKey ) . apiSecret ( sharedSecret ) . build ( FlickrApi . instance ( ) ) ; // Flickr seems to return invalid token sometimes so retry a few times. // See http://www.flickr.com/groups/api/discuss/72157628028927244/ 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 ) { // Do nothing } } } } return accessToken ; } | Trade the request token for an access token this is step three of authorization . | 316 | 15 |
146,645 | public OAuth1RequestToken exchangeAuthToken ( String authToken ) throws FlickrException { // Use TreeMap so keys are automatically sorted alphabetically Map < String , String > parameters = new TreeMap < String , String > ( ) ; parameters . put ( "method" , METHOD_EXCHANGE_TOKEN ) ; parameters . put ( Flickr . API_KEY , apiKey ) ; // This method call must be signed using Flickr (not OAuth) style signing 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 . | 193 | 17 |
146,646 | 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 . | 104 | 9 |
146,647 | 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 . | 175 | 14 |
146,648 | @ Deprecated 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 . | 50 | 5 |
146,649 | 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 ) { // Should never happen, but just in case } buffer . append ( string ) ; } if ( -- size != 0 ) { buffer . append ( ' ' ) ; } } /* * RequestContext requestContext = RequestContext.getRequestContext(); Auth auth = requestContext.getAuth(); if (auth != null && * !ignoreMethod(getMethod(parameters))) { buffer.append("&api_sig="); buffer.append(AuthUtilities.getSignature(sharedSecret, parameters)); } */ return new URL ( buffer . toString ( ) ) ; } | Build a request URL using a given scheme . | 380 | 9 |
146,650 | @ Override 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 . | 45 | 9 |
146,651 | @ Override public String upload ( File file , UploadMetaData metaData ) throws FlickrException { Payload payload = new Payload ( file ) ; return sendUploadRequest ( metaData , payload ) ; } | Upload a photo from a File . | 43 | 7 |
146,652 | @ Override public String upload ( InputStream in , UploadMetaData metaData ) throws FlickrException { Payload payload = new Payload ( in ) ; return sendUploadRequest ( metaData , payload ) ; } | Upload a photo from an InputStream . | 44 | 8 |
146,653 | @ Override 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 . | 49 | 8 |
146,654 | private String getResponseString ( boolean async , UploaderResponse response ) { return async ? response . getTicketId ( ) : response . getPhotoId ( ) ; } | Get the photo or ticket id from the response . | 36 | 10 |
146,655 | @ Deprecated 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 . | 55 | 28 |
146,656 | 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 . | 52 | 17 |
146,657 | @ Deprecated 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 . | 66 | 18 |
146,658 | 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 . | 81 | 6 |
146,659 | @ Deprecated 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 . | 49 | 9 |
146,660 | @ Deprecated 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 . | 54 | 11 |
146,661 | @ Deprecated 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 . | 52 | 23 |
146,662 | 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 . | 437 | 12 |
146,663 | 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 . | 141 | 18 |
146,664 | 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 . | 350 | 5 |
146,665 | 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 ) ; // Note: This method requires an HTTP POST request. Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } // This method has no specific response - It returns an empty // sucess response if it completes without error. } | Delete a comment as the currently authenticated user . | 157 | 9 |
146,666 | 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 ) ; // Note: This method requires an HTTP POST request. Response response = transportAPI . post ( transportAPI . getPath ( ) , parameters , apiKey , sharedSecret ) ; if ( response . isError ( ) ) { throw new FlickrException ( response . getErrorCode ( ) , response . getErrorMessage ( ) ) ; } // This method has no specific response - It returns an empty // sucess response if it completes without error. } | Edit the text of a comment as the currently authenticated user . | 173 | 12 |
146,667 | 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 . | 388 | 40 |
146,668 | public void setLabel ( String label ) { int ix = lstSizes . indexOf ( label ) ; if ( ix != - 1 ) { setLabel ( ix ) ; } } | Set the String - representation of size . | 42 | 8 |
146,669 | 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 . | 218 | 6 |
146,670 | 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 . | 161 | 11 |
146,671 | 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 . | 178 | 9 |
146,672 | 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" ) ) ; // TODO verify that this is the secret for the photo primaryPhoto . setServer ( photosetElement . getAttribute ( "server" ) ) ; // TODO verify that this is the server for the photo primaryPhoto . setFarm ( photosetElement . getAttribute ( "farm" ) ) ; photoset . setPrimaryPhoto ( primaryPhoto ) ; // TODO remove secret/server/farm from photoset? // It's rather related to the primaryPhoto, then to the photoset itself. 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 . | 653 | 9 |
146,673 | 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 . | 450 | 12 |
146,674 | 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 . | 142 | 12 |
146,675 | 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 . | 564 | 10 |
146,676 | 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 . | 522 | 22 |
146,677 | 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 . | 401 | 12 |
146,678 | 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 . | 212 | 7 |
146,679 | 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 . | 322 | 11 |
146,680 | 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 . | 416 | 11 |
146,681 | 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 . | 529 | 14 |
146,682 | 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 . | 194 | 15 |
146,683 | 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 . | 141 | 9 |
146,684 | 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 . | 137 | 10 |
146,685 | 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 . | 137 | 10 |
146,686 | @ Deprecated 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 . | 534 | 25 |
146,687 | 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 . | 417 | 29 |
146,688 | 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 . | 146 | 8 |
146,689 | 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 . | 155 | 6 |
146,690 | 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 . | 138 | 4 |
146,691 | private void setNsid ( ) throws FlickrException { if ( username != null && ! username . equals ( "" ) ) { Auth auth = null ; if ( authStore != null ) { auth = authStore . retrieve ( username ) ; // assuming FileAuthStore is enhanced else need to // keep in user-level files. 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 ; } } // For this to work: REST.java or PeopleInterface needs to change to pass apiKey // as the parameter to the call which is not authenticated. // Get nsid using flickr.people.findByUsername 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 . | 278 | 24 |
146,692 | private Auth constructAuth ( String authToken , String tokenSecret , String username ) throws IOException { Auth auth = new Auth ( ) ; auth . setToken ( authToken ) ; auth . setTokenSecret ( tokenSecret ) ; // Prompt to ask what permission is needed: read, update or delete. auth . setPermission ( Permission . fromString ( "delete" ) ) ; User user = new User ( ) ; // Later change the following 3. Either ask user to pass on command line or read // from saved file. 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 . | 161 | 17 |
146,693 | 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 . | 284 | 11 |
146,694 | 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 . | 181 | 7 |
146,695 | 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 . | 599 | 20 |
146,696 | @ Deprecated 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 . | 150 | 8 |
146,697 | @ Deprecated 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 . | 154 | 8 |
146,698 | 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 . | 565 | 9 |
146,699 | 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 | 145 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.