@Override public long lastModifiedTime( File file ) { return delegate.lastModifiedTime( file ); }
@Override public long lastModifiedTime( File file ) { return fs.lastModifiedTime( file ); }
@Override public ListSnapshot<User> getPersistedSnapshot() throws IOException { if ( lastLoaded.get() < fileSystem.lastModifiedTime( authFile ) ) { return readPersistedUsers(); } synchronized ( this ) { return new ListSnapshot<>( lastLoaded.get(), new ArrayList<>( users ), FROM_MEMORY ); } }
@Override public long lastModifiedTime( File file ) { adversary.injectFailure( SecurityException.class, NullPointerException.class ); return delegate.lastModifiedTime( file ); }
@Override public long lastModifiedTime( File file ) { return chooseFileSystem( file ).lastModifiedTime( file ); }
@Override protected ListSnapshot<User> readPersistedUsers() throws IOException { if ( fileSystem.fileExists( authFile ) ) { long readTime; List<User> readUsers; try { readTime = fileSystem.lastModifiedTime( authFile ); readUsers = serialization.loadRecordsFromFile( fileSystem, authFile ); } catch ( FormatException e ) { log.error( "Failed to read authentication file \"%s\" (%s)", authFile.getAbsolutePath(), e.getMessage() ); throw new IllegalStateException( "Failed to read authentication file: " + authFile ); } return new ListSnapshot<>( readTime, readUsers, FROM_PERSISTED ); } return null; }
@Test void lastModifiedOfNonExistingFileIsZero() { assertThat( fsa.lastModifiedTime( nonExistingFile( "blabla" ) ), is( 0L ) ); }
@Override public ListSnapshot<User> getPersistedSnapshot() throws IOException { if ( lastLoaded.get() < fileSystem.lastModifiedTime( authFile ) ) { return readPersistedUsers(); } synchronized ( this ) { return new ListSnapshot<>( lastLoaded.get(), new ArrayList<>( users ), FROM_MEMORY ); } }
@Override public ListSnapshot<RoleRecord> getPersistedSnapshot() throws IOException { if ( lastLoaded.get() < fileSystem.lastModifiedTime( roleFile ) ) { return readPersistedRoles(); } synchronized ( this ) { return new ListSnapshot<>( lastLoaded.get(), new ArrayList<>( roles ), FROM_MEMORY ); } } }
@Override protected ListSnapshot<RoleRecord> readPersistedRoles() throws IOException { if ( fileSystem.fileExists( roleFile ) ) { long readTime; List<RoleRecord> readRoles; try { readTime = fileSystem.lastModifiedTime( roleFile ); readRoles = serialization.loadRecordsFromFile( fileSystem, roleFile ); } catch ( FormatException e ) { log.error( "Failed to read role file \"%s\" (%s)", roleFile.getAbsolutePath(), e.getMessage() ); throw new IllegalStateException( "Failed to read role file '" + roleFile + "'." ); } return new ListSnapshot<>( readTime, readRoles, FROM_PERSISTED ); } return null; }
@Override protected ListSnapshot<User> readPersistedUsers() throws IOException { if ( fileSystem.fileExists( authFile ) ) { long readTime; List<User> readUsers; try { readTime = fileSystem.lastModifiedTime( authFile ); readUsers = serialization.loadRecordsFromFile( fileSystem, authFile ); } catch ( FormatException e ) { log.error( "Failed to read authentication file \"%s\" (%s)", authFile.getAbsolutePath(), e.getMessage() ); throw new IllegalStateException( "Failed to read authentication file: " + authFile ); } return new ListSnapshot<>( readTime, readUsers, FROM_PERSISTED ); } return null; }