/** * Reads the provider's directory, then rebuild the resource map. The response is * cached. */ private void readDirectory() throws AcmeException { synchronized (this) { Instant now = Instant.now(); if (directoryCacheExpiry != null && directoryCacheExpiry.isAfter(now)) { return; } directoryCacheExpiry = now.plus(Duration.ofHours(1)); } JSON directoryJson = provider().directory(this, getServerUri()); Value meta = directoryJson.get("meta"); if (meta.isPresent()) { metadata.set(new Metadata(meta.asObject())); } else { metadata.set(new Metadata(JSON.empty())); } Map<Resource, URL> map = new EnumMap<>(Resource.class); for (Resource res : Resource.values()) { directoryJson.get(res.path()) .map(Value::asURL) .ifPresent(url -> map.put(res, url)); } resourceMap.set(map); }
/** * Reads the provider's directory, then rebuild the resource map. The response is * cached. */ private void readDirectory() throws AcmeException { synchronized (this) { Instant now = Instant.now(); if (directoryCacheExpiry != null && directoryCacheExpiry.isAfter(now)) { return; } directoryCacheExpiry = now.plus(Duration.ofHours(1)); } JSON directoryJson = provider().directory(this, getServerUri()); Value meta = directoryJson.get("meta"); if (meta.isPresent()) { metadata.set(new Metadata(meta.asObject())); } else { metadata.set(new Metadata(JSON.empty())); } Map<Resource, URL> map = new EnumMap<>(Resource.class); for (Resource res : Resource.values()) { directoryJson.get(res.path()) .map(Value::asURL) .ifPresent(url -> map.put(res, url)); } resourceMap.set(map); }