idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
1,400 | public Response intercept ( Chain chain ) throws IOException { final Request request = chain . request ( ) ; final Request . Builder builder = request . newBuilder ( ) . addHeader ( HEADER_NAME , contentType ) ; if ( request . body ( ) != null ) { rewriteBodyWithCustomContentType ( request , builder ) ; } final Request contentTypeRequest = builder . build ( ) ; return chain . proceed ( contentTypeRequest ) ; } | Method called by framework to enrich current request with the header information requested . |
1,401 | public CMAArray < CMASpaceMembership > fetchAll ( Map < String , String > query ) { throwIfEnvironmentIdIsSet ( ) ; return fetchAll ( spaceId , query ) ; } | Fetch all memberships of the configured space . |
1,402 | public CMASpaceMembership fetchOne ( String spaceId , String membershipId ) { assertNotNull ( spaceId , "spaceId" ) ; assertNotNull ( membershipId , "membershipId" ) ; return service . fetchOne ( spaceId , membershipId ) . blockingFirst ( ) ; } | Fetches one space membership by its id from Contentful . |
1,403 | public CMAArray < CMAUiExtension > fetchAll ( Map < String , String > query ) { return fetchAll ( spaceId , environmentId , query ) ; } | Fetch all ui extensions from the configured space by a query . |
1,404 | public CMAUiExtension update ( CMAUiExtension extension ) { assertNotNull ( extension , "extension" ) ; final Integer version = getVersionOrThrow ( extension , "update" ) ; final String id = getResourceIdOrThrow ( extension , "extension" ) ; final String spaceId = getSpaceIdOrThrow ( extension , "extension" ) ; assertNotNull ( extension . getEnvironmentId ( ) , "environmentId" ) ; final String environmentId = extension . getEnvironmentId ( ) ; final CMASystem system = extension . getSystem ( ) ; extension . setSystem ( null ) ; try { return service . update ( spaceId , environmentId , id , extension , version ) . blockingFirst ( ) ; } finally { extension . setSystem ( system ) ; } } | Update a ui extension . |
1,405 | public Integer delete ( CMAUiExtension extension ) { assertNotNull ( extension , "extension" ) ; final Integer version = getVersionOrThrow ( extension , "update" ) ; final String spaceId = getSpaceIdOrThrow ( extension , "extension" ) ; assertNotNull ( extension . getEnvironmentId ( ) , "environmentId" ) ; final String environmentId = extension . getEnvironmentId ( ) ; final String extensionId = getResourceIdOrThrow ( extension , "extension" ) ; final CMASystem system = extension . getSystem ( ) ; extension . setSystem ( null ) ; try { return service . delete ( spaceId , environmentId , extensionId , version ) . blockingFirst ( ) . code ( ) ; } finally { extension . setSystem ( system ) ; } } | Delete a ui extension . |
1,406 | public Integer delete ( CMAAsset asset ) { final String assetId = getResourceIdOrThrow ( asset , "asset" ) ; final String spaceId = getSpaceIdOrThrow ( asset , "asset" ) ; final String environmentId = asset . getEnvironmentId ( ) ; return service . delete ( spaceId , environmentId , assetId ) . blockingFirst ( ) . code ( ) ; } | Delete an Asset . |
1,407 | public Integer process ( CMAAsset asset , String locale ) { assertNotNull ( asset , "asset" ) ; final String assetId = getResourceIdOrThrow ( asset , "asset" ) ; final String spaceId = getSpaceIdOrThrow ( asset , "asset" ) ; final String environmentId = asset . getEnvironmentId ( ) ; return service . process ( spaceId , environmentId , assetId , locale ) . blockingFirst ( ) . code ( ) ; } | Process an Asset . |
1,408 | public CMAAsset publish ( CMAAsset asset ) { assertNotNull ( asset , "asset" ) ; final String assetId = getResourceIdOrThrow ( asset , "asset" ) ; final String spaceId = getSpaceIdOrThrow ( asset , "asset" ) ; final String environmentId = asset . getEnvironmentId ( ) ; return service . publish ( asset . getSystem ( ) . getVersion ( ) , spaceId , environmentId , assetId ) . blockingFirst ( ) ; } | Publish an Asset . |
1,409 | public CMAAsset unPublish ( CMAAsset asset ) { assertNotNull ( asset , "asset" ) ; final String assetId = getResourceIdOrThrow ( asset , "asset" ) ; final String spaceId = getSpaceIdOrThrow ( asset , "asset" ) ; final String environmentId = asset . getEnvironmentId ( ) ; return service . unPublish ( spaceId , environmentId , assetId ) . blockingFirst ( ) ; } | Un - Publish an Asset . |
1,410 | public CMAAsset update ( CMAAsset asset ) { assertNotNull ( asset , "asset" ) ; final String assetId = getResourceIdOrThrow ( asset , "asset" ) ; final String spaceId = getSpaceIdOrThrow ( asset , "asset" ) ; final String environmentId = asset . getEnvironmentId ( ) ; final Integer version = getVersionOrThrow ( asset , "update" ) ; final CMASystem sys = asset . getSystem ( ) ; asset . setSystem ( null ) ; try { return service . update ( version , spaceId , environmentId , assetId , asset ) . blockingFirst ( ) ; } finally { asset . setSystem ( sys ) ; } } | Update an Asset . |
1,411 | @ SuppressWarnings ( "unchecked" ) public < T extends CMAResource > T setSystem ( CMASystem system ) { this . system = system ; return ( T ) this ; } | Sets the system field . |
1,412 | @ SuppressWarnings ( "unchecked" ) public < T extends CMAResource > T setId ( String id ) { getSystem ( ) . setId ( id ) ; return ( T ) this ; } | Sets the ID for this CMAResource . |
1,413 | @ SuppressWarnings ( "unchecked" ) public < T extends CMAResource > T setVersion ( Integer version ) { getSystem ( ) . setVersion ( version ) ; return ( T ) this ; } | Convenience method for setting a version . |
1,414 | @ SuppressWarnings ( "unchecked" ) public < T extends CMAResource > T setSpaceId ( String spaceId ) { if ( getSystem ( ) . getSpace ( ) == null ) { getSystem ( ) . space = new CMALink ( CMAType . Space ) ; } getSystem ( ) . space . setId ( spaceId ) ; return ( T ) this ; } | Convenience method for setting a space id . |
1,415 | public Integer delete ( CMAContentType contentType ) { final String spaceId = getSpaceIdOrThrow ( contentType , "contentType" ) ; final String environmentId = contentType . getEnvironmentId ( ) ; final String contentTypeId = getResourceIdOrThrow ( contentType , "contentType" ) ; return service . delete ( spaceId , environmentId , contentTypeId ) . blockingFirst ( ) . code ( ) ; } | Delete a Content Type . |
1,416 | public CMAArray < CMAContentType > fetchAll ( String spaceId , String environmentId , Map < String , String > query ) { assertNotNull ( spaceId , "spaceId" ) ; DefaultQueryParameter . putIfNotSet ( query , DefaultQueryParameter . FETCH ) ; return service . fetchAll ( spaceId , environmentId , query ) . blockingFirst ( ) ; } | Fetch all Content Types from a Space with query parameters . |
1,417 | public CMAContentType publish ( CMAContentType contentType ) { assertNotNull ( contentType , "contentType" ) ; final String contentTypeId = getResourceIdOrThrow ( contentType , "contentType" ) ; final String spaceId = getSpaceIdOrThrow ( contentType , "contentType" ) ; final String environmentId = contentType . getEnvironmentId ( ) ; return service . publish ( contentType . getVersion ( ) , spaceId , environmentId , contentTypeId ) . blockingFirst ( ) ; } | Publish a Content Type . |
1,418 | public CMAContentType update ( CMAContentType contentType ) { assertNotNull ( contentType , "contentType" ) ; assertNotNull ( contentType . getName ( ) , "contentType.name" ) ; final String contentTypeId = getResourceIdOrThrow ( contentType , "contentType" ) ; final String spaceId = getSpaceIdOrThrow ( contentType , "contentType" ) ; final String environmentId = contentType . getEnvironmentId ( ) ; final Integer version = getVersionOrThrow ( contentType , "update" ) ; final CMASystem system = contentType . getSystem ( ) ; contentType . setSystem ( null ) ; try { return service . update ( version , spaceId , environmentId , contentTypeId , contentType ) . blockingFirst ( ) ; } finally { contentType . setSystem ( system ) ; } } | Update a Content Type . |
1,419 | public CMAArray < CMASnapshot > fetchAllSnapshots ( CMAContentType contentType ) { assertNotNull ( contentType , "contentType" ) ; final String contentTypeId = getResourceIdOrThrow ( contentType , "contentType" ) ; final String spaceId = getSpaceIdOrThrow ( contentType , "contentType" ) ; final String environmentId = contentType . getEnvironmentId ( ) ; return service . fetchAllSnapshots ( spaceId , environmentId , contentTypeId ) . blockingFirst ( ) ; } | Fetch all snapshots of this content type . |
1,420 | public CMASnapshot fetchOneSnapshot ( CMAContentType contentType , String snapshotId ) { assertNotNull ( contentType , "contentType" ) ; assertNotNull ( snapshotId , "snapshotId" ) ; final String contentTypeId = getResourceIdOrThrow ( contentType , "contentType" ) ; final String spaceId = getSpaceIdOrThrow ( contentType , "contentType" ) ; final String environmentId = contentType . getEnvironmentId ( ) ; return service . fetchOneSnapshot ( spaceId , environmentId , contentTypeId , snapshotId ) . blockingFirst ( ) ; } | Fetch a specific snapshot of this content type . |
1,421 | public CMASnapshot deserialize ( JsonElement json , Type typeOfT , JsonDeserializationContext context ) throws JsonParseException { final CMASnapshot result = new CMASnapshot ( ) ; final JsonObject jsonObject = json . getAsJsonObject ( ) ; final CMASystem system = context . deserialize ( jsonObject . get ( "sys" ) , CMASystem . class ) ; result . setSystem ( system ) ; final JsonObject snapshot = jsonObject . getAsJsonObject ( "snapshot" ) ; final String type = snapshot . getAsJsonObject ( "sys" ) . getAsJsonPrimitive ( "type" ) . getAsString ( ) ; if ( CMAType . ContentType . name ( ) . equals ( type ) ) { result . setSnapshot ( context . deserialize ( snapshot , CMAContentType . class ) ) ; } else if ( CMAType . Entry . name ( ) . equals ( type ) ) { result . setSnapshot ( context . deserialize ( snapshot , CMAEntry . class ) ) ; } return result ; } | Inspect json payload and generate either a content type snapshot from it or an entry snap shot . |
1,422 | public Integer delete ( CMAEntry entry ) { assertNotNull ( entry . getSpaceId ( ) , "spaceId" ) ; assertNotNull ( entry . getEnvironmentId ( ) , "environmentId" ) ; assertNotNull ( entry . getId ( ) , "entryId" ) ; return service . delete ( entry . getSpaceId ( ) , entry . getEnvironmentId ( ) , entry . getId ( ) ) . blockingFirst ( ) . code ( ) ; } | Delete an Entry . |
1,423 | public CMAEntry fetchOne ( String spaceId , String environmentId , String entryId ) { assertNotNull ( spaceId , "spaceId" ) ; assertNotNull ( environmentId , "environmentId" ) ; assertNotNull ( entryId , "entryId" ) ; return service . fetchOne ( spaceId , environmentId , entryId ) . blockingFirst ( ) ; } | Fetch an entry with the given entryId from the given environment and space . |
1,424 | public CMAEntry publish ( CMAEntry entry ) { assertNotNull ( entry , "entry" ) ; final String entryId = getResourceIdOrThrow ( entry , "entry" ) ; final String environmentId = entry . getEnvironmentId ( ) ; final String spaceId = getSpaceIdOrThrow ( entry , "entry" ) ; return service . publish ( entry . getSystem ( ) . getVersion ( ) , spaceId , environmentId , entryId ) . blockingFirst ( ) ; } | Publish an Entry . |
1,425 | public CMAEntry unPublish ( CMAEntry entry ) { assertNotNull ( entry , "entry" ) ; final String entryId = getResourceIdOrThrow ( entry , "entry" ) ; final String spaceId = getSpaceIdOrThrow ( entry , "entry" ) ; final String environmentId = entry . getEnvironmentId ( ) ; return service . unPublish ( spaceId , environmentId , entryId ) . blockingFirst ( ) ; } | Un - Publish an Entry . |
1,426 | public CMAEntry update ( CMAEntry entry ) { assertNotNull ( entry , "entry" ) ; final String entryId = getResourceIdOrThrow ( entry , "entry" ) ; final String spaceId = getSpaceIdOrThrow ( entry , "entry" ) ; final String environmentId = entry . getEnvironmentId ( ) ; final Integer version = getVersionOrThrow ( entry , "update" ) ; final CMASystem system = entry . getSystem ( ) ; entry . setSystem ( null ) ; try { return service . update ( version , spaceId , environmentId , entryId , entry ) . blockingFirst ( ) ; } finally { entry . setSystem ( system ) ; } } | Update an Entry . |
1,427 | public CMAArray < CMASnapshot > fetchAllSnapshots ( CMAEntry entry ) { assertNotNull ( entry , "entry" ) ; final String entryId = getResourceIdOrThrow ( entry , "entry" ) ; final String spaceId = getSpaceIdOrThrow ( entry , "entry" ) ; final String environmentId = entry . getEnvironmentId ( ) ; return service . fetchAllSnapshots ( spaceId , environmentId , entryId ) . blockingFirst ( ) ; } | Fetch all snapshots of an entry . |
1,428 | public CMASnapshot fetchOneSnapshot ( CMAEntry entry , String snapshotId ) { assertNotNull ( entry , "entry" ) ; assertNotNull ( snapshotId , "snapshotId" ) ; final String entryId = getResourceIdOrThrow ( entry , "entry" ) ; final String spaceId = getSpaceIdOrThrow ( entry , "entry" ) ; final String environmentId = entry . getEnvironmentId ( ) ; return service . fetchOneSnapshot ( spaceId , environmentId , entryId , snapshotId ) . blockingFirst ( ) ; } | Fetch a specific snapshot of an entry . |
1,429 | public Response intercept ( Chain chain ) throws IOException { final Request request = chain . request ( ) ; final Response response = chain . proceed ( request ) ; if ( ! response . isSuccessful ( ) ) { throw new CMAHttpException ( request , response ) ; } return response ; } | Intercepts chain to check for unsuccessful requests . |
1,430 | public Response intercept ( Chain chain ) throws IOException { final Response response = chain . proceed ( chain . request ( ) ) ; final Headers headers = response . headers ( ) ; final Map < String , List < String > > mappedHeaders = headers . toMultimap ( ) ; final RateLimits limits = new RateLimits . DefaultParser ( ) . parse ( mappedHeaders ) ; listener . onRateLimitHeaderReceived ( limits ) ; return response ; } | Intercept a http call . |
1,431 | static CMARichNode resolveRichNode ( Map < String , Object > rawNode ) { final String type = ( String ) rawNode . get ( "nodeType" ) ; if ( RESOLVER_MAP . containsKey ( type ) ) { return RESOLVER_MAP . get ( type ) . resolve ( rawNode ) ; } else { return null ; } } | Resolve one node . |
1,432 | public CMAPersonalAccessToken addScope ( Scope scope ) { if ( scopes == null ) { scopes = new ArrayList < Scope > ( ) ; } scopes . add ( scope ) ; return this ; } | Add a new scope to the list of scopes . Creates a new list of scopes if no scopes found . |
1,433 | public CMASpace create ( CMASpace space ) { assertNotNull ( space , "space" ) ; final CMASystem system = space . getSystem ( ) ; space . setSystem ( null ) ; try { return service . create ( space ) . blockingFirst ( ) ; } finally { space . setSystem ( system ) ; } } | Create a Space . |
1,434 | public CMASpace create ( String spaceName , String organizationId ) { assertNotNull ( spaceName , "spaceName" ) ; assertNotNull ( organizationId , "organizationId" ) ; return service . create ( organizationId , new CMASpace ( ) . setName ( spaceName ) . setSystem ( null ) ) . blockingFirst ( ) ; } | Create a Space in an Organization . |
1,435 | public CMASpace create ( CMASpace space , String organizationId ) { assertNotNull ( space , "space" ) ; assertNotNull ( space . getName ( ) , "spaceName" ) ; assertNotNull ( organizationId , "organizationId" ) ; final CMASystem system = space . getSystem ( ) ; space . setSystem ( null ) ; try { return service . create ( organizationId , space ) . blockingFirst ( ) ; } finally { space . setSystem ( system ) ; } } | Create a Space in an organization . |
1,436 | public CMAArray < CMASpace > fetchAll ( Map < String , String > query ) { DefaultQueryParameter . putIfNotSet ( query , DefaultQueryParameter . FETCH ) ; return service . fetchAll ( query ) . blockingFirst ( ) ; } | Fetch all Spaces using specific queries . |
1,437 | public CMASpace update ( CMASpace space ) { assertNotNull ( space , "space" ) ; assertNotNull ( space . getName ( ) , "space.name" ) ; final String spaceId = getResourceIdOrThrow ( space , "space" ) ; final Integer version = getVersionOrThrow ( space , "update" ) ; final CMASystem system = space . getSystem ( ) ; space . setSystem ( null ) ; try { return service . update ( version , spaceId , space ) . blockingFirst ( ) ; } finally { space . setSystem ( system ) ; } } | Update a Space . |
1,438 | static void putIfNotSet ( Map < String , String > target , Map < String , String > defaults ) { for ( final String key : defaults . keySet ( ) ) { if ( ! target . containsKey ( key ) ) { target . put ( key , defaults . get ( key ) ) ; } } } | Update a given map with some default values if not already present in map . |
1,439 | public CMASpaceMembership setRoles ( CMALink ... roles ) { if ( roles == null ) { throw new IllegalArgumentException ( "Roles cannot be null!" ) ; } if ( roles . length <= 0 ) { throw new IllegalArgumentException ( "Roles cannot be empty!" ) ; } this . roles = new ArrayList < CMALink > ( Arrays . asList ( roles ) ) ; return this ; } | Replace all roles with the given argument . |
1,440 | public CMASpaceMembership addRole ( CMALink role ) { if ( role == null ) { throw new IllegalArgumentException ( "Role cannot be null!" ) ; } if ( roles == null ) { roles = new ArrayList < CMALink > ( ) ; } this . roles . add ( role ) ; return this ; } | Add a role to the list of roles . |
1,441 | public CMASpaceMembership setEmail ( String email ) { if ( email == null ) { throw new IllegalArgumentException ( "email cannot be null." ) ; } if ( ! email . contains ( "@" ) ) { throw new IllegalArgumentException ( "email needs to contain an '@' symbol." ) ; } this . email = email ; return this ; } | Set the email address when creating a new membership . |
1,442 | private void setCallbackExecutor ( Builder clientBuilder ) { if ( clientBuilder . callbackExecutor == null ) { callbackExecutor = Platform . get ( ) . callbackExecutor ( ) ; } else { callbackExecutor = clientBuilder . callbackExecutor ; } } | Sets the callback executor . |
1,443 | private Retrofit . Builder setEndpoint ( Retrofit . Builder retrofitBuilder , String endpoint ) { if ( endpoint != null ) { return retrofitBuilder . baseUrl ( endpoint ) ; } return retrofitBuilder ; } | Configures CMA core endpoint . |
1,444 | public CMAContentType addField ( CMAField field ) { if ( fields == null ) { fields = new ArrayList < CMAField > ( ) ; } fields . add ( field ) ; return this ; } | Adds a new field . |
1,445 | public CMAArray < CMAApiKey > fetchAll ( Map < String , String > query ) { throwIfEnvironmentIdIsSet ( ) ; return fetchAll ( spaceId , query ) ; } | Query for specific api keys from the configured space . |
1,446 | public CMAApiKey update ( CMAApiKey key ) { assertNotNull ( key , "key" ) ; final String keyId = getResourceIdOrThrow ( key , "key" ) ; final String spaceId = getSpaceIdOrThrow ( key , "key" ) ; final Integer version = getVersionOrThrow ( key , "update" ) ; final CMASystem system = key . getSystem ( ) ; key . setSystem ( null ) ; final String token = key . getAccessToken ( ) ; key . setAccessToken ( null ) ; final CMALink previewKey = key . getPreviewApiKey ( ) ; key . setPreviewApiKey ( null ) ; try { return service . update ( version , spaceId , keyId , key ) . blockingFirst ( ) ; } finally { key . setPreviewApiKey ( previewKey ) ; key . setAccessToken ( token ) ; key . setSystem ( system ) ; } } | Updates a delivery api key from the configured space . |
1,447 | public CMAApiKey create ( String spaceId , CMAApiKey key ) { assertNotNull ( spaceId , "spaceId" ) ; assertNotNull ( key , "key" ) ; return service . create ( spaceId , key ) . blockingFirst ( ) ; } | Create a new delivery api key . |
1,448 | public int delete ( CMAApiKey key ) { assertNotNull ( key , "key" ) ; final String space = getSpaceIdOrThrow ( key , "key" ) ; final String id = getResourceIdOrThrow ( key , "key" ) ; return service . delete ( space , id ) . blockingFirst ( ) . code ( ) ; } | Delete a given api key from the configured space . |
1,449 | static byte [ ] readAllBytes ( InputStream stream ) throws IOException { int bytesRead = 0 ; byte [ ] currentChunk = new byte [ 255 ] ; final List < byte [ ] > chunks = new ArrayList < byte [ ] > ( ) ; while ( ( bytesRead = stream . read ( currentChunk ) ) != - 1 ) { chunks . add ( copyOf ( currentChunk , bytesRead ) ) ; } if ( chunks . size ( ) <= 0 ) { throw new IOException ( "Stream did not contain any data. Please provide data to upload." ) ; } int size = 0 ; for ( byte [ ] chunk : chunks ) { size += chunk . length ; } final byte [ ] content = new byte [ size ] ; int position = 0 ; for ( byte [ ] chunk : chunks ) { arraycopy ( chunk , 0 , content , position , chunk . length ) ; position += chunk . length ; } return content ; } | Tries to read all content from a give stream . |
1,450 | public int delete ( CMAUpload upload ) { final String uploadId = getResourceIdOrThrow ( upload , "upload" ) ; final String spaceId = getSpaceIdOrThrow ( upload , "upload" ) ; final Response < Void > response = service . delete ( spaceId , uploadId ) . blockingFirst ( ) ; return response . code ( ) ; } | Delete a given upload again . |
1,451 | public CMAArray < CMARole > fetchAll ( Map < String , String > query ) { throwIfEnvironmentIdIsSet ( ) ; return fetchAll ( spaceId , query ) ; } | Fetch specific roles of the configured space . |
1,452 | public Response intercept ( Chain chain ) throws IOException { final Request request = chain . request ( ) ; return chain . proceed ( request . newBuilder ( ) . addHeader ( name , value ) . build ( ) ) ; } | Method called by framework to enrich current request chain with requested header information . |
1,453 | public CMAWebhook addTopic ( CMAWebhookTopic topic ) { if ( this . topics == null ) { this . topics = new ArrayList < CMAWebhookTopic > ( ) ; } this . topics . add ( topic ) ; return this ; } | Add a topic this webhook should be triggered on . |
1,454 | public CMAWebhook addHeader ( String key , String value ) { if ( this . headers == null ) { this . headers = new ArrayList < CMAWebhookHeader > ( ) ; } this . headers . add ( new CMAWebhookHeader ( key , value ) ) ; return this ; } | Adds a custom http header to the call done by this webhook . |
1,455 | public CMAWebhook setBasicAuthorization ( String user , String password ) { this . user = user ; this . password = password ; return this ; } | Set authorization parameter for basic HTTP authorization on the url to be called by this webhook . |
1,456 | public void close ( ) { Closeable closable = getClosable ( ) ; try { LOG . closingResponse ( this ) ; closable . close ( ) ; LOG . successfullyClosedResponse ( this ) ; } catch ( IOException e ) { throw LOG . exceptionWhileClosingResponse ( e ) ; } } | Implements the default close behavior |
1,457 | public static SearchSortGeoDistance sortGeoDistance ( double locationLon , double locationLat , String field ) { return new SearchSortGeoDistance ( locationLon , locationLat , field ) ; } | Sort by geo location . |
1,458 | public List < InetAddress > nodes ( ) { List < InetAddress > allNodes = new ArrayList < InetAddress > ( ) ; BucketConfig config = bucketConfig . get ( ) ; for ( NodeInfo nodeInfo : config . nodes ( ) ) { try { allNodes . add ( InetAddress . getByName ( nodeInfo . hostname ( ) . address ( ) ) ) ; } catch ( UnknownHostException e ) { throw new IllegalStateException ( e ) ; } } return allNodes ; } | Returns all nodes known in the current config . |
1,459 | public static AsyncSearchQueryResult fromHttp429 ( String payload ) { SearchStatus status = new DefaultSearchStatus ( 1L , 1L , 0L ) ; SearchMetrics metrics = new DefaultSearchMetrics ( 0L , 0L , 0d ) ; return new DefaultAsyncSearchQueryResult ( status , Observable . < SearchQueryRow > error ( new FtsServerOverloadException ( payload ) ) , Observable . < FacetResult > empty ( ) , Observable . just ( metrics ) ) ; } | Creates a result out of the http 429 response code if retry didn t work . |
1,460 | public static AsyncSearchQueryResult fromIndexNotFound ( final String indexName ) { SearchStatus status = new DefaultSearchStatus ( 1L , 1L , 0L ) ; SearchMetrics metrics = new DefaultSearchMetrics ( 0L , 0L , 0d ) ; return new DefaultAsyncSearchQueryResult ( status , Observable . < SearchQueryRow > error ( new IndexDoesNotExistException ( "Search Index \"" + indexName + "\" Not Found" ) ) , Observable . < FacetResult > empty ( ) , Observable . just ( metrics ) ) ; } | A utility method to return a result when the index is not found . |
1,461 | private static String extractName ( final Field fieldReference ) { com . couchbase . client . java . repository . annotation . Field annotation = fieldReference . getAnnotation ( com . couchbase . client . java . repository . annotation . Field . class ) ; if ( annotation == null || annotation . value ( ) == null || annotation . value ( ) . isEmpty ( ) ) { return fieldReference . getName ( ) ; } else { return annotation . value ( ) ; } } | Helper method to extract the potentially aliased name of the field . |
1,462 | public byte [ ] rawContent ( String path ) { if ( path == null ) { return null ; } for ( SubdocOperationResult < OPERATION > result : resultList ) { if ( path . equals ( result . path ( ) ) ) { return interpretResultRaw ( result ) ; } } return null ; } | Attempt to get the serialized form of the value corresponding to the first operation that targeted the given path as an array of bytes . |
1,463 | public ResponseStatus status ( String path ) { if ( path == null ) { return null ; } for ( SubdocOperationResult < OPERATION > result : resultList ) { if ( path . equals ( result . path ( ) ) ) { return result . status ( ) ; } } return null ; } | Get the operation status code corresponding to the first operation that targeted the given path . |
1,464 | public boolean exists ( String path ) { if ( path == null ) { return false ; } for ( SubdocOperationResult < OPERATION > result : resultList ) { if ( path . equals ( result . path ( ) ) && ! ( result . value ( ) instanceof Exception ) ) { return true ; } } return false ; } | Checks whether the given path is part of this result set eg . an operation targeted it and the operation executed successfully . |
1,465 | public boolean exists ( int specIndex ) { return specIndex >= 0 && specIndex < resultList . size ( ) && ! ( resultList . get ( specIndex ) . value ( ) instanceof Exception ) ; } | Checks whether the given index is part of this result set and the operation was executed successfully . |
1,466 | private static boolean shouldRetry ( JsonObject errorJson ) { if ( errorJson == null ) return false ; Integer code = errorJson . getInt ( ERROR_FIELD_CODE ) ; String msg = errorJson . getString ( ERROR_FIELD_MSG ) ; if ( code == null || msg == null ) return false ; if ( code == 4050 || code == 4070 || ( code == 5000 && msg . contains ( ERROR_5000_SPECIFIC_MESSAGE ) ) ) { return true ; } return false ; } | Tests a N1QL error JSON for conditions warranting a prepared statement retry . |
1,467 | protected Observable < AsyncN1qlQueryResult > retryPrepareAndExecuteOnce ( Throwable error , N1qlQuery query , CouchbaseEnvironment env , long timeout , TimeUnit timeUnit ) { if ( error instanceof QueryExecutionException && shouldRetry ( ( ( QueryExecutionException ) error ) . getN1qlError ( ) ) ) { queryCache . remove ( query . statement ( ) . toString ( ) ) ; return prepareAndExecute ( query , env , timeout , timeUnit ) ; } return Observable . error ( error ) ; } | In case the error warrants a retry issue a PREPARE followed by an update of the cache and an EXECUTE . Any failure in the EXECUTE won t continue the retry cycle . |
1,468 | protected Observable < AsyncN1qlQueryResult > prepareAndExecute ( final N1qlQuery query , final CouchbaseEnvironment env , final long timeout , final TimeUnit timeUnit ) { return prepare ( query . statement ( ) ) . flatMap ( new Func1 < PreparedPayload , Observable < AsyncN1qlQueryResult > > ( ) { public Observable < AsyncN1qlQueryResult > call ( PreparedPayload payload ) { queryCache . put ( query . statement ( ) . toString ( ) , payload ) ; return executePrepared ( query , payload , env , timeout , timeUnit ) ; } } ) ; } | Issues a N1QL PREPARE puts the plan in cache then EXECUTE it . |
1,469 | protected Observable < AsyncN1qlQueryResult > executePrepared ( final N1qlQuery query , PreparedPayload payload , CouchbaseEnvironment env , long timeout , TimeUnit timeUnit ) { PreparedN1qlQuery preparedQuery ; if ( query instanceof ParameterizedN1qlQuery ) { ParameterizedN1qlQuery pq = ( ParameterizedN1qlQuery ) query ; if ( pq . isPositional ( ) ) { preparedQuery = new PreparedN1qlQuery ( payload , ( JsonArray ) pq . statementParameters ( ) , query . params ( ) ) ; } else { preparedQuery = new PreparedN1qlQuery ( payload , ( JsonObject ) pq . statementParameters ( ) , query . params ( ) ) ; } } else { preparedQuery = new PreparedN1qlQuery ( payload , query . params ( ) ) ; } preparedQuery . setEncodedPlanEnabled ( isEncodedPlanEnabled ( ) ) ; return executeQuery ( preparedQuery , env , timeout , timeUnit ) ; } | Issues a proper N1QL EXECUTE detecting if parameters must be added to it . |
1,470 | private GenericQueryRequest createN1qlRequest ( final N1qlQuery query , String bucket , String username , String password , InetAddress targetNode ) { String rawQuery = query . n1ql ( ) . toString ( ) ; rawQuery = rawQuery . replaceAll ( CouchbaseAsyncBucket . CURRENT_BUCKET_IDENTIFIER , "`" + bucket + "`" ) ; String statement = query . statement ( ) . toString ( ) ; if ( targetNode != null ) { return GenericQueryRequest . jsonQuery ( rawQuery , bucket , username , password , targetNode , query . params ( ) . clientContextId ( ) , statement ) ; } else { return GenericQueryRequest . jsonQuery ( rawQuery , bucket , username , password , query . params ( ) . clientContextId ( ) , statement ) ; } } | Creates the core query request and performs centralized string substitution . |
1,471 | public static Expression replace ( Expression expression , String substring , String repl ) { return x ( "REPLACE(" + expression . toString ( ) + ", \"" + substring + "\", \"" + repl + "\")" ) ; } | Returned expression results in a string with all occurrences of substr replaced with repl . |
1,472 | public static Expression substr ( Expression expression , int position , int length ) { return x ( "SUBSTR(" + expression . toString ( ) + ", " + position + ", " + length + ")" ) ; } | Returned expression results in a substring from the integer position of the given length . |
1,473 | public static Expression ifMissing ( Expression expression1 , Expression expression2 , Expression ... others ) { return build ( "IFMISSING" , expression1 , expression2 , others ) ; } | Returned expression results in the first non - MISSING value . |
1,474 | public static Expression ifMissingOrNull ( Expression expression1 , Expression expression2 , Expression ... others ) { return build ( "IFMISSINGORNULL" , expression1 , expression2 , others ) ; } | Returned expression results in first non - NULL non - MISSING value . |
1,475 | public static Expression ifNull ( Expression expression1 , Expression expression2 , Expression ... others ) { return build ( "IFNULL" , expression1 , expression2 , others ) ; } | Returned expression results in first non - NULL value . Note that this function might return MISSING if there is no non - NULL value . |
1,476 | public static Expression missingIf ( Expression expression1 , Expression expression2 ) { return x ( "MISSINGIF(" + expression1 . toString ( ) + ", " + expression2 . toString ( ) + ")" ) ; } | Returned expression results in MISSING if expression1 = expression2 otherwise returns expression1 . Returns MISSING or NULL if either input is MISSING or NULL .. |
1,477 | public static Expression nullIf ( Expression expression1 , Expression expression2 ) { return x ( "NULLIF(" + expression1 . toString ( ) + ", " + expression2 . toString ( ) + ")" ) ; } | Returned expression results in NULL if expression1 = expression2 otherwise returns expression1 . Returns MISSING or NULL if either input is MISSING or NULL .. |
1,478 | public static Expression ifInf ( Expression expression1 , Expression expression2 , Expression ... others ) { return build ( "IFINF" , expression1 , expression2 , others ) ; } | Returned expression results in first non - MISSING non - Inf number . Returns MISSING or NULL if a non - number input is encountered first . |
1,479 | public static Expression ifNaN ( Expression expression1 , Expression expression2 , Expression ... others ) { return build ( "IFNAN" , expression1 , expression2 , others ) ; } | Returned expression results in first non - MISSING non - NaN number . Returns MISSING or NULL if a non - number input is encountered first |
1,480 | public static Expression ifNaNOrInf ( Expression expression1 , Expression expression2 , Expression ... others ) { return build ( "IFNANORINF" , expression1 , expression2 , others ) ; } | Returned expression results in first non - MISSING non - Inf or non - NaN number . Returns MISSING or NULL if a non - number input is encountered first . |
1,481 | public static Expression nanIf ( Expression expression1 , Expression expression2 ) { return x ( "NANIF(" + expression1 . toString ( ) + ", " + expression2 . toString ( ) + ")" ) ; } | Returned expression results in NaN if expression1 = expression2 otherwise returns expression1 . Returns MISSING or NULL if either input is MISSING or NULL . |
1,482 | public static Expression negInfIf ( Expression expression1 , Expression expression2 ) { return x ( "NEGINFIF(" + expression1 . toString ( ) + ", " + expression2 . toString ( ) + ")" ) ; } | Returned expression results in NegInf if expression1 = expression2 otherwise returns expression1 . Returns MISSING or NULL if either input is MISSING or NULL . |
1,483 | public static Expression posInfIf ( Expression expression1 , Expression expression2 ) { return x ( "POSINFIF(" + expression1 . toString ( ) + ", " + expression2 . toString ( ) + ")" ) ; } | Returned expression results in PosInf if expression1 = expression2 otherwise returns expression1 . Returns MISSING or NULL if either input is MISSING or NULL . |
1,484 | public static < D extends Document < ? > > Single < D > getFirstPrimaryOrReplica ( final String id , final Class < D > target , final Bucket bucket , final long primaryTimeout , final long replicaTimeout ) { if ( primaryTimeout <= 0 ) { throw new IllegalArgumentException ( "Primary timeout must be greater than 0ms" ) ; } if ( replicaTimeout <= 0 ) { throw new IllegalArgumentException ( "Replica timeout must be greater than 0ms" ) ; } Observable < D > fallback = bucket . async ( ) . getFromReplica ( id , ReplicaMode . ALL , target ) . timeout ( replicaTimeout , TimeUnit . MILLISECONDS ) . firstOrDefault ( null ) . filter ( new Func1 < D , Boolean > ( ) { public Boolean call ( D d ) { return d != null ; } } ) ; return bucket . async ( ) . get ( id , target ) . timeout ( primaryTimeout , TimeUnit . MILLISECONDS ) . onErrorResumeNext ( fallback ) . toSingle ( ) ; } | Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them . |
1,485 | public ViewQuery includeDocsOrdered ( boolean includeDocs , Class < ? extends Document < ? > > target ) { this . includeDocs = includeDocs ; this . retainOrder = includeDocs ; this . includeDocsTarget = target ; return this ; } | Proactively load the full document for the row returned while strictly retaining view row order . |
1,486 | public ViewQuery groupLevel ( final int grouplevel ) { params [ PARAM_GROUPLEVEL_OFFSET ] = "group_level" ; params [ PARAM_GROUPLEVEL_OFFSET + 1 ] = Integer . toString ( grouplevel ) ; return this ; } | Specify the group level to be used . |
1,487 | protected String encode ( final String source ) { try { return URLEncoder . encode ( source , "UTF-8" ) ; } catch ( Exception ex ) { throw new RuntimeException ( "Could not prepare view argument: " + ex ) ; } } | Helper method to properly encode a string . |
1,488 | public static String digestSha1Hex ( String source ) { String sha1 = "" ; try { MessageDigest crypt = MessageDigest . getInstance ( "SHA-1" ) ; crypt . reset ( ) ; crypt . update ( source . getBytes ( "UTF-8" ) ) ; sha1 = byteToHex ( crypt . digest ( ) ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } return sha1 ; } | Hashes the source with SHA1 and returns the resulting hash as an hexadecimal string . |
1,489 | public static List < String > fromDnsSrv ( final String serviceName , boolean full , boolean secure ) throws NamingException { return fromDnsSrv ( serviceName , full , secure , null ) ; } | Fetch a bootstrap list from DNS SRV using default OS name resolution . |
1,490 | public static List < String > fromDnsSrv ( final String serviceName , boolean full , boolean secure , String nameServerIP ) throws NamingException { String fullService ; if ( full ) { fullService = serviceName ; } else { fullService = ( secure ? DEFAULT_DNS_SECURE_SERVICE : DEFAULT_DNS_SERVICE ) + serviceName ; } DirContext ctx ; if ( nameServerIP == null || nameServerIP . isEmpty ( ) ) { ctx = new InitialDirContext ( DNS_ENV ) ; } else { Hashtable < String , String > finalEnv = new Hashtable < String , String > ( DNS_ENV ) ; finalEnv . put ( "java.naming.provider.url" , "dns://" + nameServerIP ) ; ctx = new InitialDirContext ( finalEnv ) ; } return loadDnsRecords ( fullService , ctx ) ; } | Fetch a bootstrap list from DNS SRV using a specific nameserver IP . |
1,491 | static List < String > loadDnsRecords ( final String serviceName , final DirContext ctx ) throws NamingException { Attributes attrs = ctx . getAttributes ( serviceName , new String [ ] { "SRV" } ) ; NamingEnumeration < ? > servers = attrs . get ( "srv" ) . getAll ( ) ; List < String > records = new ArrayList < String > ( ) ; while ( servers . hasMore ( ) ) { DnsRecord record = DnsRecord . fromString ( ( String ) servers . next ( ) ) ; records . add ( record . getHost ( ) ) ; } return records ; } | Helper method to load a list of DNS SRV records . |
1,492 | public static Expression millisToUtc ( String expression , String format ) { return millisToUtc ( x ( expression ) , format ) ; } | Returned expression results in the UTC string to which the UNIX time stamp has been converted in the supported format . |
1,493 | public static Expression nowStr ( String format ) { if ( format == null || format . isEmpty ( ) ) { return x ( "NOW_STR()" ) ; } return x ( "NOW_STR(\"" + format + "\")" ) ; } | Returned expression results in statement time stamp as a string in a supported format ; does not vary during a query . |
1,494 | private void addToken ( final MutationToken token ) { if ( token != null ) { ListIterator < MutationToken > tokenIterator = tokens . listIterator ( ) ; while ( tokenIterator . hasNext ( ) ) { MutationToken t = tokenIterator . next ( ) ; if ( t . vbucketID ( ) == token . vbucketID ( ) && t . bucket ( ) . equals ( token . bucket ( ) ) ) { if ( token . sequenceNumber ( ) > t . sequenceNumber ( ) ) { tokenIterator . set ( token ) ; } return ; } } tokens . add ( token ) ; } } | Helper method to check the incoming token and store it if needed . |
1,495 | public RestApiResponse execute ( long timeout , TimeUnit timeUnit ) { return Blocking . blockForSingle ( delegate . execute ( ) , timeout , timeUnit ) ; } | Executes the API request in a synchronous fashion using the given timeout . |
1,496 | public DateRangeQuery start ( Date start , boolean inclusive ) { this . start = SearchUtils . toFtsUtcString ( start ) ; this . inclusiveStart = inclusive ; return this ; } | Sets the lower boundary of the range inclusive or not depending on the second parameter . |
1,497 | public DateRangeQuery start ( Date start ) { this . start = SearchUtils . toFtsUtcString ( start ) ; this . inclusiveStart = null ; return this ; } | Sets the lower boundary of the range . The lower boundary is considered inclusive by default on the server side . |
1,498 | public DateRangeQuery end ( Date end , boolean inclusive ) { this . end = SearchUtils . toFtsUtcString ( end ) ; this . inclusiveEnd = inclusive ; return this ; } | Sets the upper boundary of the range inclusive or not depending on the second parameter . |
1,499 | public DateRangeQuery end ( Date end ) { this . end = SearchUtils . toFtsUtcString ( end ) ; this . inclusiveEnd = null ; return this ; } | Sets the upper boundary of the range . The upper boundary is considered exclusive by default on the server side . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.