Java Code Examples for com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse#SUCCESS_RESPONSE_CODE
The following examples show how to use
com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse#SUCCESS_RESPONSE_CODE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckMkTask.java From gocd-plugins with Apache License 2.0 | 6 votes |
@Override protected GoPluginApiResponse handleTaskView(GoPluginApiRequest request) { int responseCode = DefaultGoApiResponse.SUCCESS_RESPONSE_CODE; HashMap view = new HashMap(); view.put("displayValue", "Monitoring - Check MK"); try { String checkMkTemplate = IOUtils.toString(getClass().getResourceAsStream("/views/checkMk.template.html"), "UTF-8"); view.put("template", checkMkTemplate); } catch (Exception e) { responseCode = DefaultGoApiResponse.INTERNAL_ERROR; String errorMessage = "Failed to find template: " + e.getMessage(); view.put("exception", errorMessage); logger.error(errorMessage, e); } return createResponse(responseCode, view); }
Example 2
Source File: ServerHealthRequestProcessor.java From gocd with Apache License 2.0 | 6 votes |
@Override public GoApiResponse process(GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) { String errorMessageTitle = format("Message from plugin: {0}", pluginDescriptor.id()); HealthStateScope scope = HealthStateScope.fromPlugin(pluginDescriptor.id()); try { MessageHandlerForServerHealthRequestProcessor messageHandler = versionToMessageHandlerMap.get(goPluginApiRequest.apiVersion()); List<PluginHealthMessage> pluginHealthMessages = messageHandler.deserializeServerHealthMessages(goPluginApiRequest.requestBody()); replaceServerHealthMessages(errorMessageTitle, scope, pluginHealthMessages); } catch (Exception e) { DefaultGoApiResponse response = new DefaultGoApiResponse(DefaultGoApiResponse.INTERNAL_ERROR); response.setResponseBody(format("'{' \"message\": \"{0}\" '}'", e.getMessage())); LOGGER.warn("Failed to handle message from plugin {}: {}", pluginDescriptor.id(), goPluginApiRequest.requestBody(), e); return response; } return new DefaultGoApiResponse(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE); }
Example 3
Source File: ConsoleLogRequestProcessor.java From gocd with Apache License 2.0 | 6 votes |
@Override public GoApiResponse process(GoPluginDescriptor pluginDescriptor, GoApiRequest request) { try { validatePluginRequest(request); final MessageHandlerForConsoleLogRequestProcessor handler = versionToMessageHandlerMap.get(request.apiVersion()); final ConsoleLogAppendRequest logUpdateRequest = handler.deserializeConsoleLogAppendRequest(request.requestBody()); consoleService.appendToConsoleLog(logUpdateRequest.jobIdentifier(), logUpdateRequest.text()); } catch (Exception e) { DefaultGoApiResponse response = new DefaultGoApiResponse(DefaultGoApiResponse.INTERNAL_ERROR); response.setResponseBody(format("'{' \"message\": \"Error: {0}\" '}'", e.getMessage())); LOGGER.warn("Failed to handle message from plugin {}: {}", pluginDescriptor.id(), request.requestBody(), e); return response; } return new DefaultGoApiResponse(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE); }
Example 4
Source File: ConsoleLogger.java From docker-registry-artifact-plugin with Apache License 2.0 | 5 votes |
private void sendLog(ConsoleLogMessage consoleLogMessage) { DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.SEND_CONSOLE_LOG, CONSOLE_LOG_PROCESSOR_API_VERSION, PLUGIN_IDENTIFIER); request.setRequestBody(consoleLogMessage.toJSON()); GoApiResponse response = accessor.submit(request); if (response.responseCode() != DefaultGoApiResponse.SUCCESS_RESPONSE_CODE) { LOG.error(String.format("Failed to submit console log: %s", response.responseBody())); } }
Example 5
Source File: NessusScanTask.java From gocd-plugins with Apache License 2.0 | 5 votes |
private GoPluginApiResponse handleTaskView() { int responseCode = DefaultGoApiResponse.SUCCESS_RESPONSE_CODE; HashMap view = new HashMap(); view.put("displayValue", "Security Scan - Nessus"); try { view.put("template", IOUtils.toString(getClass().getResourceAsStream("/views/task.template.html"), "UTF-8")); } catch (Exception e) { responseCode = DefaultGoApiResponse.INTERNAL_ERROR; String errorMessage = "Failed to find template: " + e.getMessage(); view.put("exception", errorMessage); LOGGER.error(errorMessage, e); } return createResponse(responseCode, view); }
Example 6
Source File: DockerTask.java From gocd-docker with Apache License 2.0 | 5 votes |
private GoPluginApiResponse handleTaskView() { int responseCode = DefaultGoApiResponse.SUCCESS_RESPONSE_CODE; Map view = new HashMap(); view.put("displayValue", "Docker Task"); try { view.put("template", IOUtils.toString(getClass().getResourceAsStream("/views/task.template.html"), "UTF-8")); } catch (Exception e) { responseCode = DefaultGoApiResponse.INTERNAL_ERROR; String errorMessage = "Failed to find template: " + e.getMessage(); view.put("exception", errorMessage); logger.error(errorMessage, e); } return createResponse(responseCode, view); }
Example 7
Source File: Result.java From gocd-plugins with Apache License 2.0 | 4 votes |
public int responseCode() { return success ? DefaultGoApiResponse.SUCCESS_RESPONSE_CODE : DefaultGoApiResponse.INTERNAL_ERROR; }
Example 8
Source File: Result.java From gocd-docker with Apache License 2.0 | 4 votes |
public int responseCode() { return success ? DefaultGoApiResponse.SUCCESS_RESPONSE_CODE : DefaultGoApiResponse.INTERNAL_ERROR; }
Example 9
Source File: TaskExecutionResult.java From gocd-s3-artifacts with Apache License 2.0 | 4 votes |
public int responseCode() { return DefaultGoApiResponse.SUCCESS_RESPONSE_CODE; }
Example 10
Source File: MaterialResult.java From gocd-s3-artifacts with Apache License 2.0 | 4 votes |
public int responseCode() { return DefaultGoApiResponse.SUCCESS_RESPONSE_CODE; }
Example 11
Source File: TaskExecutionResult.java From gocd-s3-artifacts with Apache License 2.0 | 4 votes |
public int responseCode() { return DefaultGoApiResponse.SUCCESS_RESPONSE_CODE; }
Example 12
Source File: MaterialResult.java From gocd-s3-artifacts with Apache License 2.0 | 4 votes |
public int responseCode() { return DefaultGoApiResponse.SUCCESS_RESPONSE_CODE; }