Search in sources :

Example 1 with LifecycleRule

use of synapticloop.b2.LifecycleRule in project cyberduck by iterate-ch.

the class B2LifecycleFeature method getConfiguration.

@Override
public LifecycleConfiguration getConfiguration(final Path container) throws BackgroundException {
    try {
        final B2BucketResponse response = session.getClient().listBucket(containerService.getContainer(container).getName());
        final List<LifecycleRule> lifecycleRules = response.getLifecycleRules();
        for (LifecycleRule rule : lifecycleRules) {
            return new LifecycleConfiguration(null == rule.getDaysFromUploadingToHiding() ? null : rule.getDaysFromUploadingToHiding().intValue(), null == rule.getDaysFromHidingToDeleting() ? null : rule.getDaysFromHidingToDeleting().intValue());
        }
        return LifecycleConfiguration.empty();
    } catch (B2ApiException e) {
        throw new B2ExceptionMappingService(fileid).map("Failure to write attributes of {0}", e, container);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map("Failure to write attributes of {0}", e, container);
    }
}
Also used : B2BucketResponse(synapticloop.b2.response.B2BucketResponse) LifecycleConfiguration(ch.cyberduck.core.lifecycle.LifecycleConfiguration) B2ApiException(synapticloop.b2.exception.B2ApiException) IOException(java.io.IOException) DefaultIOExceptionMappingService(ch.cyberduck.core.DefaultIOExceptionMappingService) LifecycleRule(synapticloop.b2.LifecycleRule)

Aggregations

DefaultIOExceptionMappingService (ch.cyberduck.core.DefaultIOExceptionMappingService)1 LifecycleConfiguration (ch.cyberduck.core.lifecycle.LifecycleConfiguration)1 IOException (java.io.IOException)1 LifecycleRule (synapticloop.b2.LifecycleRule)1 B2ApiException (synapticloop.b2.exception.B2ApiException)1 B2BucketResponse (synapticloop.b2.response.B2BucketResponse)1