@Test public void test_getResource() { String location = "s3: String expectedDescription = "Amazon s3 resource [bucket='bucket', key='path/to/foobar']"; Resource actual = sut.getResource(location); assertThat(actual.getDescription(), is(expectedDescription)); verify(delegate, never()).getResource(anyString()); }
@Override public Resource getResource(String location) { UriComponents components = UriComponentsBuilder.fromUriString(location).build(); if (Objects.equals(components.getScheme(), "s3")) { String bucketName = components.getHost(); if (bucketName == null) { throw new IllegalArgumentException("location must contain host"); } String key = components.getPath(); if (key == null) { throw new IllegalArgumentException("location must contain path"); } if (key.startsWith("/")) { key = key.substring(1); } Optional<String> versionId = Optional.ofNullable(components.getQueryParams()) .flatMap(queryParams -> queryParams.getOrDefault("versionId", Collections.emptyList()).stream() .findFirst()); return new S3ObjectResource(amazonS3, bucketName, key, versionId, taskExecutor); } return delegate.getResource(location); }
S3ObjectResourceLoader implements ResourceLoader, InitializingBean { @Override public Resource getResource(String location) { UriComponents components = UriComponentsBuilder.fromUriString(location).build(); if (Objects.equals(components.getScheme(), "s3")) { String bucketName = components.getHost(); if (bucketName == null) { throw new IllegalArgumentException("location must contain host"); } String key = components.getPath(); if (key == null) { throw new IllegalArgumentException("location must contain path"); } if (key.startsWith("/")) { key = key.substring(1); } Optional<String> versionId = Optional.ofNullable(components.getQueryParams()) .flatMap(queryParams -> queryParams.getOrDefault("versionId", Collections.emptyList()).stream() .findFirst()); return new S3ObjectResource(amazonS3, bucketName, key, versionId, taskExecutor); } return delegate.getResource(location); } }
S3ObjectResourceLoader implements ResourceLoader, InitializingBean { @Override public Resource getResource(String location) { UriComponents components = UriComponentsBuilder.fromUriString(location).build(); if (Objects.equals(components.getScheme(), "s3")) { String bucketName = components.getHost(); if (bucketName == null) { throw new IllegalArgumentException("location must contain host"); } String key = components.getPath(); if (key == null) { throw new IllegalArgumentException("location must contain path"); } if (key.startsWith("/")) { key = key.substring(1); } Optional<String> versionId = Optional.ofNullable(components.getQueryParams()) .flatMap(queryParams -> queryParams.getOrDefault("versionId", Collections.emptyList()).stream() .findFirst()); return new S3ObjectResource(amazonS3, bucketName, key, versionId, taskExecutor); } return delegate.getResource(location); } S3ObjectResourceLoader(AmazonS3 amazonS3, ClassLoader classLoader);  S3ObjectResourceLoader(AmazonS3 amazonS3); }
S3ObjectResourceLoader implements ResourceLoader, InitializingBean { @Override public Resource getResource(String location) { UriComponents components = UriComponentsBuilder.fromUriString(location).build(); if (Objects.equals(components.getScheme(), "s3")) { String bucketName = components.getHost(); if (bucketName == null) { throw new IllegalArgumentException("location must contain host"); } String key = components.getPath(); if (key == null) { throw new IllegalArgumentException("location must contain path"); } if (key.startsWith("/")) { key = key.substring(1); } Optional<String> versionId = Optional.ofNullable(components.getQueryParams()) .flatMap(queryParams -> queryParams.getOrDefault("versionId", Collections.emptyList()).stream() .findFirst()); return new S3ObjectResource(amazonS3, bucketName, key, versionId, taskExecutor); } return delegate.getResource(location); } S3ObjectResourceLoader(AmazonS3 amazonS3, ClassLoader classLoader);  S3ObjectResourceLoader(AmazonS3 amazonS3); @Override void afterPropertiesSet(); @Override Resource getResource(String location); @Override ClassLoader getClassLoader(); }
S3ObjectResourceLoader implements ResourceLoader, InitializingBean { @Override public Resource getResource(String location) { UriComponents components = UriComponentsBuilder.fromUriString(location).build(); if (Objects.equals(components.getScheme(), "s3")) { String bucketName = components.getHost(); if (bucketName == null) { throw new IllegalArgumentException("location must contain host"); } String key = components.getPath(); if (key == null) { throw new IllegalArgumentException("location must contain path"); } if (key.startsWith("/")) { key = key.substring(1); } Optional<String> versionId = Optional.ofNullable(components.getQueryParams()) .flatMap(queryParams -> queryParams.getOrDefault("versionId", Collections.emptyList()).stream() .findFirst()); return new S3ObjectResource(amazonS3, bucketName, key, versionId, taskExecutor); } return delegate.getResource(location); } S3ObjectResourceLoader(AmazonS3 amazonS3, ClassLoader classLoader);  S3ObjectResourceLoader(AmazonS3 amazonS3); @Override void afterPropertiesSet(); @Override Resource getResource(String location); @Override ClassLoader getClassLoader();  }