@Test public void testDeleteContainer() 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 Path container = new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.volume, Path.Type.directory)); container.attributes().setRegion("US"); new S3DirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(container, null, new TransferStatus()); assertTrue(new SpectraFindFeature(session).find(container)); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(container), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
@Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { try { final Map<Path, TransferStatus> filtered = new LinkedHashMap<>(files); for(Iterator<Map.Entry<Path, TransferStatus>> iter = filtered.entrySet().iterator(); iter.hasNext(); ) { final Map.Entry<Path, TransferStatus> file = iter.next(); if(containerService.isContainer(file.getKey())) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteBucketSpectraS3( new DeleteBucketSpectraS3Request(containerService.getContainer(file.getKey()).getName()).withForce(true)); iter.remove(); } else if(file.getKey().isDirectory()) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteFolderRecursivelySpectraS3( new DeleteFolderRecursivelySpectraS3Request( containerService.getContainer(file.getKey()).getName(), containerService.getKey(file.getKey()))); iter.remove(); } } super.delete(filtered, prompt, callback); } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
SpectraDeleteFeature extends S3MultipleDeleteFeature { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { try { final Map<Path, TransferStatus> filtered = new LinkedHashMap<>(files); for(Iterator<Map.Entry<Path, TransferStatus>> iter = filtered.entrySet().iterator(); iter.hasNext(); ) { final Map.Entry<Path, TransferStatus> file = iter.next(); if(containerService.isContainer(file.getKey())) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteBucketSpectraS3( new DeleteBucketSpectraS3Request(containerService.getContainer(file.getKey()).getName()).withForce(true)); iter.remove(); } else if(file.getKey().isDirectory()) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteFolderRecursivelySpectraS3( new DeleteFolderRecursivelySpectraS3Request( containerService.getContainer(file.getKey()).getName(), containerService.getKey(file.getKey()))); iter.remove(); } } super.delete(filtered, prompt, callback); } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
SpectraDeleteFeature extends S3MultipleDeleteFeature { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { try { final Map<Path, TransferStatus> filtered = new LinkedHashMap<>(files); for(Iterator<Map.Entry<Path, TransferStatus>> iter = filtered.entrySet().iterator(); iter.hasNext(); ) { final Map.Entry<Path, TransferStatus> file = iter.next(); if(containerService.isContainer(file.getKey())) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteBucketSpectraS3( new DeleteBucketSpectraS3Request(containerService.getContainer(file.getKey()).getName()).withForce(true)); iter.remove(); } else if(file.getKey().isDirectory()) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteFolderRecursivelySpectraS3( new DeleteFolderRecursivelySpectraS3Request( containerService.getContainer(file.getKey()).getName(), containerService.getKey(file.getKey()))); iter.remove(); } } super.delete(filtered, prompt, callback); } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } SpectraDeleteFeature(final SpectraSession session); }
SpectraDeleteFeature extends S3MultipleDeleteFeature { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { try { final Map<Path, TransferStatus> filtered = new LinkedHashMap<>(files); for(Iterator<Map.Entry<Path, TransferStatus>> iter = filtered.entrySet().iterator(); iter.hasNext(); ) { final Map.Entry<Path, TransferStatus> file = iter.next(); if(containerService.isContainer(file.getKey())) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteBucketSpectraS3( new DeleteBucketSpectraS3Request(containerService.getContainer(file.getKey()).getName()).withForce(true)); iter.remove(); } else if(file.getKey().isDirectory()) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteFolderRecursivelySpectraS3( new DeleteFolderRecursivelySpectraS3Request( containerService.getContainer(file.getKey()).getName(), containerService.getKey(file.getKey()))); iter.remove(); } } super.delete(filtered, prompt, callback); } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } SpectraDeleteFeature(final SpectraSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isRecursive(); }
SpectraDeleteFeature extends S3MultipleDeleteFeature { @Override public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException { try { final Map<Path, TransferStatus> filtered = new LinkedHashMap<>(files); for(Iterator<Map.Entry<Path, TransferStatus>> iter = filtered.entrySet().iterator(); iter.hasNext(); ) { final Map.Entry<Path, TransferStatus> file = iter.next(); if(containerService.isContainer(file.getKey())) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteBucketSpectraS3( new DeleteBucketSpectraS3Request(containerService.getContainer(file.getKey()).getName()).withForce(true)); iter.remove(); } else if(file.getKey().isDirectory()) { final Ds3Client client = new SpectraClientBuilder().wrap(session.getClient(), session.getHost()); client.deleteFolderRecursivelySpectraS3( new DeleteFolderRecursivelySpectraS3Request( containerService.getContainer(file.getKey()).getName(), containerService.getKey(file.getKey()))); iter.remove(); } } super.delete(filtered, prompt, callback); } catch(FailedRequestException e) { throw new SpectraExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } SpectraDeleteFeature(final SpectraSession session); @Override void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback); @Override boolean isRecursive();  }