public IndexReader()

in indexer-reader/src/main/java/org/apache/maven/index/reader/IndexReader.java [68:106]


    public IndexReader(final WritableResourceHandler local, final ResourceHandler remote) throws IOException {
        requireNonNull(remote, "remote resource handler null");
        this.closed = new AtomicBoolean(false);
        this.local = local;
        this.remote = remote;
        remoteIndexProperties = loadProperties(remote.locate(Utils.INDEX_FILE_PREFIX + ".properties"));
        if (remoteIndexProperties == null) {
            throw new IllegalArgumentException("Non-existent remote index");
        }
        try {
            if (local != null) {
                Properties localProperties = loadProperties(local.locate(Utils.INDEX_FILE_PREFIX + ".properties"));
                if (localProperties != null) {
                    this.localIndexProperties = localProperties;
                    String remoteIndexId = remoteIndexProperties.getProperty("nexus.index.id");
                    String localIndexId = localIndexProperties.getProperty("nexus.index.id");
                    if (remoteIndexId == null || !remoteIndexId.equals(localIndexId)) {
                        throw new IllegalArgumentException("local and remote index IDs does not match or is null: "
                                + localIndexId + ", " + remoteIndexId);
                    }
                    this.indexId = localIndexId;
                    this.incremental = canRetrieveAllChunks();
                } else {
                    localIndexProperties = null;
                    this.indexId = remoteIndexProperties.getProperty("nexus.index.id");
                    this.incremental = false;
                }
            } else {
                localIndexProperties = null;
                this.indexId = remoteIndexProperties.getProperty("nexus.index.id");
                this.incremental = false;
            }
            this.publishedTimestamp =
                    Utils.INDEX_DATE_FORMAT.parse(remoteIndexProperties.getProperty("nexus.index.timestamp"));
            this.chunkNames = calculateChunkNames();
        } catch (ParseException e) {
            throw new IOException("Index properties corrupted", e);
        }
    }