Search in sources :

Example 1 with AcceptedResponse

use of org.jboss.pnc.rest.endpoints.internal.dto.AcceptedResponse in project pnc by project-ncl.

the class BuildTaskEndpointImpl method build.

@Override
public Response build(BuildExecutionConfigurationRest buildExecutionConfiguration, String usernameTriggered, String callbackUrl) {
    try {
        logger.debug("Endpoint /execute-build requested for buildTaskId [{}], from [{}]", buildExecutionConfiguration.getId(), request.getRemoteAddr());
        boolean temporaryBuild = buildExecutionConfiguration.isTempBuild();
        MDCUtils.addBuildContext(buildExecutionConfiguration.getBuildContentId(), temporaryBuild, ExpiresDate.getTemporaryBuildExpireDate(systemConfig.getTemporaryBuildsLifeSpan(), temporaryBuild), userService.currentUser().getId().toString());
        logger.info("Build execution requested.");
        logger.debug("Staring new build execution for configuration: {}. Caller requested a callback to {}.", buildExecutionConfiguration.toString(), callbackUrl);
        BuildExecutionSession buildExecutionSession = buildExecutorTriggerer.executeBuild(buildExecutionConfiguration.toBuildExecutionConfiguration(), callbackUrl, userService.currentUserToken());
        GlobalModuleGroup globalConfig = configuration.getGlobalConfig();
        UriBuilder uriBuilder = UriBuilder.fromUri(globalConfig.getExternalPncUrl()).path("/ws/executor/notifications");
        AcceptedResponse acceptedResponse = new AcceptedResponse(buildExecutionConfiguration.getId(), uriBuilder.build().toString());
        return Response.ok().entity(acceptedResponse).build();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e);
    } finally {
        MDCUtils.removeBuildContext();
    }
}
Also used : BuildExecutionSession(org.jboss.pnc.spi.executor.BuildExecutionSession) AcceptedResponse(org.jboss.pnc.rest.endpoints.internal.dto.AcceptedResponse) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) UriBuilder(javax.ws.rs.core.UriBuilder) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException)

Example 2 with AcceptedResponse

use of org.jboss.pnc.rest.endpoints.internal.dto.AcceptedResponse in project pnc by project-ncl.

the class BuildTaskEndpointImpl method build.

@Override
public Response build(BuildExecutionConfigurationWithCallbackRest buildExecutionConfiguration) {
    try {
        String callbackUrl = buildExecutionConfiguration.getCompletionCallbackUrl();
        boolean temporaryBuild = buildExecutionConfiguration.isTempBuild();
        MDCUtils.addBuildContext(buildExecutionConfiguration.getBuildContentId(), temporaryBuild, ExpiresDate.getTemporaryBuildExpireDate(systemConfig.getTemporaryBuildsLifeSpan(), temporaryBuild), userService.currentUser().getId().toString());
        logger.info("Build execution requested.");
        logger.debug("Staring new build execution for configuration: {}. Caller requested a callback to {}.", buildExecutionConfiguration.toString(), callbackUrl);
        BuildExecutionSession buildExecutionSession = buildExecutorTriggerer.executeBuild(buildExecutionConfiguration.toBuildExecutionConfiguration(), callbackUrl, userService.currentUserToken());
        GlobalModuleGroup globalConfig = configuration.getGlobalConfig();
        UriBuilder uriBuilder = UriBuilder.fromUri(globalConfig.getExternalPncUrl()).path("/ws/executor/notifications");
        AcceptedResponse acceptedResponse = new AcceptedResponse(buildExecutionConfiguration.getId(), uriBuilder.build().toString());
        return Response.ok().entity(acceptedResponse).build();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e);
    } finally {
        MDCUtils.removeBuildContext();
    }
}
Also used : BuildExecutionSession(org.jboss.pnc.spi.executor.BuildExecutionSession) AcceptedResponse(org.jboss.pnc.rest.endpoints.internal.dto.AcceptedResponse) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) UriBuilder(javax.ws.rs.core.UriBuilder) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException)

Aggregations

UriBuilder (javax.ws.rs.core.UriBuilder)2 GlobalModuleGroup (org.jboss.pnc.common.json.GlobalModuleGroup)2 InvalidEntityException (org.jboss.pnc.facade.validation.InvalidEntityException)2 AcceptedResponse (org.jboss.pnc.rest.endpoints.internal.dto.AcceptedResponse)2 BuildExecutionSession (org.jboss.pnc.spi.executor.BuildExecutionSession)2