public void delete(final Map<Path, TransferStatus> files, final PasswordCallback prompt, final Callback callback) throws BackgroundException {
        final List<Path> containers = new ArrayList<>();
        for(Path file : files.keySet()) {
            if(containerService.isContainer(file)) {
                containers.add(file);
            }
            else {
                callback.delete(file);
                final Path bucket = containerService.getContainer(file);
                if(file.getType().contains(Path.Type.upload)) {
                    // In-progress multipart upload
                    try {
                        multipartService.delete(new MultipartUpload(file.attributes().getVersionId(),
                                bucket.isRoot() ? StringUtils.EMPTY : bucket.getName(), containerService.getKey(file)));
                    }
                    catch(NotfoundException ignored) {
                        log.warn(String.format("Ignore failure deleting multipart upload %s", file));
                    }
                }
                else {
                    try {
                        // Always returning 204 even if the key does not exist. Does not return 404 for non-existing keys
                        session.getClient().deleteVersionedObject(
                                file.attributes().getVersionId(), bucket.isRoot() ? StringUtils.EMPTY : bucket.getName(), containerService.getKey(file));
                    }
                    catch(ServiceException e) {
                        throw new S3ExceptionMappingService().map("Cannot delete {0}", e, file);
                    }
                }
            }
        }
        for(Path file : containers) {
            callback.delete(file);
            try {
                final String bucket = containerService.getContainer(file).getName();
                session.getClient().deleteBucket(bucket);
                session.getClient().getRegionEndpointCache().removeRegionForBucketName(bucket);
            }
            catch(ServiceException e) {
                throw new S3ExceptionMappingService().map("Cannot delete {0}", e, file);
            }
        }
    }
@Test(expected = NotfoundException.class)
    public void testDeleteNotFoundBucketDnsNameCompatible() throws Exception {
        final Path container = new Path(new AlphanumericRandomStringService().random().toLowerCase(), EnumSet.of(Path.Type.directory, Path.Type.volume));
        new S3DefaultDeleteFeature(session).delete(Collections.singletonList(container), new DisabledLoginCallback(), new Delete.DisabledCallback());
    }