public Optional getResourceContent()

in src/main/java/org/apache/maven/buildcache/RemoteCacheRepositoryImpl.java [151:178]


    public Optional<byte[]> getResourceContent(String url) {
        String fullUrl = getFullUrl(url);
        try {
            LOGGER.info("Downloading {}", fullUrl);
            GetTask task = new GetTask(new URI(url));
            transporter.get(task);
            return Optional.of(task.getDataBytes());
        } catch (ResourceDoesNotExistException e) {
            logNotFound(fullUrl, e);
            return Optional.empty();
        } catch (Exception e) {
            // this can be wagon used so the exception may be different
            // we want wagon users not flooded with logs when not found
            if ((e instanceof HttpResponseException
                            || e.getClass().getName().equals(HttpResponseException.class.getName()))
                    && getStatusCode(e) == HttpStatus.SC_NOT_FOUND) {
                logNotFound(fullUrl, e);
                return Optional.empty();
            }
            if (cacheConfig.isFailFast()) {
                LOGGER.error("Error downloading cache item: {}", fullUrl, e);
                throw new RuntimeException("Error downloading cache item: " + fullUrl, e);
            } else {
                LOGGER.error("Error downloading cache item: {}", fullUrl);
                return Optional.empty();
            }
        }
    }