use of com.searchcode.app.util.UniqueRepoQueue in project searchcode-server by boyter.
the class IndexBaseRepoJobTest method testExecuteNothingInQueue.
public void testExecuteNothingInQueue() throws JobExecutionException {
IndexGitRepoJob indexGitRepoJob = new IndexGitRepoJob();
IndexGitRepoJob spy = spy(indexGitRepoJob);
spy.haveRepoResult = false;
when(spy.getNextQueuedRepo()).thenReturn(new UniqueRepoQueue());
spy.codeIndexer = mockCodeIndexer;
spy.execute(this.mockContext);
assertThat(spy.haveRepoResult).isFalse();
}
use of com.searchcode.app.util.UniqueRepoQueue in project searchcode-server by boyter.
the class EnqueueFileRepositoryJob method execute.
public void execute(JobExecutionContext context) throws JobExecutionException {
if (!Singleton.getSharedService().getBackgroundJobsEnabled()) {
return;
}
try {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
UniqueRepoQueue repoQueue = Singleton.getUniqueFileRepoQueue();
// Get all of the repositories and enqueue them
List<RepoResult> repoResultList = Singleton.getRepo().getAllRepo();
Singleton.getLogger().info("Adding repositories to be indexed. " + repoResultList.size());
for (RepoResult rr : repoResultList) {
switch(rr.getScm().toLowerCase()) {
case "file":
Singleton.getLogger().info("Adding to FILE queue " + rr.getName() + " " + rr.getScm());
repoQueue.add(rr);
break;
default:
Singleton.getLogger().info("Unable to determine job type for " + rr.getName());
break;
}
}
} catch (Exception ex) {
}
}
use of com.searchcode.app.util.UniqueRepoQueue in project searchcode-server by boyter.
the class EnqueueRepositoryJob method execute.
public void execute(JobExecutionContext context) throws JobExecutionException {
if (!Singleton.getSharedService().getBackgroundJobsEnabled()) {
return;
}
try {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
UniqueRepoQueue repoGitQueue = Singleton.getUniqueGitRepoQueue();
UniqueRepoQueue repoSvnQueue = Singleton.getUniqueSvnRepoQueue();
// Get all of the repositories and enqueue them
List<RepoResult> repoResultList = Singleton.getRepo().getAllRepo();
Singleton.getLogger().info("Adding repositories to be indexed. " + repoResultList.size());
// Filter out those queued to be deleted
List<String> persistentDelete = Singleton.getDataService().getPersistentDelete();
List<RepoResult> collect = repoResultList.stream().filter(x -> !persistentDelete.contains(x.getName())).collect(Collectors.toList());
for (RepoResult rr : collect) {
switch(rr.getScm().toLowerCase()) {
case "git":
Singleton.getLogger().info("Adding to GIT queue " + rr.getName() + " " + rr.getScm());
repoGitQueue.add(rr);
break;
case "svn":
Singleton.getLogger().info("Adding to SVN queue " + rr.getName() + " " + rr.getScm());
repoSvnQueue.add(rr);
break;
default:
Singleton.getLogger().info("Unable to determine SCM type for " + rr.getName() + " " + rr.getScm());
break;
}
}
} catch (Exception ex) {
}
}
use of com.searchcode.app.util.UniqueRepoQueue in project searchcode-server by boyter.
the class JobService method enqueueRepository.
private void enqueueRepository(RepoResult rr) {
UniqueRepoQueue repoGitQueue = Singleton.getUniqueGitRepoQueue();
UniqueRepoQueue repoSvnQueue = Singleton.getUniqueSvnRepoQueue();
UniqueRepoQueue repoFileQueue = Singleton.getUniqueFileRepoQueue();
switch(rr.getScm().toLowerCase()) {
case "git":
Singleton.getLogger().info("Adding to GIT queue " + rr.getName() + " " + rr.getScm());
repoGitQueue.add(rr);
break;
case "svn":
Singleton.getLogger().info("Adding to SVN queue " + rr.getName() + " " + rr.getScm());
repoSvnQueue.add(rr);
break;
case "file":
Singleton.getLogger().info("Adding to FILE queue " + rr.getName() + " " + rr.getScm());
repoFileQueue.add(rr);
break;
default:
Singleton.getLogger().info("Unknown SCM type " + rr.getName() + " " + rr.getScm());
break;
}
}
use of com.searchcode.app.util.UniqueRepoQueue in project searchcode-server by boyter.
the class ApiRouteServiceTest method testRepoDeleteAuthReponameFailedAuth.
public void testRepoDeleteAuthReponameFailedAuth() {
Request mockRequest = Mockito.mock(Request.class);
Repo mockRepo = Mockito.mock(Repo.class);
UniqueRepoQueue uniqueRepoQueue = new UniqueRepoQueue(new ConcurrentLinkedQueue<>());
ApiService mockApiService = Mockito.mock(ApiService.class);
when(mockApiService.validateRequest("test", "test", "pub=test", ApiService.HmacType.SHA1)).thenReturn(false);
when(mockRepo.getRepoByName("unit-test")).thenReturn(new RepoResult());
ApiRouteService apiRouteService = new ApiRouteService(mockApiService, null, mockRepo, null, null);
apiRouteService.apiEnabled = true;
apiRouteService.apiAuth = true;
when(mockRequest.queryParams("pub")).thenReturn("test");
when(mockRequest.queryParams("sig")).thenReturn("test");
when(mockRequest.queryParams("reponame")).thenReturn("unit-test");
ApiResponse apiResponse = apiRouteService.repoDelete(mockRequest, null);
assertThat(apiResponse.getMessage()).isEqualTo("invalid signed url");
assertThat(apiResponse.isSucessful()).isFalse();
assertThat(uniqueRepoQueue.size()).isEqualTo(0);
}
Aggregations