Search in sources :

Example 16 with NotFoundException

use of org.hisp.dhis.webapi.controller.exception.NotFoundException in project dhis2-core by dhis2.

the class TrackerImportController method getJobReport.

@GetMapping(value = "/jobs/{uid}/report", produces = APPLICATION_JSON_VALUE)
public TrackerImportReport getJobReport(@PathVariable String uid, @RequestParam(defaultValue = "errors", required = false) String reportMode, HttpServletResponse response) throws HttpStatusCodeException, NotFoundException {
    TrackerBundleReportMode trackerBundleReportMode = TrackerBundleReportMode.getTrackerBundleReportMode(reportMode);
    setNoStore(response);
    return Optional.ofNullable(notifier.getJobSummaryByJobId(JobType.TRACKER_IMPORT_JOB, uid)).map(report -> trackerImportService.buildImportReport((TrackerImportReport) report, trackerBundleReportMode)).orElseThrow(() -> NotFoundException.notFoundUid(uid));
}
Also used : DhisApiVersion(org.hisp.dhis.common.DhisApiVersion) PathVariable(org.springframework.web.bind.annotation.PathVariable) ContextUtils.setNoStore(org.hisp.dhis.webapi.utils.ContextUtils.setNoStore) RequestParam(org.springframework.web.bind.annotation.RequestParam) HttpStatusCodeException(org.springframework.web.client.HttpStatusCodeException) RequiredArgsConstructor(lombok.RequiredArgsConstructor) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) TrackerImportService(org.hisp.dhis.tracker.TrackerImportService) Deque(java.util.Deque) StreamUtils(org.hisp.dhis.commons.util.StreamUtils) ApiVersion(org.hisp.dhis.webapi.mvc.annotation.ApiVersion) CurrentUser(org.hisp.dhis.user.CurrentUser) Notifier(org.hisp.dhis.system.notification.Notifier) RequestBody(org.springframework.web.bind.annotation.RequestBody) WebMessageUtils.ok(org.hisp.dhis.dxf2.webmessage.WebMessageUtils.ok) HttpServletRequest(javax.servlet.http.HttpServletRequest) TrackerStatus(org.hisp.dhis.tracker.report.TrackerStatus) TrackerImportReportRequest(org.hisp.dhis.webapi.controller.tracker.TrackerImportReportRequest) TrackerJobWebMessageResponse(org.hisp.dhis.tracker.job.TrackerJobWebMessageResponse) JobType(org.hisp.dhis.scheduling.JobType) User(org.hisp.dhis.user.User) GetMapping(org.springframework.web.bind.annotation.GetMapping) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) TrackerBundleParams(org.hisp.dhis.webapi.controller.tracker.TrackerBundleParams) Event(org.hisp.dhis.tracker.domain.Event) ContextUtils(org.hisp.dhis.webapi.utils.ContextUtils) PostMapping(org.springframework.web.bind.annotation.PostMapping) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) ContextService(org.hisp.dhis.webapi.service.ContextService) CsvEventService(org.hisp.dhis.dxf2.events.event.csv.CsvEventService) Notification(org.hisp.dhis.system.notification.Notification) TrackerImportStrategyHandler(org.hisp.dhis.webapi.strategy.tracker.imports.TrackerImportStrategyHandler) HttpServletResponse(javax.servlet.http.HttpServletResponse) TrackerImportReport(org.hisp.dhis.tracker.report.TrackerImportReport) IOException(java.io.IOException) APPLICATION_JSON_VALUE(org.springframework.http.MediaType.APPLICATION_JSON_VALUE) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RestController(org.springframework.web.bind.annotation.RestController) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) TrackerBundleReportMode(org.hisp.dhis.tracker.TrackerBundleReportMode) ParseException(org.locationtech.jts.io.ParseException) Optional(java.util.Optional) RESOURCE_PATH(org.hisp.dhis.webapi.controller.tracker.TrackerControllerSupport.RESOURCE_PATH) CodeGenerator(org.hisp.dhis.common.CodeGenerator) ResponseEntity(org.springframework.http.ResponseEntity) WebMessage(org.hisp.dhis.dxf2.webmessage.WebMessage) InputStream(java.io.InputStream) TrackerBundleReportMode(org.hisp.dhis.tracker.TrackerBundleReportMode) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

NotFoundException (org.hisp.dhis.webapi.controller.exception.NotFoundException)16 PostMapping (org.springframework.web.bind.annotation.PostMapping)11 Configuration (org.hisp.dhis.configuration.Configuration)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)10 PotentialDuplicate (org.hisp.dhis.deduplication.PotentialDuplicate)4 PotentialDuplicateConflictException (org.hisp.dhis.deduplication.PotentialDuplicateConflictException)4 BadRequestException (org.hisp.dhis.webapi.controller.exception.BadRequestException)4 ConflictException (org.hisp.dhis.webapi.controller.exception.ConflictException)4 OperationNotAllowedException (org.hisp.dhis.webapi.controller.exception.OperationNotAllowedException)4 Test (org.junit.jupiter.api.Test)4 List (java.util.List)2 RequiredArgsConstructor (lombok.RequiredArgsConstructor)2 OrganisationUnitLevel (org.hisp.dhis.organisationunit.OrganisationUnitLevel)2 User (org.hisp.dhis.user.User)2 UserGroup (org.hisp.dhis.user.UserGroup)2 Joiner (com.google.common.base.Joiner)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Deque (java.util.Deque)1