From 3d2bb52ea083a1b271f8ba986de896f4d62f62a2 Mon Sep 17 00:00:00 2001 From: AndyScherzinger Date: Wed, 2 Nov 2016 19:03:19 +0100 Subject: [PATCH] fixed minor warnings --- .../datamodel/FileDataStorageManager.java | 112 ++++++++---------- 1 file changed, 48 insertions(+), 64 deletions(-) diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 8d9f5a3a41..229150796e 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -224,8 +224,7 @@ public class FileDataStorageManager { cv, ProviderTableMeta._ID + "=?", new String[]{String.valueOf(file.getFileId())}); } catch (RemoteException e) { - Log_OC.e(TAG, - FAILED_TO_INSERT_MSG + e.getMessage()); + Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e); } } } else { @@ -238,8 +237,7 @@ public class FileDataStorageManager { result_uri = getContentProviderClient().insert( ProviderTableMeta.CONTENT_URI_FILE, cv); } catch (RemoteException e) { - Log_OC.e(TAG, - FAILED_TO_INSERT_MSG + e.getMessage()); + Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e); } } if (result_uri != null) { @@ -412,7 +410,7 @@ public class FileDataStorageManager { } } catch (OperationApplicationException | RemoteException e) { - Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage()); + Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e); } @@ -603,7 +601,7 @@ public class FileDataStorageManager { ProviderTableMeta.FILE_PATH + " ASC " ); } catch (RemoteException e) { - Log_OC.e(TAG, e.getMessage()); + Log_OC.e(TAG, e.getMessage(), e); } } else { @@ -820,7 +818,7 @@ public class FileDataStorageManager { ProviderTableMeta.FILE_PARENT + "=?", new String[]{String.valueOf(parentId)}, null); } catch (RemoteException e) { - Log_OC.e(TAG, e.getMessage()); + Log_OC.e(TAG, e.getMessage(), e); return ret; } } else { @@ -872,9 +870,7 @@ public class FileDataStorageManager { + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?", new String[]{value, mAccount.name}, null); } catch (RemoteException e) { - Log_OC.e(TAG, - "Couldn't determine file existance, assuming non existance: " - + e.getMessage()); + Log_OC.e(TAG, "Couldn't determine file existance, assuming non existance: " + e.getMessage(), e); return false; } } @@ -902,7 +898,7 @@ public class FileDataStorageManager { + "=?", new String[]{value, mAccount.name}, null); } catch (RemoteException e) { - Log_OC.e(TAG, "Could not get file details: " + e.getMessage()); + Log_OC.e(TAG, "Could not get file details: " + e.getMessage(), e); c = null; } } @@ -1000,8 +996,7 @@ public class FileDataStorageManager { cv, ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + "=?", new String[]{String.valueOf(share.getRemoteId())}); } catch (RemoteException e) { - Log_OC.e(TAG, - FAILED_TO_INSERT_MSG + e.getMessage()); + Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e); } } } else { @@ -1014,8 +1009,7 @@ public class FileDataStorageManager { result_uri = getContentProviderClient().insert( ProviderTableMeta.CONTENT_URI_SHARE, cv); } catch (RemoteException e) { - Log_OC.e(TAG, - FAILED_TO_INSERT_MSG + e.getMessage()); + Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e); } } if (result_uri != null) { @@ -1102,14 +1096,12 @@ public class FileDataStorageManager { c = getContentProviderClient().query( ProviderTableMeta.CONTENT_URI_SHARE, null, - key + AND - + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?", + key + AND + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?", new String[]{value, mAccount.name}, null ); } catch (RemoteException e) { - Log_OC.w(TAG, - "Could not get details, assuming share does not exist: "+ e.getMessage()); + Log_OC.w(TAG, "Could not get details, assuming share does not exist: "+ e.getMessage()); c = null; } } @@ -1170,13 +1162,16 @@ public class FileDataStorageManager { null); } catch (RemoteException e) { - Log_OC.e(TAG, "Could not get file details: " + e.getMessage()); + Log_OC.e(TAG, "Could not get file details: " + e.getMessage(), e); cursor = null; } } + OCShare share = null; - if (cursor != null && cursor.moveToFirst()) { - share = createShareInstance(cursor); + if (cursor != null) { + if (cursor.moveToFirst()) { + share = createShareInstance(cursor); + } cursor.close(); } return share; @@ -1226,10 +1221,9 @@ public class FileDataStorageManager { } else { try { - getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, - whereArgs); + getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs); } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in resetShareFlagsInAllFiles" + e.getMessage()); + Log_OC.e(TAG, "Exception in resetShareFlagsInAllFiles" + e.getMessage(), e); } } } @@ -1248,10 +1242,9 @@ public class FileDataStorageManager { } else { try { - getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, - whereArgs); + getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs); } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in resetShareFlagsInFolder " + e.getMessage()); + Log_OC.e(TAG, "Exception in resetShareFlagsInFolder " + e.getMessage(), e); } } } @@ -1270,10 +1263,9 @@ public class FileDataStorageManager { } else { try { - getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, - whereArgs); + getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs); } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in resetShareFlagsInFolder " + e.getMessage()); + Log_OC.e(TAG, "Exception in resetShareFlagsInFolder " + e.getMessage(), e); } } } @@ -1290,7 +1282,7 @@ public class FileDataStorageManager { getContentProviderClient().delete(ProviderTableMeta.CONTENT_URI_SHARE, where, whereArgs); } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in cleanShares" + e.getMessage()); + Log_OC.e(TAG, "Exception in cleanShares" + e.getMessage(), e); } } } @@ -1353,11 +1345,8 @@ public class FileDataStorageManager { results = getContentProviderClient().applyBatch(operations); } - } catch (OperationApplicationException e) { - Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage()); - - } catch (RemoteException e) { - Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage()); + } catch (OperationApplicationException | RemoteException e) { + Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e); } } } @@ -1444,8 +1433,7 @@ public class FileDataStorageManager { } } catch (OperationApplicationException | RemoteException e) { - Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage()); - + Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e); } } } @@ -1496,8 +1484,7 @@ public class FileDataStorageManager { } } catch (OperationApplicationException | RemoteException e) { - Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage()); - + Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e); } } @@ -1542,8 +1529,7 @@ public class FileDataStorageManager { } } catch (OperationApplicationException | RemoteException e) { - Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage()); - + Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e); } } } @@ -1572,8 +1558,7 @@ public class FileDataStorageManager { } } catch (OperationApplicationException | RemoteException e) { - Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage()); - + Log_OC.e(TAG, EXCEPTION_MSG + e.getMessage(), e); } } @@ -1684,17 +1669,20 @@ public class FileDataStorageManager { null, where, whereArgs, null); } catch (RemoteException e) { - Log_OC.e(TAG, "Could not get list of shares with: " + e.getMessage()); + Log_OC.e(TAG, "Could not get list of shares with: " + e.getMessage(), e); cursor = null; } } ArrayList shares = new ArrayList(); OCShare share = null; - if (cursor != null && cursor.moveToFirst()) { - do { - share = createShareInstance(cursor); - shares.add(share); - } while (cursor.moveToNext()); + if (cursor != null) { + if (cursor.moveToFirst()) { + do { + share = createShareInstance(cursor); + shares.add(share); + } while (cursor.moveToNext()); + } + cursor.close(); } @@ -1745,7 +1733,7 @@ public class FileDataStorageManager { MediaStore.Video.Media.DATA + "=?", new String[]{path}); } } catch (RemoteException e) { - Log_OC.e(TAG, "Exception deleting media file in MediaStore " + e.getMessage()); + Log_OC.e(TAG, "Exception deleting media file in MediaStore " + e.getMessage(), e); } } } @@ -1773,7 +1761,7 @@ public class FileDataStorageManager { new String[]{String.valueOf(file.getFileId())} ); } catch (RemoteException e) { - Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage()); + Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage(), e); } } @@ -1784,7 +1772,7 @@ public class FileDataStorageManager { /// set conflict in all ancestor folders long parentId = file.getParentId(); - Set ancestorIds = new HashSet(); + Set ancestorIds = new HashSet<>(); while (parentId != FileDataStorageManager.ROOT_PARENT_ID) { ancestorIds.add(Long.toString(parentId)); parentId = getFileById(parentId).getParentId(); @@ -1814,7 +1802,7 @@ public class FileDataStorageManager { ancestorIds.toArray(new String[]{}) ); } catch (RemoteException e) { - Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage()); + Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage(), e); } } } // else file is ROOT folder, no parent to set in conflict @@ -1855,7 +1843,7 @@ public class FileDataStorageManager { null ); } catch (RemoteException e) { - Log_OC.e(TAG, "Failed querying for descendents in conflict " + e.getMessage()); + Log_OC.e(TAG, "Failed querying for descendents in conflict " + e.getMessage(), e); } } if (descendentsInConflict == null || descendentsInConflict.getCount() == 0) { @@ -1878,7 +1866,7 @@ public class FileDataStorageManager { , new String[]{mAccount.name, parentPath} ); } catch (RemoteException e) { - Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage()); + Log_OC.e(TAG, "Failed saving conflict in database " + e.getMessage(), e); } } @@ -1948,8 +1936,7 @@ public class FileDataStorageManager { cv, ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=?", new String[]{mAccount.name}); } catch (RemoteException e) { - Log_OC.e(TAG, - FAILED_TO_INSERT_MSG + e.getMessage()); + Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e); } } } else { @@ -1962,8 +1949,7 @@ public class FileDataStorageManager { result_uri = getContentProviderClient().insert( ProviderTableMeta.CONTENT_URI_CAPABILITIES, cv); } catch (RemoteException e) { - Log_OC.e(TAG, - FAILED_TO_INSERT_MSG + e.getMessage()); + Log_OC.e(TAG, FAILED_TO_INSERT_MSG + e.getMessage(), e); } } if (result_uri != null) { @@ -2003,9 +1989,7 @@ public class FileDataStorageManager { ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME + "=? ", new String[]{accountName}, null); } catch (RemoteException e) { - Log_OC.e(TAG, - "Couldn't determine capability existance, assuming non existance: " - + e.getMessage()); + Log_OC.e(TAG, "Couldn't determine capability existence, assuming non existance: " + e.getMessage(), e); } }