@Test(expected = NotfoundException.class) public void testReadNotFound() throws Exception { new GoogleStorageLoggingFeature(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(); } 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);  }