mirror of
https://github.com/etesync/android
synced 2024-11-15 12:28:57 +00:00
Version bump to 0.5.14-alpha
* added some documentation (JavaDoc) * CTags are not cached in LocalCollection anymore * added CTag test for LocalCalendar
This commit is contained in:
parent
3cab688782
commit
b7cd8baa05
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,6 +12,7 @@
|
||||
|
||||
# generated files
|
||||
bin/
|
||||
doc/javadoc/
|
||||
gen/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="at.bitfire.davdroid"
|
||||
android:versionCode="36"
|
||||
android:versionName="0.5.13-alpha" android:installLocation="internalOnly">
|
||||
android:versionCode="37"
|
||||
android:versionName="0.5.14-alpha" android:installLocation="internalOnly">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid;
|
||||
|
||||
|
@ -1,18 +1,15 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid;
|
||||
|
||||
public class Constants {
|
||||
public static final String
|
||||
APP_VERSION = "0.5.13-alpha",
|
||||
APP_VERSION = "0.5.14-alpha",
|
||||
ACCOUNT_TYPE = "bitfire.at.davdroid",
|
||||
WEB_URL_HELP = "http://davdroid.bitfire.at/configuration?pk_campaign=davdroid-app",
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@ -53,6 +53,10 @@ import ezvcard.property.Uid;
|
||||
import ezvcard.property.Url;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a contact. Locally, this is a Contact in the Android
|
||||
* device; remote, this is a VCard.
|
||||
*/
|
||||
@ToString(callSuper = true)
|
||||
public class Contact extends Resource {
|
||||
private final static String TAG = "davdroid.Contact";
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
public class InvalidResourceException extends Exception {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
@ -65,11 +62,16 @@ import android.provider.ContactsContract;
|
||||
import android.util.Log;
|
||||
import at.bitfire.davdroid.syncadapter.ServerInfo;
|
||||
|
||||
/**
|
||||
* Represents a locally stored calendar, containing Events.
|
||||
* Communicates with the Android Contacts Provider which uses an SQLite
|
||||
* database to store the contacts.
|
||||
*/
|
||||
public class LocalCalendar extends LocalCollection<Event> {
|
||||
private static final String TAG = "davdroid.LocalCalendar";
|
||||
|
||||
@Getter protected long id;
|
||||
@Getter protected String url, cTag;
|
||||
@Getter protected String url;
|
||||
|
||||
protected static String COLLECTION_COLUMN_CTAG = Calendars.CAL_SYNC1;
|
||||
|
||||
@ -149,30 +151,47 @@ public class LocalCalendar extends LocalCollection<Event> {
|
||||
|
||||
public static LocalCalendar[] findAll(Account account, ContentProviderClient providerClient) throws RemoteException {
|
||||
@Cleanup Cursor cursor = providerClient.query(calendarsURI(account),
|
||||
new String[] { Calendars._ID, Calendars.NAME, COLLECTION_COLUMN_CTAG },
|
||||
new String[] { Calendars._ID, Calendars.NAME },
|
||||
Calendars.DELETED + "=0 AND " + Calendars.SYNC_EVENTS + "=1", null, null);
|
||||
|
||||
LinkedList<LocalCalendar> calendars = new LinkedList<LocalCalendar>();
|
||||
while (cursor != null && cursor.moveToNext())
|
||||
calendars.add(new LocalCalendar(account, providerClient, cursor.getInt(0), cursor.getString(1), cursor.getString(2)));
|
||||
calendars.add(new LocalCalendar(account, providerClient, cursor.getInt(0), cursor.getString(1)));
|
||||
return calendars.toArray(new LocalCalendar[0]);
|
||||
}
|
||||
|
||||
public LocalCalendar(Account account, ContentProviderClient providerClient, long id, String url, String cTag) throws RemoteException {
|
||||
public LocalCalendar(Account account, ContentProviderClient providerClient, long id, String url) throws RemoteException {
|
||||
super(account, providerClient);
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
this.cTag = cTag;
|
||||
}
|
||||
|
||||
|
||||
/* collection operations */
|
||||
|
||||
@Override
|
||||
public void setCTag(String cTag) {
|
||||
pendingOperations.add(ContentProviderOperation.newUpdate(ContentUris.withAppendedId(calendarsURI(), id))
|
||||
.withValue(COLLECTION_COLUMN_CTAG, cTag)
|
||||
.build());
|
||||
public String getCTag() throws LocalStorageException {
|
||||
try {
|
||||
@Cleanup Cursor c = providerClient.query(ContentUris.withAppendedId(calendarsURI(), id),
|
||||
new String[] { COLLECTION_COLUMN_CTAG }, null, null, null);
|
||||
if (c.moveToFirst()) {
|
||||
return c.getString(0);
|
||||
} else
|
||||
throw new LocalStorageException("Couldn't query calendar CTag");
|
||||
} catch(RemoteException e) {
|
||||
throw new LocalStorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCTag(String cTag) throws LocalStorageException {
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put(COLLECTION_COLUMN_CTAG, cTag);
|
||||
try {
|
||||
providerClient.update(ContentUris.withAppendedId(calendarsURI(), id), values, null, null);
|
||||
} catch(RemoteException e) {
|
||||
throw new LocalStorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
@ -26,6 +23,13 @@ import android.os.RemoteException;
|
||||
import android.provider.CalendarContract;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Represents a locally-stored synchronizable collection (for instance, the
|
||||
* address book or a calendar). Manages a CTag that stores the last known
|
||||
* remote CTag (the remote CTag changes whenever something in the remote collection changes).
|
||||
*
|
||||
* @param <T> Subtype of Resource that can be stored in the collection
|
||||
*/
|
||||
public abstract class LocalCollection<T extends Resource> {
|
||||
private static final String TAG = "davdroid.LocalCollection";
|
||||
|
||||
@ -36,19 +40,30 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
|
||||
// database fields
|
||||
|
||||
/** base Uri of the collection's entries (for instance, Events.CONTENT_URI);
|
||||
* apply syncAdapterURI() before returning a value */
|
||||
abstract protected Uri entriesURI();
|
||||
|
||||
/** column name of the type of the account the entry belongs to */
|
||||
abstract protected String entryColumnAccountType();
|
||||
/** column name of the name of the account the entry belongs to */
|
||||
abstract protected String entryColumnAccountName();
|
||||
|
||||
/** column name of the collection ID the entry belongs to */
|
||||
abstract protected String entryColumnParentID();
|
||||
/** column name of an entry's ID */
|
||||
abstract protected String entryColumnID();
|
||||
/** column name of an entry's file name on the WebDAV server */
|
||||
abstract protected String entryColumnRemoteName();
|
||||
/** column name of an entry's last ETag on the WebDAV server; null if entry hasn't been uploaded yet */
|
||||
abstract protected String entryColumnETag();
|
||||
|
||||
/** column name of an entry's "dirty" flag (managed by content provider) */
|
||||
abstract protected String entryColumnDirty();
|
||||
/** column name of an entry's "deleted" flag (managed by content provider) */
|
||||
abstract protected String entryColumnDeleted();
|
||||
|
||||
/** column name of an entry's UID */
|
||||
abstract protected String entryColumnUID();
|
||||
|
||||
|
||||
@ -60,15 +75,24 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
|
||||
// collection operations
|
||||
|
||||
/** gets the ID if the collection (for instance, ID of the Android calendar) */
|
||||
abstract public long getId();
|
||||
abstract public String getCTag();
|
||||
abstract public void setCTag(String cTag);
|
||||
/** gets the CTag of the collection */
|
||||
abstract public String getCTag() throws LocalStorageException;
|
||||
/** sets the CTag of the collection */
|
||||
abstract public void setCTag(String cTag) throws LocalStorageException;
|
||||
|
||||
|
||||
// content provider (= database) querying
|
||||
|
||||
/**
|
||||
* Finds new resources (resources which haven't been uploaded yet).
|
||||
* New resources are 1) dirty, and 2) don't have an ETag yet.
|
||||
*
|
||||
* @return IDs of new resources
|
||||
* @throws LocalStorageException when the content provider couldn't be queried
|
||||
*/
|
||||
public long[] findNew() throws LocalStorageException {
|
||||
// new records are 1) dirty, and 2) don't have an ETag yet
|
||||
String where = entryColumnDirty() + "=1 AND " + entryColumnETag() + " IS NULL";
|
||||
if (entryColumnParentID() != null)
|
||||
where += " AND " + entryColumnParentID() + "=" + String.valueOf(getId());
|
||||
@ -100,8 +124,14 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds updated resources (resources which have already been uploaded, but have changed locally).
|
||||
* Updated resources are 1) dirty, and 2) already have an ETag.
|
||||
*
|
||||
* @return IDs of updated resources
|
||||
* @throws LocalStorageException when the content provider couldn't be queried
|
||||
*/
|
||||
public long[] findUpdated() throws LocalStorageException {
|
||||
// updated records are 1) dirty, and 2) already have an ETag
|
||||
String where = entryColumnDirty() + "=1 AND " + entryColumnETag() + " IS NOT NULL";
|
||||
if (entryColumnParentID() != null)
|
||||
where += " AND " + entryColumnParentID() + "=" + String.valueOf(getId());
|
||||
@ -121,6 +151,13 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds deleted resources (resources which have been marked for deletion).
|
||||
* Deleted resources have the "deleted" flag set.
|
||||
*
|
||||
* @return IDs of deleted resources
|
||||
* @throws LocalStorageException when the content provider couldn't be queried
|
||||
*/
|
||||
public long[] findDeleted() throws LocalStorageException {
|
||||
String where = entryColumnDeleted() + "=1";
|
||||
if (entryColumnParentID() != null)
|
||||
@ -141,6 +178,15 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a specific resource by ID.
|
||||
* @param localID ID of the resource
|
||||
* @param populate true: populates all data fields (for instance, contact or event details);
|
||||
* false: only remote file name and ETag are populated
|
||||
* @return resource with either ID/remote file/name/ETag or all fields populated
|
||||
* @throws RecordNotFoundException when the resource couldn't be found
|
||||
* @throws LocalStorageException when the content provider couldn't be queried
|
||||
*/
|
||||
public T findById(long localID, boolean populate) throws LocalStorageException {
|
||||
try {
|
||||
@Cleanup Cursor cursor = providerClient.query(ContentUris.withAppendedId(entriesURI(), localID),
|
||||
@ -157,6 +203,15 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a specific resource by remote file name.
|
||||
* @param localID remote file name of the resource
|
||||
* @param populate true: populates all data fields (for instance, contact or event details);
|
||||
* false: only remote file name and ETag are populated
|
||||
* @return resource with either ID/remote file/name/ETag or all fields populated
|
||||
* @throws RecordNotFoundException when the resource couldn't be found
|
||||
* @throws LocalStorageException when the content provider couldn't be queried
|
||||
*/
|
||||
public T findByRemoteName(String remoteName, boolean populate) throws LocalStorageException {
|
||||
try {
|
||||
@Cleanup Cursor cursor = providerClient.query(entriesURI(),
|
||||
@ -174,19 +229,21 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** populates all data fields from the content provider */
|
||||
public abstract void populate(Resource record) throws LocalStorageException;
|
||||
|
||||
protected void queueOperation(Builder builder) {
|
||||
if (builder != null)
|
||||
pendingOperations.add(builder.build());
|
||||
}
|
||||
|
||||
|
||||
// create/update/delete
|
||||
|
||||
/**
|
||||
* Creates a new resource object in memory. No content provider operations involved.
|
||||
* @param localID the ID of the resource
|
||||
* @param resourceName the (remote) file name of the resource
|
||||
* @param ETag of the resource
|
||||
* @return the new resource object */
|
||||
abstract public T newResource(long localID, String resourceName, String eTag);
|
||||
|
||||
/** Enqueues adding the resource (including all data) to the local collection. Requires commit(). */
|
||||
public void add(Resource resource) {
|
||||
int idx = pendingOperations.size();
|
||||
pendingOperations.add(
|
||||
@ -197,6 +254,8 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
addDataRows(resource, -1, idx);
|
||||
}
|
||||
|
||||
/** Enqueues updating an existing resource in the local collection. The resource will be found by
|
||||
* the remote file name and all data will be updated. Requires commit(). */
|
||||
public void updateByRemoteName(Resource remoteResource) throws LocalStorageException {
|
||||
T localResource = findByRemoteName(remoteResource.getName(), false);
|
||||
pendingOperations.add(
|
||||
@ -209,6 +268,7 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
addDataRows(remoteResource, localResource.getLocalID(), -1);
|
||||
}
|
||||
|
||||
/** Enqueues deleting a resource from the local collection. Requires commit(). */
|
||||
public void delete(Resource resource) {
|
||||
pendingOperations.add(ContentProviderOperation
|
||||
.newDelete(ContentUris.withAppendedId(entriesURI(), resource.getLocalID()))
|
||||
@ -216,8 +276,13 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues deleting all resources except the give ones from the local collection. Requires commit().
|
||||
* @param remoteResources resources with these remote file names will be kept
|
||||
*/
|
||||
public abstract void deleteAllExceptRemoteNames(Resource[] remoteResources);
|
||||
|
||||
/** Updates the locally-known ETag of a resource. */
|
||||
public void updateETag(Resource res, String eTag) throws LocalStorageException {
|
||||
Log.d(TAG, "Setting ETag of local resource " + res + " to " + eTag);
|
||||
|
||||
@ -230,6 +295,7 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Enqueues removing the dirty flag from a locally-stored resource. Requires commit(). */
|
||||
public void clearDirty(Resource resource) {
|
||||
pendingOperations.add(ContentProviderOperation
|
||||
.newUpdate(ContentUris.withAppendedId(entriesURI(), resource.getLocalID()))
|
||||
@ -237,6 +303,7 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
.build());
|
||||
}
|
||||
|
||||
/** Commits enqueued operations to the content provider (for batch operations). */
|
||||
public void commit() throws LocalStorageException {
|
||||
if (!pendingOperations.isEmpty())
|
||||
try {
|
||||
@ -252,7 +319,13 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
|
||||
|
||||
// helpers
|
||||
|
||||
|
||||
protected void queueOperation(Builder builder) {
|
||||
if (builder != null)
|
||||
pendingOperations.add(builder.build());
|
||||
}
|
||||
|
||||
/** Appends account type, name and CALLER_IS_SYNCADAPTER to an Uri. */
|
||||
protected Uri syncAdapterURI(Uri baseURI) {
|
||||
return baseURI.buildUpon()
|
||||
.appendQueryParameter(entryColumnAccountType(), account.type)
|
||||
@ -272,8 +345,17 @@ public abstract class LocalCollection<T extends Resource> {
|
||||
|
||||
// content builders
|
||||
|
||||
/**
|
||||
* Builds the main entry (for instance, a ContactsContract.RawContacts row) from a resource.
|
||||
* The entry is built for insertion to the location identified by entriesURI().
|
||||
*
|
||||
* @param builder Builder to be extended by all resource data that can be stored without extra data rows.
|
||||
*/
|
||||
protected abstract Builder buildEntry(Builder builder, Resource resource);
|
||||
|
||||
/** Enqueues adding extra data rows of the resource to the local collection. */
|
||||
protected abstract void addDataRows(Resource resource, long localID, int backrefIdx);
|
||||
|
||||
/** Enqueues removing all extra data rows of the resource from the local collection. */
|
||||
protected abstract void removeDataRows(Resource resource);
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
/**
|
||||
* Thrown when a local record (for instance, Contact with ID 12345) should be read
|
||||
* but could not be found.
|
||||
*/
|
||||
public class RecordNotFoundException extends LocalStorageException {
|
||||
private static final long serialVersionUID = 4961024282198632578L;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
@ -32,6 +29,12 @@ import at.bitfire.davdroid.webdav.WebDavResource;
|
||||
import at.bitfire.davdroid.webdav.WebDavResource.PutMode;
|
||||
import ch.boye.httpclientandroidlib.impl.client.CloseableHttpClient;
|
||||
|
||||
/**
|
||||
* Represents a remotely stored synchronizable collection (collection as in
|
||||
* WebDAV terminology).
|
||||
*
|
||||
* @param <T> Subtype of Resource that can be stored in the collection
|
||||
*/
|
||||
public abstract class RemoteCollection<T extends Resource> {
|
||||
private static final String TAG = "davdroid.RemoteCollection";
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource;
|
||||
|
||||
@ -18,6 +15,10 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* Represents a resource that can be contained in a LocalCollection or RemoteCollection
|
||||
* for synchronization by WebDAV.
|
||||
*/
|
||||
@ToString
|
||||
public abstract class Resource {
|
||||
@Getter @Setter protected String name, ETag;
|
||||
@ -35,9 +36,11 @@ public abstract class Resource {
|
||||
this.localID = localID;
|
||||
}
|
||||
|
||||
// sets UID and resource name (= remote file name)
|
||||
/** initializes UID and remote file name (required for first upload) */
|
||||
public abstract void initialize();
|
||||
|
||||
/** fills the resource data from an input stream (for instance, .vcf file for Contact) */
|
||||
public abstract void parseEntity(InputStream entity) throws IOException, InvalidResourceException;
|
||||
/** writes the resource data to an output stream (for instance, .vcf file for Contact) */
|
||||
public abstract ByteArrayOutputStream toEntity() throws IOException;
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
@ -95,7 +95,6 @@ public class SyncManager {
|
||||
// update collection CTag
|
||||
Log.i(TAG, "Sync complete, fetching new CTag");
|
||||
local.setCTag(remote.getCTag());
|
||||
local.commit();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
import java.util.Locale;
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Contributors:
|
||||
* Richard Hirner (bitfire web engineering) - initial API and implementation
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav;
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.resource.test;
|
||||
|
||||
import java.util.Calendar;
|
||||
@ -33,10 +40,38 @@ public class LocalCalendarTest extends InstrumentationTestCase {
|
||||
Account testAccount = new Account(calendarName, CalendarContract.ACCOUNT_TYPE_LOCAL);
|
||||
LocalCalendar testCalendar;
|
||||
|
||||
|
||||
|
||||
// helpers
|
||||
|
||||
private Uri syncAdapterURI(Uri uri) {
|
||||
return uri.buildUpon()
|
||||
.appendQueryParameter(Calendars.ACCOUNT_NAME, calendarName)
|
||||
.appendQueryParameter(Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL)
|
||||
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true").
|
||||
build();
|
||||
}
|
||||
|
||||
private long insertNewEvent() throws LocalStorageException, RemoteException {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Events.CALENDAR_ID, testCalendar.getId());
|
||||
values.put(Events.TITLE, "Test Event");
|
||||
values.put(Events.ALL_DAY, 0);
|
||||
values.put(Events.DTSTART, Calendar.getInstance().getTimeInMillis());
|
||||
values.put(Events.DTEND, Calendar.getInstance().getTimeInMillis());
|
||||
values.put(Events.EVENT_TIMEZONE, "UTC");
|
||||
values.put(Events.DIRTY, 1);
|
||||
return ContentUris.parseId(providerClient.insert(syncAdapterURI(Events.CONTENT_URI), values));
|
||||
}
|
||||
|
||||
private void deleteEvent(long id) throws RemoteException {
|
||||
providerClient.delete(syncAdapterURI(ContentUris.withAppendedId(Events.CONTENT_URI, id)), null, null);
|
||||
}
|
||||
|
||||
|
||||
// initialization
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
|
||||
protected void setUp() throws Exception {
|
||||
// get content resolver
|
||||
ContentResolver resolver = getInstrumentation().getContext().getContentResolver();
|
||||
providerClient = resolver.acquireContentProviderClient(CalendarContract.AUTHORITY);
|
||||
|
||||
@ -50,7 +85,7 @@ public class LocalCalendarTest extends InstrumentationTestCase {
|
||||
if (cursor.moveToNext()) {
|
||||
// found local test calendar
|
||||
id = cursor.getLong(0);
|
||||
Log.i(TAG, "Found test calendar with ID " + id);
|
||||
Log.d(TAG, "Found test calendar with ID " + id);
|
||||
|
||||
} else {
|
||||
// no local test calendar found, create
|
||||
@ -69,68 +104,51 @@ public class LocalCalendarTest extends InstrumentationTestCase {
|
||||
values.put(Calendars.ALLOWED_ATTENDEE_TYPES, Attendees.TYPE_NONE + "," + Attendees.TYPE_OPTIONAL + "," + Attendees.TYPE_REQUIRED + "," + Attendees.TYPE_RESOURCE);
|
||||
}
|
||||
|
||||
Uri calendarURI = providerClient.insert(calendarsURI(), values);
|
||||
Uri calendarURI = providerClient.insert(syncAdapterURI(Calendars.CONTENT_URI), values);
|
||||
|
||||
id = ContentUris.parseId(calendarURI);
|
||||
Log.i(TAG, "Created test calendar with ID " + id);
|
||||
Log.d(TAG, "Created test calendar with ID " + id);
|
||||
}
|
||||
|
||||
testCalendar = new LocalCalendar(testAccount, providerClient, id, null, null);
|
||||
testCalendar = new LocalCalendar(testAccount, providerClient, id, null);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
Uri uri = ContentUris.withAppendedId(calendarsURI(), testCalendar.getId());
|
||||
Uri uri = ContentUris.withAppendedId(syncAdapterURI(Calendars.CONTENT_URI), testCalendar.getId());
|
||||
providerClient.delete(uri, null, null);
|
||||
}
|
||||
|
||||
|
||||
// tests
|
||||
|
||||
public void testCTags() throws LocalStorageException {
|
||||
assertNull(testCalendar.getCTag());
|
||||
|
||||
final String cTag = "just-modified";
|
||||
testCalendar.setCTag(cTag);
|
||||
|
||||
assertEquals(cTag, testCalendar.getCTag());
|
||||
}
|
||||
|
||||
public void testFindNew() throws LocalStorageException, RemoteException {
|
||||
// at the beginning, there are no dirty events
|
||||
assertTrue(testCalendar.findNew().length == 0);
|
||||
assertTrue(testCalendar.findUpdated().length == 0);
|
||||
|
||||
// insert a "new" event
|
||||
insertNewEvent();
|
||||
|
||||
// there must be one "new" event now
|
||||
assertTrue(testCalendar.findNew().length == 1);
|
||||
assertTrue(testCalendar.findUpdated().length == 0);
|
||||
|
||||
// nothing has changed, the record must still be "new"
|
||||
// see issue #233
|
||||
assertTrue(testCalendar.findNew().length == 1);
|
||||
assertTrue(testCalendar.findUpdated().length == 0);
|
||||
}
|
||||
|
||||
|
||||
// helpers
|
||||
|
||||
protected Uri calendarsURI() {
|
||||
return Calendars.CONTENT_URI.buildUpon()
|
||||
.appendQueryParameter(Calendars.ACCOUNT_NAME, calendarName)
|
||||
.appendQueryParameter(Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL)
|
||||
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true").
|
||||
build();
|
||||
}
|
||||
|
||||
protected long insertNewEvent() throws LocalStorageException, RemoteException {
|
||||
Uri uri = Events.CONTENT_URI.buildUpon()
|
||||
.appendQueryParameter(Calendars.ACCOUNT_TYPE, testAccount.type)
|
||||
.appendQueryParameter(Calendars.ACCOUNT_NAME, testAccount.name)
|
||||
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
|
||||
.build();
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Events.CALENDAR_ID, testCalendar.getId());
|
||||
values.put(Events.TITLE, "Test Event");
|
||||
values.put(Events.ALL_DAY, 0);
|
||||
values.put(Events.DTSTART, Calendar.getInstance().getTimeInMillis());
|
||||
values.put(Events.DTEND, Calendar.getInstance().getTimeInMillis());
|
||||
values.put(Events.EVENT_TIMEZONE, "UTC");
|
||||
values.put(Events.DIRTY, 1);
|
||||
return ContentUris.parseId(providerClient.insert(uri, values));
|
||||
long id = insertNewEvent();
|
||||
try {
|
||||
// there must be one "new" event now
|
||||
assertTrue(testCalendar.findNew().length == 1);
|
||||
assertTrue(testCalendar.findUpdated().length == 0);
|
||||
|
||||
// nothing has changed, the record must still be "new"
|
||||
// see issue #233
|
||||
assertTrue(testCalendar.findNew().length == 1);
|
||||
assertTrue(testCalendar.findUpdated().length == 0);
|
||||
} finally {
|
||||
deleteEvent(id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.test;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 Richard Hirner (bitfire web engineering).
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2014 Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
******************************************************************************/
|
||||
package at.bitfire.davdroid.webdav.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
Loading…
Reference in New Issue
Block a user