@Override
    public File saveObjectToFile(S3URI s3uri, File file) throws IOException {
    """
	{@inheritDoc}
	<p>
	WARNING: If the content at {@code s3uri} was previously saved using this method, and the old file to which it was
	saved is <b>not</b> the same as {@code file}, the object content will be copied to the new file and the old file
	will be deleted.
    """
        Optional<File> cachedFile = objectFileCache.getIfPresent(s3uri);

        if (cachedFile == null) {
            logger.debug("Object cache MISS: '%s'", s3uri);
            // Do download below.
        } else {
            logger.debug("Object cache hit: '%s'", s3uri);

            if (!cachedFile.isPresent()) {
                return null;
            } else if (!cachedFile.get().exists()) {
                logger.info(String.format("Found cache entry {'%s'-->'%s'}, but local file doesn't exist. " +
                        "Was it deleted? Re-downloading.", s3uri, cachedFile.get()));
                objectFileCache.invalidate(s3uri);  // Evict old entry. Re-download below.
            } else if (!cachedFile.get().equals(file)) {
                // Copy content of cachedFile to file. Evict cachedFile from the cache.
                Files.copy(cachedFile.get(), file);
                objectFileCache.put(s3uri, Optional.of(file));
                return file;
            } else {
                return file;  // File already contains the content of the object at s3uri.
            }
        }

        cachedFile = Optional.fromNullable(threddsS3Client.saveObjectToFile(s3uri, file));
        objectFileCache.put(s3uri, cachedFile);
        return cachedFile.orNull();
    }
@Override
    public File saveObjectToFile(S3URI s3uri, File file) throws IOException {
        Optional<File> cachedFile = objectFileCache.getIfPresent(s3uri);

        if (cachedFile == null) {
            logger.debug("Object cache MISS: '%s'", s3uri);
            // Do download below.
        } else {
            logger.debug("Object cache hit: '%s'", s3uri);

            if (!cachedFile.isPresent()) {
                return null;
            } else if (!cachedFile.get().exists()) {
                logger.info(String.format("Found cache entry {'%s'-->'%s'}, but local file doesn't exist. " +
                        "Was it deleted? Re-downloading.", s3uri, cachedFile.get()));
                objectFileCache.invalidate(s3uri);  // Evict old entry. Re-download below.
            } else if (!cachedFile.get().equals(file)) {
                // Copy content of cachedFile to file. Evict cachedFile from the cache.
                Files.copy(cachedFile.get(), file);
                objectFileCache.put(s3uri, Optional.of(file));
                return file;
            } else {
                return file;  // File already contains the content of the object at s3uri.
            }
        }

        cachedFile = Optional.fromNullable(threddsS3Client.saveObjectToFile(s3uri, file));
        objectFileCache.put(s3uri, cachedFile);
        return cachedFile.orNull();
    }
@ Override public File saveObjectToFile ( S3URI s3uri , File file ) throws IOException { Optional < File > cachedFile = objectFileCache . getIfPresent ( s3uri ) ; if ( cachedFile == null ) { logger . debug ( "Object cache MISS: '%s'" , s3uri ) ; // Do download below. } else { logger . debug ( "Object cache hit: '%s'" , s3uri ) ; if ( ! cachedFile . isPresent ( ) ) { return null ; } else if ( ! cachedFile . get ( ) . exists ( ) ) { logger . info ( String . format ( "Found cache entry {'%s'-->'%s'}, but local file doesn't exist. " + "Was it deleted? Re-downloading." , s3uri , cachedFile . get ( ) ) ) ; objectFileCache . invalidate ( s3uri ) ; // Evict old entry. Re-download below. } else if ( ! cachedFile . get ( ) . equals ( file ) ) { // Copy content of cachedFile to file. Evict cachedFile from the cache. Files . copy ( cachedFile . get ( ) , file ) ; objectFileCache . put ( s3uri , Optional . of ( file ) ) ; return file ; } else { return file ; // File already contains the content of the object at s3uri. } } cachedFile = Optional . fromNullable ( threddsS3Client . saveObjectToFile ( s3uri , file ) ) ; objectFileCache . put ( s3uri , cachedFile ) ; return cachedFile . orNull ( ) ; }
{@inheritDoc}
<p>
WARNING: If the content at {@code s3uri} was previously saved using this method, and the old file to which it was
saved is <b>not</b> the same as {@code file}, the object content will be copied to the new file and the old file
will be deleted.
{