class BackupsApiController implements BackupsApi {

    @Override
    @PreAuthorize("hasAuthority('RESTORE_CONFIGURATION')")
    @AuditEventMethod(event = RESTORE_BACKUP)
    public synchronized ResponseEntity<TokensLoggedOut> restoreBackup(String filename) {
        boolean hasHardwareTokens = tokenService.hasHardwareTokens();
        // If hardware tokens exist prior to the restore -> they will be logged out by the restore script
        TokensLoggedOut tokensLoggedOut = new TokensLoggedOut().hsmTokensLoggedOut(hasHardwareTokens);
        try {
            restoreService.restoreFromBackup(filename);
        } catch (BackupFileNotFoundException e) {
            throw new BadRequestException(e);
        } catch (InterruptedException e) {
            throw new InternalServerErrorException(new ErrorDeviation(RESTORE_INTERRUPTED));
        } catch (RestoreProcessFailedException e) {
            throw new InternalServerErrorException(e);
        }
        return new ResponseEntity<>(tokensLoggedOut, HttpStatus.OK);
    }

    @Autowired public  BackupsApiController(BackupService backupService,
            RestoreService restoreService, BackupConverter backupConverter,
            TokenService tokenService);

}