From aeb631472159e9c7305a4f2afbcf57ec09259ef9 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Tue, 13 Mar 2012 15:48:26 -0700 Subject: [PATCH] Bug 735475 - Invert AndroidBrowserRepositorySession.checkRecordType into shouldIgnore. r=nalexander --- ...roidBrowserBookmarksRepositorySession.java | 10 ++-- .../AndroidBrowserRepositorySession.java | 54 +++++-------------- 2 files changed, 17 insertions(+), 47 deletions(-) diff --git a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java index 3fa15fbe581..81af2e45395 100644 --- a/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java +++ b/mobile/android/base/sync/repositories/android/AndroidBrowserBookmarksRepositorySession.java @@ -459,21 +459,21 @@ public class AndroidBrowserBookmarksRepositorySession extends AndroidBrowserRepo } @Override - protected boolean checkRecordType(Record record) { + protected boolean shouldIgnore(Record record) { if (!(record instanceof BookmarkRecord)) { - return false; + return true; } if (record.deleted) { - return true; + return false; } BookmarkRecord bmk = (BookmarkRecord) record; if (bmk.isBookmark() || bmk.isFolder()) { - return true; + return false; } Logger.info(LOG_TAG, "Ignoring record with guid: " + bmk.guid + " and type: " + bmk.type); - return false; + return true; } @Override diff --git a/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java b/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java index 8505f423b75..2207b8b6909 100644 --- a/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java +++ b/mobile/android/base/sync/repositories/android/AndroidBrowserRepositorySession.java @@ -1,40 +1,6 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Android Sync Client. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Jason Voll - * Richard Newman - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ package org.mozilla.gecko.sync.repositories.android; @@ -118,9 +84,13 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos */ protected abstract Record retrieveDuringFetch(Cursor cur) throws NoGuidForIdException, NullCursorException, ParentNotFoundException; - // Must be overriden by AndroidBookmarkRepositorySession. - protected boolean checkRecordType(Record record) { - return true; + /** + * Override this to allow records to be skipped during insertion. + * + * For example, a session subclass might skip records of an unsupported type. + */ + protected boolean shouldIgnore(Record record) { + return false; } /** @@ -393,8 +363,8 @@ public abstract class AndroidBrowserRepositorySession extends StoreTrackingRepos // including livemarks and queries, are simply ignored. // See Bug 708149. This might be resolved by Fennec changing its database // schema, or by Sync storing non-applied records in its own private database. - if (!checkRecordType(record)) { - Logger.debug(LOG_TAG, "Ignoring record " + record.guid + " due to unknown record type."); + if (shouldIgnore(record)) { + Logger.debug(LOG_TAG, "Ignoring record " + record.guid); // Don't throw: we don't want to abort the entire sync when we get a livemark! // delegate.onRecordStoreFailed(new InvalidBookmarkTypeException(null));