本文整理汇总了Java中org.springframework.web.HttpMediaTypeNotSupportedException类的典型用法代码示例。如果您正苦于以下问题:Java HttpMediaTypeNotSupportedException类的具体用法?Java HttpMediaTypeNotSupportedException怎么用?Java HttpMediaTypeNotSupportedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpMediaTypeNotSupportedException类属于org.springframework.web包,在下文中一共展示了HttpMediaTypeNotSupportedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleHttpMediaTypeNotSupported
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(final HttpMediaTypeNotSupportedException ex, final HttpHeaders headers,
final HttpStatus status, final WebRequest request) {
logger.info(ex.getClass().getName());
//
final ErrorDetail errorDetail = new ErrorDetail();
final StringBuilder builder = new StringBuilder();
builder.append(ex.getContentType());
builder.append(" media type is not supported. Supported media types are ");
// ex.getSupportedMediaTypes().forEach(t -> builder.append(t + " "));
errorDetail.setTimeStamp(new Date().getTime());
errorDetail.setStatus(status.value());
errorDetail.setTitle("Method not supported");
errorDetail.setDetail(builder.toString());
errorDetail.setDeveloperMessage(ex.getClass().getName());
return handleExceptionInternal(ex, errorDetail, headers, status, request);
}
示例2: resolveArgument
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory)
throws IOException, HttpMediaTypeNotSupportedException {
ServletServerHttpRequest inputMessage = createInputMessage(webRequest);
Type paramType = getHttpEntityType(parameter);
Object body = readWithMessageConverters(webRequest, parameter, paramType);
if (RequestEntity.class == parameter.getParameterType()) {
return new RequestEntity<Object>(body, inputMessage.getHeaders(),
inputMessage.getMethod(), inputMessage.getURI());
}
else {
return new HttpEntity<Object>(body, inputMessage.getHeaders());
}
}
示例3: readWithMessageConverters
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
protected <T> Object readWithMessageConverters(NativeWebRequest webRequest, MethodParameter methodParam,
Type paramType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException {
HttpServletRequest servletRequest = webRequest.getNativeRequest(HttpServletRequest.class);
ServletServerHttpRequest inputMessage = new ServletServerHttpRequest(servletRequest);
Object arg = readWithMessageConverters(inputMessage, methodParam, paramType);
if (arg == null) {
if (methodParam.getParameterAnnotation(RequestBody.class).required()) {
throw new HttpMessageNotReadableException("Required request body is missing: " +
methodParam.getMethod().toGenericString());
}
}
return arg;
}
示例4: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(OAAnnotation oaAnnotation, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = oaAnnotation.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例5: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(OABatchOperation oaBatchOperation, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = oaBatchOperation.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例6: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(OAAnnotationPage oaAnnotationPage, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = oaAnnotationPage.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例7: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(OAAnnotationCollection oaAnnotationCollection, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = oaAnnotationCollection.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例8: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(OAStatisticsPage oaStatisticsPage, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = oaStatisticsPage.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例9: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(OAAnnotationHistory oaAnnotationHistory, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = oaAnnotationHistory.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
JSONLDProfile.Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(JSONLDProfile.Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(JSONLDProfile.Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(JSONLDProfile.Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例10: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(W3CAnnotation w3cAnnotation, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = w3cAnnotation.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例11: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(W3CBatchOperation w3cBatchOperation, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = w3cBatchOperation.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例12: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(W3CAnnotationPage w3cAnnotationPage, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = w3cAnnotationPage.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例13: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(W3CAnnotationCollection w3cAnnotationCollection, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = w3cAnnotationCollection.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例14: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(W3CStatisticsPage w3cStatisticsPage, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = w3cStatisticsPage.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}
示例15: getStringRepresentation
import org.springframework.web.HttpMediaTypeNotSupportedException; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected String getStringRepresentation(W3CAnnotationHistory w3cAnnotationHistory, MediaType contentType) throws Exception {
Map<String, Object> jsonMap = w3cAnnotationHistory.getJsonMap();
JSONLDProfile jsonLdProfile = getJsonLdProfile(contentType, defaultContexts);
JSONLDProfile.Format format = jsonLdProfile.getFormats().get(0);
if (format.equals(JSONLDProfile.Format.COMPACTED)) {
jsonMap = JsonLdProcessor.compact(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else if (format.equals(JSONLDProfile.Format.EXPANDED)) {
List<Object> jsonList = JsonLdProcessor.expand(jsonMap, jsonLdOptions);
jsonMap = (Map<String, Object>) jsonList.get(0);
} else if (format.equals(JSONLDProfile.Format.FLATTENED)) {
jsonMap = (Map<String, Object>) JsonLdProcessor.flatten(jsonMap, jsonLdProfile.getContexts(), jsonLdOptions);
} else {
throw new HttpMediaTypeNotSupportedException(contentType, getSupportedMediaTypes());
}
jsonMap = reorderJsonAttributes(jsonMap);
return JsonUtils.toPrettyString(jsonMap);
}