Example usage for com.google.common.net MediaType JSON_UTF_8

List of usage examples for com.google.common.net MediaType JSON_UTF_8

Introduction

In this page you can find the example usage for com.google.common.net MediaType JSON_UTF_8.

Prototype

MediaType JSON_UTF_8

To view the source code for com.google.common.net MediaType JSON_UTF_8.

Click Source Link

Usage

From source file:com.github.mike10004.jenkinsbbhook.DefaultExceptionMapper.java

@Override
public Response toResponse(Throwable exception) {
    if (exception instanceof WebApplicationException) {
        return ((WebApplicationException) exception).getResponse();
    }// ww  w.  jav a2 s  .  c  om
    ExceptionInfo info = new ExceptionInfo(exception);
    if (exception.getCause() != null) {
        info.cause = new ExceptionInfo(exception.getCause());
    }
    String json = gson.toJson(info);
    Response response = Response.serverError().entity(json)
            .type(MediaType.JSON_UTF_8.withoutParameters().toString()).build();
    return response;
}

From source file:com.ericsson.gerrit.plugins.evictcache.HttpSession.java

CacheResult post(String endpoint, String json) throws IOException {
    HttpPost post = new HttpPost(url + endpoint);
    StringEntity params = new StringEntity(json.trim());
    post.addHeader("Content-Type", MediaType.JSON_UTF_8.toString());
    post.addHeader("Accept", MediaType.JSON_UTF_8.toString());
    post.setEntity(params);/*from w w w  .j  a v  a2  s . c  o m*/
    return httpClient.execute(post, new CacheResponseHandler());
}

From source file:controllers.MessageCountsController.java

public Result total() {
    long countResult = messagesService.total();

    Map<String, Long> result = Maps.newHashMap();
    result.put("events", countResult);

    return ok(Json.toJsonString(result)).as(MediaType.JSON_UTF_8.toString());
}

From source file:com.github.achatain.catalog.filter.JsonResponseFilter.java

@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
        throws IOException, ServletException {
    final HttpServletResponse httpResp = (HttpServletResponse) response;
    httpResp.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8.toString());

    chain.doFilter(request, response);/*ww w. j a v a  2  s.  c om*/
}

From source file:controllers.api.SourcesApiController.java

public Result list(int range) {
    if (range < 0) {
        return status(400, views.html.errors.error.render("Invalid time range for sources list",
                new Exception(), request()));
    }//from w  ww .j  a v  a  2 s  .c om
    try {
        List<Source> sources = sourcesService.all(range);
        return ok(Json.toJsonString(sources)).as(MediaType.JSON_UTF_8.toString());
    } catch (IOException e) {
        return internalServerError("io exception");
    } catch (APIException e) {
        if (e.getHttpCode() == 400) {
            // This usually means the field does not have a numeric type. Pass through!
            return badRequest();
        }

        return internalServerError("api exception " + e);
    }
}

From source file:com.mastfrog.webapi.builtin.BodyFromMap.java

@Override
public void decorate(WebCall call, HttpRequestBuilder builder, Map obj, Class<Map> type) throws IOException {
    builder.setBody(obj, MediaType.JSON_UTF_8);
}

From source file:be.nbb.cli.util.jackson.JsonSerializerFactory.java

@Override
public boolean canHandle(MediaType mediaType, Class<?> type) {
    return available && MediaType.JSON_UTF_8.is(mediaType);
}

From source file:io.rebolt.http.converters.JsonConverter.java

@Override
public String getContentType() {
    return MediaType.JSON_UTF_8.toString();
}

From source file:io.rebolt.http.converters.FormToJsonConverter.java

@Override
public String getAccept() {
    return MediaType.JSON_UTF_8.toString();
}

From source file:org.flockdata.integration.MessageSupport.java

@PostConstruct
public void createTransformer() {
    objectToJsonTransformer = new ObjectToJsonTransformer(new Jackson2JsonObjectMapper(JsonUtils.getMapper()));
    objectToJsonTransformer.setContentType(MediaType.JSON_UTF_8.toString());

    j2o = new JsonToObjectTransformer(new Jackson2JsonObjectMapper(JsonUtils.getMapper()));

}