@Test public void testGetBadResource() throws IOException { CacheResourceDownloadingException actual = null; try { cacheResourcesManager.getResource("http: } catch (CacheResourceDownloadingException e) { actual = e; } assertNotNull(actual); assertEquals( "The resource 'http: actual.getMessage()); }
public Path getResource(final String resourceURI) throws IOException { Path resourceCachePath = getResourceCachePath(resourceURI); if (Files.exists(resourceCachePath)) { return resourceCachePath; } if (!FilesUtils.isIncludedInDeployedPath(resourceCachePath)) { throw new CacheResourceDownloadingException(resourceURI); } if (unavailableURICache.getIfPresent(resourceURI) != null) { LOGGER.info("Ignored unavailable schema URI: " + resourceURI + "\n"); return null; } CompletableFuture<Path> f = null; synchronized (resourcesLoading) { if (resourcesLoading.containsKey(resourceURI)) { CompletableFuture<Path> future = resourcesLoading.get(resourceURI); throw new CacheResourceDownloadingException(resourceURI, future); } f = downloadResource(resourceURI, resourceCachePath); resourcesLoading.put(resourceURI, f); } if (f.getNow(null) == null) { throw new CacheResourceDownloadingException(resourceURI, f); } return resourceCachePath; }
CacheResourcesManager { public Path getResource(final String resourceURI) throws IOException { Path resourceCachePath = getResourceCachePath(resourceURI); if (Files.exists(resourceCachePath)) { return resourceCachePath; } if (!FilesUtils.isIncludedInDeployedPath(resourceCachePath)) { throw new CacheResourceDownloadingException(resourceURI); } if (unavailableURICache.getIfPresent(resourceURI) != null) { LOGGER.info("Ignored unavailable schema URI: " + resourceURI + "\n"); return null; } CompletableFuture<Path> f = null; synchronized (resourcesLoading) { if (resourcesLoading.containsKey(resourceURI)) { CompletableFuture<Path> future = resourcesLoading.get(resourceURI); throw new CacheResourceDownloadingException(resourceURI, future); } f = downloadResource(resourceURI, resourceCachePath); resourcesLoading.put(resourceURI, f); } if (f.getNow(null) == null) { throw new CacheResourceDownloadingException(resourceURI, f); } return resourceCachePath; } }
CacheResourcesManager { public Path getResource(final String resourceURI) throws IOException { Path resourceCachePath = getResourceCachePath(resourceURI); if (Files.exists(resourceCachePath)) { return resourceCachePath; } if (!FilesUtils.isIncludedInDeployedPath(resourceCachePath)) { throw new CacheResourceDownloadingException(resourceURI); } if (unavailableURICache.getIfPresent(resourceURI) != null) { LOGGER.info("Ignored unavailable schema URI: " + resourceURI + "\n"); return null; } CompletableFuture<Path> f = null; synchronized (resourcesLoading) { if (resourcesLoading.containsKey(resourceURI)) { CompletableFuture<Path> future = resourcesLoading.get(resourceURI); throw new CacheResourceDownloadingException(resourceURI, future); } f = downloadResource(resourceURI, resourceCachePath); resourcesLoading.put(resourceURI, f); } if (f.getNow(null) == null) { throw new CacheResourceDownloadingException(resourceURI, f); } return resourceCachePath; } CacheResourcesManager();  CacheResourcesManager(Cache<String, Boolean> cache); }
CacheResourcesManager { public Path getResource(final String resourceURI) throws IOException { Path resourceCachePath = getResourceCachePath(resourceURI); if (Files.exists(resourceCachePath)) { return resourceCachePath; } if (!FilesUtils.isIncludedInDeployedPath(resourceCachePath)) { throw new CacheResourceDownloadingException(resourceURI); } if (unavailableURICache.getIfPresent(resourceURI) != null) { LOGGER.info("Ignored unavailable schema URI: " + resourceURI + "\n"); return null; } CompletableFuture<Path> f = null; synchronized (resourcesLoading) { if (resourcesLoading.containsKey(resourceURI)) { CompletableFuture<Path> future = resourcesLoading.get(resourceURI); throw new CacheResourceDownloadingException(resourceURI, future); } f = downloadResource(resourceURI, resourceCachePath); resourcesLoading.put(resourceURI, f); } if (f.getNow(null) == null) { throw new CacheResourceDownloadingException(resourceURI, f); } return resourceCachePath; } CacheResourcesManager();  CacheResourcesManager(Cache<String, Boolean> cache); Path getResource(final String resourceURI); static Path getResourceCachePath(String resourceURI); static Path getResourceCachePath(URI uri); static Path getResourceCachePath(ResourceToDeploy resource); boolean canUseCache(String url); void setUseCache(boolean useCache); boolean isUseCache(); }
CacheResourcesManager { public Path getResource(final String resourceURI) throws IOException { Path resourceCachePath = getResourceCachePath(resourceURI); if (Files.exists(resourceCachePath)) { return resourceCachePath; } if (!FilesUtils.isIncludedInDeployedPath(resourceCachePath)) { throw new CacheResourceDownloadingException(resourceURI); } if (unavailableURICache.getIfPresent(resourceURI) != null) { LOGGER.info("Ignored unavailable schema URI: " + resourceURI + "\n"); return null; } CompletableFuture<Path> f = null; synchronized (resourcesLoading) { if (resourcesLoading.containsKey(resourceURI)) { CompletableFuture<Path> future = resourcesLoading.get(resourceURI); throw new CacheResourceDownloadingException(resourceURI, future); } f = downloadResource(resourceURI, resourceCachePath); resourcesLoading.put(resourceURI, f); } if (f.getNow(null) == null) { throw new CacheResourceDownloadingException(resourceURI, f); } return resourceCachePath; } CacheResourcesManager();  CacheResourcesManager(Cache<String, Boolean> cache); Path getResource(final String resourceURI); static Path getResourceCachePath(String resourceURI); static Path getResourceCachePath(URI uri); static Path getResourceCachePath(ResourceToDeploy resource); boolean canUseCache(String url); void setUseCache(boolean useCache); boolean isUseCache();  }