Commit 88f4507d authored by Richard Bruskiewich's avatar Richard Bruskiewich Committed by Matija Obreza
Browse files

the CropSerializer.serializer method probably needs to check if

croprules are null (from the database retrieval) before attempting for
iteration to serialize.
parent de080aa0
......@@ -17,6 +17,7 @@
package org.genesys2.server.servlet.controller.rest.serialization;
import java.io.IOException;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.genesys2.server.model.impl.Crop;
......@@ -42,11 +43,15 @@ public class CropSerializer extends JsonSerializer<Crop> {
if (StringUtils.isNotBlank(crop.getI18n()))
jgen.writeObjectField("i18n", crop.getI18n());
jgen.writeArrayFieldStart("rules");
for (CropRule cropRule : crop.getCropRules()) {
jgen.writeObject(cropRule);
List<CropRule> croprules = crop.getCropRules() ;
if(croprules != null) {
jgen.writeArrayFieldStart("rules");
for (CropRule cropRule : croprules ) {
jgen.writeObject(cropRule);
}
jgen.writeEndArray();
}
jgen.writeEndArray();
jgen.writeEndObject();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment