in src/main/java/org/apache/maven/doxia/linkcheck/validation/LinkValidatorManager.java [234:277]
public void saveCache( File cacheFile )
throws IOException
{
if ( cacheFile == null )
{
LOG.warn( "No cache file specified! Ignoring request to store results." );
return;
}
if ( cacheFile.isDirectory() )
{
LOG.debug( "Cache file is a directory! Ignoring request to load." );
return;
}
// Remove non-persistent items from cache
Map<Object, LinkValidationResult> persistentCache = new HashMap<Object, LinkValidationResult>();
for ( Map.Entry<Object, LinkValidationResult> resource : this.cache.entrySet() )
{
if ( resource.getValue().isPersistent() )
{
persistentCache.put( resource.getKey(), resource.getValue() );
if ( LOG.isDebugEnabled() )
{
LOG.debug( "[" + resource.getKey() + "] with result [" + resource.getValue()
+ "] is stored in the cache." );
}
}
}
File dir = cacheFile.getParentFile();
if ( dir != null )
{
dir.mkdirs();
}
try ( ObjectOutputStream os = new ObjectOutputStream( new FileOutputStream( cacheFile ) ) )
{
os.writeObject( persistentCache );
}
}