@Test public void testGetConfigurationEnabled() throws Exception { final VersioningConfiguration configuration = new S3VersioningFeature(session, new S3AccessControlListFeature(session)).getConfiguration(new Path("versioning-test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume))); assertNotNull(configuration); assertTrue(configuration.isEnabled()); }
@Override public VersioningConfiguration getConfiguration(final Path file) throws BackgroundException { final Path container = containerService.getContainer(file); if(container.isRoot()) { return VersioningConfiguration.empty(); } if(cache.contains(container)) { return cache.get(container); } try { final S3BucketVersioningStatus status = session.getClient().getBucketVersioningStatus(container.getName()); final VersioningConfiguration configuration = new VersioningConfiguration(status.isVersioningEnabled(), status.isMultiFactorAuthDeleteRequired()); cache.put(container, configuration); return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Cannot read container configuration", e); } catch(AccessDeniedException l) { log.warn(String.format("Missing permission to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } catch(InteroperabilityException i) { log.warn(String.format("Not supported to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } } }
S3VersioningFeature implements Versioning { @Override public VersioningConfiguration getConfiguration(final Path file) throws BackgroundException { final Path container = containerService.getContainer(file); if(container.isRoot()) { return VersioningConfiguration.empty(); } if(cache.contains(container)) { return cache.get(container); } try { final S3BucketVersioningStatus status = session.getClient().getBucketVersioningStatus(container.getName()); final VersioningConfiguration configuration = new VersioningConfiguration(status.isVersioningEnabled(), status.isMultiFactorAuthDeleteRequired()); cache.put(container, configuration); return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Cannot read container configuration", e); } catch(AccessDeniedException l) { log.warn(String.format("Missing permission to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } catch(InteroperabilityException i) { log.warn(String.format("Not supported to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } } } }
S3VersioningFeature implements Versioning { @Override public VersioningConfiguration getConfiguration(final Path file) throws BackgroundException { final Path container = containerService.getContainer(file); if(container.isRoot()) { return VersioningConfiguration.empty(); } if(cache.contains(container)) { return cache.get(container); } try { final S3BucketVersioningStatus status = session.getClient().getBucketVersioningStatus(container.getName()); final VersioningConfiguration configuration = new VersioningConfiguration(status.isVersioningEnabled(), status.isMultiFactorAuthDeleteRequired()); cache.put(container, configuration); return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Cannot read container configuration", e); } catch(AccessDeniedException l) { log.warn(String.format("Missing permission to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } catch(InteroperabilityException i) { log.warn(String.format("Not supported to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } } } S3VersioningFeature(final S3Session session, final S3AccessControlListFeature accessControlListFeature); }
S3VersioningFeature implements Versioning { @Override public VersioningConfiguration getConfiguration(final Path file) throws BackgroundException { final Path container = containerService.getContainer(file); if(container.isRoot()) { return VersioningConfiguration.empty(); } if(cache.contains(container)) { return cache.get(container); } try { final S3BucketVersioningStatus status = session.getClient().getBucketVersioningStatus(container.getName()); final VersioningConfiguration configuration = new VersioningConfiguration(status.isVersioningEnabled(), status.isMultiFactorAuthDeleteRequired()); cache.put(container, configuration); return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Cannot read container configuration", e); } catch(AccessDeniedException l) { log.warn(String.format("Missing permission to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } catch(InteroperabilityException i) { log.warn(String.format("Not supported to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } } } S3VersioningFeature(final S3Session session, final S3AccessControlListFeature accessControlListFeature); @Override S3VersioningFeature withCache(final LRUCache<Path, VersioningConfiguration> cache); @Override void setConfiguration(final Path file, final PasswordCallback prompt, final VersioningConfiguration configuration); @Override VersioningConfiguration getConfiguration(final Path file); @Override void revert(final Path file); @Override boolean isRevertable(final Path file); @Override Credentials getToken(final String mfaSerial, final PasswordCallback callback); }
S3VersioningFeature implements Versioning { @Override public VersioningConfiguration getConfiguration(final Path file) throws BackgroundException { final Path container = containerService.getContainer(file); if(container.isRoot()) { return VersioningConfiguration.empty(); } if(cache.contains(container)) { return cache.get(container); } try { final S3BucketVersioningStatus status = session.getClient().getBucketVersioningStatus(container.getName()); final VersioningConfiguration configuration = new VersioningConfiguration(status.isVersioningEnabled(), status.isMultiFactorAuthDeleteRequired()); cache.put(container, configuration); return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Cannot read container configuration", e); } catch(AccessDeniedException l) { log.warn(String.format("Missing permission to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } catch(InteroperabilityException i) { log.warn(String.format("Not supported to read versioning configuration for %s %s", container, e.getMessage())); return VersioningConfiguration.empty(); } } } S3VersioningFeature(final S3Session session, final S3AccessControlListFeature accessControlListFeature); @Override S3VersioningFeature withCache(final LRUCache<Path, VersioningConfiguration> cache); @Override void setConfiguration(final Path file, final PasswordCallback prompt, final VersioningConfiguration configuration); @Override VersioningConfiguration getConfiguration(final Path file); @Override void revert(final Path file); @Override boolean isRevertable(final Path file); @Override Credentials getToken(final String mfaSerial, final PasswordCallback callback);  }