|
|
@ -14,8 +14,10 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
import ru.ulstu.extractor.branch.model.Branch;
|
|
|
|
import ru.ulstu.extractor.branch.model.Branch;
|
|
|
|
|
|
|
|
import ru.ulstu.extractor.branch.service.BranchService;
|
|
|
|
import ru.ulstu.extractor.gitrepository.model.FilterForm;
|
|
|
|
import ru.ulstu.extractor.gitrepository.model.FilterForm;
|
|
|
|
import ru.ulstu.extractor.gitrepository.model.RepoForm;
|
|
|
|
import ru.ulstu.extractor.gitrepository.model.RepoForm;
|
|
|
|
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
|
|
|
import ru.ulstu.extractor.gitrepository.service.GitRepositoryService;
|
|
|
@ -27,6 +29,7 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import static ru.ulstu.extractor.core.Route.FILTER_COMMITS;
|
|
|
|
import static ru.ulstu.extractor.core.Route.FILTER_COMMITS;
|
|
|
|
import static ru.ulstu.extractor.core.Route.INDEXING_NEW_REPOSITORY;
|
|
|
|
import static ru.ulstu.extractor.core.Route.INDEXING_NEW_REPOSITORY;
|
|
|
|
|
|
|
|
import static ru.ulstu.extractor.core.Route.REINDEX_BRANCH;
|
|
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
@Controller
|
|
|
|
@ApiIgnore
|
|
|
|
@ApiIgnore
|
|
|
@ -34,11 +37,14 @@ public class GitIndexingController {
|
|
|
|
private final static Logger LOG = LoggerFactory.getLogger(GitIndexingController.class);
|
|
|
|
private final static Logger LOG = LoggerFactory.getLogger(GitIndexingController.class);
|
|
|
|
private final GitRepositoryService gitRepositoryService;
|
|
|
|
private final GitRepositoryService gitRepositoryService;
|
|
|
|
private final IndexService indexService;
|
|
|
|
private final IndexService indexService;
|
|
|
|
|
|
|
|
private final BranchService branchService;
|
|
|
|
|
|
|
|
|
|
|
|
public GitIndexingController(GitRepositoryService gitRepositoryService,
|
|
|
|
public GitIndexingController(GitRepositoryService gitRepositoryService,
|
|
|
|
IndexService indexService) {
|
|
|
|
IndexService indexService,
|
|
|
|
|
|
|
|
BranchService branchService) {
|
|
|
|
this.gitRepositoryService = gitRepositoryService;
|
|
|
|
this.gitRepositoryService = gitRepositoryService;
|
|
|
|
this.indexService = indexService;
|
|
|
|
this.indexService = indexService;
|
|
|
|
|
|
|
|
this.branchService = branchService;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(INDEXING_NEW_REPOSITORY)
|
|
|
|
@GetMapping(INDEXING_NEW_REPOSITORY)
|
|
|
@ -76,4 +82,21 @@ public class GitIndexingController {
|
|
|
|
return "redirect:/" + FILTER_COMMITS;
|
|
|
|
return "redirect:/" + FILTER_COMMITS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(REINDEX_BRANCH)
|
|
|
|
|
|
|
|
public String reindexBranch(Model model,
|
|
|
|
|
|
|
|
RedirectAttributes redirectAttributes,
|
|
|
|
|
|
|
|
@RequestParam Integer branchId) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
indexService.index(branchId);
|
|
|
|
|
|
|
|
} catch (IOException | GitAPIException ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
model.addAttribute("error", ex.getMessage());
|
|
|
|
|
|
|
|
return INDEXING_NEW_REPOSITORY;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Branch branch = branchService.findByBranchId(branchId).orElseThrow(() -> new RuntimeException("Ветка не найдена по id"));
|
|
|
|
|
|
|
|
redirectAttributes.addAttribute("repositoryUrl", branch.getGitRepository().getUrl());
|
|
|
|
|
|
|
|
redirectAttributes.addAttribute("branchName", branch.getName());
|
|
|
|
|
|
|
|
return "redirect:/" + FILTER_COMMITS;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|