@Test public void numeric_search_only() { assertFalse(extension.getSearchProvider().isTokenSearchable("120 000")); }
@Override public SearchProvider getSearchProvider() { return new AbstractSearchProvider(uriBuilder) { @Override public boolean isTokenSearchable(String token) { if (StringUtils.isNumeric(token)) { long value = Long.parseLong(token, 10); return value > 0 && value < Integer.MAX_VALUE; } else { return false; } } @Override public Collection<SearchResult> search(String token) { return configurationService.getConfigurationDescriptors().stream() .map(descriptor -> svnService.getRepository(descriptor.getId())) .map(repository -> { try { return new SVNRepositoryRevision( repository, svnService.getRevisionInfo(repository, Long.valueOf(token, 10)) ); } catch (SVNRevisionNotFoundException ex) { return null; } }) .filter(repositoryRevision -> repositoryRevision != null) .map(repositoryRevision -> new SearchResult( String.valueOf(repositoryRevision.getRevisionInfo().getRevision()), getSearchRevisionDescription(repositoryRevision), uri(on(SVNController.class).revisionInfo( repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision() )), uriBuilder.page("extension/svn/revision/%s/%d", repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision()), 100, resultType )) .collect(Collectors.toList()); } }; }
SVNRevisionSearchExtension extends AbstractExtension implements SearchExtension { @Override public SearchProvider getSearchProvider() { return new AbstractSearchProvider(uriBuilder) { @Override public boolean isTokenSearchable(String token) { if (StringUtils.isNumeric(token)) { long value = Long.parseLong(token, 10); return value > 0 && value < Integer.MAX_VALUE; } else { return false; } } @Override public Collection<SearchResult> search(String token) { return configurationService.getConfigurationDescriptors().stream() .map(descriptor -> svnService.getRepository(descriptor.getId())) .map(repository -> { try { return new SVNRepositoryRevision( repository, svnService.getRevisionInfo(repository, Long.valueOf(token, 10)) ); } catch (SVNRevisionNotFoundException ex) { return null; } }) .filter(repositoryRevision -> repositoryRevision != null) .map(repositoryRevision -> new SearchResult( String.valueOf(repositoryRevision.getRevisionInfo().getRevision()), getSearchRevisionDescription(repositoryRevision), uri(on(SVNController.class).revisionInfo( repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision() )), uriBuilder.page("extension/svn/revision/%s/%d", repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision()), 100, resultType )) .collect(Collectors.toList()); } }; } }
SVNRevisionSearchExtension extends AbstractExtension implements SearchExtension { @Override public SearchProvider getSearchProvider() { return new AbstractSearchProvider(uriBuilder) { @Override public boolean isTokenSearchable(String token) { if (StringUtils.isNumeric(token)) { long value = Long.parseLong(token, 10); return value > 0 && value < Integer.MAX_VALUE; } else { return false; } } @Override public Collection<SearchResult> search(String token) { return configurationService.getConfigurationDescriptors().stream() .map(descriptor -> svnService.getRepository(descriptor.getId())) .map(repository -> { try { return new SVNRepositoryRevision( repository, svnService.getRevisionInfo(repository, Long.valueOf(token, 10)) ); } catch (SVNRevisionNotFoundException ex) { return null; } }) .filter(repositoryRevision -> repositoryRevision != null) .map(repositoryRevision -> new SearchResult( String.valueOf(repositoryRevision.getRevisionInfo().getRevision()), getSearchRevisionDescription(repositoryRevision), uri(on(SVNController.class).revisionInfo( repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision() )), uriBuilder.page("extension/svn/revision/%s/%d", repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision()), 100, resultType )) .collect(Collectors.toList()); } }; } @Autowired  SVNRevisionSearchExtension(
            SVNExtensionFeature extensionFeature,
            URIBuilder uriBuilder,
            SVNConfigurationService configurationService,
            SVNService svnService
    ); }
SVNRevisionSearchExtension extends AbstractExtension implements SearchExtension { @Override public SearchProvider getSearchProvider() { return new AbstractSearchProvider(uriBuilder) { @Override public boolean isTokenSearchable(String token) { if (StringUtils.isNumeric(token)) { long value = Long.parseLong(token, 10); return value > 0 && value < Integer.MAX_VALUE; } else { return false; } } @Override public Collection<SearchResult> search(String token) { return configurationService.getConfigurationDescriptors().stream() .map(descriptor -> svnService.getRepository(descriptor.getId())) .map(repository -> { try { return new SVNRepositoryRevision( repository, svnService.getRevisionInfo(repository, Long.valueOf(token, 10)) ); } catch (SVNRevisionNotFoundException ex) { return null; } }) .filter(repositoryRevision -> repositoryRevision != null) .map(repositoryRevision -> new SearchResult( String.valueOf(repositoryRevision.getRevisionInfo().getRevision()), getSearchRevisionDescription(repositoryRevision), uri(on(SVNController.class).revisionInfo( repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision() )), uriBuilder.page("extension/svn/revision/%s/%d", repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision()), 100, resultType )) .collect(Collectors.toList()); } }; } @Autowired  SVNRevisionSearchExtension(
            SVNExtensionFeature extensionFeature,
            URIBuilder uriBuilder,
            SVNConfigurationService configurationService,
            SVNService svnService
    ); @Override SearchProvider getSearchProvider(); }
SVNRevisionSearchExtension extends AbstractExtension implements SearchExtension { @Override public SearchProvider getSearchProvider() { return new AbstractSearchProvider(uriBuilder) { @Override public boolean isTokenSearchable(String token) { if (StringUtils.isNumeric(token)) { long value = Long.parseLong(token, 10); return value > 0 && value < Integer.MAX_VALUE; } else { return false; } } @Override public Collection<SearchResult> search(String token) { return configurationService.getConfigurationDescriptors().stream() .map(descriptor -> svnService.getRepository(descriptor.getId())) .map(repository -> { try { return new SVNRepositoryRevision( repository, svnService.getRevisionInfo(repository, Long.valueOf(token, 10)) ); } catch (SVNRevisionNotFoundException ex) { return null; } }) .filter(repositoryRevision -> repositoryRevision != null) .map(repositoryRevision -> new SearchResult( String.valueOf(repositoryRevision.getRevisionInfo().getRevision()), getSearchRevisionDescription(repositoryRevision), uri(on(SVNController.class).revisionInfo( repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision() )), uriBuilder.page("extension/svn/revision/%s/%d", repositoryRevision.getRepository().getConfiguration().getName(), repositoryRevision.getRevisionInfo().getRevision()), 100, resultType )) .collect(Collectors.toList()); } }; } @Autowired  SVNRevisionSearchExtension(
            SVNExtensionFeature extensionFeature,
            URIBuilder uriBuilder,
            SVNConfigurationService configurationService,
            SVNService svnService
    ); @Override SearchProvider getSearchProvider();  }