-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3033 Fixed HttpMessageNotWritableException:
- Added serializers: ChronologySerializer, LocalDateTimeSerializer; - Corrected package for SnippetContentGenerator, SnippetServletResponse (from org.scada_lts.web.contnet to org.scada_lts.web.content);
- Loading branch information
Showing
8 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/org/scada_lts/web/beans/serializer/ChronologySerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.scada_lts.web.beans.serializer; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; | ||
|
||
import java.io.IOException; | ||
import java.time.chrono.Chronology; | ||
|
||
|
||
public class ChronologySerializer extends StdSerializer<Chronology> { | ||
|
||
public ChronologySerializer() { | ||
super(Chronology.class); | ||
} | ||
|
||
@Override | ||
public void serialize(Chronology value, JsonGenerator jgen, SerializerProvider provider) throws IOException { | ||
jgen.writeStartObject(); | ||
jgen.writeStringField("id", value.getId()); | ||
jgen.writeStringField("calendarType", value.getCalendarType()); | ||
jgen.writeEndObject(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/org/scada_lts/web/beans/serializer/LocalDateTimeSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.scada_lts.web.beans.serializer; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; | ||
|
||
import java.io.IOException; | ||
import java.time.LocalDateTime; | ||
|
||
|
||
public class LocalDateTimeSerializer extends StdSerializer<LocalDateTime> { | ||
|
||
public LocalDateTimeSerializer() { | ||
super(LocalDateTime.class); | ||
} | ||
|
||
@Override | ||
public void serialize(LocalDateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException { | ||
jgen.writeStartObject(); | ||
jgen.writeNumberField("nano", value.getNano()); | ||
jgen.writeNumberField("year", value.getYear()); | ||
jgen.writeNumberField("monthValue", value.getMonthValue()); | ||
jgen.writeNumberField("dayOfMonth", value.getDayOfMonth()); | ||
jgen.writeNumberField("hour", value.getHour()); | ||
jgen.writeNumberField("minute", value.getMinute()); | ||
jgen.writeNumberField("second", value.getSecond()); | ||
jgen.writeStringField("month", value.getMonth().name()); | ||
jgen.writeStringField("dayOfWeek", value.getDayOfWeek().name()); | ||
jgen.writeNumberField("dayOfYear", value.getDayOfYear()); | ||
jgen.writeObjectField("chronology", value.getChronology()); | ||
jgen.writeEndObject(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../web/contnet/SnippetContentGenerator.java → .../web/content/SnippetContentGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/web/contnet/SnippetServletResponse.java → ...s/web/content/SnippetServletResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters