algoliasearch/src/main/java/com/algolia/search/saas/Index.java
public JSONObject waitTask(String taskID, long timeToWait) throws AlgoliaException {
        try {
            while (true) {
                JSONObject obj = client.getRequest("/1/indexes/" + encodedIndexName + "/task/" + URLEncoder.encode(taskID, "UTF-8"), /* urlParameters: */ null, false, /* requestOptions: */ null);
                if (obj.getString("status").equals("published")) {
                    return obj;
                }
                try {
                    Thread.sleep(timeToWait >= MAX_TIME_MS_TO_WAIT ? MAX_TIME_MS_TO_WAIT : timeToWait);
                } catch (InterruptedException e) {
                    continue;
                }

                final long newTimeout = timeToWait * 2;
                timeToWait = (newTimeout <= 0 || newTimeout >= MAX_TIME_MS_TO_WAIT) ? MAX_TIME_MS_TO_WAIT : newTimeout;
            }
        } catch (JSONException e) {
            throw new AlgoliaException(e.getMessage());
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
public JSONObject waitTask(String taskID, long timeToWait) throws AlgoliaException {
        try {
            while (true) {
                JSONObject obj = client.getRequest("/1/indexes/" + encodedIndexName + "/task/" + URLEncoder.encode(taskID, "UTF-8"), /* urlParameters: */ null, false, /* requestOptions: */ null);
                if (obj.getString("status").equals("published")) {
                    return obj;
                }
                try {
                    Thread.sleep(timeToWait >= MAX_TIME_MS_TO_WAIT ? MAX_TIME_MS_TO_WAIT : timeToWait);
                } catch (InterruptedException e) {
                    continue;
                }

                final long newTimeout = timeToWait * 2;
                timeToWait = (newTimeout <= 0 || newTimeout >= MAX_TIME_MS_TO_WAIT) ? MAX_TIME_MS_TO_WAIT : newTimeout;
            }
        } catch (JSONException e) {
            throw new AlgoliaException(e.getMessage());
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
public JSONObject waitTask ( String taskID , long timeToWait ) throws AlgoliaException { try { while ( true ) { JSONObject obj = client . getRequest ( "/1/indexes/" + encodedIndexName + "/task/" + URLEncoder . encode ( taskID , "UTF-8" ) , /* urlParameters: */ null , false , /* requestOptions: */ null ) ; if ( obj . getString ( "status" ) . equals ( "published" ) ) { return obj ; } try { Thread . sleep ( timeToWait >= MAX_TIME_MS_TO_WAIT ? MAX_TIME_MS_TO_WAIT : timeToWait ) ; } catch ( InterruptedException e ) { continue ; } final long newTimeout = timeToWait * 2 ; timeToWait = ( newTimeout <= 0 || newTimeout >= MAX_TIME_MS_TO_WAIT ) ? MAX_TIME_MS_TO_WAIT : newTimeout ; } } catch ( JSONException e ) { throw new AlgoliaException ( e . getMessage ( ) ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }
Wait the publication of a task on the server.
All server task are asynchronous and you can check with this method that the task is published.

@param taskID     the id of the task returned by server
@param timeToWait time to sleep seed
@throws AlgoliaException
Wait the publication of a task on the server . All server task are asynchronous and you can check with this method that the task is published .