Class ContentUrlSerializer

java.lang.Object
com.fasterxml.jackson.databind.JsonSerializer<T>
com.fasterxml.jackson.databind.ser.std.StdSerializer<String>
com.broadleafcommerce.asset.jackson.ContentUrlSerializer
All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable, com.fasterxml.jackson.databind.jsonschema.SchemaAware, Serializable

public class ContentUrlSerializer extends com.fasterxml.jackson.databind.ser.std.StdSerializer<String>
Serializer for Asset.url that writes the URL field itself and also introduces a new contentUrl property on the serialized output.

Delegates to ContentUrlResolver to create the content URL itself.

Author:
Samarth Dhruva (samarthd)
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer

    com.fasterxml.jackson.databind.JsonSerializer.None
  • Field Summary

    Fields inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer

    _handledType
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    void
    serialize(String url, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider provider)
     
    void
    We use this autowired setter here, as Jackson will throw a JsonMappingException if it cannot find a default constructor.

    Methods inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer

    _neitherNull, _nonEmpty, acceptJsonFormatVisitor, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow

    Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer

    getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId, withIgnoredProperties

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ContentUrlSerializer

      public ContentUrlSerializer()
  • Method Details

    • setContentResolver

      @Autowired public void setContentResolver(@NonNull ContentUrlResolver contentUrlResolver)
      We use this autowired setter here, as Jackson will throw a JsonMappingException if it cannot find a default constructor.
      Parameters:
      contentUrlResolver - the content URL resolver responsible for creating the content URL for an asset
      See Also:
      • SpringHandlerInstantiator
    • serialize

      public void serialize(String url, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider provider) throws IOException
      Specified by:
      serialize in class com.fasterxml.jackson.databind.ser.std.StdSerializer<String>
      Throws:
      IOException
    • getContentUrlResolver

      protected ContentUrlResolver getContentUrlResolver()