本文整理汇总了Java中com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse.setResponseBody方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultGoPluginApiResponse.setResponseBody方法的具体用法?Java DefaultGoPluginApiResponse.setResponseBody怎么用?Java DefaultGoPluginApiResponse.setResponseBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse
的用法示例。
在下文中一共展示了DefaultGoPluginApiResponse.setResponseBody方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJson
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
protected GoPluginApiResponse toJson(Object data) throws JsonProcessingException {
String json = data == null ? null : new ObjectMapper().writeValueAsString(data);
DefaultGoPluginApiResponse response = new DefaultGoPluginApiResponse(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE);
response.setResponseBody(json);
logger.debug("sending back json: " + json);
return response;
}
示例2: error
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
private GoPluginApiResponse error(String requestName, String requestBody, Exception e) {
StringBuilder msg = new StringBuilder();
msg.append("ERROR!");
msg.append("\n\t");
msg.append("request name: ");
msg.append(requestName);
msg.append("\n\t");
msg.append("request body: ");
msg.append(requestBody);
logger.error(msg.toString(), e);
String json = e.toString();
DefaultGoPluginApiResponse response = new DefaultGoPluginApiResponse(DefaultGoPluginApiResponse.INTERNAL_ERROR);
response.setResponseBody(json);
return response;
}
示例3: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() throws Exception {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("template", Util.readResource("/plugin-settings.template.html"));
DefaultGoPluginApiResponse defaultGoPluginApiResponse = new DefaultGoPluginApiResponse(200);
defaultGoPluginApiResponse.setResponseBody(GSON.toJson(jsonObject));
return defaultGoPluginApiResponse;
}
示例4: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() throws Exception {
JsonObject jsonObject = new JsonObject();
JsonArray notifications = new JsonArray();
notifications.add(REQUEST_STAGE_STATUS.requestName());
jsonObject.add("notifications", notifications);
DefaultGoPluginApiResponse defaultGoPluginApiResponse = new DefaultGoPluginApiResponse(200);
defaultGoPluginApiResponse.setResponseBody(GSON.toJson(jsonObject));
return defaultGoPluginApiResponse;
}
开发者ID:gocd-contrib,项目名称:notification-skeleton-plugin,代码行数:12,代码来源:NotificationInterestedInExecutor.java
示例5: createErrorResponse
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
/**
* Creates the error response.
*
* @param e the exception
* @return the error response
*/
private GoPluginApiResponse createErrorResponse(Exception e) {
final Map body = new HashMap();
body.put("exception", e.getMessage());
final DefaultGoPluginApiResponse response = new DefaultGoPluginApiResponse(DefaultGoApiResponse.INTERNAL_ERROR);
response.setResponseBody(parser.toJson(body));
return response;
}
示例6: createResponse
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
private GoPluginApiResponse createResponse(int responseCode, Map body) {
final DefaultGoPluginApiResponse response = new DefaultGoPluginApiResponse(responseCode);
response.setResponseBody(new GsonBuilder().serializeNulls().create().toJson(body));
return response;
}
示例7: createResponse
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
private GoPluginApiResponse createResponse(int responseCode, Object body) {
final DefaultGoPluginApiResponse response = new DefaultGoPluginApiResponse(responseCode);
response.setResponseBody(new GsonBuilder().serializeNulls().create().toJson(body));
return response;
}
示例8: createResponse
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
private GoPluginApiResponse createResponse(int responseCode, Map body) throws IOException {
final DefaultGoPluginApiResponse response = new DefaultGoPluginApiResponse(responseCode);
String bodyString = new JacksonFactory().toString(body);
response.setResponseBody(bodyString);
return response;
}
示例9: createResponse
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
/**
* Creates the response with the specific response code and content.
*
* @param responseCode the response code
* @param body the body content
* @return the API response
*/
protected GoPluginApiResponse createResponse(int responseCode, Map body) {
final DefaultGoPluginApiResponse response = new DefaultGoPluginApiResponse(responseCode);
response.setResponseBody(parser.toJson(body));
return response;
}