// Create a BookmarkRecord object from a cursor on a row containing a Fennec bookmark. public static BookmarkRecord bookmarkFromMirrorCursor( Cursor cur, String parentGUID, String parentName, JSONArray children) { final String collection = "bookmarks"; final String guid = RepoUtils.getStringFromCursor(cur, BrowserContract.SyncColumns.GUID); final long lastModified = RepoUtils.getLongFromCursor(cur, BrowserContract.SyncColumns.DATE_MODIFIED); final boolean deleted = isDeleted(cur); BookmarkRecord rec = new BookmarkRecord(guid, collection, lastModified, deleted); // No point in populating it. if (deleted) { return logBookmark(rec); } int rowType = getTypeFromCursor(cur); String typeString = BrowserContractHelpers.typeStringForCode(rowType); if (typeString == null) { Logger.warn(LOG_TAG, "Unsupported type code " + rowType); return null; } else { Logger.trace(LOG_TAG, "Record " + guid + " has type " + typeString); } rec.type = typeString; rec.title = RepoUtils.getStringFromCursor(cur, BrowserContract.Bookmarks.TITLE); rec.bookmarkURI = RepoUtils.getStringFromCursor(cur, BrowserContract.Bookmarks.URL); rec.description = RepoUtils.getStringFromCursor(cur, BrowserContract.Bookmarks.DESCRIPTION); rec.tags = RepoUtils.getJSONArrayFromCursor(cur, BrowserContract.Bookmarks.TAGS); rec.keyword = RepoUtils.getStringFromCursor(cur, BrowserContract.Bookmarks.KEYWORD); rec.androidID = RepoUtils.getLongFromCursor(cur, BrowserContract.Bookmarks._ID); rec.androidPosition = RepoUtils.getLongFromCursor(cur, BrowserContract.Bookmarks.POSITION); rec.children = children; // Need to restore the parentId since it isn't stored in content provider. // We also take this opportunity to fix up parents for special folders, // allowing us to map between the hierarchies used by Fennec and Places. BookmarkRecord withParentFields = computeParentFields(rec, parentGUID, parentName); if (withParentFields == null) { // Oh dear. Something went wrong. return null; } return logBookmark(withParentFields); }