/** * Set the default representation media type to be used * if JAX-RS Produces or Consumes annotation is missing. * Wild-card media type is used by default in such cases. * @param mt the default representation media type */ public void setDefaultRepresentationMediaType(String mt) { this.defaultWadlResponseMediaType = JAXRSUtils.toMediaType(mt); }
/** * Set the default WADL response media type. * For example, a browser may display WADL better if Content-Type * is set to application/xml which is a default response content type. * Users may set it to application/vnd.sun.wadl+xml or other type. * @param mt WADL response media type */ public void setDefaultMediaType(String mt) { this.defaultWadlResponseMediaType = JAXRSUtils.toMediaType(mt); }
private MediaType getResponseMediaType(Object mediaTypeHeader) { MediaType responseMediaType; if (mediaTypeHeader instanceof MediaType) { responseMediaType = (MediaType)mediaTypeHeader; } else { responseMediaType = mediaTypeHeader == null ? MediaType.WILDCARD_TYPE : JAXRSUtils.toMediaType(mediaTypeHeader.toString()); } return responseMediaType; }
private MediaType getResponseMediaType(Object mediaTypeHeader) { MediaType responseMediaType; if (mediaTypeHeader instanceof MediaType) { responseMediaType = (MediaType)mediaTypeHeader; } else { responseMediaType = mediaTypeHeader == null ? MediaType.WILDCARD_TYPE : JAXRSUtils.toMediaType(mediaTypeHeader.toString()); } return responseMediaType; }
public MediaType getMediaType() { Object header = metadata.getFirst(HttpHeaders.CONTENT_TYPE); return header == null || header instanceof MediaType ? (MediaType)header : (MediaType)JAXRSUtils.toMediaType(header.toString()); }
public static List<MediaType> getMediaTypes(String[] values) { List<MediaType> supportedMimeTypes = new ArrayList<MediaType>(values.length); for (int i = 0; i < values.length; i++) { supportedMimeTypes.add(toMediaType(values[i])); } return supportedMimeTypes; }
private void setJoseMediaType(WriterInterceptorContext ctx) { MediaType joseMediaType = JAXRSUtils.toMediaType(JoseConstants.MEDIA_TYPE_JOSE_JSON); ctx.setMediaType(joseMediaType); }
@Override public MediaType getMediaType() { Object value = getHeaders().getFirst(HttpHeaders.CONTENT_TYPE); return value instanceof MediaType ? (MediaType)value : JAXRSUtils.toMediaType((String)value); }
private void setJoseMediaType(WriterInterceptorContext ctx) { MediaType joseMediaType = JAXRSUtils.toMediaType(JoseConstants.MEDIA_TYPE_JOSE); ctx.setMediaType(joseMediaType); } public void setEncodePayload(boolean encodePayload) {
private void setJoseMediaType(WriterInterceptorContext ctx) { MediaType joseMediaType = JAXRSUtils.toMediaType(JoseConstants.MEDIA_TYPE_JOSE); ctx.setMediaType(joseMediaType); }
@Override public MediaType getMediaType() { if (!hasEntity()) { return null; } Object mt = HttpUtils.getModifiableHeaders(m).getFirst(HttpHeaders.CONTENT_TYPE); return mt instanceof MediaType ? (MediaType)mt : JAXRSUtils.toMediaType(mt.toString()); }
@Override public MediaType getMediaType() { if (!hasEntity()) { return null; } Object mt = HttpUtils.getModifiableHeaders(m).getFirst(HttpHeaders.CONTENT_TYPE); return mt instanceof MediaType ? (MediaType)mt : JAXRSUtils.toMediaType(mt.toString()); }
public MediaType getContentType() { String value = handler != null && handler.getContentType() != null ? handler.getContentType() : headers.getFirst("Content-Type"); return value == null ? MediaType.TEXT_PLAIN_TYPE : JAXRSUtils.toMediaType(value); }
private void setContentTypeIfNeeded(MediaType type, MultivaluedMap<String, Object> headers, String ct) { if (!StringUtils.isEmpty(ct) && !type.equals(JAXRSUtils.toMediaType(ct))) { headers.putSingle("Content-Type", ct); } }
private static void checkMediaTypes(MediaType mt1, String mt2) { if (!mt1.isCompatible(JAXRSUtils.toMediaType(mt2))) { throw ExceptionUtils.toNotSupportedException(null, null); } } }
private static void checkMediaTypes(MediaType mt1, String mt2) { if (!mt1.isCompatible(JAXRSUtils.toMediaType(mt2))) { throw ExceptionUtils.toNotSupportedException(null, null); } } }
@Override public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { String callback = getCallbackValue(JAXRSUtils.getCurrentMessage()); if (!StringUtils.isEmpty(callback)) { context.getHeaders().putSingle(Message.CONTENT_TYPE, JAXRSUtils.toMediaType(getMediaType())); context.getOutputStream().write((callback + getPaddingEnd()).getBytes(StandardCharsets.UTF_8)); } context.proceed(); }
@Override public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { String callback = getCallbackValue(JAXRSUtils.getCurrentMessage()); if (!StringUtils.isEmpty(callback)) { context.getHeaders().putSingle(Message.CONTENT_TYPE, JAXRSUtils.toMediaType(getMediaType())); context.getOutputStream().write((callback + getPaddingEnd()).getBytes(StandardCharsets.UTF_8)); } context.proceed(); }
@Override public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { handleMessage(PhaseInterceptorChain.getCurrentMessage()); context.setMediaType(MediaType.APPLICATION_JSON_TYPE); context.proceed(); context.setMediaType(JAXRSUtils.toMediaType(getMediaType())); } }
@Override public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException { handleMessage(PhaseInterceptorChain.getCurrentMessage()); context.setMediaType(MediaType.APPLICATION_JSON_TYPE); context.proceed(); context.setMediaType(JAXRSUtils.toMediaType(getMediaType())); } }