001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.data.imagery;
003
004import java.util.Map;
005import java.util.concurrent.ThreadPoolExecutor;
006
007import org.apache.commons.jcs.access.behavior.ICacheAccess;
008import org.openstreetmap.gui.jmapviewer.Tile;
009import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener;
010import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
011
012/**
013 * Separate class to handle WMS jobs, as it needs to react differently to HTTP response codes from WMS server
014 *
015 * @author Wiktor Niesiobędzki
016 * @since 8526
017 */
018public class WMSCachedTileLoaderJob extends TMSCachedTileLoaderJob {
019
020    /**
021     * Creates a job - that will download specific tile
022     * @param listener will be notified, when tile has loaded
023     * @param tile to load
024     * @param cache to use (get/put)
025     * @param connectTimeout to tile source
026     * @param readTimeout to tile source
027     * @param headers to be sent with request
028     * @param downloadExecutor that will execute the download task (if needed)
029     */
030    public WMSCachedTileLoaderJob(TileLoaderListener listener, Tile tile,
031            ICacheAccess<String, BufferedImageCacheEntry> cache, int connectTimeout, int readTimeout,
032            Map<String, String> headers, ThreadPoolExecutor downloadExecutor) {
033        super(listener, tile, cache, connectTimeout, readTimeout, headers, downloadExecutor);
034    }
035
036    @Override
037    public String getCacheKey() {
038        // include projection in cache key, as with different projections different response will be returned from server
039        String key = super.getCacheKey();
040        if (key != null) {
041            return key + tile.getSource().getServerCRS();
042        }
043        return null;
044    }
045}