|
@@ -85,28 +85,18 @@ public class FileDataStorageManager {
|
|
|
|
|
|
private ContentResolver contentResolver;
|
|
private ContentResolver contentResolver;
|
|
private ContentProviderClient contentProviderClient;
|
|
private ContentProviderClient contentProviderClient;
|
|
- private Account account;
|
|
|
|
|
|
+ private User user;
|
|
|
|
|
|
- @Deprecated
|
|
|
|
- public FileDataStorageManager(Account account, ContentResolver contentResolver) {
|
|
|
|
|
|
+ public FileDataStorageManager(User user, ContentResolver contentResolver) {
|
|
this.contentProviderClient = null;
|
|
this.contentProviderClient = null;
|
|
this.contentResolver = contentResolver;
|
|
this.contentResolver = contentResolver;
|
|
- this.account = account;
|
|
|
|
|
|
+ this.user = user;
|
|
}
|
|
}
|
|
|
|
|
|
- public FileDataStorageManager(User user, ContentResolver contentResolver) {
|
|
|
|
- this(user.toPlatformAccount(), contentResolver);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Deprecated
|
|
|
|
- public FileDataStorageManager(Account account, ContentProviderClient contentProviderClient) {
|
|
|
|
|
|
+ public FileDataStorageManager(User user, ContentProviderClient contentProviderClient) {
|
|
this.contentProviderClient = contentProviderClient;
|
|
this.contentProviderClient = contentProviderClient;
|
|
this.contentResolver = null;
|
|
this.contentResolver = null;
|
|
- this.account = account;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public FileDataStorageManager(User user, ContentProviderClient contentProviderClient) {
|
|
|
|
- this(user.toPlatformAccount(), contentProviderClient);
|
|
|
|
|
|
+ this.user = user;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -236,7 +226,7 @@ public class FileDataStorageManager {
|
|
if (!ocFile.isFolder()) {
|
|
if (!ocFile.isFolder()) {
|
|
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, ocFile.getStoragePath());
|
|
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, ocFile.getStoragePath());
|
|
}
|
|
}
|
|
- cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
|
|
|
|
|
+ cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, ocFile.getLastSyncDateForProperties());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, ocFile.getLastSyncDateForProperties());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, ocFile.getLastSyncDateForData());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, ocFile.getLastSyncDateForData());
|
|
cv.put(ProviderTableMeta.FILE_ETAG, ocFile.getEtag());
|
|
cv.put(ProviderTableMeta.FILE_ETAG, ocFile.getEtag());
|
|
@@ -403,7 +393,7 @@ public class FileDataStorageManager {
|
|
// prepare operations to remove files in the given folder
|
|
// prepare operations to remove files in the given folder
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " = ?";
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " = ?";
|
|
String[] whereArgs = new String[2];
|
|
String[] whereArgs = new String[2];
|
|
- whereArgs[0] = account.name;
|
|
|
|
|
|
+ whereArgs[0] = user.getAccountName();
|
|
for (OCFile ocFile : filesToRemove) {
|
|
for (OCFile ocFile : filesToRemove) {
|
|
if (ocFile.getParentId() == folder.getFileId()) {
|
|
if (ocFile.getParentId() == folder.getFileId()) {
|
|
whereArgs[1] = ocFile.getRemotePath();
|
|
whereArgs[1] = ocFile.getRemotePath();
|
|
@@ -412,7 +402,7 @@ public class FileDataStorageManager {
|
|
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_DIR, ocFile.getFileId()))
|
|
ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_DIR, ocFile.getFileId()))
|
|
.withSelection(where, whereArgs).build());
|
|
.withSelection(where, whereArgs).build());
|
|
|
|
|
|
- File localFolder = new File(FileStorageUtils.getDefaultSavePathFor(account.name, ocFile));
|
|
|
|
|
|
+ File localFolder = new File(FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), ocFile));
|
|
if (localFolder.exists()) {
|
|
if (localFolder.exists()) {
|
|
removeLocalFolder(localFolder);
|
|
removeLocalFolder(localFolder);
|
|
}
|
|
}
|
|
@@ -490,7 +480,7 @@ public class FileDataStorageManager {
|
|
cv.put(ProviderTableMeta.FILE_PARENT, folder.getParentId());
|
|
cv.put(ProviderTableMeta.FILE_PARENT, folder.getParentId());
|
|
cv.put(ProviderTableMeta.FILE_PATH, folder.getRemotePath());
|
|
cv.put(ProviderTableMeta.FILE_PATH, folder.getRemotePath());
|
|
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, folder.getDecryptedRemotePath());
|
|
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, folder.getDecryptedRemotePath());
|
|
- cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
|
|
|
|
|
+ cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, folder.getLastSyncDateForProperties());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, folder.getLastSyncDateForProperties());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, folder.getLastSyncDateForData());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, folder.getLastSyncDateForData());
|
|
cv.put(ProviderTableMeta.FILE_ETAG, folder.getEtag());
|
|
cv.put(ProviderTableMeta.FILE_ETAG, folder.getEtag());
|
|
@@ -524,7 +514,7 @@ public class FileDataStorageManager {
|
|
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
|
|
cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath());
|
|
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, file.getDecryptedRemotePath());
|
|
cv.put(ProviderTableMeta.FILE_PATH_DECRYPTED, file.getDecryptedRemotePath());
|
|
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
|
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
|
- cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
|
|
|
|
|
+ cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
|
|
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
|
|
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
|
|
@@ -563,7 +553,7 @@ public class FileDataStorageManager {
|
|
// ""+file.getFileId());
|
|
// ""+file.getFileId());
|
|
Uri file_uri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, ocFile.getFileId());
|
|
Uri file_uri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, ocFile.getFileId());
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
|
- String[] whereArgs = new String[]{account.name, ocFile.getRemotePath()};
|
|
|
|
|
|
+ String[] whereArgs = new String[]{user.getAccountName(), ocFile.getRemotePath()};
|
|
int deleted = 0;
|
|
int deleted = 0;
|
|
if (getContentProviderClient() != null) {
|
|
if (getContentProviderClient() != null) {
|
|
try {
|
|
try {
|
|
@@ -620,7 +610,7 @@ public class FileDataStorageManager {
|
|
Uri folderUri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, String.valueOf(folder.getFileId()));
|
|
Uri folderUri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, String.valueOf(folder.getFileId()));
|
|
// for recursive deletion
|
|
// for recursive deletion
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
|
|
- String[] whereArgs = new String[]{account.name, folder.getRemotePath()};
|
|
|
|
|
|
+ String[] whereArgs = new String[]{user.getAccountName(), folder.getRemotePath()};
|
|
int deleted = 0;
|
|
int deleted = 0;
|
|
if (getContentProviderClient() != null) {
|
|
if (getContentProviderClient() != null) {
|
|
try {
|
|
try {
|
|
@@ -636,7 +626,7 @@ public class FileDataStorageManager {
|
|
|
|
|
|
private boolean removeLocalFolder(OCFile folder) {
|
|
private boolean removeLocalFolder(OCFile folder) {
|
|
boolean success = true;
|
|
boolean success = true;
|
|
- String localFolderPath = FileStorageUtils.getDefaultSavePathFor(account.name, folder);
|
|
|
|
|
|
+ String localFolderPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), folder);
|
|
File localFolder = new File(localFolderPath);
|
|
File localFolder = new File(localFolderPath);
|
|
|
|
|
|
if (localFolder.exists()) {
|
|
if (localFolder.exists()) {
|
|
@@ -705,7 +695,7 @@ public class FileDataStorageManager {
|
|
ProviderTableMeta.CONTENT_URI,
|
|
ProviderTableMeta.CONTENT_URI,
|
|
null,
|
|
null,
|
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
|
- new String[]{account.name, ocFile.getRemotePath() + "%"},
|
|
|
|
|
|
+ new String[]{user.getAccountName(), ocFile.getRemotePath() + "%"},
|
|
ProviderTableMeta.FILE_PATH + " ASC "
|
|
ProviderTableMeta.FILE_PATH + " ASC "
|
|
);
|
|
);
|
|
} catch (RemoteException e) {
|
|
} catch (RemoteException e) {
|
|
@@ -717,14 +707,14 @@ public class FileDataStorageManager {
|
|
ProviderTableMeta.CONTENT_URI,
|
|
ProviderTableMeta.CONTENT_URI,
|
|
null,
|
|
null,
|
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " LIKE ? ",
|
|
- new String[]{account.name, ocFile.getRemotePath() + "%"},
|
|
|
|
|
|
+ new String[]{user.getAccountName(), ocFile.getRemotePath() + "%"},
|
|
ProviderTableMeta.FILE_PATH + " ASC "
|
|
ProviderTableMeta.FILE_PATH + " ASC "
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
/// 2. prepare a batch of update operations to change all the descendants
|
|
/// 2. prepare a batch of update operations to change all the descendants
|
|
ArrayList<ContentProviderOperation> operations = new ArrayList<>(cursor.getCount());
|
|
ArrayList<ContentProviderOperation> operations = new ArrayList<>(cursor.getCount());
|
|
- String defaultSavePath = FileStorageUtils.getSavePath(account.name);
|
|
|
|
|
|
+ String defaultSavePath = FileStorageUtils.getSavePath(user.getAccountName());
|
|
List<String> originalPathsToTriggerMediaScan = new ArrayList<>();
|
|
List<String> originalPathsToTriggerMediaScan = new ArrayList<>();
|
|
List<String> newPathsToTriggerMediaScan = new ArrayList<>();
|
|
List<String> newPathsToTriggerMediaScan = new ArrayList<>();
|
|
|
|
|
|
@@ -780,7 +770,7 @@ public class FileDataStorageManager {
|
|
}
|
|
}
|
|
|
|
|
|
/// 4. move in local file system
|
|
/// 4. move in local file system
|
|
- String originalLocalPath = FileStorageUtils.getDefaultSavePathFor(account.name, ocFile);
|
|
|
|
|
|
+ String originalLocalPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), ocFile);
|
|
String targetLocalPath = defaultSavePath + targetPath;
|
|
String targetLocalPath = defaultSavePath + targetPath;
|
|
File localFile = new File(originalLocalPath);
|
|
File localFile = new File(originalLocalPath);
|
|
boolean renamed = false;
|
|
boolean renamed = false;
|
|
@@ -812,10 +802,10 @@ public class FileDataStorageManager {
|
|
|
|
|
|
public void copyLocalFile(OCFile ocFile, String targetPath) {
|
|
public void copyLocalFile(OCFile ocFile, String targetPath) {
|
|
if (ocFile.fileExists() && !OCFile.ROOT_PATH.equals(ocFile.getFileName())) {
|
|
if (ocFile.fileExists() && !OCFile.ROOT_PATH.equals(ocFile.getFileName())) {
|
|
- String localPath = FileStorageUtils.getDefaultSavePathFor(account.name, ocFile);
|
|
|
|
|
|
+ String localPath = FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), ocFile);
|
|
File localFile = new File(localPath);
|
|
File localFile = new File(localPath);
|
|
boolean copied = false;
|
|
boolean copied = false;
|
|
- String defaultSavePath = FileStorageUtils.getSavePath(account.name);
|
|
|
|
|
|
+ String defaultSavePath = FileStorageUtils.getSavePath(user.getAccountName());
|
|
if (localFile.exists()) {
|
|
if (localFile.exists()) {
|
|
File targetFile = new File(defaultSavePath + targetPath);
|
|
File targetFile = new File(defaultSavePath + targetPath);
|
|
File targetFolder = targetFile.getParentFile();
|
|
File targetFolder = targetFile.getParentFile();
|
|
@@ -828,6 +818,10 @@ public class FileDataStorageManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * This method does not require {@link FileDataStorageManager} being initialized
|
|
|
|
+ * with any specific user. Migration can be performed with {@link com.nextcloud.client.account.AnonymousUser}.
|
|
|
|
+ */
|
|
public void migrateStoredFiles(String sourcePath, String destinationPath)
|
|
public void migrateStoredFiles(String sourcePath, String destinationPath)
|
|
throws RemoteException, OperationApplicationException {
|
|
throws RemoteException, OperationApplicationException {
|
|
Cursor cursor;
|
|
Cursor cursor;
|
|
@@ -962,14 +956,14 @@ public class FileDataStorageManager {
|
|
key + AND
|
|
key + AND
|
|
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
|
+ ProviderTableMeta.FILE_ACCOUNT_OWNER
|
|
+ "=?",
|
|
+ "=?",
|
|
- new String[]{value, account.name}, null);
|
|
|
|
|
|
+ new String[]{value, user.getAccountName()}, null);
|
|
} else {
|
|
} else {
|
|
try {
|
|
try {
|
|
cursor = getContentProviderClient().query(
|
|
cursor = getContentProviderClient().query(
|
|
ProviderTableMeta.CONTENT_URI,
|
|
ProviderTableMeta.CONTENT_URI,
|
|
null,
|
|
null,
|
|
key + AND + ProviderTableMeta.FILE_ACCOUNT_OWNER
|
|
key + AND + ProviderTableMeta.FILE_ACCOUNT_OWNER
|
|
- + "=?", new String[]{value, account.name},
|
|
|
|
|
|
+ + "=?", new String[]{value, user.getAccountName()},
|
|
null);
|
|
null);
|
|
} catch (RemoteException e) {
|
|
} catch (RemoteException e) {
|
|
Log_OC.e(TAG, "Could not get file details: " + e.getMessage(), e);
|
|
Log_OC.e(TAG, "Could not get file details: " + e.getMessage(), e);
|
|
@@ -999,7 +993,7 @@ public class FileDataStorageManager {
|
|
// try to find existing file and bind it with current account;
|
|
// try to find existing file and bind it with current account;
|
|
// with the current update of SynchronizeFolderOperation, this won't be
|
|
// with the current update of SynchronizeFolderOperation, this won't be
|
|
// necessary anymore after a full synchronization of the account
|
|
// necessary anymore after a full synchronization of the account
|
|
- File file = new File(FileStorageUtils.getDefaultSavePathFor(account.name, ocFile));
|
|
|
|
|
|
+ File file = new File(FileStorageUtils.getDefaultSavePathFor(user.getAccountName(), ocFile));
|
|
if (file.exists()) {
|
|
if (file.exists()) {
|
|
ocFile.setStoragePath(file.getAbsolutePath());
|
|
ocFile.setStoragePath(file.getAbsolutePath());
|
|
ocFile.setLastSyncDateForData(file.lastModified());
|
|
ocFile.setLastSyncDateForData(file.lastModified());
|
|
@@ -1160,7 +1154,7 @@ public class FileDataStorageManager {
|
|
null,
|
|
null,
|
|
key + AND
|
|
key + AND
|
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
|
- new String[]{value, account.name},
|
|
|
|
|
|
+ new String[]{value, user.getAccountName()},
|
|
null
|
|
null
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
@@ -1169,7 +1163,7 @@ public class FileDataStorageManager {
|
|
ProviderTableMeta.CONTENT_URI_SHARE,
|
|
ProviderTableMeta.CONTENT_URI_SHARE,
|
|
null,
|
|
null,
|
|
key + AND + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
|
key + AND + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?",
|
|
- new String[]{value, account.name},
|
|
|
|
|
|
+ new String[]{value, user.getAccountName()},
|
|
null
|
|
null
|
|
);
|
|
);
|
|
} catch (RemoteException e) {
|
|
} catch (RemoteException e) {
|
|
@@ -1205,21 +1199,21 @@ public class FileDataStorageManager {
|
|
selectionArgs = new String[]{
|
|
selectionArgs = new String[]{
|
|
path,
|
|
path,
|
|
Integer.toString(type.getValue()),
|
|
Integer.toString(type.getValue()),
|
|
- account.name
|
|
|
|
|
|
+ user.getAccountName()
|
|
};
|
|
};
|
|
} else {
|
|
} else {
|
|
if (shareWith == null) {
|
|
if (shareWith == null) {
|
|
selectionArgs = new String[]{
|
|
selectionArgs = new String[]{
|
|
path,
|
|
path,
|
|
Integer.toString(type.getValue()),
|
|
Integer.toString(type.getValue()),
|
|
- account.name,
|
|
|
|
|
|
+ user.getAccountName(),
|
|
""
|
|
""
|
|
};
|
|
};
|
|
} else {
|
|
} else {
|
|
selectionArgs = new String[]{
|
|
selectionArgs = new String[]{
|
|
path,
|
|
path,
|
|
Integer.toString(type.getValue()),
|
|
Integer.toString(type.getValue()),
|
|
- account.name,
|
|
|
|
|
|
+ user.getAccountName(),
|
|
shareWith
|
|
shareWith
|
|
};
|
|
};
|
|
}
|
|
}
|
|
@@ -1274,7 +1268,7 @@ public class FileDataStorageManager {
|
|
contentValues.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
|
contentValues.put(ProviderTableMeta.OCSHARES_IS_DIRECTORY, share.isFolder() ? 1 : 0);
|
|
contentValues.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
|
contentValues.put(ProviderTableMeta.OCSHARES_USER_ID, share.getUserId());
|
|
contentValues.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
|
contentValues.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getRemoteId());
|
|
- contentValues.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, account.name);
|
|
|
|
|
|
+ contentValues.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, user.getAccountName());
|
|
contentValues.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
|
contentValues.put(ProviderTableMeta.OCSHARES_IS_PASSWORD_PROTECTED, share.isPasswordProtected() ? 1 : 0);
|
|
contentValues.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
|
contentValues.put(ProviderTableMeta.OCSHARES_NOTE, share.getNote());
|
|
contentValues.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
|
contentValues.put(ProviderTableMeta.OCSHARES_HIDE_DOWNLOAD, share.isHideFileDownload());
|
|
@@ -1313,7 +1307,7 @@ public class FileDataStorageManager {
|
|
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
|
|
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
|
|
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
|
|
cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
|
|
- String[] whereArgs = new String[]{account.name};
|
|
|
|
|
|
+ String[] whereArgs = new String[]{user.getAccountName()};
|
|
|
|
|
|
if (getContentResolver() != null) {
|
|
if (getContentResolver() != null) {
|
|
getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
|
|
getContentResolver().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs);
|
|
@@ -1332,7 +1326,7 @@ public class FileDataStorageManager {
|
|
contentValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
|
|
contentValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
|
|
contentValues.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
|
|
contentValues.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PARENT + " = ?";
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PARENT + " = ?";
|
|
- String[] whereArgs = new String[]{account.name, String.valueOf(folder.getFileId())};
|
|
|
|
|
|
+ String[] whereArgs = new String[]{user.getAccountName(), String.valueOf(folder.getFileId())};
|
|
|
|
|
|
if (getContentResolver() != null) {
|
|
if (getContentResolver() != null) {
|
|
getContentResolver().update(ProviderTableMeta.CONTENT_URI, contentValues, where, whereArgs);
|
|
getContentResolver().update(ProviderTableMeta.CONTENT_URI, contentValues, where, whereArgs);
|
|
@@ -1351,7 +1345,7 @@ public class FileDataStorageManager {
|
|
contentValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
|
|
contentValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, Boolean.FALSE);
|
|
contentValues.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
|
|
contentValues.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, Boolean.FALSE);
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " = ?";
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + " = ?";
|
|
- String[] whereArgs = new String[]{account.name, filePath};
|
|
|
|
|
|
+ String[] whereArgs = new String[]{user.getAccountName(), filePath};
|
|
|
|
|
|
if (getContentResolver() != null) {
|
|
if (getContentResolver() != null) {
|
|
getContentResolver().update(ProviderTableMeta.CONTENT_URI, contentValues, where, whereArgs);
|
|
getContentResolver().update(ProviderTableMeta.CONTENT_URI, contentValues, where, whereArgs);
|
|
@@ -1368,7 +1362,7 @@ public class FileDataStorageManager {
|
|
@VisibleForTesting
|
|
@VisibleForTesting
|
|
public void cleanShares() {
|
|
public void cleanShares() {
|
|
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
|
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
|
- String[] whereArgs = new String[]{account.name};
|
|
|
|
|
|
+ String[] whereArgs = new String[]{user.getAccountName()};
|
|
|
|
|
|
if (getContentResolver() != null) {
|
|
if (getContentResolver() != null) {
|
|
getContentResolver().delete(ProviderTableMeta.CONTENT_URI_SHARE, where, whereArgs);
|
|
getContentResolver().delete(ProviderTableMeta.CONTENT_URI_SHARE, where, whereArgs);
|
|
@@ -1451,7 +1445,7 @@ public class FileDataStorageManager {
|
|
if (!file.isFolder()) {
|
|
if (!file.isFolder()) {
|
|
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
|
cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath());
|
|
}
|
|
}
|
|
- cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account.name);
|
|
|
|
|
|
+ cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, user.getAccountName());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
|
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
|
|
cv.put(
|
|
cv.put(
|
|
ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA,
|
|
ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA,
|
|
@@ -1512,7 +1506,7 @@ public class FileDataStorageManager {
|
|
Uri contentUriShare = ProviderTableMeta.CONTENT_URI_SHARE;
|
|
Uri contentUriShare = ProviderTableMeta.CONTENT_URI_SHARE;
|
|
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + AND +
|
|
String where = ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + AND +
|
|
ProviderTableMeta._ID + " = ?";
|
|
ProviderTableMeta._ID + " = ?";
|
|
- String[] whereArgs = {account.name, Long.toString(share.getId())};
|
|
|
|
|
|
+ String[] whereArgs = {user.getAccountName(), Long.toString(share.getId())};
|
|
|
|
|
|
if (getContentProviderClient() != null) {
|
|
if (getContentProviderClient() != null) {
|
|
try {
|
|
try {
|
|
@@ -1635,7 +1629,7 @@ public class FileDataStorageManager {
|
|
if (folder != null) {
|
|
if (folder != null) {
|
|
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
|
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?";
|
|
- String[] whereArgs = new String[]{"", account.name};
|
|
|
|
|
|
+ String[] whereArgs = new String[]{"", user.getAccountName()};
|
|
|
|
|
|
List<OCFile> files = getFolderContent(folder, false);
|
|
List<OCFile> files = getFolderContent(folder, false);
|
|
|
|
|
|
@@ -1656,7 +1650,7 @@ public class FileDataStorageManager {
|
|
|
|
|
|
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
|
String where = ProviderTableMeta.OCSHARES_PATH + AND
|
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?";
|
|
+ ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + " = ?";
|
|
- String[] whereArgs = new String[]{filePath, account.name};
|
|
|
|
|
|
+ String[] whereArgs = new String[]{filePath, user.getAccountName()};
|
|
|
|
|
|
preparedOperations.add(
|
|
preparedOperations.add(
|
|
ContentProviderOperation
|
|
ContentProviderOperation
|
|
@@ -1889,7 +1883,7 @@ public class FileDataStorageManager {
|
|
ProviderTableMeta.CONTENT_URI_FILE,
|
|
ProviderTableMeta.CONTENT_URI_FILE,
|
|
projection,
|
|
projection,
|
|
whereForDescencentsInConflict,
|
|
whereForDescencentsInConflict,
|
|
- new String[]{account.name, parentPath + "%"},
|
|
|
|
|
|
+ new String[]{user.getAccountName(), parentPath + "%"},
|
|
null
|
|
null
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
@@ -1898,7 +1892,7 @@ public class FileDataStorageManager {
|
|
ProviderTableMeta.CONTENT_URI_FILE,
|
|
ProviderTableMeta.CONTENT_URI_FILE,
|
|
projection,
|
|
projection,
|
|
whereForDescencentsInConflict,
|
|
whereForDescencentsInConflict,
|
|
- new String[]{account.name, parentPath + "%"},
|
|
|
|
|
|
+ new String[]{user.getAccountName(), parentPath + "%"},
|
|
null
|
|
null
|
|
);
|
|
);
|
|
} catch (RemoteException e) {
|
|
} catch (RemoteException e) {
|
|
@@ -1914,7 +1908,7 @@ public class FileDataStorageManager {
|
|
cv,
|
|
cv,
|
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
|
ProviderTableMeta.FILE_PATH + "=?",
|
|
ProviderTableMeta.FILE_PATH + "=?",
|
|
- new String[]{account.name, parentPath}
|
|
|
|
|
|
+ new String[]{user.getAccountName(), parentPath}
|
|
);
|
|
);
|
|
} else {
|
|
} else {
|
|
try {
|
|
try {
|
|
@@ -1923,7 +1917,7 @@ public class FileDataStorageManager {
|
|
cv,
|
|
cv,
|
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
|
ProviderTableMeta.FILE_ACCOUNT_OWNER + AND +
|
|
ProviderTableMeta.FILE_PATH + "=?"
|
|
ProviderTableMeta.FILE_PATH + "=?"
|
|
- , new String[]{account.name, parentPath}
|
|
|
|
|
|
+ , new String[]{user.getAccountName(), parentPath}
|
|
);
|
|
);
|
|
} catch (RemoteException e) {
|
|
} catch (RemoteException e) {
|
|
Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage(), e);
|
|
Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage(), e);
|
|
@@ -1948,18 +1942,18 @@ public class FileDataStorageManager {
|
|
|
|
|
|
public void saveCapabilities(OCCapability capability) {
|
|
public void saveCapabilities(OCCapability capability) {
|
|
// Prepare capabilities data
|
|
// Prepare capabilities data
|
|
- ContentValues contentValues = createContentValues(account.name, capability);
|
|
|
|
|
|
+ ContentValues contentValues = createContentValues(user.getAccountName(), capability);
|
|
|
|
|
|
- if (capabilityExists(account.name)) {
|
|
|
|
|
|
+ if (capabilityExists(user.getAccountName())) {
|
|
if (getContentResolver() != null) {
|
|
if (getContentResolver() != null) {
|
|
getContentResolver().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES, contentValues,
|
|
getContentResolver().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES, contentValues,
|
|
ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?",
|
|
ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?",
|
|
- new String[]{account.name});
|
|
|
|
|
|
+ new String[]{user.getAccountName()});
|
|
} else {
|
|
} else {
|
|
try {
|
|
try {
|
|
getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES,
|
|
getContentProviderClient().update(ProviderTableMeta.CONTENT_URI_CAPABILITIES,
|
|
contentValues, ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?",
|
|
contentValues, ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?",
|
|
- new String[]{account.name});
|
|
|
|
|
|
+ new String[]{user.getAccountName()});
|
|
} catch (RemoteException e) {
|
|
} catch (RemoteException e) {
|
|
Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e);
|
|
Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e);
|
|
}
|
|
}
|
|
@@ -1981,7 +1975,7 @@ public class FileDataStorageManager {
|
|
long new_id = Long.parseLong(result_uri.getPathSegments()
|
|
long new_id = Long.parseLong(result_uri.getPathSegments()
|
|
.get(1));
|
|
.get(1));
|
|
capability.setId(new_id);
|
|
capability.setId(new_id);
|
|
- capability.setAccountName(account.name);
|
|
|
|
|
|
+ capability.setAccountName(user.getAccountName());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2341,7 +2335,7 @@ public class FileDataStorageManager {
|
|
public void deleteAllFiles() {
|
|
public void deleteAllFiles() {
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "= ? AND " +
|
|
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "= ? AND " +
|
|
ProviderTableMeta.FILE_PATH + "= ?";
|
|
ProviderTableMeta.FILE_PATH + "= ?";
|
|
- String[] whereArgs = new String[]{account.name, OCFile.ROOT_PATH};
|
|
|
|
|
|
+ String[] whereArgs = new String[]{user.getAccountName(), OCFile.ROOT_PATH};
|
|
|
|
|
|
if (getContentResolver() != null) {
|
|
if (getContentResolver() != null) {
|
|
getContentResolver().delete(ProviderTableMeta.CONTENT_URI_DIR, where, whereArgs);
|
|
getContentResolver().delete(ProviderTableMeta.CONTENT_URI_DIR, where, whereArgs);
|
|
@@ -2349,14 +2343,14 @@ public class FileDataStorageManager {
|
|
try {
|
|
try {
|
|
getContentProviderClient().delete(ProviderTableMeta.CONTENT_URI_DIR, where, whereArgs);
|
|
getContentProviderClient().delete(ProviderTableMeta.CONTENT_URI_DIR, where, whereArgs);
|
|
} catch (RemoteException e) {
|
|
} catch (RemoteException e) {
|
|
- Log_OC.e(TAG, "Exception in deleteAllFiles for account " + account.name + ": " + e.getMessage(), e);
|
|
|
|
|
|
+ Log_OC.e(TAG, "Exception in deleteAllFiles for account " + user.getAccountName() + ": " + e.getMessage(), e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public List<OCFile> getAllFiles() {
|
|
public List<OCFile> getAllFiles() {
|
|
String selection = ProviderTableMeta.FILE_ACCOUNT_OWNER + "= ? ";
|
|
String selection = ProviderTableMeta.FILE_ACCOUNT_OWNER + "= ? ";
|
|
- String[] selectionArgs = new String[]{account.name};
|
|
|
|
|
|
+ String[] selectionArgs = new String[]{user.getAccountName()};
|
|
|
|
|
|
List<OCFile> folderContent = new ArrayList<>();
|
|
List<OCFile> folderContent = new ArrayList<>();
|
|
|
|
|
|
@@ -2410,7 +2404,8 @@ public class FileDataStorageManager {
|
|
return this.contentProviderClient;
|
|
return this.contentProviderClient;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Deprecated
|
|
public Account getAccount() {
|
|
public Account getAccount() {
|
|
- return this.account;
|
|
|
|
|
|
+ return this.user.toPlatformAccount();
|
|
}
|
|
}
|
|
}
|
|
}
|