@Test public void testGetConfiguration() throws Exception { final GoogleStorageLoggingFeature feature = new GoogleStorageLoggingFeature(session); final Path bucket = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); feature.setConfiguration(bucket, new LoggingConfiguration(true, "test.cyberduck.ch")); final LoggingConfiguration configuration = feature.getConfiguration(bucket); assertNotNull(configuration); assertEquals("test.cyberduck.ch", configuration.getLoggingTarget()); assertTrue(configuration.isEnabled()); }
@Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } try { final Bucket.Logging status = session.getClient().buckets().get(bucket.getName()).execute().getLogging(); if(null == status) { return LoggingConfiguration.empty(); } final LoggingConfiguration configuration = new LoggingConfiguration( status.getLogObjectPrefix() != null, status.getLogBucket()); try { configuration.setContainers(new GoogleStorageBucketListService(session).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(IOException e) { try { throw new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, bucket); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } }
GoogleStorageLoggingFeature implements Logging, DistributionLogging { @Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } try { final Bucket.Logging status = session.getClient().buckets().get(bucket.getName()).execute().getLogging(); if(null == status) { return LoggingConfiguration.empty(); } final LoggingConfiguration configuration = new LoggingConfiguration( status.getLogObjectPrefix() != null, status.getLogBucket()); try { configuration.setContainers(new GoogleStorageBucketListService(session).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(IOException e) { try { throw new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, bucket); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } } }
GoogleStorageLoggingFeature implements Logging, DistributionLogging { @Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } try { final Bucket.Logging status = session.getClient().buckets().get(bucket.getName()).execute().getLogging(); if(null == status) { return LoggingConfiguration.empty(); } final LoggingConfiguration configuration = new LoggingConfiguration( status.getLogObjectPrefix() != null, status.getLogBucket()); try { configuration.setContainers(new GoogleStorageBucketListService(session).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(IOException e) { try { throw new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, bucket); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } } GoogleStorageLoggingFeature(final GoogleStorageSession session); }
GoogleStorageLoggingFeature implements Logging, DistributionLogging { @Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } try { final Bucket.Logging status = session.getClient().buckets().get(bucket.getName()).execute().getLogging(); if(null == status) { return LoggingConfiguration.empty(); } final LoggingConfiguration configuration = new LoggingConfiguration( status.getLogObjectPrefix() != null, status.getLogBucket()); try { configuration.setContainers(new GoogleStorageBucketListService(session).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(IOException e) { try { throw new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, bucket); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } } GoogleStorageLoggingFeature(final GoogleStorageSession session); @Override LoggingConfiguration getConfiguration(final Path file); @Override void setConfiguration(final Path container, final LoggingConfiguration configuration); }
GoogleStorageLoggingFeature implements Logging, DistributionLogging { @Override public LoggingConfiguration getConfiguration(final Path file) throws BackgroundException { final Path bucket = containerService.getContainer(file); if(bucket.isRoot()) { return LoggingConfiguration.empty(); } try { final Bucket.Logging status = session.getClient().buckets().get(bucket.getName()).execute().getLogging(); if(null == status) { return LoggingConfiguration.empty(); } final LoggingConfiguration configuration = new LoggingConfiguration( status.getLogObjectPrefix() != null, status.getLogBucket()); try { configuration.setContainers(new GoogleStorageBucketListService(session).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(IOException e) { try { throw new GoogleStorageExceptionMappingService().map("Failure to read attributes of {0}", e, bucket); } catch(AccessDeniedException | InteroperabilityException l) { log.warn(String.format("Missing permission to read logging configuration for %s %s", bucket.getName(), e.getMessage())); return LoggingConfiguration.empty(); } } } GoogleStorageLoggingFeature(final GoogleStorageSession session); @Override LoggingConfiguration getConfiguration(final Path file); @Override void setConfiguration(final Path container, final LoggingConfiguration configuration);  }