rest/src/main/java/org/jboss/pnc/rest/endpoint/BuildTaskEndpoint.java
@POST
    @Path("/{taskId}/completed")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public Response buildTaskCompleted(
            @PathParam("taskId") Integer buildId,
            @FormParam("buildResult") BuildResultRest buildResult) throws CoreException {

//TODO set MDC from request headers instead of business data
//        logger.debug("Received task completed notification for coordinating task id [{}].", buildId);
//        BuildExecutionConfigurationRest buildExecutionConfiguration = buildResult.getBuildExecutionConfiguration();
//        buildResult.getRepositoryManagerResult().getBuildContentId();
//        if (buildExecutionConfiguration == null) {
//            logger.error("Missing buildExecutionConfiguration in buildResult for buildTaskId [{}].", buildId);
//            throw new CoreException("Missing buildExecutionConfiguration in buildResult for buildTaskId " + buildId);
//        }
//        MDCUtils.addContext(buildExecutionConfiguration.getBuildContentId(), buildExecutionConfiguration.isTempBuild(), systemConfig.getTemporalBuildExpireDate());
        logger.info("Received build task completed notification for id {}.", buildId);

        Integer taskId = bpmManager.getTaskIdByBuildId(buildId);
        if(taskId == null) {
            logger.error("No task for id [{}].", buildId);
            throw new CoreException("Could not find BPM task for build with ID " + buildId);
        }

        //check if task is already completed
        //required workaround as we don't remove the BpmTasks immediately after the completion
        Optional<BpmTask> taskOptional = bpmManager.getTaskById(taskId);
        if (taskOptional.isPresent()) {
            BpmBuildTask bpmBuildTask = (BpmBuildTask) taskOptional.get();
            BuildTask buildTask = bpmBuildTask.getBuildTask();

            MDCUtils.addBuildContext(buildTask.getContentId(), buildTask.getBuildOptions().isTemporaryBuild(), systemConfig.getTemporalBuildExpireDate());
            if (buildTask.getStatus().isCompleted()) {
                logger.warn("Task with id: {} is already completed with status: {}", buildTask.getId(), buildTask.getStatus());
                return Response.status(Response.Status.GONE).entity("Task with id: " + buildTask.getId() + " is already completed with status: " + buildTask.getStatus() + ".").build();
            }
        }

        if (logger.isTraceEnabled()) {
            logger.trace("Received build result wit full log: {}.", buildResult.toFullLogString());
        }
        logger.debug("Will notify for bpmTaskId[{}] linked to buildTaskId [{}].", taskId, buildId);
        bpmManager.notify(taskId, buildResult);
        logger.debug("Notified for bpmTaskId[{}] linked to buildTaskId [{}].", taskId, buildId);
        return Response.ok().build();
    }
@POST
    @Path("/{taskId}/completed")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public Response buildTaskCompleted(
            @PathParam("taskId") Integer buildId,
            @FormParam("buildResult") BuildResultRest buildResult) throws CoreException {

//TODO set MDC from request headers instead of business data
//        logger.debug("Received task completed notification for coordinating task id [{}].", buildId);
//        BuildExecutionConfigurationRest buildExecutionConfiguration = buildResult.getBuildExecutionConfiguration();
//        buildResult.getRepositoryManagerResult().getBuildContentId();
//        if (buildExecutionConfiguration == null) {
//            logger.error("Missing buildExecutionConfiguration in buildResult for buildTaskId [{}].", buildId);
//            throw new CoreException("Missing buildExecutionConfiguration in buildResult for buildTaskId " + buildId);
//        }
//        MDCUtils.addContext(buildExecutionConfiguration.getBuildContentId(), buildExecutionConfiguration.isTempBuild(), systemConfig.getTemporalBuildExpireDate());
        logger.info("Received build task completed notification for id {}.", buildId);

        Integer taskId = bpmManager.getTaskIdByBuildId(buildId);
        if(taskId == null) {
            logger.error("No task for id [{}].", buildId);
            throw new CoreException("Could not find BPM task for build with ID " + buildId);
        }

        //check if task is already completed
        //required workaround as we don't remove the BpmTasks immediately after the completion
        Optional<BpmTask> taskOptional = bpmManager.getTaskById(taskId);
        if (taskOptional.isPresent()) {
            BpmBuildTask bpmBuildTask = (BpmBuildTask) taskOptional.get();
            BuildTask buildTask = bpmBuildTask.getBuildTask();

            MDCUtils.addBuildContext(buildTask.getContentId(), buildTask.getBuildOptions().isTemporaryBuild(), systemConfig.getTemporalBuildExpireDate());
            if (buildTask.getStatus().isCompleted()) {
                logger.warn("Task with id: {} is already completed with status: {}", buildTask.getId(), buildTask.getStatus());
                return Response.status(Response.Status.GONE).entity("Task with id: " + buildTask.getId() + " is already completed with status: " + buildTask.getStatus() + ".").build();
            }
        }

        if (logger.isTraceEnabled()) {
            logger.trace("Received build result wit full log: {}.", buildResult.toFullLogString());
        }
        logger.debug("Will notify for bpmTaskId[{}] linked to buildTaskId [{}].", taskId, buildId);
        bpmManager.notify(taskId, buildResult);
        logger.debug("Notified for bpmTaskId[{}] linked to buildTaskId [{}].", taskId, buildId);
        return Response.ok().build();
    }
CDI workaround