diff --git a/owncloud-android-library b/owncloud-android-library index fc8c256463f..837aa39b231 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit fc8c256463fc8c068a9694e3db5c980d2ac72fa3 +Subproject commit 837aa39b2317fcf833a7ec2a84bf5a81528906b5 diff --git a/owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.kt b/owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.kt index 97af64d39cf..7d50ea7e3d0 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.kt @@ -739,7 +739,7 @@ class FileDataStorageManager { sortOrder = "$FILE_PATH ASC " ) } catch (e: RemoteException) { - Timber.e(e.message) + Timber.e(e) null } @@ -923,7 +923,7 @@ class FileDataStorageManager { sortOrder = null ) } catch (e: RemoteException) { - Timber.e(e.message) + Timber.e(e) return ret } @@ -1246,11 +1246,9 @@ class FileDataStorageManager { put(CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED, capability.filesSharingPublicExpireDateEnabled.value) put(CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS, capability.filesSharingPublicExpireDateDays) put(CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED, capability.filesSharingPublicExpireDateEnforced.value) - put(CAPABILITIES_SHARING_PUBLIC_SEND_MAIL, capability.filesSharingPublicSendMail.value) put(CAPABILITIES_SHARING_PUBLIC_UPLOAD, capability.filesSharingPublicUpload.value) put(CAPABILITIES_SHARING_PUBLIC_MULTIPLE, capability.filesSharingPublicMultiple.value) put(CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY, capability.filesSharingPublicSupportsUploadOnly.value) - put(CAPABILITIES_SHARING_USER_SEND_MAIL, capability.filesSharingUserSendMail.value) put(CAPABILITIES_SHARING_RESHARING, capability.filesSharingResharing.value) put(CAPABILITIES_SHARING_FEDERATION_OUTGOING, capability.filesSharingFederationOutgoing.value) put(CAPABILITIES_SHARING_FEDERATION_INCOMING, capability.filesSharingFederationIncoming.value) @@ -1396,13 +1394,6 @@ class FileDataStorageManager { ) ) ), - filesSharingPublicSendMail = CapabilityBooleanType.fromValue( - c.getInt( - c.getColumnIndex( - CAPABILITIES_SHARING_PUBLIC_SEND_MAIL - ) - ) - ), filesSharingPublicUpload = CapabilityBooleanType.fromValue( c.getInt( c.getColumnIndex( @@ -1424,13 +1415,6 @@ class FileDataStorageManager { ) ) ), - filesSharingUserSendMail = CapabilityBooleanType.fromValue( - c.getInt( - c.getColumnIndex( - CAPABILITIES_SHARING_USER_SEND_MAIL - ) - ) - ), filesSharingResharing = CapabilityBooleanType.fromValue( c.getInt( c.getColumnIndex( diff --git a/owncloudApp/src/main/java/com/owncloud/android/db/ProviderMeta.java b/owncloudApp/src/main/java/com/owncloud/android/db/ProviderMeta.java index 4a29ac8abc4..2b4bae8e72a 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/db/ProviderMeta.java +++ b/owncloudApp/src/main/java/com/owncloud/android/db/ProviderMeta.java @@ -148,11 +148,9 @@ static public class ProviderTableMeta implements BaseColumns { "sharing_public_expire_date_days"; public static final String CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED = "sharing_public_expire_date_enforced"; - public static final String CAPABILITIES_SHARING_PUBLIC_SEND_MAIL = "sharing_public_send_mail"; public static final String CAPABILITIES_SHARING_PUBLIC_UPLOAD = "sharing_public_upload"; public static final String CAPABILITIES_SHARING_PUBLIC_MULTIPLE = "sharing_public_multiple"; public static final String CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY = "supports_upload_only"; - public static final String CAPABILITIES_SHARING_USER_SEND_MAIL = "sharing_user_send_mail"; public static final String CAPABILITIES_SHARING_RESHARING = "sharing_resharing"; public static final String CAPABILITIES_SHARING_FEDERATION_OUTGOING = "sharing_federation_outgoing"; public static final String CAPABILITIES_SHARING_FEDERATION_INCOMING = "sharing_federation_incoming"; diff --git a/owncloudApp/src/main/java/com/owncloud/android/providers/FileContentProvider.kt b/owncloudApp/src/main/java/com/owncloud/android/providers/FileContentProvider.kt index be25b9a7fc0..413741e723d 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/providers/FileContentProvider.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/providers/FileContentProvider.kt @@ -1091,11 +1091,9 @@ class FileContentProvider(val executors: Executors = Executors()) : ContentProvi + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED + " INTEGER, " // boolean + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS + " INTEGER, " + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED + " INTEGER, " // boolean - + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL + " INTEGER, " // boolean + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD + " INTEGER, " // boolean + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_MULTIPLE + " INTEGER, " // boolean + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY + " INTEGER, " // boolean - + ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL + " INTEGER, " // boolean + ProviderTableMeta.CAPABILITIES_SHARING_RESHARING + " INTEGER, " // boolean + ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING + " INTEGER, " // boolean + ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_INCOMING + " INTEGER, " // boolean @@ -1434,16 +1432,12 @@ class FileContentProvider(val executors: Executors = Executors()) : ContentProvi ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS capabilityProjectionMap[ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED] = ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED - capabilityProjectionMap[ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL] = - ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SEND_MAIL capabilityProjectionMap[ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD] = ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_UPLOAD capabilityProjectionMap[ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_MULTIPLE] = ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_MULTIPLE capabilityProjectionMap[ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY] = ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY - capabilityProjectionMap[ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL] = - ProviderTableMeta.CAPABILITIES_SHARING_USER_SEND_MAIL capabilityProjectionMap[ProviderTableMeta.CAPABILITIES_SHARING_RESHARING] = ProviderTableMeta.CAPABILITIES_SHARING_RESHARING capabilityProjectionMap[ProviderTableMeta.CAPABILITIES_SHARING_FEDERATION_OUTGOING] = diff --git a/owncloudData/schemas/com.owncloud.android.data.OwncloudDatabase/30.json b/owncloudData/schemas/com.owncloud.android.data.OwncloudDatabase/30.json new file mode 100644 index 00000000000..f46446d069a --- /dev/null +++ b/owncloudData/schemas/com.owncloud.android.data.OwncloudDatabase/30.json @@ -0,0 +1,323 @@ +{ + "formatVersion": 1, + "database": { + "version": 30, + "identityHash": "45e86e960b3c9693de0a3008cc2b425c", + "entities": [ + { + "tableName": "ocshares", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `file_source` TEXT NOT NULL, `item_source` TEXT NOT NULL, `share_type` INTEGER NOT NULL, `shate_with` TEXT, `path` TEXT NOT NULL, `permissions` INTEGER NOT NULL, `shared_date` INTEGER NOT NULL, `expiration_date` INTEGER NOT NULL, `token` TEXT, `shared_with_display_name` TEXT, `share_with_additional_info` TEXT, `is_directory` INTEGER NOT NULL, `user_id` INTEGER NOT NULL, `id_remote_shared` INTEGER NOT NULL, `owner_share` TEXT NOT NULL, `name` TEXT, `url` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "fileSource", + "columnName": "file_source", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "itemSource", + "columnName": "item_source", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "shareType", + "columnName": "share_type", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "shareWith", + "columnName": "shate_with", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "path", + "columnName": "path", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "permissions", + "columnName": "permissions", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "sharedDate", + "columnName": "shared_date", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "expirationDate", + "columnName": "expiration_date", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "token", + "columnName": "token", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "sharedWithDisplayName", + "columnName": "shared_with_display_name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "sharedWithAdditionalInfo", + "columnName": "share_with_additional_info", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "isFolder", + "columnName": "is_directory", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "userId", + "columnName": "user_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "remoteId", + "columnName": "id_remote_shared", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "accountOwner", + "columnName": "owner_share", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "shareLink", + "columnName": "url", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "capabilities", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `account` TEXT, `version_mayor` INTEGER NOT NULL, `version_minor` INTEGER NOT NULL, `version_micro` INTEGER NOT NULL, `version_string` TEXT, `version_edition` TEXT, `core_pollinterval` INTEGER NOT NULL, `sharing_api_enabled` INTEGER NOT NULL DEFAULT -1, `sharing_public_enabled` INTEGER NOT NULL DEFAULT -1, `sharing_public_password_enforced` INTEGER NOT NULL DEFAULT -1, `sharing_public_password_enforced_read_only` INTEGER NOT NULL DEFAULT -1, `sharing_public_password_enforced_read_write` INTEGER NOT NULL DEFAULT -1, `sharing_public_password_enforced_public_only` INTEGER NOT NULL DEFAULT -1, `sharing_public_expire_date_enabled` INTEGER NOT NULL DEFAULT -1, `sharing_public_expire_date_days` INTEGER NOT NULL, `sharing_public_expire_date_enforced` INTEGER NOT NULL DEFAULT -1, `sharing_public_upload` INTEGER NOT NULL DEFAULT -1, `sharing_public_multiple` INTEGER NOT NULL DEFAULT -1, `supports_upload_only` INTEGER NOT NULL DEFAULT -1, `sharing_resharing` INTEGER NOT NULL DEFAULT -1, `sharing_federation_outgoing` INTEGER NOT NULL DEFAULT -1, `sharing_federation_incoming` INTEGER NOT NULL DEFAULT -1, `files_bigfilechunking` INTEGER NOT NULL DEFAULT -1, `files_undelete` INTEGER NOT NULL DEFAULT -1, `files_versioning` INTEGER NOT NULL DEFAULT -1)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "accountName", + "columnName": "account", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "versionMayor", + "columnName": "version_mayor", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "versionMinor", + "columnName": "version_minor", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "versionMicro", + "columnName": "version_micro", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "versionString", + "columnName": "version_string", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "versionEdition", + "columnName": "version_edition", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "corePollInterval", + "columnName": "core_pollinterval", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "filesSharingApiEnabled", + "columnName": "sharing_api_enabled", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicEnabled", + "columnName": "sharing_public_enabled", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicPasswordEnforced", + "columnName": "sharing_public_password_enforced", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicPasswordEnforcedReadOnly", + "columnName": "sharing_public_password_enforced_read_only", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicPasswordEnforcedReadWrite", + "columnName": "sharing_public_password_enforced_read_write", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicPasswordEnforcedUploadOnly", + "columnName": "sharing_public_password_enforced_public_only", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicExpireDateEnabled", + "columnName": "sharing_public_expire_date_enabled", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicExpireDateDays", + "columnName": "sharing_public_expire_date_days", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "filesSharingPublicExpireDateEnforced", + "columnName": "sharing_public_expire_date_enforced", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicUpload", + "columnName": "sharing_public_upload", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicMultiple", + "columnName": "sharing_public_multiple", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingPublicSupportsUploadOnly", + "columnName": "supports_upload_only", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingResharing", + "columnName": "sharing_resharing", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingFederationOutgoing", + "columnName": "sharing_federation_outgoing", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesSharingFederationIncoming", + "columnName": "sharing_federation_incoming", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesBigFileChunking", + "columnName": "files_bigfilechunking", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesUndelete", + "columnName": "files_undelete", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + }, + { + "fieldPath": "filesVersioning", + "columnName": "files_versioning", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "-1" + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '45e86e960b3c9693de0a3008cc2b425c')" + ] + } +} \ No newline at end of file diff --git a/owncloudData/src/androidTest/java/com/owncloud/android/data/roommigrations/MigrationTest.kt b/owncloudData/src/androidTest/java/com/owncloud/android/data/roommigrations/MigrationTest.kt index cc624aded4c..f239ce0d6ca 100644 --- a/owncloudData/src/androidTest/java/com/owncloud/android/data/roommigrations/MigrationTest.kt +++ b/owncloudData/src/androidTest/java/com/owncloud/android/data/roommigrations/MigrationTest.kt @@ -62,5 +62,6 @@ open class MigrationTest { const val DB_VERSION_27 = 27 const val DB_VERSION_28 = 28 const val DB_VERSION_29 = 29 + const val DB_VERSION_30 = 30 } } diff --git a/owncloudData/src/androidTest/java/com/owncloud/android/data/roommigrations/MigrationToDB30.kt b/owncloudData/src/androidTest/java/com/owncloud/android/data/roommigrations/MigrationToDB30.kt new file mode 100644 index 00000000000..92f878effe6 --- /dev/null +++ b/owncloudData/src/androidTest/java/com/owncloud/android/data/roommigrations/MigrationToDB30.kt @@ -0,0 +1,89 @@ +/** + * ownCloud Android client application + * + * @author Abel García de Prada + * Copyright (C) 2020 ownCloud GmbH. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +package com.owncloud.android.data.roommigrations + +import android.database.sqlite.SQLiteDatabase +import androidx.sqlite.db.SupportSQLiteDatabase +import androidx.test.filters.SmallTest +import com.owncloud.android.data.OwncloudDatabase +import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.CAPABILITIES_TABLE_NAME +import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.OCSHARES_TABLE_NAME +import com.owncloud.android.data.sharing.shares.datasources.mapper.OCShareMapper +import com.owncloud.android.testutil.OC_SHARE +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Test the migration from database to version 30. + */ +@SmallTest +class MigrationToDB30 : MigrationTest() { + + @Test + fun migrationFrom27To30_containsCorrectData() { + performMigrationTest( + previousVersion = DB_VERSION_27, + currentVersion = DB_VERSION_30, + insertData = { database -> insertDataToTest(database) }, + validateMigration = { database -> validateMigrationTo30(database) }, + listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS + ) + } + + @Test + fun migrationFrom28To30_containsCorrectData() { + performMigrationTest( + previousVersion = DB_VERSION_28, + currentVersion = DB_VERSION_30, + insertData = { database -> insertDataToTest(database) }, + validateMigration = { database -> validateMigrationTo30(database) }, + listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS + ) + } + + @Test + fun startInVersion30_containsCorrectData() { + performMigrationTest( + previousVersion = DB_VERSION_30, + currentVersion = DB_VERSION_30, + insertData = { database -> insertDataToTest(database) }, + validateMigration = { Unit }, + listOfMigrations = arrayOf() + ) + } + + private fun insertDataToTest(database: SupportSQLiteDatabase) { + database.run { + insert( + CAPABILITIES_TABLE_NAME, + SQLiteDatabase.CONFLICT_NONE, + MigrationToDB28.cvWithDefaultValues + ) + close() + } + } + + private fun validateMigrationTo30(database: SupportSQLiteDatabase) { + val capabilitiesCount = getCount(database, CAPABILITIES_TABLE_NAME) + assertEquals(1, capabilitiesCount) + database.close() + } +} diff --git a/owncloudData/src/main/java/com/owncloud/android/data/OwncloudDatabase.kt b/owncloudData/src/main/java/com/owncloud/android/data/OwncloudDatabase.kt index 0c3acf5d242..271b84708a4 100644 --- a/owncloudData/src/main/java/com/owncloud/android/data/OwncloudDatabase.kt +++ b/owncloudData/src/main/java/com/owncloud/android/data/OwncloudDatabase.kt @@ -31,6 +31,7 @@ import com.owncloud.android.data.capabilities.db.OCCapabilityDao import com.owncloud.android.data.capabilities.db.OCCapabilityEntity import com.owncloud.android.data.migrations.MIGRATION_27_28 import com.owncloud.android.data.migrations.MIGRATION_28_29 +import com.owncloud.android.data.migrations.MIGRATION_29_30 import com.owncloud.android.data.sharing.shares.db.OCShareDao import com.owncloud.android.data.sharing.shares.db.OCShareEntity @@ -53,7 +54,8 @@ abstract class OwncloudDatabase : RoomDatabase() { // Array of all migrations val ALL_MIGRATIONS = arrayOf( MIGRATION_27_28, - MIGRATION_28_29 + MIGRATION_28_29, + MIGRATION_29_30 ) fun getDatabase( diff --git a/owncloudData/src/main/java/com/owncloud/android/data/ProviderMeta.java b/owncloudData/src/main/java/com/owncloud/android/data/ProviderMeta.java index 627a5971125..fb95f56bf87 100644 --- a/owncloudData/src/main/java/com/owncloud/android/data/ProviderMeta.java +++ b/owncloudData/src/main/java/com/owncloud/android/data/ProviderMeta.java @@ -31,7 +31,7 @@ public class ProviderMeta { public static final String DB_NAME = "filelist"; public static final String NEW_DB_NAME = "owncloud_database"; - public static final int DB_VERSION = 29; + public static final int DB_VERSION = 30; private ProviderMeta() { } @@ -82,11 +82,9 @@ static public class ProviderTableMeta implements BaseColumns { "sharing_public_expire_date_days"; public static final String CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED = "sharing_public_expire_date_enforced"; - public static final String CAPABILITIES_SHARING_PUBLIC_SEND_MAIL = "sharing_public_send_mail"; public static final String CAPABILITIES_SHARING_PUBLIC_UPLOAD = "sharing_public_upload"; public static final String CAPABILITIES_SHARING_PUBLIC_MULTIPLE = "sharing_public_multiple"; public static final String CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY = "supports_upload_only"; - public static final String CAPABILITIES_SHARING_USER_SEND_MAIL = "sharing_user_send_mail"; public static final String CAPABILITIES_SHARING_RESHARING = "sharing_resharing"; public static final String CAPABILITIES_SHARING_FEDERATION_OUTGOING = "sharing_federation_outgoing"; public static final String CAPABILITIES_SHARING_FEDERATION_INCOMING = "sharing_federation_incoming"; diff --git a/owncloudData/src/main/java/com/owncloud/android/data/capabilities/datasources/mapper/OCCapabilityMapper.kt b/owncloudData/src/main/java/com/owncloud/android/data/capabilities/datasources/mapper/OCCapabilityMapper.kt index d7c3525aafe..eed501869fc 100644 --- a/owncloudData/src/main/java/com/owncloud/android/data/capabilities/datasources/mapper/OCCapabilityMapper.kt +++ b/owncloudData/src/main/java/com/owncloud/android/data/capabilities/datasources/mapper/OCCapabilityMapper.kt @@ -45,11 +45,9 @@ class OCCapabilityMapper : Mapper { filesSharingPublicExpireDateEnabled = CapabilityBooleanType.fromValue(entity.filesSharingPublicExpireDateEnabled), filesSharingPublicExpireDateDays = entity.filesSharingPublicExpireDateDays, filesSharingPublicExpireDateEnforced = CapabilityBooleanType.fromValue(entity.filesSharingPublicExpireDateEnforced), - filesSharingPublicSendMail = CapabilityBooleanType.fromValue(entity.filesSharingPublicSendMail), filesSharingPublicUpload = CapabilityBooleanType.fromValue(entity.filesSharingPublicUpload), filesSharingPublicMultiple = CapabilityBooleanType.fromValue(entity.filesSharingPublicMultiple), filesSharingPublicSupportsUploadOnly = CapabilityBooleanType.fromValue(entity.filesSharingPublicSupportsUploadOnly), - filesSharingUserSendMail = CapabilityBooleanType.fromValue(entity.filesSharingUserSendMail), filesSharingResharing = CapabilityBooleanType.fromValue(entity.filesSharingResharing), filesSharingFederationOutgoing = CapabilityBooleanType.fromValue(entity.filesSharingFederationOutgoing), filesSharingFederationIncoming = CapabilityBooleanType.fromValue(entity.filesSharingFederationIncoming), @@ -78,11 +76,9 @@ class OCCapabilityMapper : Mapper { filesSharingPublicExpireDateEnabled = model.filesSharingPublicExpireDateEnabled.value, filesSharingPublicExpireDateDays = model.filesSharingPublicExpireDateDays, filesSharingPublicExpireDateEnforced = model.filesSharingPublicExpireDateEnforced.value, - filesSharingPublicSendMail = model.filesSharingPublicSendMail.value, filesSharingPublicUpload = model.filesSharingPublicUpload.value, filesSharingPublicMultiple = model.filesSharingPublicMultiple.value, filesSharingPublicSupportsUploadOnly = model.filesSharingPublicSupportsUploadOnly.value, - filesSharingUserSendMail = model.filesSharingUserSendMail.value, filesSharingResharing = model.filesSharingResharing.value, filesSharingFederationOutgoing = model.filesSharingFederationOutgoing.value, filesSharingFederationIncoming = model.filesSharingFederationIncoming.value, diff --git a/owncloudData/src/main/java/com/owncloud/android/data/capabilities/datasources/mapper/RemoteCapabilityMapper.kt b/owncloudData/src/main/java/com/owncloud/android/data/capabilities/datasources/mapper/RemoteCapabilityMapper.kt index 47e92e9b39d..6cad24f71b1 100644 --- a/owncloudData/src/main/java/com/owncloud/android/data/capabilities/datasources/mapper/RemoteCapabilityMapper.kt +++ b/owncloudData/src/main/java/com/owncloud/android/data/capabilities/datasources/mapper/RemoteCapabilityMapper.kt @@ -51,12 +51,10 @@ class RemoteCapabilityMapper : RemoteMapper { filesSharingPublicExpireDateDays = remote.filesSharingPublicExpireDateDays, filesSharingPublicExpireDateEnforced = CapabilityBooleanType.fromValue(remote.filesSharingPublicExpireDateEnforced.value), - filesSharingPublicSendMail = CapabilityBooleanType.fromValue(remote.filesSharingPublicSendMail.value), filesSharingPublicUpload = CapabilityBooleanType.fromValue(remote.filesSharingPublicUpload.value), filesSharingPublicMultiple = CapabilityBooleanType.fromValue(remote.filesSharingPublicMultiple.value), filesSharingPublicSupportsUploadOnly = CapabilityBooleanType.fromValue(remote.filesSharingPublicSupportsUploadOnly.value), - filesSharingUserSendMail = CapabilityBooleanType.fromValue(remote.filesSharingUserSendMail.value), filesSharingResharing = CapabilityBooleanType.fromValue(remote.filesSharingResharing.value), filesSharingFederationOutgoing = CapabilityBooleanType.fromValue(remote.filesSharingFederationOutgoing.value), @@ -93,12 +91,10 @@ class RemoteCapabilityMapper : RemoteMapper { filesSharingPublicExpireDateDays = model.filesSharingPublicExpireDateDays, filesSharingPublicExpireDateEnforced = RemoteCapabilityBooleanType.fromValue(model.filesSharingPublicExpireDateEnforced.value)!!, - filesSharingPublicSendMail = RemoteCapabilityBooleanType.fromValue(model.filesSharingPublicSendMail.value)!!, filesSharingPublicUpload = RemoteCapabilityBooleanType.fromValue(model.filesSharingPublicUpload.value)!!, filesSharingPublicMultiple = RemoteCapabilityBooleanType.fromValue(model.filesSharingPublicMultiple.value)!!, filesSharingPublicSupportsUploadOnly = RemoteCapabilityBooleanType.fromValue(model.filesSharingPublicSupportsUploadOnly.value)!!, - filesSharingUserSendMail = RemoteCapabilityBooleanType.fromValue(model.filesSharingUserSendMail.value)!!, filesSharingResharing = RemoteCapabilityBooleanType.fromValue(model.filesSharingResharing.value)!!, filesSharingFederationOutgoing = RemoteCapabilityBooleanType.fromValue(model.filesSharingFederationOutgoing.value)!!, diff --git a/owncloudData/src/main/java/com/owncloud/android/data/capabilities/db/OCCapabilityEntity.kt b/owncloudData/src/main/java/com/owncloud/android/data/capabilities/db/OCCapabilityEntity.kt index 1c0119a1adb..7128836bc2b 100644 --- a/owncloudData/src/main/java/com/owncloud/android/data/capabilities/db/OCCapabilityEntity.kt +++ b/owncloudData/src/main/java/com/owncloud/android/data/capabilities/db/OCCapabilityEntity.kt @@ -20,14 +20,12 @@ package com.owncloud.android.data.capabilities.db -import android.content.ContentValues import android.database.Cursor import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.* import com.owncloud.android.domain.capabilities.model.CapabilityBooleanType.Companion.capabilityBooleanTypeUnknownString -import com.owncloud.android.domain.capabilities.model.OCCapability /** * Represents one record of the Capabilities table. @@ -66,16 +64,12 @@ data class OCCapabilityEntity( val filesSharingPublicExpireDateDays: Int, @ColumnInfo(name = CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED, defaultValue = capabilityBooleanTypeUnknownString) val filesSharingPublicExpireDateEnforced: Int, - @ColumnInfo(name = CAPABILITIES_SHARING_PUBLIC_SEND_MAIL, defaultValue = capabilityBooleanTypeUnknownString) - val filesSharingPublicSendMail: Int, @ColumnInfo(name = CAPABILITIES_SHARING_PUBLIC_UPLOAD, defaultValue = capabilityBooleanTypeUnknownString) val filesSharingPublicUpload: Int, @ColumnInfo(name = CAPABILITIES_SHARING_PUBLIC_MULTIPLE, defaultValue = capabilityBooleanTypeUnknownString) val filesSharingPublicMultiple: Int, @ColumnInfo(name = CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY, defaultValue = capabilityBooleanTypeUnknownString) val filesSharingPublicSupportsUploadOnly: Int, - @ColumnInfo(name = CAPABILITIES_SHARING_USER_SEND_MAIL, defaultValue = capabilityBooleanTypeUnknownString) - val filesSharingUserSendMail: Int, @ColumnInfo(name = CAPABILITIES_SHARING_RESHARING, defaultValue = capabilityBooleanTypeUnknownString) val filesSharingResharing: Int, @ColumnInfo(name = CAPABILITIES_SHARING_FEDERATION_OUTGOING, defaultValue = capabilityBooleanTypeUnknownString) @@ -109,11 +103,9 @@ data class OCCapabilityEntity( cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENABLED)), cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_DAYS)), cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_PUBLIC_EXPIRE_DATE_ENFORCED)), - cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_PUBLIC_SEND_MAIL)), cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_PUBLIC_UPLOAD)), cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_PUBLIC_MULTIPLE)), cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_PUBLIC_SUPPORTS_UPLOAD_ONLY)), - cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_USER_SEND_MAIL)), cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_RESHARING)), cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_FEDERATION_OUTGOING)), cursor.getInt(cursor.getColumnIndex(CAPABILITIES_SHARING_FEDERATION_INCOMING)), diff --git a/owncloudData/src/main/java/com/owncloud/android/data/migrations/Migration_30.kt b/owncloudData/src/main/java/com/owncloud/android/data/migrations/Migration_30.kt new file mode 100644 index 00000000000..0a4ed91deef --- /dev/null +++ b/owncloudData/src/main/java/com/owncloud/android/data/migrations/Migration_30.kt @@ -0,0 +1,40 @@ +/** + * ownCloud Android client application + * + * @author Abel García de Prada + * Copyright (C) 2020 ownCloud GmbH. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +package com.owncloud.android.data.migrations + +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase +import com.owncloud.android.data.ProviderMeta + +val MIGRATION_29_30 = object : Migration(29, 30) { + override fun migrate(database: SupportSQLiteDatabase) { + database.run { + execSQL( + "CREATE TABLE IF NOT EXISTS `${ProviderMeta.ProviderTableMeta.CAPABILITIES_TABLE_NAME}2` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `account` TEXT, `version_mayor` INTEGER NOT NULL, `version_minor` INTEGER NOT NULL, `version_micro` INTEGER NOT NULL, `version_string` TEXT, `version_edition` TEXT, `core_pollinterval` INTEGER NOT NULL, `sharing_api_enabled` INTEGER NOT NULL DEFAULT -1, `sharing_public_enabled` INTEGER NOT NULL DEFAULT -1, `sharing_public_password_enforced` INTEGER NOT NULL DEFAULT -1, `sharing_public_password_enforced_read_only` INTEGER NOT NULL DEFAULT -1, `sharing_public_password_enforced_read_write` INTEGER NOT NULL DEFAULT -1, `sharing_public_password_enforced_public_only` INTEGER NOT NULL DEFAULT -1, `sharing_public_expire_date_enabled` INTEGER NOT NULL DEFAULT -1, `sharing_public_expire_date_days` INTEGER NOT NULL, `sharing_public_expire_date_enforced` INTEGER NOT NULL DEFAULT -1, `sharing_public_upload` INTEGER NOT NULL DEFAULT -1, `sharing_public_multiple` INTEGER NOT NULL DEFAULT -1, `supports_upload_only` INTEGER NOT NULL DEFAULT -1, `sharing_resharing` INTEGER NOT NULL DEFAULT -1, `sharing_federation_outgoing` INTEGER NOT NULL DEFAULT -1, `sharing_federation_incoming` INTEGER NOT NULL DEFAULT -1, `files_bigfilechunking` INTEGER NOT NULL DEFAULT -1, `files_undelete` INTEGER NOT NULL DEFAULT -1, `files_versioning` INTEGER NOT NULL DEFAULT -1)" + ) + execSQL( + "INSERT INTO `${ProviderMeta.ProviderTableMeta.CAPABILITIES_TABLE_NAME}2` SELECT id, account, version_mayor, version_minor, version_micro, version_string, version_edition, core_pollinterval, IFNULL(sharing_api_enabled, -1), IFNULL(sharing_public_enabled, -1), IFNULL(sharing_public_password_enforced, -1),IFNULL(sharing_public_password_enforced_read_only, -1),IFNULL(sharing_public_password_enforced_read_write, -1),IFNULL(sharing_public_password_enforced_public_only, -1),IFNULL(sharing_public_expire_date_enabled, -1),IFNULL(sharing_public_expire_date_days, 0),IFNULL(sharing_public_expire_date_enforced, -1), IFNULL(sharing_public_upload, -1),IFNULL(sharing_public_multiple, -1), IFNULL(supports_upload_only, -1), IFNULL(sharing_resharing, -1),IFNULL(sharing_federation_outgoing, -1),IFNULL(sharing_federation_incoming, -1),IFNULL(files_bigfilechunking, -1),IFNULL(files_undelete, -1),IFNULL(files_versioning, -1) FROM ${ProviderMeta.ProviderTableMeta.CAPABILITIES_TABLE_NAME}" + ) + execSQL("DROP TABLE ${ProviderMeta.ProviderTableMeta.CAPABILITIES_TABLE_NAME}") + execSQL("ALTER TABLE ${ProviderMeta.ProviderTableMeta.CAPABILITIES_TABLE_NAME}2 RENAME TO ${ProviderMeta.ProviderTableMeta.CAPABILITIES_TABLE_NAME}") + + } + } +} diff --git a/owncloudData/src/test/java/com/owncloud/android/data/capabilities/db/OCCapabilityEntityTest.kt b/owncloudData/src/test/java/com/owncloud/android/data/capabilities/db/OCCapabilityEntityTest.kt index 03457b7cb68..3eed634e2a8 100644 --- a/owncloudData/src/test/java/com/owncloud/android/data/capabilities/db/OCCapabilityEntityTest.kt +++ b/owncloudData/src/test/java/com/owncloud/android/data/capabilities/db/OCCapabilityEntityTest.kt @@ -43,11 +43,9 @@ class OCCapabilityEntityTest { filesSharingPublicExpireDateEnabled = 0, filesSharingPublicExpireDateDays = 0, filesSharingPublicExpireDateEnforced = 0, - filesSharingPublicSendMail = 0, filesSharingPublicUpload = 0, filesSharingPublicMultiple = 0, filesSharingPublicSupportsUploadOnly = 0, - filesSharingUserSendMail = 0, filesSharingResharing = 0, filesSharingFederationOutgoing = 0, filesSharingFederationIncoming = 0, @@ -81,8 +79,6 @@ class OCCapabilityEntityTest { 0, 0, 0, - 0, - 0, 0 ) @@ -111,11 +107,9 @@ class OCCapabilityEntityTest { filesSharingPublicExpireDateEnabled = 0, filesSharingPublicExpireDateDays = 0, filesSharingPublicExpireDateEnforced = 0, - filesSharingPublicSendMail = 0, filesSharingPublicUpload = 0, filesSharingPublicMultiple = 0, filesSharingPublicSupportsUploadOnly = 0, - filesSharingUserSendMail = 0, filesSharingResharing = 0, filesSharingFederationOutgoing = 0, filesSharingFederationIncoming = 0, @@ -149,8 +143,6 @@ class OCCapabilityEntityTest { 0, 0, 0, - 0, - 0, 0 ) @@ -179,11 +171,9 @@ class OCCapabilityEntityTest { filesSharingPublicExpireDateEnabled = 0, filesSharingPublicExpireDateDays = 0, filesSharingPublicExpireDateEnforced = 0, - filesSharingPublicSendMail = 0, filesSharingPublicUpload = 0, filesSharingPublicMultiple = 0, filesSharingPublicSupportsUploadOnly = 0, - filesSharingUserSendMail = 0, filesSharingResharing = 0, filesSharingFederationOutgoing = 0, filesSharingFederationIncoming = 0, @@ -217,8 +207,6 @@ class OCCapabilityEntityTest { 0, 0, 0, - 0, - 0, 0 ) diff --git a/owncloudDomain/src/main/java/com/owncloud/android/domain/capabilities/model/OCCapability.kt b/owncloudDomain/src/main/java/com/owncloud/android/domain/capabilities/model/OCCapability.kt index 406ab43ed7b..7acadfa6bc9 100644 --- a/owncloudDomain/src/main/java/com/owncloud/android/domain/capabilities/model/OCCapability.kt +++ b/owncloudDomain/src/main/java/com/owncloud/android/domain/capabilities/model/OCCapability.kt @@ -37,11 +37,9 @@ data class OCCapability( val filesSharingPublicExpireDateEnabled: CapabilityBooleanType, val filesSharingPublicExpireDateDays: Int, val filesSharingPublicExpireDateEnforced: CapabilityBooleanType, - val filesSharingPublicSendMail: CapabilityBooleanType, val filesSharingPublicUpload: CapabilityBooleanType, val filesSharingPublicMultiple: CapabilityBooleanType, val filesSharingPublicSupportsUploadOnly: CapabilityBooleanType, - val filesSharingUserSendMail: CapabilityBooleanType, val filesSharingResharing: CapabilityBooleanType, val filesSharingFederationOutgoing: CapabilityBooleanType, val filesSharingFederationIncoming: CapabilityBooleanType, diff --git a/owncloudDomain/src/test/java/com/owncloud/android/domain/capabilities/model/OCCapabilityTest.kt b/owncloudDomain/src/test/java/com/owncloud/android/domain/capabilities/model/OCCapabilityTest.kt index 169b028f9ff..caebd6e6624 100644 --- a/owncloudDomain/src/test/java/com/owncloud/android/domain/capabilities/model/OCCapabilityTest.kt +++ b/owncloudDomain/src/test/java/com/owncloud/android/domain/capabilities/model/OCCapabilityTest.kt @@ -59,8 +59,6 @@ class OCCapabilityTest { FALSE, FALSE, FALSE, - FALSE, - FALSE, FALSE ) @@ -81,11 +79,9 @@ class OCCapabilityTest { assertEquals(FALSE, item.filesSharingPublicExpireDateEnabled) assertEquals(0, item.filesSharingPublicExpireDateDays) assertEquals(FALSE, item.filesSharingPublicExpireDateEnforced) - assertEquals(FALSE, item.filesSharingPublicSendMail) assertEquals(FALSE, item.filesSharingPublicUpload) assertEquals(FALSE, item.filesSharingPublicMultiple) assertEquals(FALSE, item.filesSharingPublicSupportsUploadOnly) - assertEquals(FALSE, item.filesSharingUserSendMail) assertEquals(FALSE, item.filesSharingResharing) assertEquals(FALSE, item.filesSharingFederationOutgoing) assertEquals(FALSE, item.filesSharingFederationIncoming) @@ -114,11 +110,9 @@ class OCCapabilityTest { filesSharingPublicExpireDateEnabled = FALSE, filesSharingPublicExpireDateDays = 0, filesSharingPublicExpireDateEnforced = FALSE, - filesSharingPublicSendMail = FALSE, filesSharingPublicUpload = FALSE, filesSharingPublicMultiple = FALSE, filesSharingPublicSupportsUploadOnly = FALSE, - filesSharingUserSendMail = FALSE, filesSharingResharing = FALSE, filesSharingFederationOutgoing = FALSE, filesSharingFederationIncoming = FALSE, @@ -153,8 +147,6 @@ class OCCapabilityTest { FALSE, FALSE, FALSE, - FALSE, - FALSE, FALSE ) @@ -182,11 +174,9 @@ class OCCapabilityTest { filesSharingPublicExpireDateEnabled = FALSE, filesSharingPublicExpireDateDays = 0, filesSharingPublicExpireDateEnforced = FALSE, - filesSharingPublicSendMail = FALSE, filesSharingPublicUpload = FALSE, filesSharingPublicMultiple = FALSE, filesSharingPublicSupportsUploadOnly = FALSE, - filesSharingUserSendMail = FALSE, filesSharingResharing = FALSE, filesSharingFederationOutgoing = FALSE, filesSharingFederationIncoming = FALSE, @@ -221,8 +211,6 @@ class OCCapabilityTest { FALSE, FALSE, FALSE, - FALSE, - FALSE, FALSE ) diff --git a/owncloudTestUtil/src/main/java/com/owncloud/android/testutil/OCCapability.kt b/owncloudTestUtil/src/main/java/com/owncloud/android/testutil/OCCapability.kt index e2d15736765..44707432465 100644 --- a/owncloudTestUtil/src/main/java/com/owncloud/android/testutil/OCCapability.kt +++ b/owncloudTestUtil/src/main/java/com/owncloud/android/testutil/OCCapability.kt @@ -21,11 +21,9 @@ val OC_CAPABILITY = filesSharingPublicExpireDateEnabled = CapabilityBooleanType.FALSE, filesSharingPublicExpireDateDays = 0, filesSharingPublicExpireDateEnforced = CapabilityBooleanType.FALSE, - filesSharingPublicSendMail = CapabilityBooleanType.FALSE, filesSharingPublicUpload = CapabilityBooleanType.FALSE, filesSharingPublicMultiple = CapabilityBooleanType.FALSE, filesSharingPublicSupportsUploadOnly = CapabilityBooleanType.FALSE, - filesSharingUserSendMail = CapabilityBooleanType.FALSE, filesSharingResharing = CapabilityBooleanType.FALSE, filesSharingFederationOutgoing = CapabilityBooleanType.FALSE, filesSharingFederationIncoming = CapabilityBooleanType.FALSE,