@Test(expected = NotfoundException.class) public void testReadNotFound() throws Exception { new S3LoggingFeature(session).getConfiguration( new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)) ); }
@Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } if(file.getType().contains(Path.Type.upload)) { return LoggingConfiguration.empty(); } try { final StorageBucketLoggingStatus status = session.getClient().getBucketLoggingStatusImpl(bucket.getName()); final LoggingConfiguration configuration = new LoggingConfiguration(status.isLoggingEnabled(), status.getTargetBucketName()); try { configuration.setContainers(new S3BucketListService(session, new S3LocationFeature.S3Region(session.getHost().getRegion())).list( new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener()).toList()); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Failure listing buckets. %s", e.getMessage())); } return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } }
S3LoggingFeature implements Logging { @Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } if(file.getType().contains(Path.Type.upload)) { return LoggingConfiguration.empty(); } try { final StorageBucketLoggingStatus status = session.getClient().getBucketLoggingStatusImpl(bucket.getName()); final LoggingConfiguration configuration = new LoggingConfiguration(status.isLoggingEnabled(), status.getTargetBucketName()); try { configuration.setContainers(new S3BucketListService(session, new S3LocationFeature.S3Region(session.getHost().getRegion())).list( new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener()).toList()); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Failure listing buckets. %s", e.getMessage())); } return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } } }
S3LoggingFeature implements Logging { @Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } if(file.getType().contains(Path.Type.upload)) { return LoggingConfiguration.empty(); } try { final StorageBucketLoggingStatus status = session.getClient().getBucketLoggingStatusImpl(bucket.getName()); final LoggingConfiguration configuration = new LoggingConfiguration(status.isLoggingEnabled(), status.getTargetBucketName()); try { configuration.setContainers(new S3BucketListService(session, new S3LocationFeature.S3Region(session.getHost().getRegion())).list( new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener()).toList()); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Failure listing buckets. %s", e.getMessage())); } return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } } S3LoggingFeature(final S3Session session); }
S3LoggingFeature implements Logging { @Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } if(file.getType().contains(Path.Type.upload)) { return LoggingConfiguration.empty(); } try { final StorageBucketLoggingStatus status = session.getClient().getBucketLoggingStatusImpl(bucket.getName()); final LoggingConfiguration configuration = new LoggingConfiguration(status.isLoggingEnabled(), status.getTargetBucketName()); try { configuration.setContainers(new S3BucketListService(session, new S3LocationFeature.S3Region(session.getHost().getRegion())).list( new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener()).toList()); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Failure listing buckets. %s", e.getMessage())); } return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } } S3LoggingFeature(final S3Session session); @Override LoggingConfiguration getConfiguration(final Path file); @Override void setConfiguration(final Path file, final LoggingConfiguration configuration); }
S3LoggingFeature implements Logging { @Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } if(file.getType().contains(Path.Type.upload)) { return LoggingConfiguration.empty(); } try { final StorageBucketLoggingStatus status = session.getClient().getBucketLoggingStatusImpl(bucket.getName()); final LoggingConfiguration configuration = new LoggingConfiguration(status.isLoggingEnabled(), status.getTargetBucketName()); try { configuration.setContainers(new S3BucketListService(session, new S3LocationFeature.S3Region(session.getHost().getRegion())).list( new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener()).toList()); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Failure listing buckets. %s", e.getMessage())); } return configuration; } catch(ServiceException e) { try { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } } S3LoggingFeature(final S3Session session); @Override LoggingConfiguration getConfiguration(final Path file); @Override void setConfiguration(final Path file, final LoggingConfiguration configuration);  }