|
|
|
@ -29,7 +29,11 @@ import com.fasterxml.jackson.databind.JsonNode;
@@ -29,7 +29,11 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonSerializer; |
|
|
|
|
import com.fasterxml.jackson.databind.SerializerProvider; |
|
|
|
|
import com.fasterxml.jackson.databind.node.ArrayNode; |
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
|
|
|
|
|
|
import org.springframework.core.convert.ConversionFailedException; |
|
|
|
|
import org.springframework.core.convert.TypeDescriptor; |
|
|
|
|
import org.springframework.data.domain.Sort; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -39,6 +43,8 @@ import org.springframework.data.domain.Sort;
@@ -39,6 +43,8 @@ import org.springframework.data.domain.Sort;
|
|
|
|
|
*/ |
|
|
|
|
public class SortJsonComponent { |
|
|
|
|
|
|
|
|
|
private static final Log LOG = LogFactory.getLog(SortJsonComponent.class); |
|
|
|
|
|
|
|
|
|
public static class SortSerializer extends JsonSerializer<Sort> { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -50,7 +56,14 @@ public class SortJsonComponent {
@@ -50,7 +56,14 @@ public class SortJsonComponent {
|
|
|
|
|
gen.writeObject(v); |
|
|
|
|
} |
|
|
|
|
catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
String message = "Couldn't serialize Sort object for " + v; |
|
|
|
|
if (LOG.isErrorEnabled()) { |
|
|
|
|
LOG.error(message, e); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
throw new ConversionFailedException(TypeDescriptor.valueOf(Sort.class), |
|
|
|
|
TypeDescriptor.valueOf(String.class), v, e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
gen.writeEndArray(); |
|
|
|
|