|
|
@ -273,12 +273,13 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M |
|
|
|
|
|
|
|
|
|
|
|
void merge(InputStream input, Charset charset, MediaType contentType, |
|
|
|
void merge(InputStream input, Charset charset, MediaType contentType, |
|
|
|
ExtensionRegistry extensionRegistry, Message.Builder builder) |
|
|
|
ExtensionRegistry extensionRegistry, Message.Builder builder) |
|
|
|
throws IOException, HttpMessageNotReadableException; |
|
|
|
throws IOException, HttpMessageConversionException; |
|
|
|
|
|
|
|
|
|
|
|
void print(Message message, OutputStream output, MediaType contentType, Charset charset) |
|
|
|
void print(Message message, OutputStream output, MediaType contentType, Charset charset) |
|
|
|
throws IOException, HttpMessageNotWritableException; |
|
|
|
throws IOException, HttpMessageConversionException; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* {@link ProtobufFormatSupport} implementation used when |
|
|
|
* {@link ProtobufFormatSupport} implementation used when |
|
|
|
* {@code com.googlecode.protobuf.format.FormatFactory} is available. |
|
|
|
* {@code com.googlecode.protobuf.format.FormatFactory} is available. |
|
|
@ -311,7 +312,7 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void merge(InputStream input, Charset charset, MediaType contentType, |
|
|
|
public void merge(InputStream input, Charset charset, MediaType contentType, |
|
|
|
ExtensionRegistry extensionRegistry, Message.Builder builder) |
|
|
|
ExtensionRegistry extensionRegistry, Message.Builder builder) |
|
|
|
throws IOException, HttpMessageNotReadableException { |
|
|
|
throws IOException, HttpMessageConversionException { |
|
|
|
|
|
|
|
|
|
|
|
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
|
|
|
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
|
|
|
this.jsonFormatter.merge(input, charset, extensionRegistry, builder); |
|
|
|
this.jsonFormatter.merge(input, charset, extensionRegistry, builder); |
|
|
@ -320,14 +321,14 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M |
|
|
|
this.xmlFormatter.merge(input, charset, extensionRegistry, builder); |
|
|
|
this.xmlFormatter.merge(input, charset, extensionRegistry, builder); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
throw new HttpMessageNotReadableException( |
|
|
|
throw new HttpMessageConversionException( |
|
|
|
"protobuf-java-format does not support parsing " + contentType); |
|
|
|
"protobuf-java-format does not support parsing " + contentType); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void print(Message message, OutputStream output, MediaType contentType, Charset charset) |
|
|
|
public void print(Message message, OutputStream output, MediaType contentType, Charset charset) |
|
|
|
throws IOException, HttpMessageNotWritableException { |
|
|
|
throws IOException, HttpMessageConversionException { |
|
|
|
|
|
|
|
|
|
|
|
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
|
|
|
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
|
|
|
this.jsonFormatter.print(message, output, charset); |
|
|
|
this.jsonFormatter.print(message, output, charset); |
|
|
@ -339,7 +340,7 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M |
|
|
|
this.htmlFormatter.print(message, output, charset); |
|
|
|
this.htmlFormatter.print(message, output, charset); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
throw new HttpMessageNotWritableException( |
|
|
|
throw new HttpMessageConversionException( |
|
|
|
"protobuf-java-format does not support printing " + contentType); |
|
|
|
"protobuf-java-format does not support printing " + contentType); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -374,21 +375,21 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void merge(InputStream input, Charset charset, MediaType contentType, |
|
|
|
public void merge(InputStream input, Charset charset, MediaType contentType, |
|
|
|
ExtensionRegistry extensionRegistry, Message.Builder builder) |
|
|
|
ExtensionRegistry extensionRegistry, Message.Builder builder) |
|
|
|
throws IOException, HttpMessageNotReadableException { |
|
|
|
throws IOException, HttpMessageConversionException { |
|
|
|
|
|
|
|
|
|
|
|
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
|
|
|
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
|
|
|
InputStreamReader reader = new InputStreamReader(input, charset); |
|
|
|
InputStreamReader reader = new InputStreamReader(input, charset); |
|
|
|
this.parser.merge(reader, builder); |
|
|
|
this.parser.merge(reader, builder); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
throw new HttpMessageNotReadableException( |
|
|
|
throw new HttpMessageConversionException( |
|
|
|
"protobuf-java-util does not support parsing " + contentType); |
|
|
|
"protobuf-java-util does not support parsing " + contentType); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void print(Message message, OutputStream output, MediaType contentType, Charset charset) |
|
|
|
public void print(Message message, OutputStream output, MediaType contentType, Charset charset) |
|
|
|
throws IOException, HttpMessageNotWritableException { |
|
|
|
throws IOException, HttpMessageConversionException { |
|
|
|
|
|
|
|
|
|
|
|
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
|
|
|
if (contentType.isCompatibleWith(APPLICATION_JSON)) { |
|
|
|
OutputStreamWriter writer = new OutputStreamWriter(output, charset); |
|
|
|
OutputStreamWriter writer = new OutputStreamWriter(output, charset); |
|
|
@ -396,7 +397,7 @@ public class ProtobufHttpMessageConverter extends AbstractHttpMessageConverter<M |
|
|
|
writer.flush(); |
|
|
|
writer.flush(); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
throw new HttpMessageNotWritableException( |
|
|
|
throw new HttpMessageConversionException( |
|
|
|
"protobuf-java-util does not support printing " + contentType); |
|
|
|
"protobuf-java-util does not support printing " + contentType); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|