After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 748253 - gdata: Treat the GDataEntry:id as an opaque string
gdata: Treat the GDataEntry:id as an opaque string
Status: RESOLVED FIXED
Product: gnome-online-miners
Classification: Applications
Component: general
3.14.x
Other All
: Immediate critical
: ---
Assigned To: GNOME Online Miners maintainer(s)
GNOME Online Miners maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-04-21 14:56 UTC by Debarshi Ray
Modified: 2015-06-03 16:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gdata: Treat the GDataEntry:id as an opaque string (1.98 KB, patch)
2015-04-21 15:05 UTC, Debarshi Ray
none Details | Review
gdata: Use pre-defined constants (1.22 KB, patch)
2015-04-21 15:05 UTC, Debarshi Ray
committed Details | Review
documents: Adapt to changes in nao:identifier syntax for Google items (1.46 KB, patch)
2015-04-21 15:11 UTC, Debarshi Ray
none Details | Review
gdata: Treat the GDataEntry:id as an opaque string (2.26 KB, patch)
2015-04-22 08:51 UTC, Debarshi Ray
committed Details | Review
gdata: Use a #define for the PicasaWeb prefix (1.60 KB, patch)
2015-04-22 08:56 UTC, Debarshi Ray
committed Details | Review
documents: Remove unused constants (1.00 KB, patch)
2015-04-22 09:44 UTC, Debarshi Ray
committed Details | Review
Adapt to changes in nao:identifier syntax for Google items (3.65 KB, patch)
2015-04-22 09:45 UTC, Debarshi Ray
committed Details | Review
gdata: Explain the need for adding our own prefix to the IDs (824 bytes, patch)
2015-04-22 16:51 UTC, Debarshi Ray
committed Details | Review
sharing: Adapt to changes in nao:identifier syntax for Google items (3.47 KB, patch)
2015-06-03 16:13 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2015-04-21 14:56:59 UTC
We have been assuming that GDataEntry:id is a string with "https://docs.google.com" as the prefix. The ID is stored verbatim as the nao:identifier, and gnome-documents uses the presence of "https://docs.google.com" in nao:identifier to decide whether to create a GoogleDocument instance or something else.

This assumption is flawed because we should be treating the ID as an opaque string. In fact, in the new Drive v2 API (see bug 684920), the ID is just an alphanumeric string.

I suggest that we add our own prefix to the ID before storing it as nao:identifier. eg., google:drive:xxxxyyyyzzzz. This is what we do for PicasaWeb and OneDrive, and I don't see why we shouldn't be doing it for Drive as well.
Comment 1 Debarshi Ray 2015-04-21 14:58:17 UTC
Bumping the importance because things will break when we merge the Drive v2 support in libgdata.
Comment 2 Debarshi Ray 2015-04-21 15:05:17 UTC
Created attachment 302076 [details] [review]
gdata: Treat the GDataEntry:id as an opaque string
Comment 3 Debarshi Ray 2015-04-21 15:05:44 UTC
Created attachment 302077 [details] [review]
gdata: Use pre-defined constants
Comment 4 Debarshi Ray 2015-04-21 15:11:28 UTC
Created attachment 302079 [details] [review]
documents: Adapt to changes in nao:identifier syntax for Google items
Comment 5 Philip Withnall 2015-04-21 15:41:27 UTC
Review of attachment 302076 [details] [review]:

::: src/gom-gdata-miner.c
@@ +83,2 @@
       link = gdata_entry_look_up_link (entry, GDATA_LINK_SELF);
+      identifier = g_strdup_printf ("gd:collection:google:drive:%s", gdata_link_get_uri (link));

I would suggest ‘google:drive:v2:’ just in case the ID format changes again for v3, necessitating another re-index.

Also, it would be neater to move this out as a #define.
Comment 6 Philip Withnall 2015-04-21 15:43:08 UTC
Review of attachment 302077 [details] [review]:

++
Comment 7 Philip Withnall 2015-04-21 15:44:09 UTC
Review of attachment 302079 [details] [review]:

::: src/documents.js
@@ +792,3 @@
 
+        const gdata_prefix = "google:drive:";
+        let gdata_id = this.identifier.substring(gdata_prefix.length);

Moving the ‘google:drive:’ prefix into some kind of const would be good.
Comment 8 Philip Withnall 2015-04-21 15:44:48 UTC
Review of attachment 302076 [details] [review]:

::: src/gom-gdata-miner.c
@@ +83,2 @@
       link = gdata_entry_look_up_link (entry, GDATA_LINK_SELF);
+      identifier = g_strdup_printf ("gd:collection:google:drive:%s", gdata_link_get_uri (link));

> I would suggest ‘google:drive:v2:’ just in case the ID format changes again for v3, necessitating another re-index.

Actually, ignore me, that was a stupid suggestion.
Comment 9 Cosimo Cecchi 2015-04-21 18:22:50 UTC
Review of attachment 302076 [details] [review]:

Looks good to me as well, with Philip's suggestion of moving the google drive string to a #define
Comment 10 Debarshi Ray 2015-04-22 08:51:34 UTC
Created attachment 302128 [details] [review]
gdata: Treat the GDataEntry:id as an opaque string

Added a #define for the prefix
Comment 11 Debarshi Ray 2015-04-22 08:56:29 UTC
Created attachment 302129 [details] [review]
gdata: Use a #define for the PicasaWeb prefix
Comment 12 Debarshi Ray 2015-04-22 09:44:13 UTC
Created attachment 302132 [details] [review]
documents: Remove unused constants
Comment 13 Debarshi Ray 2015-04-22 09:45:05 UTC
Created attachment 302133 [details] [review]
Adapt to changes in nao:identifier syntax for Google items
Comment 14 Cosimo Cecchi 2015-04-22 16:19:27 UTC
Review of attachment 302128 [details] [review]:

Looks good
Comment 15 Cosimo Cecchi 2015-04-22 16:20:41 UTC
Review of attachment 302129 [details] [review]:

Looks good
Comment 16 Cosimo Cecchi 2015-04-22 16:20:58 UTC
Review of attachment 302132 [details] [review]:

Sure
Comment 17 Cosimo Cecchi 2015-04-22 16:22:56 UTC
Review of attachment 302133 [details] [review]:

Looks good
Comment 18 Philip Withnall 2015-04-22 16:35:45 UTC
Review of attachment 302128 [details] [review]:

::: src/gom-gdata-miner.c
@@ +31,3 @@
 #define MINER_IDENTIFIER "gd:gdata:miner:86ec9bc9-c242-427f-aa19-77b5a2c9b6f0"
 #define PARENT_LINK_REL "http://schemas.google.com/docs/2007#parent"
+#define PREFIX_DRIVE "google:drive:"

I would also suggest putting a comment above here explaining briefly why on earth we add out own prefix to all the IDs, so it doesn't get 'optimised out' by someone in future.
Comment 19 Debarshi Ray 2015-04-22 16:51:42 UTC
Created attachment 302168 [details] [review]
gdata: Explain the need for adding our own prefix to the IDs
Comment 20 Debarshi Ray 2015-06-03 16:11:31 UTC
I forgot to adapt the sharing dialog to the new nao:identifier syntax for Google items. Reopening.
Comment 21 Debarshi Ray 2015-06-03 16:13:14 UTC
Created attachment 304532 [details] [review]
sharing: Adapt to changes in nao:identifier syntax for Google items
Comment 22 Philip Withnall 2015-06-03 16:34:05 UTC
Review of attachment 304532 [details] [review]:

Looks good to me.
Comment 23 Debarshi Ray 2015-06-03 16:53:50 UTC
Comment on attachment 304532 [details] [review]
sharing: Adapt to changes in nao:identifier syntax for Google items

Thanks Philip. Pushed to master, gnome-3-16 and gnome-3-14.