Put JSON null in changes happened when value is null

pull/14/head
Sam Bosley 12 years ago
parent c2a31285c0
commit c9f2dfb14c

@ -299,7 +299,7 @@ public class DateUtilities {
public static String timeToIso8601(long time, boolean includeTime) { public static String timeToIso8601(long time, boolean includeTime) {
if (time == 0) if (time == 0)
return ""; //$NON-NLS-1$ return null;
Date date = new Date(time); Date date = new Date(time);
String formatString = "yyyy-MM-dd'T'HH:mm:ssZ"; //$NON-NLS-1$ String formatString = "yyyy-MM-dd'T'HH:mm:ssZ"; //$NON-NLS-1$
if (!includeTime) if (!includeTime)

@ -144,7 +144,10 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
if (!validateValue(localProperty, value)) if (!validateValue(localProperty, value))
return null; return null;
changeJson.put("value", value); if (value == null)
changeJson.put("value", JSONObject.NULL);
else
changeJson.put("value", value);
} }
changeJson.put("column", serverColumn); changeJson.put("column", serverColumn);
@ -261,15 +264,18 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
String value = getAsString(data); String value = getAsString(data);
if (RemoteModel.NO_UUID.equals(value) && property.checkFlag(Property.PROP_FLAG_USER_ID)) if (RemoteModel.NO_UUID.equals(value) && property.checkFlag(Property.PROP_FLAG_USER_ID))
return ActFmPreferenceService.userId(); return ActFmPreferenceService.userId();
if (property.checkFlag(Property.PROP_FLAG_JSON)) if (property.checkFlag(Property.PROP_FLAG_JSON)) {
if (TextUtils.isEmpty(value))
return null;
try { try {
if (value != null && value.startsWith("[")) if (value != null && value.startsWith("["))
return new JSONArray(value); return new JSONArray(value);
else else
return new JSONObject(value); return new JSONObject(value);
} catch (JSONException e) { } catch (JSONException e) {
// return null;
} }
}
return value; return value;
} }

Loading…
Cancel
Save