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();
}
}
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();
}
}
Aggregations