use of net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService in project ontrack by nemerosa.
the class GitServiceImpl method getIssueInfo.
@Override
public OntrackGitIssueInfo getIssueInfo(ID branchId, String key) {
Branch branch = structureService.getBranch(branchId);
// Configuration
GitBranchConfiguration branchConfiguration = getRequiredBranchConfiguration(branch);
GitConfiguration configuration = branchConfiguration.getConfiguration();
// Issue service
ConfiguredIssueService configuredIssueService = configuration.getConfiguredIssueService().orElse(null);
if (configuredIssueService == null) {
throw new GitBranchIssueServiceNotConfiguredException(branchId);
}
// Gets the details about the issue
Issue issue = configuredIssueService.getIssue(key);
// Collects commits per branches
List<OntrackGitIssueCommitInfo> commitInfos = collectIssueCommitInfos(branch.getProject(), issue);
// OK
return new OntrackGitIssueInfo(configuredIssueService.getIssueServiceConfigurationRepresentation(), issue, commitInfos);
}
use of net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService in project ontrack by nemerosa.
the class GitController method changeLog.
/**
* Change log export
*/
@RequestMapping(value = "changelog/export", method = RequestMethod.GET)
public ResponseEntity<String> changeLog(IssueChangeLogExportRequest request) {
// Gets the change log
GitChangeLog changeLog = gitService.changeLog(request);
// Gets the associated project
Project project = changeLog.getProject();
// Gets the configuration for the project
GitConfiguration gitConfiguration = gitService.getProjectConfiguration(project).orElseThrow(() -> new GitProjectNotConfiguredException(project.getId()));
// Gets the issue service
Optional<ConfiguredIssueService> optConfiguredIssueService = gitConfiguration.getConfiguredIssueService();
if (!optConfiguredIssueService.isPresent()) {
return new ResponseEntity<>("The branch is not configured for issues", HttpStatus.NO_CONTENT);
}
ConfiguredIssueService configuredIssueService = optConfiguredIssueService.get();
// Gets the issue change log
GitChangeLogIssues changeLogIssues = gitService.getChangeLogIssues(changeLog);
// List of issues
List<Issue> issues = changeLogIssues.getList().stream().map(SCMChangeLogIssue::getIssue).collect(Collectors.toList());
// Exports the change log using the given format
ExportedIssues exportedChangeLogIssues = configuredIssueService.getIssueServiceExtension().exportIssues(configuredIssueService.getIssueServiceConfiguration(), issues, request);
// Content type
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.set("Content-Type", exportedChangeLogIssues.getFormat() + "; charset=utf-8");
// Body and headers
return new ResponseEntity<>(exportedChangeLogIssues.getContent(), responseHeaders, HttpStatus.OK);
}
Aggregations