Example usage for com.amazonaws.services.s3.model DeleteObjectsRequest setQuiet

List of usage examples for com.amazonaws.services.s3.model DeleteObjectsRequest setQuiet

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model DeleteObjectsRequest setQuiet.

Prototype

public void setQuiet(boolean quiet) 

Source Link

Document

Sets the quiet element for this request.

Usage

From source file:org.geowebcache.s3.S3BlobStore.java

License:Open Source License

@Override
public boolean delete(final TileRange tileRange) throws StorageException {

    final String coordsPrefix = keyBuilder.coordinatesPrefix(tileRange);
    if (!s3Ops.prefixExists(coordsPrefix)) {
        return false;
    }//from w  ww  .j av a 2 s. co  m

    final Iterator<long[]> tileLocations = new AbstractIterator<long[]>() {

        // TileRange iterator with 1x1 meta tiling factor
        private TileRangeIterator trIter = new TileRangeIterator(tileRange, new int[] { 1, 1 });

        @Override
        protected long[] computeNext() {
            long[] gridLoc = trIter.nextMetaGridLocation(new long[3]);
            return gridLoc == null ? endOfData() : gridLoc;
        }
    };

    if (listeners.isEmpty()) {
        // if there are no listeners, don't bother requesting every tile
        // metadata to notify the listeners
        Iterator<List<long[]>> partition = Iterators.partition(tileLocations, 1000);
        final TileToKey tileToKey = new TileToKey(coordsPrefix, tileRange.getMimeType());

        while (partition.hasNext() && !shutDown) {
            List<long[]> locations = partition.next();
            List<KeyVersion> keys = Lists.transform(locations, tileToKey);

            DeleteObjectsRequest req = new DeleteObjectsRequest(bucketName);
            req.setQuiet(true);
            req.setKeys(keys);
            conn.deleteObjects(req);
        }

    } else {
        long[] xyz;
        String layerName = tileRange.getLayerName();
        String gridSetId = tileRange.getGridSetId();
        String format = tileRange.getMimeType().getFormat();
        Map<String, String> parameters = tileRange.getParameters();

        while (tileLocations.hasNext()) {
            xyz = tileLocations.next();
            TileObject tile = TileObject.createQueryTileObject(layerName, xyz, gridSetId, format, parameters);
            tile.setParametersId(tileRange.getParametersId());
            delete(tile);
        }
    }

    return true;
}