Tomdroid does not send the "create-data" field in JSON when web syncing

Bug #1074602 reported by McFry
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Tomdroid
Fix Released
High
NoahY
Beta
Fix Released
High
NoahY

Bug Description

When pushing changed notes to the websync server, tomboy serializes the Notes into JSON. However, as far as I can see in the sourcecode, the "create-data" element that is required by the syncing REST API (see https://live.gnome.org/Tomboy/Synchronization/REST/1.0) is missing. This causes trouble when syncing.

I think the affected line is here: http://bazaar.launchpad.net/~tomdroid-maintainers/tomdroid/note-editing-and-syncing/view/head:/src/org/tomdroid/sync/web/SnowySyncService.java#L374

(aournd line 374):
else { // changed note
  Jnote.put("title", note.getTitle());
  Jnote.put("note-content", note.getXmlContent());
  Jnote.put("note-content-version", "0.1");
  Jnote.put("last-change-date", note.getLastChangeDate().format3339(false));
}

The should be a lie similiar to setting "last-change-date", maybe sth like this (untested!):

 Jnote.put("create-date", note.getCreateDate().format3339(false));

Additionally, from what I can see, the also required field "last-metadata-change-date" is missing in the same way and needs fixing. Here is the JSON sent by tomdroid which I could sniff from the connection:

200010 [DEBUG] Rainy.WebService.RequestLogFilter->RequestFilter - Received request at: //api/1.0/timo/notes
JSON Data received:
{
 latest-sync-revision: 1,
 note-changes:
 [
  {
   title: hgg,
   note-content: ,
   note-content-version: 0.3,
   guid: bf362e5c-ba70-41f6-b572-b55d1027d6bd,
   create-date: "0001-01-01T00:00:00.0000000+00:00",
   last-change-date: "2012-11-03T10:21:20.0000000+00:00",
   last-metadata-change-date: "0001-01-01T00:00:00.0000000+00:00",
   last-sync-revision: 0,
   tags: []
  }
 ],
 test: 0
}

So, the fields are present (and I don't know why that is, I cant finde the source where it is set) but not initialized. This will cause tomboy to through an exception when syncing.

Revision history for this message
McFry (timo-latecrew) wrote :

Watch out, I made a typo. The missing field is "create-date"

Revision history for this message
McFry (timo-latecrew) wrote :

As I am currently working on a sync server and looking at the lowel data that tomdroid transfers, it would also be very helpful to get the raw JSON data tomdroid sends into the log (via TLog). The JSON tomdroid *reveices* is already logged, but the raw JSON that is send over the wire will be as helpful.

Revision history for this message
NoahY (noahy) wrote :

Thanks for reporting this bug. Can you try the latest revision and let me know if this is fixed?

The data sent is being logged, afaics, at SnowySyncService.java line 397:

TLog.v(TAG, "pushing data to remote service: {0}",data.toString());

Changed in tomdroid:
status: New → Fix Committed
Revision history for this message
Stefan Hammer (j-4-deactivatedaccount) wrote : Re: [Bug 1074602] Re: Tomdroid does not send the "create-data" field in JSON when web syncing

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Noah, thanks for your fast fix. Please push your bugfixes only to
lp:tomdroid otherwise it will get confusing. I already merged your
recent changes for now.
Thanks!

On 03/11/12 13:21, NoahY wrote:
> Thanks for reporting this bug. Can you try the latest revision and
> let me know if this is fixed?
>
> The data sent is being logged, afaics, at SnowySyncService.java
> line 397:
>
> TLog.v(TAG, "pushing data to remote service:
> {0}",data.toString());
>
>
> ** Changed in: tomdroid Status: New => Fix Committed
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlCVIswACgkQXeaPvgR0RGch+wCfa5domMXhaOK8mPlFXMNDCzT6
Oh8AoNTdT/+s51jalaLGVcioTV9EA0sy
=exGF
-----END PGP SIGNATURE-----

Changed in tomdroid:
milestone: none → 0.7.3
Revision history for this message
McFry (timo-latecrew) wrote :

unfortunately, that does only fix it half :/ Stefan just send me a new build with the fix in place and i tested again: The last-metadata-change-date is now set correctly, but the create-date field is still send incorrectly. I assume that is because create-date is not well-formated, using .format3339(false) ?

Here is the sniffed JSON:
185312 [DEBUG] Rainy.WebService.RequestLogFilterAttribute->RequestFilter - Received request at: //api/1.0/johndoe/notes
JSON Data received:
{
 Username: johndoe,
 latest-sync-revision: 1,
 note-changes:
 [
  {
   title: asdfg,
   note-content: dggdtv,
   note-content-version: 0.3,
   guid: f5614cc3-bdf6-4e86-b2ff-3c2da525d881,
   create-date: "1970-01-01T00:00:00.0000000+00:00",
   last-change-date: "2012-11-03T14:38:33.0000000+00:00",
   last-metadata-change-date: "2012-11-03T14:38:33.0000000+00:00",
   last-sync-revision: 0,
   tags: []
  }
 ],

(observe that last-metadata-change-date now is changed, which inidicates that new build stefan send me already includes the fix).

Revision history for this message
NoahY (noahy) wrote :

I think I see the problem; Tomdroid doesn't store create dates in the database yet so they are given as the epoch date. Someone will have to modify the database to store them. Anyway, that create date should allow you to sync, since it is formatted properly, afaics.

Revision history for this message
McFry (timo-latecrew) wrote :

Storing the epoch-date on the sync server is no problem, but when tomboy pulls the note it performs some date calculations and somehow tries to substract from the epoch date (which will cause an overflow exception). As a workaround, one could send a newer timestamp as the create-date, like i.e. 1.1.2000. That might fix the sync issues without having to patch tomboy.

Nonetheless, tomdroid should store the create-date for a note, since it is usefull information to the user. So maybe put this into a another bugreport titled "Save note creation date in the database".

By the way, the sync server I am working on is now on github and has extensive logging, might be usefull for any tomdroid user or developer: https://github.com/Dynalon/Rainy

Revision history for this message
Stefan Hammer (j-4-deactivatedaccount) wrote :

i changed the date to 1.1.2000 ;-) and created a new bug for storing the create date

Changed in tomdroid:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.