@Test public void testListWithRootDefaultPath() throws Exception { final Host host = new Host(new SpectraProtocol() { @Override public Scheme getScheme() { return Scheme.http; } }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials( System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key") )); final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final AttributedList<Path> list = new SpectraBucketListService(session).list( new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener()); assertFalse(list.isEmpty()); assertTrue(list.contains(new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)))); session.close(); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); final GetServiceResponse response = client.getService(new GetServiceRequest()); for(final BucketDetails b : response.getListAllMyBucketsResult().getBuckets()) { final Path bucket = new Path(PathNormalizer.normalize(b.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory)); bucket.attributes().setCreationDate(b.getCreationDate().getTime()); buckets.add(bucket); } return buckets; } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e, directory); } }
SpectraBucketListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); final GetServiceResponse response = client.getService(new GetServiceRequest()); for(final BucketDetails b : response.getListAllMyBucketsResult().getBuckets()) { final Path bucket = new Path(PathNormalizer.normalize(b.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory)); bucket.attributes().setCreationDate(b.getCreationDate().getTime()); buckets.add(bucket); } return buckets; } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e, directory); } } }
SpectraBucketListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); final GetServiceResponse response = client.getService(new GetServiceRequest()); for(final BucketDetails b : response.getListAllMyBucketsResult().getBuckets()) { final Path bucket = new Path(PathNormalizer.normalize(b.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory)); bucket.attributes().setCreationDate(b.getCreationDate().getTime()); buckets.add(bucket); } return buckets; } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e, directory); } } SpectraBucketListService(final SpectraSession session); }
SpectraBucketListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); final GetServiceResponse response = client.getService(new GetServiceRequest()); for(final BucketDetails b : response.getListAllMyBucketsResult().getBuckets()) { final Path bucket = new Path(PathNormalizer.normalize(b.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory)); bucket.attributes().setCreationDate(b.getCreationDate().getTime()); buckets.add(bucket); } return buckets; } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e, directory); } } SpectraBucketListService(final SpectraSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
SpectraBucketListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); final GetServiceResponse response = client.getService(new GetServiceRequest()); for(final BucketDetails b : response.getListAllMyBucketsResult().getBuckets()) { final Path bucket = new Path(PathNormalizer.normalize(b.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory)); bucket.attributes().setCreationDate(b.getCreationDate().getTime()); buckets.add(bucket); } return buckets; } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e, directory); } } SpectraBucketListService(final SpectraSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }