From 26c0d1320fb91a30976747fc37eeaa7d7103f54f Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 21 Jan 2013 11:33:46 -0800 Subject: [PATCH] Fixes to make changes throwing NPE when no values set --- .../astrid/actfm/sync/messages/MakeChanges.java | 12 +++++------- .../com/todoroo/astrid/tags/TagService.java | 6 ++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/MakeChanges.java b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/MakeChanges.java index f929c70e8..4b72884e5 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/MakeChanges.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/sync/messages/MakeChanges.java @@ -61,7 +61,7 @@ public class MakeChanges extends ServerToClientMessage } StringProperty uuidProperty = (StringProperty) NameMaps.serverColumnNameToLocalProperty(table, "uuid"); - if (model.getSetValues().containsKey(uuidProperty.name)) + if (model.getSetValues() != null && model.getSetValues().containsKey(uuidProperty.name)) uuid = model.getValue(uuidProperty); beforeSaveChanges(changes, model, uuid); @@ -69,19 +69,17 @@ public class MakeChanges extends ServerToClientMessage if (pushedAtProperty != null && pushedAt > 0) model.setValue(pushedAtProperty, pushedAt); - if (!model.getSetValues().containsKey(uuidProperty.name)) + if (model.getSetValues() != null && !model.getSetValues().containsKey(uuidProperty.name)) model.setValue(uuidProperty, uuid); - if (model.getSetValues().size() > 0) { + if (model.getSetValues() != null && model.getSetValues().size() > 0) { model.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true); - boolean success = true; if (dao.update(RemoteModel.UUID_PROPERTY.eq(uuid), model) <= 0) { // If update doesn't update rows. create a new model model.putTransitory(SyncFlags.ACTFM_SUPPRESS_OUTSTANDING_ENTRIES, true); - success = dao.createNew(model); + dao.createNew(model); } - if (success) - afterSaveChanges(changes, model, uuid); } + afterSaveChanges(changes, model, uuid); } catch (IllegalAccessException e) { Log.e(ERROR_TAG, "Error instantiating model for MakeChanges", e); diff --git a/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java b/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java index 4ef91c606..aa792456c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java +++ b/astrid/plugin-src/com/todoroo/astrid/tags/TagService.java @@ -263,6 +263,12 @@ public final class TagService { } } + /** + * Creates a link for a nameless tag. We expect the server to fill in the tag name with a MakeChanges message later + * @param taskId + * @param taskUuid + * @param tagUuid + */ public void createLink(long taskId, String taskUuid, String tagUuid) { TodorooCursor existingTag = tagDataService.query(Query.select(TagData.NAME, TagData.UUID).where(TagData.UUID.eq(tagUuid))); try {