Java Code Examples for com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse#SUCCESS_RESPONSE_CODE

The following examples show how to use com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse#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 5 votes vote down vote up
@Override
protected GoPluginApiResponse handleValidation(GoPluginApiRequest request) {
    HashMap validationResult = new HashMap();
    int responseCode = DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE;
    Map configMap = (Map) new GsonBuilder().create().fromJson(request.requestBody(), Object.class);
    HashMap errorMap = new HashMap();
 /*   if (!configMap.containsKey(URL_PROPERTY) || ((Map) configMap.get(URL_PROPERTY)).get("value") == null || ((String) ((Map) configMap.get(URL_PROPERTY)).get("value")).trim().isEmpty()) {
        errorMap.put(URL_PROPERTY, "URL cannot be empty");
    }
    validationResult.put("errors", errorMap);
    */
    return createResponse(responseCode, validationResult);
}
 
Example 2
Source File: PublishTask.java    From gocd-s3-artifacts with Apache License 2.0 5 votes vote down vote up
private GoPluginApiResponse handleTaskView() {
    int responseCode = DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE;
    Map view = new HashMap();
    view.put("displayValue", "Publish To S3");
    try {
        view.put("template", IOUtils.toString(getClass().getResourceAsStream("/views/task.template.html"), "UTF-8"));
    } catch (Exception e) {
        responseCode = DefaultGoPluginApiResponse.INTERNAL_ERROR;
        String errorMessage = "Failed to find template: " + e.getMessage();
        view.put("exception", errorMessage);
        logger.error(errorMessage, e);
    }
    return createResponse(responseCode, view);
}
 
Example 3
Source File: FetchTask.java    From gocd-s3-artifacts with Apache License 2.0 5 votes vote down vote up
private GoPluginApiResponse handleTaskView() {
    int responseCode = DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE;
    Map view = new HashMap();
    view.put("displayValue", "Fetch from S3");
    try {
        view.put("template", IOUtils.toString(getClass().getResourceAsStream("/views/task.template.html"), "UTF-8"));
    } catch (Exception e) {
        responseCode = DefaultGoPluginApiResponse.INTERNAL_ERROR;
        String errorMessage = "Failed to find template: " + e.getMessage();
        view.put("exception", errorMessage);
        logger.error(errorMessage, e);
    }
    return createResponse(responseCode, view);
}
 
Example 4
Source File: PublishTask.java    From gocd-s3-artifacts with Apache License 2.0 5 votes vote down vote up
private GoPluginApiResponse handleTaskView() {
    int responseCode = DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE;
    Map view = new HashMap();
    view.put("displayValue", "Publish To S3");
    try {
        view.put("template", IOUtils.toString(getClass().getResourceAsStream("/views/task.template.html"), "UTF-8"));
    } catch (Exception e) {
        responseCode = DefaultGoPluginApiResponse.INTERNAL_ERROR;
        String errorMessage = "Failed to find template: " + e.getMessage();
        view.put("exception", errorMessage);
        logger.error(errorMessage, e);
    }
    return createResponse(responseCode, view);
}
 
Example 5
Source File: FetchTask.java    From gocd-s3-artifacts with Apache License 2.0 5 votes vote down vote up
private GoPluginApiResponse handleTaskView() {
    int responseCode = DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE;
    Map view = new HashMap();
    view.put("displayValue", "Fetch from S3");
    try {
        view.put("template", IOUtils.toString(getClass().getResourceAsStream("/views/task.template.html"), "UTF-8"));
    } catch (Exception e) {
        responseCode = DefaultGoPluginApiResponse.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: AnalyticsExtensionImplementation.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) {
    System.setProperty("valid-plugin-with-multiple-extensions.analytics_extension.request.count", String.valueOf(++numberOfCallsToHandle));
    System.setProperty("valid-plugin-with-multiple-extensions.analytics_extension.request.name", goPluginApiRequest.requestName());
    System.setProperty("valid-plugin-with-multiple-extensions.analytics_extension.request.body", goPluginApiRequest.requestBody());

    return new DefaultGoPluginApiResponse(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE, "{}");
}
 
Example 7
Source File: TaskExtensionImplementation.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest goPluginApiRequest) {
    System.setProperty("valid-plugin-with-multiple-extensions.task_extension.request.count", String.valueOf(++numberOfCallsToHandle));
    System.setProperty("valid-plugin-with-multiple-extensions.task_extension.request.name", goPluginApiRequest.requestName());
    System.setProperty("valid-plugin-with-multiple-extensions.task_extension.request.body", goPluginApiRequest.requestBody());

    return new DefaultGoPluginApiResponse(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE, "{}");
}
 
Example 8
Source File: NessusScanTask.java    From gocd-plugins with Apache License 2.0 4 votes vote down vote up
private GoPluginApiResponse handleValidation() {
    HashMap validationResult = new HashMap();
    int responseCode = DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE;

    return createResponse(responseCode, validationResult);
}
 
Example 9
Source File: DockerTask.java    From gocd-docker with Apache License 2.0 4 votes vote down vote up
private GoPluginApiResponse handleValidation(GoPluginApiRequest request) {
    HashMap validationResult = new HashMap();
    int responseCode = DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE;
    Map configMap = (Map) new GsonBuilder().create().fromJson(request.requestBody(), Object.class);

    boolean dockerBuildStatus = validateDockerBuild(validationResult, configMap);

    boolean dockerRunStatus = validateDockerRun(validationResult, configMap);

    boolean dockerPushStatus = validateDockerPush(validationResult, configMap);

    if(!dockerBuildStatus || !dockerRunStatus || !dockerPushStatus)
        responseCode = DefaultGoPluginApiResponse.VALIDATION_FAILED;

    return createResponse(responseCode, validationResult);
}
 
Example 10
Source File: PublicGoExtensionClassWhichWillLoadSuccessfullyAndProvideAValidIdentifier.java    From gocd with Apache License 2.0 4 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest requestMessage) throws UnhandledRequestTypeException {
    return new DefaultGoPluginApiResponse(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE, "{}");
}
 
Example 11
Source File: PublicGoExtensionClassWhichWillAlsoLoadSuccessfully.java    From gocd with Apache License 2.0 4 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest requestMessage) {
    return new DefaultGoPluginApiResponse(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE, "{}");
}
 
Example 12
Source File: PublicGoExtensionClassWhichWillLoadSuccessfullyButThrowWhenAskedForPluginIdentifier.java    From gocd with Apache License 2.0 4 votes vote down vote up
@Override
public GoPluginApiResponse handle(GoPluginApiRequest requestMessage) throws UnhandledRequestTypeException {
    return new DefaultGoPluginApiResponse(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE, "{}");
}