idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
149,600
public ItemRequest < Project > addCustomFieldSetting ( String project ) { String path = String . format ( "/projects/%s/addCustomFieldSetting" , project ) ; return new ItemRequest < Project > ( this , Project . class , path , "POST" ) ; }
Create a new custom field setting on the project .
59
10
149,601
public ItemRequest < Project > removeCustomFieldSetting ( String project ) { String path = String . format ( "/projects/%s/removeCustomFieldSetting" , project ) ; return new ItemRequest < Project > ( this , Project . class , path , "POST" ) ; }
Remove a custom field setting on the project .
59
9
149,602
private void retrieveNextPage ( ) { if ( this . pageSize < Long . MAX_VALUE || this . itemLimit < Long . MAX_VALUE ) { this . request . query ( "limit" , Math . min ( this . pageSize , this . itemLimit - this . count ) ) ; } else { this . request . query ( "limit" , null ) ; } ResultBodyCollection < T > page = null ; try { page = this . getNext ( ) ; } catch ( IOException exception ) { // See comments in hasNext(). this . ioException = exception ; } if ( page != null ) { this . continuation = this . getContinuation ( page ) ; if ( page . data != null && ! page . data . isEmpty ( ) ) { this . count += page . data . size ( ) ; this . nextData = page . data ; } else { this . nextData = null ; } } else { this . continuation = null ; this . nextData = null ; } }
Retrieve the next page and store the continuation token the new data and any IOException that may occur .
213
21
149,603
public ItemRequest < User > findById ( String user ) { String path = String . format ( "/users/%s" , user ) ; return new ItemRequest < User > ( this , User . class , path , "GET" ) ; }
Returns the full user record for the single user with the provided ID .
52
14
149,604
public CollectionRequest < User > findByWorkspace ( String workspace ) { String path = String . format ( "/workspaces/%s/users" , workspace ) ; return new CollectionRequest < User > ( this , User . class , path , "GET" ) ; }
Returns the user records for all users in the specified workspace or organization .
57
14
149,605
public ItemRequest < CustomField > findById ( String customField ) { String path = String . format ( "/custom_fields/%s" , customField ) ; return new ItemRequest < CustomField > ( this , CustomField . class , path , "GET" ) ; }
Returns the complete definition of a custom field s metadata .
59
11
149,606
public CollectionRequest < CustomField > findByWorkspace ( String workspace ) { String path = String . format ( "/workspaces/%s/custom_fields" , workspace ) ; return new CollectionRequest < CustomField > ( this , CustomField . class , path , "GET" ) ; }
Returns a list of the compact representation of all of the custom fields in a workspace .
62
17
149,607
public ItemRequest < CustomField > update ( String customField ) { String path = String . format ( "/custom_fields/%s" , customField ) ; return new ItemRequest < CustomField > ( this , CustomField . class , path , "PUT" ) ; }
A specific existing custom field can be updated by making a PUT request on the URL for that custom field . Only the fields provided in the data block will be updated ; any unspecified fields will remain unchanged
58
40
149,608
public ItemRequest < CustomField > delete ( String customField ) { String path = String . format ( "/custom_fields/%s" , customField ) ; return new ItemRequest < CustomField > ( this , CustomField . class , path , "DELETE" ) ; }
A specific existing custom field can be deleted by making a DELETE request on the URL for that custom field .
60
23
149,609
public ItemRequest < CustomField > updateEnumOption ( String enumOption ) { String path = String . format ( "/enum_options/%s" , enumOption ) ; return new ItemRequest < CustomField > ( this , CustomField . class , path , "PUT" ) ; }
Updates an existing enum option . Enum custom fields require at least one enabled enum option .
61
19
149,610
public ItemRequest < CustomField > insertEnumOption ( String customField ) { String path = String . format ( "/custom_fields/%s/enum_options/insert" , customField ) ; return new ItemRequest < CustomField > ( this , CustomField . class , path , "POST" ) ; }
Moves a particular enum option to be either before or after another specified enum option in the custom field .
67
21
149,611
public ItemRequest < ProjectStatus > createInProject ( String project ) { String path = String . format ( "/projects/%s/project_statuses" , project ) ; return new ItemRequest < ProjectStatus > ( this , ProjectStatus . class , path , "POST" ) ; }
Creates a new status update on the project .
61
10
149,612
public CollectionRequest < ProjectStatus > findByProject ( String project ) { String path = String . format ( "/projects/%s/project_statuses" , project ) ; return new CollectionRequest < ProjectStatus > ( this , ProjectStatus . class , path , "GET" ) ; }
Returns the compact project status update records for all updates on the project .
61
14
149,613
public ItemRequest < ProjectStatus > findById ( String projectStatus ) { String path = String . format ( "/project_statuses/%s" , projectStatus ) ; return new ItemRequest < ProjectStatus > ( this , ProjectStatus . class , path , "GET" ) ; }
Returns the complete record for a single status update .
60
10
149,614
public ItemRequest < ProjectStatus > delete ( String projectStatus ) { String path = String . format ( "/project_statuses/%s" , projectStatus ) ; return new ItemRequest < ProjectStatus > ( this , ProjectStatus . class , path , "DELETE" ) ; }
Deletes a specific existing project status update .
61
9
149,615
public ItemRequest < Webhook > getById ( String webhook ) { String path = String . format ( "/webhooks/%s" , webhook ) ; return new ItemRequest < Webhook > ( this , Webhook . class , path , "GET" ) ; }
Returns the full record for the given webhook .
59
10
149,616
public ItemRequest < Webhook > deleteById ( String webhook ) { String path = String . format ( "/webhooks/%s" , webhook ) ; return new ItemRequest < Webhook > ( this , Webhook . class , path , "DELETE" ) ; }
This method permanently removes a webhook . Note that it may be possible to receive a request that was already in flight after deleting the webhook but no further requests will be issued .
61
36
149,617
public EventsRequest < Event > get ( String resource , String sync ) { return new EventsRequest < Event > ( this , Event . class , "/events" , "GET" ) . query ( "resource" , resource ) . query ( "sync" , sync ) ; }
Returns any events for the given resource ID since the last sync token
57
13
149,618
public CollectionRequest < ProjectMembership > findByProject ( String project ) { String path = String . format ( "/projects/%s/project_memberships" , project ) ; return new CollectionRequest < ProjectMembership > ( this , ProjectMembership . class , path , "GET" ) ; }
Returns the compact project membership records for the project .
64
10
149,619
public ItemRequest < ProjectMembership > findById ( String projectMembership ) { String path = String . format ( "/project_memberships/%s" , projectMembership ) ; return new ItemRequest < ProjectMembership > ( this , ProjectMembership . class , path , "GET" ) ; }
Returns the project membership record .
65
6
149,620
public CollectionRequest < Story > findByTask ( String task ) { String path = String . format ( "/tasks/%s/stories" , task ) ; return new CollectionRequest < Story > ( this , Story . class , path , "GET" ) ; }
Returns the compact records for all stories on the task .
56
11
149,621
public ItemRequest < Story > findById ( String story ) { String path = String . format ( "/stories/%s" , story ) ; return new ItemRequest < Story > ( this , Story . class , path , "GET" ) ; }
Returns the full record for a single story .
52
9
149,622
public ItemRequest < Story > update ( String story ) { String path = String . format ( "/stories/%s" , story ) ; return new ItemRequest < Story > ( this , Story . class , path , "PUT" ) ; }
Updates the story and returns the full record for the updated story . Only comment stories can have their text updated and only comment stories and attachment stories can be pinned . Only one of text and html_text can be specified .
51
45
149,623
public ItemRequest < Story > delete ( String story ) { String path = String . format ( "/stories/%s" , story ) ; return new ItemRequest < Story > ( this , Story . class , path , "DELETE" ) ; }
Deletes a story . A user can only delete stories they have created . Returns an empty data record .
53
21
149,624
public ItemRequest < Workspace > findById ( String workspace ) { String path = String . format ( "/workspaces/%s" , workspace ) ; return new ItemRequest < Workspace > ( this , Workspace . class , path , "GET" ) ; }
Returns the full workspace record for a single workspace .
56
10
149,625
public ItemRequest < Workspace > update ( String workspace ) { String path = String . format ( "/workspaces/%s" , workspace ) ; return new ItemRequest < Workspace > ( this , Workspace . class , path , "PUT" ) ; }
A specific existing workspace can be updated by making a PUT request on the URL for that workspace . Only the fields provided in the data block will be updated ; any unspecified fields will remain unchanged .
55
39
149,626
public ItemRequest < Workspace > addUser ( String workspace ) { String path = String . format ( "/workspaces/%s/addUser" , workspace ) ; return new ItemRequest < Workspace > ( this , Workspace . class , path , "POST" ) ; }
The user can be referenced by their globally unique user ID or their email address . Returns the full user record for the invited user .
59
26
149,627
public ItemRequest < Workspace > removeUser ( String workspace ) { String path = String . format ( "/workspaces/%s/removeUser" , workspace ) ; return new ItemRequest < Workspace > ( this , Workspace . class , path , "POST" ) ; }
The user making this call must be an admin in the workspace . Returns an empty data record .
59
19
149,628
public ItemRequest < Attachment > createOnTask ( String task , InputStream fileContent , String fileName , String fileType ) { MultipartContent . Part part = new MultipartContent . Part ( ) . setContent ( new InputStreamContent ( fileType , fileContent ) ) . setHeaders ( new HttpHeaders ( ) . set ( "Content-Disposition" , String . format ( "form-data; name=\"file\"; filename=\"%s\"" , fileName ) // TODO: escape fileName? ) ) ; MultipartContent content = new MultipartContent ( ) . setMediaType ( new HttpMediaType ( "multipart/form-data" ) . setParameter ( "boundary" , UUID . randomUUID ( ) . toString ( ) ) ) . addPart ( part ) ; String path = String . format ( "/tasks/%s/attachments" , task ) ; return new ItemRequest < Attachment > ( this , Attachment . class , path , "POST" ) . data ( content ) ; }
Upload a file and attach it to a task
233
9
149,629
public ItemRequest < OrganizationExport > findById ( String organizationExport ) { String path = String . format ( "/organization_exports/%s" , organizationExport ) ; return new ItemRequest < OrganizationExport > ( this , OrganizationExport . class , path , "GET" ) ; }
Returns details of a previously - requested Organization export .
61
10
149,630
public Request option ( String key , Object value ) { this . options . put ( key , value ) ; return this ; }
Sets a client option per - request
26
8
149,631
public Request header ( String key , String value ) { this . headers . put ( key , value ) ; return this ; }
Sets a header per - request
26
7
149,632
public ItemRequest < Attachment > findById ( String attachment ) { String path = String . format ( "/attachments/%s" , attachment ) ; return new ItemRequest < Attachment > ( this , Attachment . class , path , "GET" ) ; }
Returns the full record for a single attachment .
56
9
149,633
public CollectionRequest < Attachment > findByTask ( String task ) { String path = String . format ( "/tasks/%s/attachments" , task ) ; return new CollectionRequest < Attachment > ( this , Attachment . class , path , "GET" ) ; }
Returns the compact records for all attachments on the task .
60
11
149,634
public ItemRequest < Section > createInProject ( String project ) { String path = String . format ( "/projects/%s/sections" , project ) ; return new ItemRequest < Section > ( this , Section . class , path , "POST" ) ; }
Creates a new section in a project .
55
9
149,635
public CollectionRequest < Section > findByProject ( String project ) { String path = String . format ( "/projects/%s/sections" , project ) ; return new CollectionRequest < Section > ( this , Section . class , path , "GET" ) ; }
Returns the compact records for all sections in the specified project .
55
12
149,636
public ItemRequest < Section > findById ( String section ) { String path = String . format ( "/sections/%s" , section ) ; return new ItemRequest < Section > ( this , Section . class , path , "GET" ) ; }
Returns the complete record for a single section .
52
9
149,637
public ItemRequest < Section > delete ( String section ) { String path = String . format ( "/sections/%s" , section ) ; return new ItemRequest < Section > ( this , Section . class , path , "DELETE" ) ; }
A specific existing section can be deleted by making a DELETE request on the URL for that section .
53
21
149,638
public ItemRequest < Section > insertInProject ( String project ) { String path = String . format ( "/projects/%s/sections/insert" , project ) ; return new ItemRequest < Section > ( this , Section . class , path , "POST" ) ; }
Move sections relative to each other in a board view . One of before_section or after_section is required .
57
23
149,639
public ItemRequest < Team > findById ( String team ) { String path = String . format ( "/teams/%s" , team ) ; return new ItemRequest < Team > ( this , Team . class , path , "GET" ) ; }
Returns the full record for a single team .
53
9
149,640
public CollectionRequest < Team > findByOrganization ( String organization ) { String path = String . format ( "/organizations/%s/teams" , organization ) ; return new CollectionRequest < Team > ( this , Team . class , path , "GET" ) ; }
Returns the compact records for all teams in the organization visible to the authorized user .
58
16
149,641
public CollectionRequest < Team > findByUser ( String user ) { String path = String . format ( "/users/%s/teams" , user ) ; return new CollectionRequest < Team > ( this , Team . class , path , "GET" ) ; }
Returns the compact records for all teams to which user is assigned .
56
13
149,642
public CollectionRequest < Team > users ( String team ) { String path = String . format ( "/teams/%s/users" , team ) ; return new CollectionRequest < Team > ( this , Team . class , path , "GET" ) ; }
Returns the compact records for all users that are members of the team .
54
14
149,643
public ItemRequest < Team > addUser ( String team ) { String path = String . format ( "/teams/%s/addUser" , team ) ; return new ItemRequest < Team > ( this , Team . class , path , "POST" ) ; }
The user making this call must be a member of the team in order to add others . The user to add must exist in the same organization as the team in order to be added . The user to add can be referenced by their globally unique user ID or their email address . Returns the full user record for the added user .
56
65
149,644
public ItemRequest < Team > removeUser ( String team ) { String path = String . format ( "/teams/%s/removeUser" , team ) ; return new ItemRequest < Team > ( this , Team . class , path , "POST" ) ; }
The user to remove can be referenced by their globally unique user ID or their email address . Removes the user from the specified team . Returns an empty data record .
56
33
149,645
protected InternalHttpResponse sendInternalRequest ( HttpRequest request ) { InternalHttpResponder responder = new InternalHttpResponder ( ) ; httpResourceHandler . handle ( request , responder ) ; return responder . getResponse ( ) ; }
Send a request to another handler internal to the server getting back the response body and response code .
51
19
149,646
public SslHandler create ( ByteBufAllocator bufferAllocator ) { SSLEngine engine = sslContext . newEngine ( bufferAllocator ) ; engine . setNeedClientAuth ( needClientAuth ) ; engine . setUseClientMode ( false ) ; return new SslHandler ( engine ) ; }
Creates an SslHandler
69
6
149,647
private Set < HttpMethod > getHttpMethods ( Method method ) { Set < HttpMethod > httpMethods = new HashSet <> ( ) ; if ( method . isAnnotationPresent ( GET . class ) ) { httpMethods . add ( HttpMethod . GET ) ; } if ( method . isAnnotationPresent ( PUT . class ) ) { httpMethods . add ( HttpMethod . PUT ) ; } if ( method . isAnnotationPresent ( POST . class ) ) { httpMethods . add ( HttpMethod . POST ) ; } if ( method . isAnnotationPresent ( DELETE . class ) ) { httpMethods . add ( HttpMethod . DELETE ) ; } return Collections . unmodifiableSet ( httpMethods ) ; }
Fetches the HttpMethod from annotations and returns String representation of HttpMethod . Return emptyString if not present .
163
25
149,648
public void handle ( HttpRequest request , HttpResponder responder ) { if ( urlRewriter != null ) { try { request . setUri ( URI . create ( request . uri ( ) ) . normalize ( ) . toString ( ) ) ; if ( ! urlRewriter . rewrite ( request , responder ) ) { return ; } } catch ( Throwable t ) { responder . sendString ( HttpResponseStatus . INTERNAL_SERVER_ERROR , String . format ( "Caught exception processing request. Reason: %s" , t . getMessage ( ) ) ) ; LOG . error ( "Exception thrown during rewriting of uri {}" , request . uri ( ) , t ) ; return ; } } try { String path = URI . create ( request . uri ( ) ) . normalize ( ) . getPath ( ) ; List < PatternPathRouterWithGroups . RoutableDestination < HttpResourceModel > > routableDestinations = patternRouter . getDestinations ( path ) ; PatternPathRouterWithGroups . RoutableDestination < HttpResourceModel > matchedDestination = getMatchedDestination ( routableDestinations , request . method ( ) , path ) ; if ( matchedDestination != null ) { //Found a httpresource route to it. HttpResourceModel httpResourceModel = matchedDestination . getDestination ( ) ; // Call preCall method of handler hooks. boolean terminated = false ; HandlerInfo info = new HandlerInfo ( httpResourceModel . getMethod ( ) . getDeclaringClass ( ) . getName ( ) , httpResourceModel . getMethod ( ) . getName ( ) ) ; for ( HandlerHook hook : handlerHooks ) { if ( ! hook . preCall ( request , responder , info ) ) { // Terminate further request processing if preCall returns false. terminated = true ; break ; } } // Call httpresource method if ( ! terminated ) { // Wrap responder to make post hook calls. responder = new WrappedHttpResponder ( responder , handlerHooks , request , info ) ; if ( httpResourceModel . handle ( request , responder , matchedDestination . getGroupNameValues ( ) ) . isStreaming ( ) ) { responder . sendString ( HttpResponseStatus . METHOD_NOT_ALLOWED , String . format ( "Body Consumer not supported for internalHttpResponder: %s" , request . uri ( ) ) ) ; } } } else if ( routableDestinations . size ( ) > 0 ) { //Found a matching resource but could not find the right HttpMethod so return 405 responder . sendString ( HttpResponseStatus . METHOD_NOT_ALLOWED , String . format ( "Problem accessing: %s. Reason: Method Not Allowed" , request . uri ( ) ) ) ; } else { responder . sendString ( HttpResponseStatus . NOT_FOUND , String . format ( "Problem accessing: %s. Reason: Not Found" , request . uri ( ) ) ) ; } } catch ( Throwable t ) { responder . sendString ( HttpResponseStatus . INTERNAL_SERVER_ERROR , String . format ( "Caught exception processing request. Reason: %s" , t . getMessage ( ) ) ) ; LOG . error ( "Exception thrown during request processing for uri {}" , request . uri ( ) , t ) ; } }
Call the appropriate handler for handling the httprequest . 404 if path is not found . 405 if path is found but httpMethod does not match what s configured .
742
32
149,649
private PatternPathRouterWithGroups . RoutableDestination < HttpResourceModel > getMatchedDestination ( List < PatternPathRouterWithGroups . RoutableDestination < HttpResourceModel > > routableDestinations , HttpMethod targetHttpMethod , String requestUri ) { LOG . trace ( "Routable destinations for request {}: {}" , requestUri , routableDestinations ) ; Iterable < String > requestUriParts = splitAndOmitEmpty ( requestUri , ' ' ) ; List < PatternPathRouterWithGroups . RoutableDestination < HttpResourceModel > > matchedDestinations = new ArrayList <> ( ) ; long maxScore = 0 ; for ( PatternPathRouterWithGroups . RoutableDestination < HttpResourceModel > destination : routableDestinations ) { HttpResourceModel resourceModel = destination . getDestination ( ) ; for ( HttpMethod httpMethod : resourceModel . getHttpMethod ( ) ) { if ( targetHttpMethod . equals ( httpMethod ) ) { long score = getWeightedMatchScore ( requestUriParts , splitAndOmitEmpty ( resourceModel . getPath ( ) , ' ' ) ) ; LOG . trace ( "Max score = {}. Weighted score for {} is {}. " , maxScore , destination , score ) ; if ( score > maxScore ) { maxScore = score ; matchedDestinations . clear ( ) ; matchedDestinations . add ( destination ) ; } else if ( score == maxScore ) { matchedDestinations . add ( destination ) ; } } } } if ( matchedDestinations . size ( ) > 1 ) { throw new IllegalStateException ( String . format ( "Multiple matched handlers found for request uri %s: %s" , requestUri , matchedDestinations ) ) ; } else if ( matchedDestinations . size ( ) == 1 ) { return matchedDestinations . get ( 0 ) ; } return null ; }
Get HttpResourceModel which matches the HttpMethod of the request .
420
15
149,650
private long getWeightedMatchScore ( Iterable < String > requestUriParts , Iterable < String > destUriParts ) { // The score calculated below is a base 5 number // The score will have one digit for one part of the URI // This will allow for 27 parts in the path since log (Long.MAX_VALUE) to base 5 = 27.13 // We limit the number of parts in the path to 25 using MAX_PATH_PARTS constant above to avoid overflow during // score calculation long score = 0 ; for ( Iterator < String > rit = requestUriParts . iterator ( ) , dit = destUriParts . iterator ( ) ; rit . hasNext ( ) && dit . hasNext ( ) ; ) { String requestPart = rit . next ( ) ; String destPart = dit . next ( ) ; if ( requestPart . equals ( destPart ) ) { score = ( score * 5 ) + 4 ; } else if ( PatternPathRouterWithGroups . GROUP_PATTERN . matcher ( destPart ) . matches ( ) ) { score = ( score * 5 ) + 3 ; } else { score = ( score * 5 ) + 2 ; } } return score ; }
Generate a weighted score based on position for matches of URI parts . The matches are weighted in descending order from left to right . Exact match is weighted higher than group match and group match is weighted higher than wildcard match .
263
46
149,651
private static Iterable < String > splitAndOmitEmpty ( final String str , final char splitChar ) { return new Iterable < String > ( ) { @ Override public Iterator < String > iterator ( ) { return new Iterator < String > ( ) { int startIdx = 0 ; String next = null ; @ Override public boolean hasNext ( ) { while ( next == null && startIdx < str . length ( ) ) { int idx = str . indexOf ( splitChar , startIdx ) ; if ( idx == startIdx ) { // Omit empty string startIdx ++ ; continue ; } if ( idx >= 0 ) { // Found the next part next = str . substring ( startIdx , idx ) ; startIdx = idx ; } else { // The last part if ( startIdx < str . length ( ) ) { next = str . substring ( startIdx ) ; startIdx = str . length ( ) ; } break ; } } return next != null ; } @ Override public String next ( ) { if ( hasNext ( ) ) { String next = this . next ; this . next = null ; return next ; } throw new NoSuchElementException ( "No more element" ) ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( "Remove not supported" ) ; } } ; } } ; }
Helper method to split a string by a given character with empty parts omitted .
302
15
149,652
@ Nullable private static Converter < List < String > , Object > createPrimitiveTypeConverter ( final Class < ? > resultClass ) { Object defaultValue = defaultValue ( resultClass ) ; if ( defaultValue == null ) { // For primitive type, the default value shouldn't be null return null ; } return new BasicConverter ( defaultValue ) { @ Override protected Object convert ( String value ) throws Exception { return valueOf ( value , resultClass ) ; } } ; }
Creates a converter function that converts value into primitive type .
105
12
149,653
private static Converter < List < String > , Object > createStringConstructorConverter ( Class < ? > resultClass ) { try { final Constructor < ? > constructor = resultClass . getConstructor ( String . class ) ; return new BasicConverter ( defaultValue ( resultClass ) ) { @ Override protected Object convert ( String value ) throws Exception { return constructor . newInstance ( value ) ; } } ; } catch ( Exception e ) { return null ; } }
Creates a converter function that converts value using a constructor that accepts a single String argument .
102
18
149,654
@ Nullable private static Object valueOf ( String value , Class < ? > cls ) { if ( cls == Boolean . TYPE ) { return Boolean . valueOf ( value ) ; } if ( cls == Character . TYPE ) { return value . length ( ) >= 1 ? value . charAt ( 0 ) : defaultValue ( char . class ) ; } if ( cls == Byte . TYPE ) { return Byte . valueOf ( value ) ; } if ( cls == Short . TYPE ) { return Short . valueOf ( value ) ; } if ( cls == Integer . TYPE ) { return Integer . valueOf ( value ) ; } if ( cls == Long . TYPE ) { return Long . valueOf ( value ) ; } if ( cls == Float . TYPE ) { return Float . valueOf ( value ) ; } if ( cls == Double . TYPE ) { return Double . valueOf ( value ) ; } return null ; }
Returns the value of the primitive type from the given string value .
200
13
149,655
private static Class < ? > getRawClass ( Type type ) { if ( type instanceof Class ) { return ( Class < ? > ) type ; } if ( type instanceof ParameterizedType ) { return getRawClass ( ( ( ParameterizedType ) type ) . getRawType ( ) ) ; } // For TypeVariable and WildcardType, returns the first upper bound. if ( type instanceof TypeVariable ) { return getRawClass ( ( ( TypeVariable ) type ) . getBounds ( ) [ 0 ] ) ; } if ( type instanceof WildcardType ) { return getRawClass ( ( ( WildcardType ) type ) . getUpperBounds ( ) [ 0 ] ) ; } if ( type instanceof GenericArrayType ) { Class < ? > componentClass = getRawClass ( ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ) ; return Array . newInstance ( componentClass , 0 ) . getClass ( ) ; } // This shouldn't happen as we captured all implementations of Type above (as or Java 8) throw new IllegalArgumentException ( "Unsupported type " + type + " of type class " + type . getClass ( ) ) ; }
Returns the raw class of the given type .
256
9
149,656
void invoke ( HttpRequest request ) throws Exception { bodyConsumer = null ; Object invokeResult ; try { args [ 0 ] = this . request = request ; invokeResult = method . invoke ( handler , args ) ; } catch ( InvocationTargetException e ) { exceptionHandler . handle ( e . getTargetException ( ) , request , responder ) ; return ; } catch ( Throwable t ) { exceptionHandler . handle ( t , request , responder ) ; return ; } if ( isStreaming ) { // Casting guarantee to be succeeded. bodyConsumer = ( BodyConsumer ) invokeResult ; } }
Calls the httpHandler method .
126
7
149,657
void sendError ( HttpResponseStatus status , Throwable ex ) { String msg ; if ( ex instanceof InvocationTargetException ) { msg = String . format ( "Exception Encountered while processing request : %s" , ex . getCause ( ) . getMessage ( ) ) ; } else { msg = String . format ( "Exception Encountered while processing request: %s" , ex . getMessage ( ) ) ; } // Send the status and message, followed by closing of the connection. responder . sendString ( status , msg , new DefaultHttpHeaders ( ) . set ( HttpHeaderNames . CONNECTION , HttpHeaderValues . CLOSE ) ) ; if ( bodyConsumer != null ) { bodyConsumerError ( ex ) ; } }
Sends the error to responder .
162
8
149,658
public void add ( final String source , final T destination ) { // replace multiple slashes with a single slash. String path = source . replaceAll ( "/+" , "/" ) ; path = ( path . endsWith ( "/" ) && path . length ( ) > 1 ) ? path . substring ( 0 , path . length ( ) - 1 ) : path ; String [ ] parts = path . split ( "/" , maxPathParts + 2 ) ; if ( parts . length - 1 > maxPathParts ) { throw new IllegalArgumentException ( String . format ( "Number of parts of path %s exceeds allowed limit %s" , source , maxPathParts ) ) ; } StringBuilder sb = new StringBuilder ( ) ; List < String > groupNames = new ArrayList <> ( ) ; for ( String part : parts ) { Matcher groupMatcher = GROUP_PATTERN . matcher ( part ) ; if ( groupMatcher . matches ( ) ) { groupNames . add ( groupMatcher . group ( 1 ) ) ; sb . append ( "([^/]+?)" ) ; } else if ( WILD_CARD_PATTERN . matcher ( part ) . matches ( ) ) { sb . append ( ".*?" ) ; } else { sb . append ( part ) ; } sb . append ( "/" ) ; } //Ignore the last "/" sb . setLength ( sb . length ( ) - 1 ) ; Pattern pattern = Pattern . compile ( sb . toString ( ) ) ; patternRouteList . add ( ImmutablePair . of ( pattern , new RouteDestinationWithGroups ( destination , groupNames ) ) ) ; }
Add a source and destination .
365
6
149,659
public List < RoutableDestination < T > > getDestinations ( String path ) { String cleanPath = ( path . endsWith ( "/" ) && path . length ( ) > 1 ) ? path . substring ( 0 , path . length ( ) - 1 ) : path ; List < RoutableDestination < T > > result = new ArrayList <> ( ) ; for ( ImmutablePair < Pattern , RouteDestinationWithGroups > patternRoute : patternRouteList ) { Map < String , String > groupNameValuesBuilder = new HashMap <> ( ) ; Matcher matcher = patternRoute . getFirst ( ) . matcher ( cleanPath ) ; if ( matcher . matches ( ) ) { int matchIndex = 1 ; for ( String name : patternRoute . getSecond ( ) . getGroupNames ( ) ) { String value = matcher . group ( matchIndex ) ; groupNameValuesBuilder . put ( name , value ) ; matchIndex ++ ; } result . add ( new RoutableDestination <> ( patternRoute . getSecond ( ) . getDestination ( ) , groupNameValuesBuilder ) ) ; } } return result ; }
Get a list of destinations and the values matching templated parameter for the given path . Returns an empty list when there are no destinations that are matched .
247
31
149,660
public synchronized void start ( ) throws Exception { if ( state == State . RUNNING ) { LOG . debug ( "Ignore start() call on HTTP service {} since it has already been started." , serviceName ) ; return ; } if ( state != State . NOT_STARTED ) { if ( state == State . STOPPED ) { throw new IllegalStateException ( "Cannot start the HTTP service " + serviceName + " again since it has been stopped" ) ; } throw new IllegalStateException ( "Cannot start the HTTP service " + serviceName + " because it was failed earlier" ) ; } try { LOG . info ( "Starting HTTP Service {} at address {}" , serviceName , bindAddress ) ; channelGroup = new DefaultChannelGroup ( ImmediateEventExecutor . INSTANCE ) ; resourceHandler . init ( handlerContext ) ; eventExecutorGroup = createEventExecutorGroup ( execThreadPoolSize ) ; bootstrap = createBootstrap ( channelGroup ) ; Channel serverChannel = bootstrap . bind ( bindAddress ) . sync ( ) . channel ( ) ; channelGroup . add ( serverChannel ) ; bindAddress = ( InetSocketAddress ) serverChannel . localAddress ( ) ; LOG . debug ( "Started HTTP Service {} at address {}" , serviceName , bindAddress ) ; state = State . RUNNING ; } catch ( Throwable t ) { // Release resources if there is any failure channelGroup . close ( ) . awaitUninterruptibly ( ) ; try { if ( bootstrap != null ) { shutdownExecutorGroups ( 0 , 5 , TimeUnit . SECONDS , bootstrap . config ( ) . group ( ) , bootstrap . config ( ) . childGroup ( ) , eventExecutorGroup ) ; } else { shutdownExecutorGroups ( 0 , 5 , TimeUnit . SECONDS , eventExecutorGroup ) ; } } catch ( Throwable t2 ) { t . addSuppressed ( t2 ) ; } state = State . FAILED ; throw t ; } }
Starts the HTTP service .
430
6
149,661
public synchronized void stop ( long quietPeriod , long timeout , TimeUnit unit ) throws Exception { if ( state == State . STOPPED ) { LOG . debug ( "Ignore stop() call on HTTP service {} since it has already been stopped." , serviceName ) ; return ; } LOG . info ( "Stopping HTTP Service {}" , serviceName ) ; try { try { channelGroup . close ( ) . awaitUninterruptibly ( ) ; } finally { try { shutdownExecutorGroups ( quietPeriod , timeout , unit , bootstrap . config ( ) . group ( ) , bootstrap . config ( ) . childGroup ( ) , eventExecutorGroup ) ; } finally { resourceHandler . destroy ( handlerContext ) ; } } } catch ( Throwable t ) { state = State . FAILED ; throw t ; } state = State . STOPPED ; LOG . debug ( "Stopped HTTP Service {} on address {}" , serviceName , bindAddress ) ; }
Stops the HTTP service gracefully and release all resources .
208
12
149,662
private ServerBootstrap createBootstrap ( final ChannelGroup channelGroup ) throws Exception { EventLoopGroup bossGroup = new NioEventLoopGroup ( bossThreadPoolSize , createDaemonThreadFactory ( serviceName + "-boss-thread-%d" ) ) ; EventLoopGroup workerGroup = new NioEventLoopGroup ( workerThreadPoolSize , createDaemonThreadFactory ( serviceName + "-worker-thread-%d" ) ) ; ServerBootstrap bootstrap = new ServerBootstrap ( ) ; bootstrap . group ( bossGroup , workerGroup ) . channel ( NioServerSocketChannel . class ) . childHandler ( new ChannelInitializer < SocketChannel > ( ) { @ Override protected void initChannel ( SocketChannel ch ) throws Exception { channelGroup . add ( ch ) ; ChannelPipeline pipeline = ch . pipeline ( ) ; if ( sslHandlerFactory != null ) { // Add SSLHandler if SSL is enabled pipeline . addLast ( "ssl" , sslHandlerFactory . create ( ch . alloc ( ) ) ) ; } pipeline . addLast ( "codec" , new HttpServerCodec ( ) ) ; pipeline . addLast ( "compressor" , new HttpContentCompressor ( ) ) ; pipeline . addLast ( "chunkedWriter" , new ChunkedWriteHandler ( ) ) ; pipeline . addLast ( "keepAlive" , new HttpServerKeepAliveHandler ( ) ) ; pipeline . addLast ( "router" , new RequestRouter ( resourceHandler , httpChunkLimit , sslHandlerFactory != null ) ) ; if ( eventExecutorGroup == null ) { pipeline . addLast ( "dispatcher" , new HttpDispatcher ( ) ) ; } else { pipeline . addLast ( eventExecutorGroup , "dispatcher" , new HttpDispatcher ( ) ) ; } if ( pipelineModifier != null ) { pipelineModifier . modify ( pipeline ) ; } } } ) ; for ( Map . Entry < ChannelOption , Object > entry : channelConfigs . entrySet ( ) ) { bootstrap . option ( entry . getKey ( ) , entry . getValue ( ) ) ; } for ( Map . Entry < ChannelOption , Object > entry : childChannelConfigs . entrySet ( ) ) { bootstrap . childOption ( entry . getKey ( ) , entry . getValue ( ) ) ; } return bootstrap ; }
Creates the server bootstrap .
517
7
149,663
@ Override public void channelRead ( ChannelHandlerContext ctx , Object msg ) throws Exception { try { if ( exceptionRaised . get ( ) ) { return ; } if ( ! ( msg instanceof HttpRequest ) ) { // If there is no methodInfo, it means the request was already rejected. // What we received here is just residue of the request, which can be ignored. if ( methodInfo != null ) { ReferenceCountUtil . retain ( msg ) ; ctx . fireChannelRead ( msg ) ; } return ; } HttpRequest request = ( HttpRequest ) msg ; BasicHttpResponder responder = new BasicHttpResponder ( ctx . channel ( ) , sslEnabled ) ; // Reset the methodInfo for the incoming request error handling methodInfo = null ; methodInfo = prepareHandleMethod ( request , responder , ctx ) ; if ( methodInfo != null ) { ReferenceCountUtil . retain ( msg ) ; ctx . fireChannelRead ( msg ) ; } else { if ( ! responder . isResponded ( ) ) { // If not yet responded, just respond with a not found and close the connection HttpResponse response = new DefaultFullHttpResponse ( HttpVersion . HTTP_1_1 , HttpResponseStatus . NOT_FOUND ) ; HttpUtil . setContentLength ( response , 0 ) ; HttpUtil . setKeepAlive ( response , false ) ; ctx . channel ( ) . writeAndFlush ( response ) . addListener ( ChannelFutureListener . CLOSE ) ; } else { // If already responded, just close the connection ctx . channel ( ) . close ( ) ; } } } finally { ReferenceCountUtil . release ( msg ) ; } }
If the HttpRequest is valid and handled it will be sent upstream if it cannot be invoked the response will be written back immediately .
371
27
149,664
@ SuppressWarnings ( "unchecked" ) public HttpMethodInfo handle ( HttpRequest request , HttpResponder responder , Map < String , String > groupValues ) throws Exception { //TODO: Refactor group values. try { if ( httpMethods . contains ( request . method ( ) ) ) { //Setup args for reflection call Object [ ] args = new Object [ paramsInfo . size ( ) ] ; int idx = 0 ; for ( Map < Class < ? extends Annotation > , ParameterInfo < ? > > info : paramsInfo ) { if ( info . containsKey ( PathParam . class ) ) { args [ idx ] = getPathParamValue ( info , groupValues ) ; } if ( info . containsKey ( QueryParam . class ) ) { args [ idx ] = getQueryParamValue ( info , request . uri ( ) ) ; } if ( info . containsKey ( HeaderParam . class ) ) { args [ idx ] = getHeaderParamValue ( info , request ) ; } idx ++ ; } return new HttpMethodInfo ( method , handler , responder , args , exceptionHandler ) ; } else { //Found a matching resource but could not find the right HttpMethod so return 405 throw new HandlerException ( HttpResponseStatus . METHOD_NOT_ALLOWED , String . format ( "Problem accessing: %s. Reason: Method Not Allowed" , request . uri ( ) ) ) ; } } catch ( Throwable e ) { throw new HandlerException ( HttpResponseStatus . INTERNAL_SERVER_ERROR , String . format ( "Error in executing request: %s %s" , request . method ( ) , request . uri ( ) ) , e ) ; } }
Handle http Request .
377
4
149,665
private List < Map < Class < ? extends Annotation > , ParameterInfo < ? > > > createParametersInfos ( Method method ) { if ( method . getParameterTypes ( ) . length <= 2 ) { return Collections . emptyList ( ) ; } List < Map < Class < ? extends Annotation > , ParameterInfo < ? > > > result = new ArrayList <> ( ) ; Type [ ] parameterTypes = method . getGenericParameterTypes ( ) ; Annotation [ ] [ ] parameterAnnotations = method . getParameterAnnotations ( ) ; for ( int i = 2 ; i < parameterAnnotations . length ; i ++ ) { Annotation [ ] annotations = parameterAnnotations [ i ] ; Map < Class < ? extends Annotation > , ParameterInfo < ? > > paramAnnotations = new IdentityHashMap <> ( ) ; for ( Annotation annotation : annotations ) { Class < ? extends Annotation > annotationType = annotation . annotationType ( ) ; ParameterInfo < ? > parameterInfo ; if ( PathParam . class . isAssignableFrom ( annotationType ) ) { parameterInfo = ParameterInfo . create ( annotation , ParamConvertUtils . createPathParamConverter ( parameterTypes [ i ] ) ) ; } else if ( QueryParam . class . isAssignableFrom ( annotationType ) ) { parameterInfo = ParameterInfo . create ( annotation , ParamConvertUtils . createQueryParamConverter ( parameterTypes [ i ] ) ) ; } else if ( HeaderParam . class . isAssignableFrom ( annotationType ) ) { parameterInfo = ParameterInfo . create ( annotation , ParamConvertUtils . createHeaderParamConverter ( parameterTypes [ i ] ) ) ; } else { parameterInfo = ParameterInfo . create ( annotation , null ) ; } paramAnnotations . put ( annotationType , parameterInfo ) ; } // Must have either @PathParam, @QueryParam or @HeaderParam, but not two or more. int presence = 0 ; for ( Class < ? extends Annotation > annotationClass : paramAnnotations . keySet ( ) ) { if ( SUPPORTED_PARAM_ANNOTATIONS . contains ( annotationClass ) ) { presence ++ ; } } if ( presence != 1 ) { throw new IllegalArgumentException ( String . format ( "Must have exactly one annotation from %s for parameter %d in method %s" , SUPPORTED_PARAM_ANNOTATIONS , i , method ) ) ; } result . add ( Collections . unmodifiableMap ( paramAnnotations ) ) ; } return Collections . unmodifiableList ( result ) ; }
Gathers all parameters annotations for the given method starting from the third parameter .
558
16
149,666
public static < T > ServiceFuture < T > fromResponse ( final Observable < ServiceResponse < T > > observable ) { final ServiceFuture < T > serviceFuture = new ServiceFuture <> ( ) ; serviceFuture . subscription = observable . last ( ) . subscribe ( new Action1 < ServiceResponse < T > > ( ) { @ Override public void call ( ServiceResponse < T > t ) { serviceFuture . set ( t . body ( ) ) ; } } , new Action1 < Throwable > ( ) { @ Override public void call ( Throwable throwable ) { serviceFuture . setException ( throwable ) ; } } ) ; return serviceFuture ; }
Creates a ServiceCall from an observable object .
141
10
149,667
public static < T > ServiceFuture < T > fromResponse ( final Observable < ServiceResponse < T > > observable , final ServiceCallback < T > callback ) { final ServiceFuture < T > serviceFuture = new ServiceFuture <> ( ) ; serviceFuture . subscription = observable . last ( ) . subscribe ( new Action1 < ServiceResponse < T > > ( ) { @ Override public void call ( ServiceResponse < T > t ) { if ( callback != null ) { callback . success ( t . body ( ) ) ; } serviceFuture . set ( t . body ( ) ) ; } } , new Action1 < Throwable > ( ) { @ Override public void call ( Throwable throwable ) { if ( callback != null ) { callback . failure ( throwable ) ; } serviceFuture . setException ( throwable ) ; } } ) ; return serviceFuture ; }
Creates a ServiceCall from an observable object and a callback .
184
13
149,668
public static ServiceFuture < Void > fromBody ( final Completable completable , final ServiceCallback < Void > callback ) { final ServiceFuture < Void > serviceFuture = new ServiceFuture <> ( ) ; completable . subscribe ( new Action0 ( ) { Void value = null ; @ Override public void call ( ) { if ( callback != null ) { callback . success ( value ) ; } serviceFuture . set ( value ) ; } } , new Action1 < Throwable > ( ) { @ Override public void call ( Throwable throwable ) { if ( callback != null ) { callback . failure ( throwable ) ; } serviceFuture . setException ( throwable ) ; } } ) ; return serviceFuture ; }
Creates a ServiceFuture from an Completable object and a callback .
152
15
149,669
protected void cacheCollection ( ) { this . clear ( ) ; for ( FluentModelTImpl childResource : this . listChildResources ( ) ) { this . childCollection . put ( childResource . childResourceKey ( ) , childResource ) ; } }
Initializes the external child resource collection .
54
8
149,670
public void addDependencyGraph ( DAGraph < DataT , NodeT > dependencyGraph ) { this . rootNode . addDependency ( dependencyGraph . rootNode . key ( ) ) ; Map < String , NodeT > sourceNodeTable = dependencyGraph . nodeTable ; Map < String , NodeT > targetNodeTable = this . nodeTable ; this . merge ( sourceNodeTable , targetNodeTable ) ; dependencyGraph . parentDAGs . add ( this ) ; if ( this . hasParents ( ) ) { this . bubbleUpNodeTable ( this , new LinkedList < String > ( ) ) ; } }
Mark root of this DAG depends on given DAG s root .
134
14
149,671
public void prepareForEnumeration ( ) { if ( isPreparer ( ) ) { for ( NodeT node : nodeTable . values ( ) ) { // Prepare each node for traversal node . initialize ( ) ; if ( ! this . isRootNode ( node ) ) { // Mark other sub-DAGs as non-preparer node . setPreparer ( false ) ; } } initializeDependentKeys ( ) ; initializeQueue ( ) ; } }
Prepares this DAG for node enumeration using getNext method each call to getNext returns next node in the DAG with no dependencies .
97
29
149,672
public NodeT getNext ( ) { String nextItemKey = queue . poll ( ) ; if ( nextItemKey == null ) { return null ; } return nodeTable . get ( nextItemKey ) ; }
Gets next node in the DAG which has no dependency or all of it s dependencies are resolved and ready to be consumed .
44
26
149,673
public void reportCompletion ( NodeT completed ) { completed . setPreparer ( true ) ; String dependency = completed . key ( ) ; for ( String dependentKey : nodeTable . get ( dependency ) . dependentKeys ( ) ) { DAGNode < DataT , NodeT > dependent = nodeTable . get ( dependentKey ) ; dependent . lock ( ) . lock ( ) ; try { dependent . onSuccessfulResolution ( dependency ) ; if ( dependent . hasAllResolved ( ) ) { queue . add ( dependent . key ( ) ) ; } } finally { dependent . lock ( ) . unlock ( ) ; } } }
Reports that a node is resolved hence other nodes depends on it can consume it .
133
16
149,674
public void reportError ( NodeT faulted , Throwable throwable ) { faulted . setPreparer ( true ) ; String dependency = faulted . key ( ) ; for ( String dependentKey : nodeTable . get ( dependency ) . dependentKeys ( ) ) { DAGNode < DataT , NodeT > dependent = nodeTable . get ( dependentKey ) ; dependent . lock ( ) . lock ( ) ; try { dependent . onFaultedResolution ( dependency , throwable ) ; if ( dependent . hasAllResolved ( ) ) { queue . add ( dependent . key ( ) ) ; } } finally { dependent . lock ( ) . unlock ( ) ; } } }
Reports that a node is faulted .
144
8
149,675
private void initializeQueue ( ) { this . queue . clear ( ) ; for ( Map . Entry < String , NodeT > entry : nodeTable . entrySet ( ) ) { if ( ! entry . getValue ( ) . hasDependencies ( ) ) { this . queue . add ( entry . getKey ( ) ) ; } } if ( queue . isEmpty ( ) ) { throw new IllegalStateException ( "Detected circular dependency" ) ; } }
Initializes the queue that tracks the next set of nodes with no dependencies or whose dependencies are resolved .
97
20
149,676
private void merge ( Map < String , NodeT > source , Map < String , NodeT > target ) { for ( Map . Entry < String , NodeT > entry : source . entrySet ( ) ) { String key = entry . getKey ( ) ; if ( ! target . containsKey ( key ) ) { target . put ( key , entry . getValue ( ) ) ; } } }
Copies entries in the source map to target map .
83
11
149,677
private void bubbleUpNodeTable ( DAGraph < DataT , NodeT > from , LinkedList < String > path ) { if ( path . contains ( from . rootNode . key ( ) ) ) { path . push ( from . rootNode . key ( ) ) ; // For better error message throw new IllegalStateException ( "Detected circular dependency: " + StringUtils . join ( path , " -> " ) ) ; } path . push ( from . rootNode . key ( ) ) ; for ( DAGraph < DataT , NodeT > to : from . parentDAGs ) { this . merge ( from . nodeTable , to . nodeTable ) ; this . bubbleUpNodeTable ( to , path ) ; } path . pop ( ) ; }
Propagates node table of given DAG to all of it ancestors .
164
15
149,678
public static IndexableTaskItem create ( final FunctionalTaskItem taskItem ) { return new IndexableTaskItem ( ) { @ Override protected Observable < Indexable > invokeTaskAsync ( TaskGroup . InvocationContext context ) { FunctionalTaskItem . Context fContext = new FunctionalTaskItem . Context ( this ) ; fContext . setInnerContext ( context ) ; return taskItem . call ( fContext ) ; } } ; }
Creates an IndexableTaskItem from provided FunctionalTaskItem .
91
13
149,679
@ SuppressWarnings ( "unchecked" ) protected String addeDependency ( Appliable < ? extends Indexable > appliable ) { TaskGroup . HasTaskGroup dependency = ( TaskGroup . HasTaskGroup ) appliable ; return this . addDependency ( dependency ) ; }
Add an appliable dependency for this task item .
63
10
149,680
public String addPostRunDependent ( FunctionalTaskItem dependent ) { Objects . requireNonNull ( dependent ) ; return this . taskGroup ( ) . addPostRunDependent ( dependent ) ; }
Add a post - run dependent task item for this task item .
41
13
149,681
@ SuppressWarnings ( "unchecked" ) protected String addPostRunDependent ( Creatable < ? extends Indexable > creatable ) { TaskGroup . HasTaskGroup dependency = ( TaskGroup . HasTaskGroup ) creatable ; return this . addPostRunDependent ( dependency ) ; }
Add a creatable post - run dependent for this task item .
64
13
149,682
@ SuppressWarnings ( "unchecked" ) protected String addPostRunDependent ( Appliable < ? extends Indexable > appliable ) { TaskGroup . HasTaskGroup dependency = ( TaskGroup . HasTaskGroup ) appliable ; return this . addPostRunDependent ( dependency ) ; }
Add an appliable post - run dependent for this task item .
64
13
149,683
@ SuppressWarnings ( "unchecked" ) protected < T extends Indexable > T taskResult ( String key ) { Indexable result = this . taskGroup . taskResult ( key ) ; if ( result == null ) { return null ; } else { T castedResult = ( T ) result ; return castedResult ; } }
Get result of one of the task that belongs to this task s task group .
72
16
149,684
public static Region create ( String name , String label ) { Region region = VALUES_BY_NAME . get ( name . toLowerCase ( ) ) ; if ( region != null ) { return region ; } else { return new Region ( name , label ) ; } }
Creates a region from a name and a label .
57
11
149,685
public static Region fromName ( String name ) { if ( name == null ) { return null ; } Region region = VALUES_BY_NAME . get ( name . toLowerCase ( ) . replace ( " " , "" ) ) ; if ( region != null ) { return region ; } else { return Region . create ( name . toLowerCase ( ) . replace ( " " , "" ) , name ) ; } }
Parses a name into a Region object and creates a new Region instance if not found among the existing ones .
89
23
149,686
protected FluentModelTImpl prepareForFutureCommitOrPostRun ( FluentModelTImpl childResource ) { if ( this . isPostRunMode ) { if ( ! childResource . taskGroup ( ) . dependsOn ( this . parentTaskGroup ) ) { this . parentTaskGroup . addPostRunDependentTaskGroup ( childResource . taskGroup ( ) ) ; } return childResource ; } else { return childResource ; } }
Mark the given child resource as the post run dependent of the parent of this collection .
93
17
149,687
protected FluentModelTImpl find ( String key ) { for ( Map . Entry < String , FluentModelTImpl > entry : this . childCollection . entrySet ( ) ) { if ( entry . getKey ( ) . equalsIgnoreCase ( key ) ) { return entry . getValue ( ) ; } } return null ; }
Finds a child resource with the given key .
71
10
149,688
public static < E > ServiceFuture < List < E > > fromPageResponse ( Observable < ServiceResponse < Page < E > > > first , final Func1 < String , Observable < ServiceResponse < Page < E > > > > next , final ListOperationCallback < E > callback ) { final AzureServiceFuture < List < E > > serviceCall = new AzureServiceFuture <> ( ) ; final PagingSubscriber < E > subscriber = new PagingSubscriber <> ( serviceCall , next , callback ) ; serviceCall . setSubscription ( first . single ( ) . subscribe ( subscriber ) ) ; return serviceCall ; }
Creates a ServiceCall from a paging operation .
137
11
149,689
public static < E , V > ServiceFuture < List < E > > fromHeaderPageResponse ( Observable < ServiceResponseWithHeaders < Page < E > , V > > first , final Func1 < String , Observable < ServiceResponseWithHeaders < Page < E > , V > > > next , final ListOperationCallback < E > callback ) { final AzureServiceFuture < List < E > > serviceCall = new AzureServiceFuture <> ( ) ; final PagingSubscriber < E > subscriber = new PagingSubscriber <> ( serviceCall , new Func1 < String , Observable < ServiceResponse < Page < E > > > > ( ) { @ Override public Observable < ServiceResponse < Page < E > > > call ( String s ) { return next . call ( s ) . map ( new Func1 < ServiceResponseWithHeaders < Page < E > , V > , ServiceResponse < Page < E > > > ( ) { @ Override public ServiceResponse < Page < E > > call ( ServiceResponseWithHeaders < Page < E > , V > pageVServiceResponseWithHeaders ) { return pageVServiceResponseWithHeaders ; } } ) ; } } , callback ) ; serviceCall . setSubscription ( first . single ( ) . subscribe ( subscriber ) ) ; return serviceCall ; }
Creates a ServiceCall from a paging operation that returns a header response .
286
16
149,690
private static JsonNode findNestedNode ( JsonNode jsonNode , String composedKey ) { String [ ] jsonNodeKeys = splitKeyByFlatteningDots ( composedKey ) ; for ( String jsonNodeKey : jsonNodeKeys ) { jsonNode = jsonNode . get ( unescapeEscapedDots ( jsonNodeKey ) ) ; if ( jsonNode == null ) { return null ; } } return jsonNode ; }
Given a json node find a nested node using given composed key .
92
13
149,691
private static JsonParser newJsonParserForNode ( JsonNode jsonNode ) throws IOException { JsonParser parser = new JsonFactory ( ) . createParser ( jsonNode . toString ( ) ) ; parser . nextToken ( ) ; return parser ; }
Create a JsonParser for a given json node .
57
11
149,692
protected String addDependency ( FunctionalTaskItem dependency ) { Objects . requireNonNull ( dependency ) ; return this . taskGroup ( ) . addDependency ( dependency ) ; }
Add a dependency task item for this model .
39
9
149,693
protected String addDependency ( TaskGroup . HasTaskGroup dependency ) { Objects . requireNonNull ( dependency ) ; this . taskGroup ( ) . addDependencyTaskGroup ( dependency . taskGroup ( ) ) ; return dependency . taskGroup ( ) . key ( ) ; }
Add a dependency task group for this model .
60
9
149,694
@ SuppressWarnings ( "unchecked" ) protected void addPostRunDependent ( Executable < ? extends Indexable > executable ) { TaskGroup . HasTaskGroup dependency = ( TaskGroup . HasTaskGroup ) executable ; this . addPostRunDependent ( dependency ) ; }
Add an executable post - run dependent for this model .
61
11
149,695
public void addNode ( NodeT node ) { node . setOwner ( this ) ; nodeTable . put ( node . key ( ) , node ) ; }
Adds a node to this graph .
33
7
149,696
protected String findPath ( String start , String end ) { if ( start . equals ( end ) ) { return start ; } else { return findPath ( start , parent . get ( end ) ) + " -> " + end ; } }
Find the path .
50
4
149,697
public Map < String , ImplT > convertToUnmodifiableMap ( List < InnerT > innerList ) { Map < String , ImplT > result = new HashMap <> ( ) ; for ( InnerT inner : innerList ) { result . put ( name ( inner ) , impl ( inner ) ) ; } return Collections . unmodifiableMap ( result ) ; }
Converts the passed list of inners to unmodifiable map of impls .
79
17
149,698
public static String createOdataFilterForTags ( String tagName , String tagValue ) { if ( tagName == null ) { return null ; } else if ( tagValue == null ) { return String . format ( "tagname eq '%s'" , tagName ) ; } else { return String . format ( "tagname eq '%s' and tagvalue eq '%s'" , tagName , tagValue ) ; } }
Creates an Odata filter string that can be used for filtering list results by tags .
92
18
149,699
public static Observable < byte [ ] > downloadFileAsync ( String url , Retrofit retrofit ) { FileService service = retrofit . create ( FileService . class ) ; Observable < ResponseBody > response = service . download ( url ) ; return response . map ( new Func1 < ResponseBody , byte [ ] > ( ) { @ Override public byte [ ] call ( ResponseBody responseBody ) { try { return responseBody . bytes ( ) ; } catch ( IOException e ) { throw Exceptions . propagate ( e ) ; } } } ) ; }
Download a file asynchronously .
120
7