|
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
|
|
import org.apache.http.entity.mime.MultipartEntity;
|
|
|
|
|
import org.apache.http.entity.mime.content.FileBody;
|
|
|
|
@ -110,6 +111,7 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
|
|
|
|
|
JSONArray array = new JSONArray();
|
|
|
|
|
AtomicInteger uploadCounter = new AtomicInteger();
|
|
|
|
|
PropertyToJSONVisitor visitor = new PropertyToJSONVisitor();
|
|
|
|
|
AtomicReference<Object> valueRef = new AtomicReference<Object>();
|
|
|
|
|
for (OE change : changes) {
|
|
|
|
|
try {
|
|
|
|
|
String localColumn = change.getValue(OutstandingEntry.COLUMN_STRING_PROPERTY);
|
|
|
|
@ -150,9 +152,12 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
|
|
|
|
|
throw new RuntimeException("No server column found for local column " + localColumn + " in table " + table);
|
|
|
|
|
|
|
|
|
|
Object value = localProperty.accept(visitor, change);
|
|
|
|
|
if (!validateValue(localProperty, value))
|
|
|
|
|
valueRef.set(value);
|
|
|
|
|
if (!validateValue(localProperty, valueRef))
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
value = valueRef.get();
|
|
|
|
|
|
|
|
|
|
if (value == null)
|
|
|
|
|
changeJson.put("value", JSONObject.NULL);
|
|
|
|
|
else {
|
|
|
|
@ -218,10 +223,13 @@ public class ChangesHappened<TYPE extends RemoteModel, OE extends OutstandingEnt
|
|
|
|
|
|
|
|
|
|
// Return false if value is detected to be something that would definitely cause a server error
|
|
|
|
|
// (e.g. empty task title, etc.)
|
|
|
|
|
private boolean validateValue(Property<?> property, Object value) {
|
|
|
|
|
private boolean validateValue(Property<?> property, AtomicReference<Object> valueRef) {
|
|
|
|
|
if (Task.TITLE.equals(property)) {
|
|
|
|
|
if (!(value instanceof String) || TextUtils.isEmpty((String) value))
|
|
|
|
|
if (!(valueRef.get() instanceof String) || TextUtils.isEmpty((String) valueRef.get()))
|
|
|
|
|
return false;
|
|
|
|
|
} else if (Task.RECURRENCE.equals(property)) {
|
|
|
|
|
if (";FROM=COMPLETION".equals(valueRef.get()))
|
|
|
|
|
valueRef.set("");
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|