Search in sources :

Example 1 with SCMChangeLogIssue

use of net.nemerosa.ontrack.extension.scm.model.SCMChangeLogIssue in project ontrack by nemerosa.

the class SVNController method changeLog.

/**
 * Change log export
 */
@RequestMapping(value = "changelog/export", method = RequestMethod.GET)
public ResponseEntity<String> changeLog(IssueChangeLogExportRequest request) {
    // Gets the change log
    SVNChangeLog changeLog = changeLogService.changeLog(request);
    // Gets the issue service
    ConfiguredIssueService configuredIssueService = changeLog.getRepository().getConfiguredIssueService();
    if (configuredIssueService == null) {
        return new ResponseEntity<>("The branch is not configured for issues", HttpStatus.NO_CONTENT);
    }
    // Gets the issue change log
    SVNChangeLogIssues changeLogIssues = changeLogService.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());
    // Body and headers
    return new ResponseEntity<>(exportedChangeLogIssues.getContent(), responseHeaders, HttpStatus.OK);
}
Also used : ExportedIssues(net.nemerosa.ontrack.extension.issues.export.ExportedIssues) HttpHeaders(org.springframework.http.HttpHeaders) ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) ResponseEntity(org.springframework.http.ResponseEntity) Issue(net.nemerosa.ontrack.extension.issues.model.Issue) SCMChangeLogIssue(net.nemerosa.ontrack.extension.scm.model.SCMChangeLogIssue)

Example 2 with SCMChangeLogIssue

use of net.nemerosa.ontrack.extension.scm.model.SCMChangeLogIssue 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);
}
Also used : ExportedIssues(net.nemerosa.ontrack.extension.issues.export.ExportedIssues) Project(net.nemerosa.ontrack.model.structure.Project) HttpHeaders(org.springframework.http.HttpHeaders) ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) ResponseEntity(org.springframework.http.ResponseEntity) Issue(net.nemerosa.ontrack.extension.issues.model.Issue) SCMChangeLogIssue(net.nemerosa.ontrack.extension.scm.model.SCMChangeLogIssue)

Aggregations

ExportedIssues (net.nemerosa.ontrack.extension.issues.export.ExportedIssues)2 ConfiguredIssueService (net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService)2 Issue (net.nemerosa.ontrack.extension.issues.model.Issue)2 SCMChangeLogIssue (net.nemerosa.ontrack.extension.scm.model.SCMChangeLogIssue)2 HttpHeaders (org.springframework.http.HttpHeaders)2 ResponseEntity (org.springframework.http.ResponseEntity)2 Project (net.nemerosa.ontrack.model.structure.Project)1