List of usage examples for org.springframework.http MediaType MediaType
public MediaType(String type)
From source file:com.art4ul.jcoon.util.HttpRequestUtil.java
public static List<MediaType> getAcceptedTypes(String[] types) { List<MediaType> result = new ArrayList<MediaType>(); if (types == null) { return result; }//from ww w .j av a 2 s. c om for (String type : types) { result.add(new MediaType(type)); } return result; }
From source file:com.art4ul.jcoon.handlers.RequestMappingAnnotationBeforeHandler.java
@Override public void doHandle(Context context, Annotation annotation, Object paramValue) { if (context == null) { throw new ContextException("Context is null"); }/* www.j a va2 s. c om*/ RequestMapping requestMapping = (RequestMapping) annotation; if (requestMapping != null) { RequestMethod requestMethod = ArrayUtil.getFirstValue(requestMapping.method()); if (requestMethod != null) { context.setHttpMethod(HttpMethod.valueOf(requestMethod.name())); } if (requestMapping.consumes() != null && requestMapping.consumes().length > 0) { context.getHttpHeaders() .setContentType(new MediaType(ArrayUtil.getFirstValue(requestMapping.consumes()))); } if (requestMapping.produces() != null && requestMapping.produces().length > 0) { context.getHttpHeaders().setAccept(HttpRequestUtil.getAcceptedTypes(requestMapping.produces())); } context.addUrlPath(ArrayUtil.getFirstValue(requestMapping.value())); addHeaders(context, requestMapping.headers()); addParams(context, requestMapping.params()); } }