private boolean canRetrieveAllChunks()

in indexer-core/src/main/java/org/apache/maven/index/incremental/DefaultIncrementalHandler.java [232:273]


    private boolean canRetrieveAllChunks(Properties localProps, Properties remoteProps) {
        // no localprops, can't retrieve chunks
        if (localProps == null) {
            return false;
        }

        String localChainId = localProps.getProperty(IndexingContext.INDEX_CHAIN_ID);
        String remoteChainId = remoteProps.getProperty(IndexingContext.INDEX_CHAIN_ID);

        // If no chain id, or not the same, do whole download
        if (StringUtils.isEmpty(localChainId) || !localChainId.equals(remoteChainId)) {
            return false;
        }

        String counterProp = localProps.getProperty(IndexingContext.INDEX_CHUNK_COUNTER);

        // no counter, cant retrieve chunks
        // not a number, cant retrieve chunks
        if (StringUtils.isEmpty(counterProp) || !StringUtils.isNumeric(counterProp)) {
            return false;
        }

        int currentLocalCounter = Integer.parseInt(counterProp);

        // check remote props for existence of next chunk after local
        // if we find it, then we are ok to retrieve the rest of the chunks
        for (Object key : remoteProps.keySet()) {
            String sKey = (String) key;

            if (sKey.startsWith(IndexingContext.INDEX_CHUNK_PREFIX)) {
                String value = remoteProps.getProperty(sKey);

                // If we have the current counter, or the next counter, we are good to go
                if (Integer.toString(currentLocalCounter).equals(value)
                        || Integer.toString(currentLocalCounter + 1).equals(value)) {
                    return true;
                }
            }
        }

        return false;
    }