@Test public void testSetConfiguration() throws Exception { final Path bucket = new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)); final B2FileidProvider fileid = new B2FileidProvider(session).withCache(cache); new B2DirectoryFeature(session, fileid).mkdir(bucket, null, new TransferStatus()); assertEquals(LifecycleConfiguration.empty(), new B2LifecycleFeature(session, fileid).getConfiguration(bucket)); new B2LifecycleFeature(session, fileid).setConfiguration(bucket, new LifecycleConfiguration(1, null, 30)); final LifecycleConfiguration configuration = new B2LifecycleFeature(session, fileid).getConfiguration(bucket); assertEquals(30, configuration.getExpiration(), 0L); assertEquals(1, configuration.getTransition(), 0L); new B2LifecycleFeature(session, fileid).setConfiguration(bucket, LifecycleConfiguration.empty()); assertEquals(LifecycleConfiguration.empty(), new B2LifecycleFeature(session, fileid).getConfiguration(bucket)); new B2DeleteFeature(session, fileid).delete(Collections.singletonList(bucket), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public void setConfiguration(final Path container, final LifecycleConfiguration configuration) throws BackgroundException { try { if(LifecycleConfiguration.empty().equals(configuration)) { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()) ); } else { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()), new LifecycleRule( null == configuration.getExpiration() ? null : configuration.getExpiration().longValue(), null == configuration.getTransition() ? null : configuration.getTransition().longValue(), StringUtils.EMPTY) ); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Failure to write attributes of {0}", e, container); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to write attributes of {0}", e, container); } }
B2LifecycleFeature implements Lifecycle { @Override public void setConfiguration(final Path container, final LifecycleConfiguration configuration) throws BackgroundException { try { if(LifecycleConfiguration.empty().equals(configuration)) { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()) ); } else { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()), new LifecycleRule( null == configuration.getExpiration() ? null : configuration.getExpiration().longValue(), null == configuration.getTransition() ? null : configuration.getTransition().longValue(), StringUtils.EMPTY) ); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Failure to write attributes of {0}", e, container); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to write attributes of {0}", e, container); } } }
B2LifecycleFeature implements Lifecycle { @Override public void setConfiguration(final Path container, final LifecycleConfiguration configuration) throws BackgroundException { try { if(LifecycleConfiguration.empty().equals(configuration)) { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()) ); } else { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()), new LifecycleRule( null == configuration.getExpiration() ? null : configuration.getExpiration().longValue(), null == configuration.getTransition() ? null : configuration.getTransition().longValue(), StringUtils.EMPTY) ); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Failure to write attributes of {0}", e, container); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to write attributes of {0}", e, container); } } B2LifecycleFeature(final B2Session session, final B2FileidProvider fileid); }
B2LifecycleFeature implements Lifecycle { @Override public void setConfiguration(final Path container, final LifecycleConfiguration configuration) throws BackgroundException { try { if(LifecycleConfiguration.empty().equals(configuration)) { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()) ); } else { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()), new LifecycleRule( null == configuration.getExpiration() ? null : configuration.getExpiration().longValue(), null == configuration.getTransition() ? null : configuration.getTransition().longValue(), StringUtils.EMPTY) ); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Failure to write attributes of {0}", e, container); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to write attributes of {0}", e, container); } } B2LifecycleFeature(final B2Session session, final B2FileidProvider fileid); @Override LifecycleConfiguration getConfiguration(final Path container); @Override void setConfiguration(final Path container, final LifecycleConfiguration configuration); }
B2LifecycleFeature implements Lifecycle { @Override public void setConfiguration(final Path container, final LifecycleConfiguration configuration) throws BackgroundException { try { if(LifecycleConfiguration.empty().equals(configuration)) { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()) ); } else { session.getClient().updateBucket( fileid.getFileid(containerService.getContainer(container), new DisabledListProgressListener()), new B2BucketTypeFeature(session, fileid).convert(container.attributes().getAcl()), new LifecycleRule( null == configuration.getExpiration() ? null : configuration.getExpiration().longValue(), null == configuration.getTransition() ? null : configuration.getTransition().longValue(), StringUtils.EMPTY) ); } } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Failure to write attributes of {0}", e, container); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to write attributes of {0}", e, container); } } B2LifecycleFeature(final B2Session session, final B2FileidProvider fileid); @Override LifecycleConfiguration getConfiguration(final Path container); @Override void setConfiguration(final Path container, final LifecycleConfiguration configuration);  }