Package io.permazen.spring
Class PermazenObjectHttpMessageConverter
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<PermazenObject>
io.permazen.spring.PermazenObjectHttpMessageConverter
- All Implemented Interfaces:
HttpMessageConverter<PermazenObject>
public class PermazenObjectHttpMessageConverter
extends AbstractHttpMessageConverter<PermazenObject>
Spring
HttpMessageConverter
capable of
encoding and decoding one or more PermazenObject
s contained in a DetachedPermazenTransaction
.
The payload MIME type is set to application/x-permazen-transaction
with an additional root
parameter specifying the root PermazenObject
in the encoded transaction.
There may of course be arbitrarily many other supporting PermazenObject
s riding along with it.
Validation of all incoming objects is supported; see setValidationGroups()
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of the object ID parameter incluced in the MIME type.Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
logger
-
Constructor Summary
ConstructorDescriptionConstructor.PermazenObjectHttpMessageConverter
(Permazen pdb, MediaType... supportedMediaTypes) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
protected Long
getContentLength
(PermazenObject jobj, MediaType contentType) protected MediaType
protected PermazenObject
readInternal
(Class<? extends PermazenObject> type, HttpInputMessage input) void
setValidationGroups
(Class<?>... groups) Set validation groups used to validate all incoming objects.protected boolean
protected void
writeInternal
(PermazenObject jobj, HttpOutputMessage output) Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
addDefaultHeaders, canRead, canWrite, canWrite, getDefaultCharset, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, supportsRepeatableWrites, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.http.converter.HttpMessageConverter
getSupportedMediaTypes
-
Field Details
-
ROOT_OBJECT_ID_PARAMETER_NAME
Name of the object ID parameter incluced in the MIME type.- See Also:
-
-
Constructor Details
-
PermazenObjectHttpMessageConverter
Constructor.- Parameters:
pdb
-Permazen
instance- Throws:
IllegalArgumentException
- ifpdb
is null
-
PermazenObjectHttpMessageConverter
Constructor.- Parameters:
pdb
-Permazen
instancesupportedMediaTypes
- supported media types- Throws:
IllegalArgumentException
- ifpdb
is null
-
-
Method Details
-
setValidationGroups
Set validation groups used to validate all incoming objects.If set to null, no validation is performed; this is the default behavior.
Otherwise, validation of all incoming objects (not just the root object) is performed using the specified validation groups, or
Default
if an empty array is specified.- Parameters:
groups
- validation group(s) to use for validation; if empty,Default
is assumed; if null, no validation is performed
-
getContentLength
- Overrides:
getContentLength
in classAbstractHttpMessageConverter<PermazenObject>
-
canRead
- Specified by:
canRead
in interfaceHttpMessageConverter<PermazenObject>
- Overrides:
canRead
in classAbstractHttpMessageConverter<PermazenObject>
-
supports
- Specified by:
supports
in classAbstractHttpMessageConverter<PermazenObject>
-
getDefaultContentType
- Overrides:
getDefaultContentType
in classAbstractHttpMessageConverter<PermazenObject>
-
readInternal
protected PermazenObject readInternal(Class<? extends PermazenObject> type, HttpInputMessage input) throws IOException - Specified by:
readInternal
in classAbstractHttpMessageConverter<PermazenObject>
- Throws:
IOException
-
writeInternal
- Specified by:
writeInternal
in classAbstractHttpMessageConverter<PermazenObject>
- Throws:
IOException
-