List of usage examples for com.fasterxml.jackson.databind.util JSONWrappedObject JSONWrappedObject
public JSONWrappedObject(String prefix, String suffix, Object value)
From source file:edu.sdsc.scigraph.services.jersey.JaxRsUtil.java
/*** * Build a Response, optionally wrapped in a JSONP callback. * <p>The response will be wrapped in a JSONP callback if any of the following apply: * <ul>/*w w w . jav a 2 s.c o m*/ * <li> The requested media type is <em>application/javascript</em> * <li> The callback is not null or empty * </ul> * @param request The request * @param response The response to wrap * @param callback The callback * @return A Response object, wrapped if necessary. */ public static Object wrapJsonp(Request request, GenericEntity<?> response, @Nullable String callback) { if (JaxRsUtil.isVariant(request, CustomMediaTypes.APPLICATION_JSONP_TYPE) || !isNullOrEmpty(callback)) { callback = Optional.fromNullable(callback).or(DEFAULT_JSONP_CALLBACK); return new JSONWrappedObject(format("%s(", callback), ");", response.getEntity()); } else { return Response.ok(response).build(); } }