/** * Create a list of quality source media type from the Produces annotation. * <p> * * @param mime the Produces annotation. * @return the list of {@link QualitySourceMediaType}, ordered according to * {@link org.glassfish.jersey.message.internal.QualitySourceMediaType#COMPARATOR}. */ public static List<MediaType> createQualitySourceMediaTypes(Produces mime) { if (mime == null || mime.value().length == 0) { return WILDCARD_QS_TYPE_SINGLETON_LIST; } return new ArrayList<MediaType>(createQualitySourceMediaTypes(mime.value())); }
/** * Create a list of quality source media type from the Produces annotation. * <p> * * @param mime the Produces annotation. * @return the list of {@link QualitySourceMediaType}, ordered according to * {@link org.glassfish.jersey.message.internal.QualitySourceMediaType#COMPARATOR}. */ public static List<MediaType> createQualitySourceMediaTypes(Produces mime) { if (mime == null || mime.value().length == 0) { return WILDCARD_QS_TYPE_SINGLETON_LIST; } return new ArrayList<MediaType>(createQualitySourceMediaTypes(mime.value())); }
private List<String> getProducibleMediaTypes(final AbstractResourceMethod method) { List<String> mediaTypes = Collections.emptyList(); final Produces produces = method.getMethod().getAnnotation(Produces.class); if (produces != null && produces.value() != null) { mediaTypes = Arrays.asList(produces.value()); } return mediaTypes; }
/** * Create an unmodifiable list of media types from the values declared in the {@link Produces} * annotation. * * @param annotation the Produces annotation. * @return the list of {@link MediaType}, ordered according to {@link #PARTIAL_ORDER_COMPARATOR}. */ public static List<MediaType> createFrom(Produces annotation) { if (annotation == null) { return WILDCARD_TYPE_SINGLETON_LIST; } return createFrom(annotation.value()); }
/** * Create an unmodifiable list of media types from the values declared in the {@link Produces} * annotation. * * @param annotation the Produces annotation. * @return the list of {@link MediaType}, ordered according to {@link #PARTIAL_ORDER_COMPARATOR}. */ public static List<MediaType> createFrom(Produces annotation) { if (annotation == null) { return WILDCARD_TYPE_SINGLETON_LIST; } return createFrom(annotation.value()); }
private static List<MediaType> extractMediaTypes(final Produces annotation) { return (annotation != null) ? extractMediaTypes(annotation.value()) : Collections.<MediaType>emptyList(); }
private static List<MediaType> extractMediaTypes(final Produces annotation) { return (annotation != null) ? extractMediaTypes(annotation.value()) : Collections.<MediaType>emptyList(); }
public static ContainerException badMethodProduces(Exception e, Class resourceClass, Method m, Produces p) { return new ContainerException(ImplMessages.BAD_METHOD_PRODUCEMIME(resourceClass, p.value(), m.toString()), e); } }
public static ContainerException badClassProduces(Exception e, Class resourceClass, Produces p) { return new ContainerException(ImplMessages.BAD_CLASS_PRODUCEMIME(resourceClass, p.value()), e); }
operation.put("nickname", method.getName()); if (produces != null) { operation.put("produces", produces.value());
AnnotationsUtils.getContent(response.content(), classProduces == null ? new String[0] : classProduces.value(), methodProduces == null ? new String[0] : methodProduces.value(), null, components, jsonViewAnnotation).ifPresent(apiResponseObject::content); AnnotationsUtils.getHeaders(response.headers(), jsonViewAnnotation).ifPresent(apiResponseObject::headers); if (StringUtils.isNotBlank(apiResponseObject.getDescription()) || apiResponseObject.getContent() != null || apiResponseObject.getHeaders() != null) {
produces = proxyIfc.getAnnotation(Produces.class); final String[] accepts = (produces == null) ? EMPTY : produces.value();
Content content = new Content(); MediaType mediaType = new MediaType().schema(returnTypeSchema); AnnotationsUtils.applyTypes(classProduces == null ? new String[0] : classProduces.value(), methodProduces == null ? new String[0] : methodProduces.value(), content, mediaType); if (operation.getResponses() == null) { operation.responses( Content content = new Content(); MediaType mediaType = new MediaType(); AnnotationsUtils.applyTypes(classProduces == null ? new String[0] : classProduces.value(), methodProduces == null ? new String[0] : methodProduces.value(), content, mediaType);
private List<String> getProduces(Produces produces) { if (produces == null) return new ArrayList<>(); String[] values = produces.value(); return Arrays.asList(values); }
private String getWants(Produces produces) { if (produces == null) return null; String[] value = produces.value(); if (value.length == 0) return null; if (value.length == 1) return value[0]; StringBuffer buf = new StringBuffer(); for (String mime : produces.value()) { if (buf.length() != 0) buf.append(","); buf.append(mime); } return buf.toString(); }
@SuppressWarnings(value = "unchecked") public static MediaType[] getProduces(Class declaring, Method method, MediaType defaultProduces) { Produces consume = method.getAnnotation(Produces.class); if (consume == null) { consume = (Produces) declaring.getAnnotation(Produces.class); } if (consume == null) { if (defaultProduces != null) { return new MediaType[]{defaultProduces}; } else { return null; } } MediaType[] mediaTypes = new MediaType[consume.value().length]; for(int i = 0; i< consume.value().length;i++){ mediaTypes[i] = MediaType.valueOf(consume.value()[i]); } return mediaTypes.length != 0 ? mediaTypes : null; }
private static List<MediaType> extractMediaTypes(final Produces annotation) { return (annotation != null) ? extractMediaTypes(annotation.value()) : Collections.<MediaType>emptyList(); }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { Produces produces = (Produces) annotation; List<String> produceList = Arrays.stream(produces.value()).filter(s -> !StringUtils.isEmpty(s)) .collect(Collectors.toList()); if (!produceList.isEmpty()) { operationGenerator.getOperation().setProduces(produceList); } } }
public MediaType getConcreteMediaTypeFromMessageBodyWriters(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { List<SortedKey<MessageBodyWriter>> writers = getServerMessageBodyWriters().getPossible(mediaType, type); for (SortedKey<MessageBodyWriter> writer : writers) { if (writer.obj.isWriteable(type, genericType, annotations, mediaType)) { MessageBodyWriter mbw = writer.obj; Class writerType = Types.getTemplateParameterOfInterface(mbw.getClass(), MessageBodyWriter.class); if (writerType == null || writerType.equals(Object.class) || !writerType.isAssignableFrom(type)) continue; Produces produces = mbw.getClass().getAnnotation(Produces.class); if (produces == null) continue; for (String produce : produces.value()) { MediaType mt = MediaType.valueOf(produce); if (mt.isWildcardType() || mt.isWildcardSubtype()) continue; return mt; } } } return null; }
if (produces != null) for (String produce : produces.value())