private Dashboard getDashboard(
DashboardWcdfDescriptor wcdf,
String cdeFilePath,
boolean bypassCacheRead )
throws ThingReadException {
Dashboard cachedDash = null;
if ( !bypassCacheRead ) {
cachedDash = this.getDashboardFromCache( cdeFilePath );
if ( cachedDash == null ) {
_logger.debug( "Dashboard instance is not in cache, reading from repository." );
}
} else {
_logger.info( "Bypassing Dashboard instance cache, reading from repository." );
}
IReadAccess userAccess = Utils.getSystemOrUserReadAccess( cdeFilePath );
// Read cache, cache item existed and it is valid?
if ( cachedDash != null
&& cachedDash.getSourceDate().getTime() >= userAccess.getLastModified( cdeFilePath ) ) {
// Check WCDF file date as well
if ( !userAccess.fileExists( wcdf.getPath() ) ) {
throw new ThingReadException( new FileNotFoundException( wcdf.getPath() ) );
}
if ( cachedDash.getSourceDate().getTime() >= userAccess.getLastModified( wcdf.getPath() ) ) {
_logger.debug( "Cached Dashboard instance is valid, using it." );
return cachedDash;
}
}
if ( cachedDash != null ) {
_logger.info( "Cached Dashboard instance invalidated, reading from repository." );
}
Dashboard newDash = this.readDashboardFromCdfdeJs( wcdf );
return this.replaceDashboardInCache( cdeFilePath, newDash, cachedDash );
}