From df977e4e9a9584ad81779092f272614cfa4b3a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Thu, 9 Jan 2020 12:39:51 +0100 Subject: [PATCH] Finish replacing logOC with timber --- .../lib/common/DynamicSessionManager.java | 3 +- .../lib/common/OwnCloudClientFactory.java | 4 +- .../lib/common/SimpleFactoryManager.java | 15 +- .../lib/common/SingleSessionManager.java | 64 ++----- .../lib/common/accounts/AccountUtils.java | 14 +- .../oauth/OAuth2QueryParser.java | 4 +- .../OAuth2RefreshAccessTokenOperation.java | 5 +- .../oauth/OwnCloudOAuth2Provider.java | 14 +- .../android/lib/common/http/HttpClient.java | 34 +--- .../network/AdvancedX509TrustManager.java | 4 +- .../lib/common/network/NetworkUtils.java | 39 +--- .../common/network/ServerNameIndicator.java | 145 --------------- .../common/network/WriteTimeoutEnforcer.java | 167 ------------------ .../common/operations/RemoteOperation.java | 21 +-- .../operations/RemoteOperationResult.java | 18 +- .../android/lib/common/utils/LoggingHelper.kt | 2 +- .../files/CreateRemoteFolderOperation.java | 8 +- .../files/DownloadRemoteFileOperation.java | 13 +- .../files/ExistenceCheckRemoteOperation.java | 15 +- .../files/ReadRemoteFileOperation.java | 6 +- .../files/ReadRemoteFolderOperation.java | 11 +- .../files/RemoveRemoteFileOperation.java | 7 +- .../files/RenameRemoteFileOperation.java | 14 +- .../files/UploadRemoteFileOperation.java | 17 +- .../ChunkedUploadRemoteFileOperation.java | 5 +- .../shares/CreateRemoteShareOperation.kt | 6 +- .../shares/GetRemoteShareOperation.java | 6 +- .../shares/GetRemoteSharesForFileOperation.kt | 11 +- .../lib/resources/shares/ShareXMLParser.kt | 4 - .../users/GetRemoteUserInfoOperation.java | 16 +- .../users/GetRemoteUserQuotaOperation.java | 10 +- 31 files changed, 120 insertions(+), 582 deletions(-) delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ServerNameIndicator.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/WriteTimeoutEnforcer.java diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/DynamicSessionManager.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/DynamicSessionManager.java index 38fb11e427..4a69fac43a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/DynamicSessionManager.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/DynamicSessionManager.java @@ -26,8 +26,7 @@ public class DynamicSessionManager implements OwnCloudClientManager { @Override public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) - throws AccountUtils.AccountNotFoundException, - OperationCanceledException, AuthenticatorException, IOException { + throws OperationCanceledException, AuthenticatorException, IOException { OwnCloudVersion ownCloudVersion = null; if (account.getSavedAccount() != null) { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java index 6fb5345f03..94a44c2608 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientFactory.java @@ -29,8 +29,6 @@ public class OwnCloudClientFactory { - final private static String TAG = OwnCloudClientFactory.class.getSimpleName(); - /** * Creates a OwnCloudClient to access a URL and sets the desired parameters for ownCloud * client connections. @@ -49,4 +47,4 @@ public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, return client; } -} \ No newline at end of file +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SimpleFactoryManager.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SimpleFactoryManager.java index 46f722e97b..d039162e73 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SimpleFactoryManager.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SimpleFactoryManager.java @@ -29,31 +29,25 @@ import android.content.Context; import com.owncloud.android.lib.common.accounts.AccountUtils; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.io.IOException; public class SimpleFactoryManager implements OwnCloudClientManager { - private static final String TAG = SimpleFactoryManager.class.getSimpleName(); - @Override public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws OperationCanceledException, AuthenticatorException, IOException { - Log_OC.d(TAG, "getClientFor(OwnCloudAccount ... : "); + Timber.d("getClientFor(OwnCloudAccount ... : "); OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient( account.getBaseUri(), context.getApplicationContext(), true); - Log_OC.v(TAG, " new client {" + - (account.getName() != null ? - account.getName() : - AccountUtils.buildAccountName(account.getBaseUri(), "") - - ) + ", " + client.hashCode() + "}"); + Timber.v(" new client {" + (account.getName() != null ? account.getName() : + AccountUtils.buildAccountName(account.getBaseUri(), "")) + ", " + client.hashCode() + "}"); if (account.getCredentials() == null) { account.loadCredentials(context); @@ -75,5 +69,4 @@ public OwnCloudClient removeClientFor(OwnCloudAccount account) { public void saveAllClients(Context context, String accountType) { // nothing to do - not taking care of tracking instances! } - } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SingleSessionManager.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SingleSessionManager.java index 21bdf925de..e4b190a4e0 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SingleSessionManager.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SingleSessionManager.java @@ -30,11 +30,10 @@ import android.accounts.OperationCanceledException; import android.content.Context; import android.net.Uri; -import android.util.Log; import com.owncloud.android.lib.common.accounts.AccountUtils; import com.owncloud.android.lib.common.http.HttpClient; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.io.IOException; import java.util.Iterator; @@ -54,8 +53,6 @@ public class SingleSessionManager implements OwnCloudClientManager { - private static final String TAG = SingleSessionManager.class.getSimpleName(); - private ConcurrentMap mClientsWithKnownUsername = new ConcurrentHashMap<>(); private ConcurrentMap mClientsWithUnknownUsername = new ConcurrentHashMap<>(); @@ -64,9 +61,7 @@ public class SingleSessionManager implements OwnCloudClientManager { public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws OperationCanceledException, AuthenticatorException, IOException { - if (Log.isLoggable(TAG, Log.DEBUG)) { - Log_OC.d(TAG, "getClientFor starting "); - } + Timber.d("getClientFor starting "); if (account == null) { throw new IllegalArgumentException("Cannot get an OwnCloudClient for a null account"); } @@ -84,21 +79,16 @@ public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) thr if (accountName != null) { client = mClientsWithUnknownUsername.remove(sessionName); if (client != null) { - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log_OC.v(TAG, "reusing client for session " + sessionName); - } + Timber.v("reusing client for session %s", sessionName); + mClientsWithKnownUsername.put(accountName, client); - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log_OC.v(TAG, "moved client to account " + accountName); - } + Timber.v("moved client to account %s", accountName); } } else { client = mClientsWithUnknownUsername.get(sessionName); } } else { - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log_OC.v(TAG, "reusing client for account " + accountName); - } + Timber.v("reusing client for account %s", accountName); reusingKnown = true; } @@ -117,37 +107,28 @@ public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) thr if (accountName != null) { mClientsWithKnownUsername.put(accountName, client); - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log_OC.v(TAG, "new client for account " + accountName); - } + Timber.v("new client for account %s", accountName); } else { mClientsWithUnknownUsername.put(sessionName, client); - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log_OC.v(TAG, "new client for session " + sessionName); - } + Timber.v("new client for session %s", sessionName); } } else { - if (!reusingKnown && Log.isLoggable(TAG, Log.VERBOSE)) { - Log_OC.v(TAG, "reusing client for session " + sessionName); + if (!reusingKnown) { + Timber.v("reusing client for session %s", sessionName); } keepCredentialsUpdated(client); keepCookiesUpdated(context, account, client); keepUriUpdated(account, client); } - - if (Log.isLoggable(TAG, Log.DEBUG)) { - Log_OC.d(TAG, "getClientFor finishing "); - } + Timber.d("getClientFor finishing "); return client; } @Override public OwnCloudClient removeClientFor(OwnCloudAccount account) { - if (Log.isLoggable(TAG, Log.DEBUG)) { - Log_OC.d(TAG, "removeClientFor starting "); - } + Timber.d("removeClientFor starting "); if (account == null) { return null; @@ -158,31 +139,22 @@ public OwnCloudClient removeClientFor(OwnCloudAccount account) { if (accountName != null) { client = mClientsWithKnownUsername.remove(accountName); if (client != null) { - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log_OC.v(TAG, "Removed client for account " + accountName); - } + Timber.v("Removed client for account %s", accountName); return client; } else { - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log_OC.v(TAG, "No client tracked for account " + accountName); - } + Timber.v("No client tracked for account %s", accountName); } } mClientsWithUnknownUsername.clear(); - if (Log.isLoggable(TAG, Log.DEBUG)) { - Log_OC.d(TAG, "removeClientFor finishing "); - } + Timber.d("removeClientFor finishing "); return null; } @Override public void saveAllClients(Context context, String accountType) { - - if (Log.isLoggable(TAG, Log.DEBUG)) { - Log_OC.d(TAG, "Saving sessions... "); - } + Timber.d("Saving sessions... "); Iterator accountNames = mClientsWithKnownUsername.keySet().iterator(); String accountName; @@ -193,9 +165,7 @@ public void saveAllClients(Context context, String accountType) { AccountUtils.saveClient(mClientsWithKnownUsername.get(accountName), account, context); } - if (Log.isLoggable(TAG, Log.DEBUG)) { - Log_OC.d(TAG, "All sessions saved"); - } + Timber.d("All sessions saved"); } private void keepCredentialsUpdated(OwnCloudClient reusedClient) { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java index 2be339d836..0b5911b22b 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountUtils.java @@ -36,10 +36,10 @@ import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.authentication.OwnCloudCredentials; import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory; -import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import okhttp3.Cookie; +import timber.log.Timber; import java.io.IOException; import java.util.ArrayList; @@ -47,8 +47,6 @@ public class AccountUtils { - private static final String TAG = AccountUtils.class.getSimpleName(); - /** * Constructs full url to host and webdav resource basing on host version * @@ -104,7 +102,7 @@ public static String getUsernameForAccount(Account account) { try { username = account.name.substring(0, account.name.lastIndexOf('@')); } catch (Exception e) { - Log_OC.e(TAG, "Couldn't get a username for the given account", e); + Timber.e(e, "Couldn't get a username for the given account"); } return username; } @@ -124,7 +122,7 @@ public static OwnCloudVersion getServerVersionForAccount(Account account, Contex version = new OwnCloudVersion(versionString); } catch (Exception e) { - Log_OC.e(TAG, "Couldn't get a the server version for an account", e); + Timber.e(e, "Couldn't get a the server version for an account"); } return version; } @@ -216,7 +214,7 @@ public static void saveClient(OwnCloudClient client, Account savedAccount, Conte String cookiesString = client.getCookiesString(); if (!"".equals(cookiesString)) { ac.setUserData(savedAccount, Constants.KEY_COOKIES, cookiesString); - Log_OC.d(TAG, "Saving Cookies: " + cookiesString); + Timber.d("Saving Cookies: %s", cookiesString); } } } @@ -230,10 +228,10 @@ public static void saveClient(OwnCloudClient client, Account savedAccount, Conte */ public static void restoreCookies(Account account, OwnCloudClient client, Context context) { if (account == null) { - Log_OC.d(TAG, "Cannot restore cookie for null account"); + Timber.d("Cannot restore cookie for null account"); } else { - Log_OC.d(TAG, "Restoring cookies for " + account.name); + Timber.d("Restoring cookies for %s", account.name); // Account Manager AccountManager am = AccountManager.get(context.getApplicationContext()); diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java index aacd8bab9a..152ffdbe19 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java @@ -26,7 +26,7 @@ package com.owncloud.android.lib.common.authentication.oauth; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.util.HashMap; import java.util.Map; @@ -61,7 +61,7 @@ public Map parse(String query) { mOAuth2ParsedAuthorizationResponse.put(key, value); } - Log_OC.v(TAG, "[" + i + "," + j + "] = " + p); + Timber.v("[" + i + "," + j + "] = " + p); j++; } i++; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RefreshAccessTokenOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RefreshAccessTokenOperation.java index 5f78883150..9b3337b797 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RefreshAccessTokenOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RefreshAccessTokenOperation.java @@ -30,17 +30,16 @@ import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.common.utils.Log_OC; import okhttp3.MultipartBody; import okhttp3.RequestBody; import org.json.JSONObject; +import timber.log.Timber; import java.net.URL; import java.util.Map; public class OAuth2RefreshAccessTokenOperation extends RemoteOperation> { - private static final String TAG = OAuth2RefreshAccessTokenOperation.class.getSimpleName(); private final String mAccessTokenEndpointPath; private final OAuth2ResponseParser mResponseParser; private String mClientId; @@ -96,7 +95,7 @@ protected RemoteOperationResult> run(OwnCloudClient client) switchClientCredentials(oldCredentials); final String responseData = postMethod.getResponseBodyAsString(); - Log_OC.d(TAG, "OAUTH2: raw response from POST TOKEN: " + responseData); + Timber.d("OAUTH2: raw response from POST TOKEN: %s", responseData); if (responseData != null && responseData.length() > 0) { final JSONObject tokenJson = new JSONObject(responseData); diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2Provider.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2Provider.java index 58f149c7a5..e06551ca0a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2Provider.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2Provider.java @@ -26,13 +26,11 @@ package com.owncloud.android.lib.common.authentication.oauth; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; public class OwnCloudOAuth2Provider implements OAuth2Provider { - public static final String NAME = OAuth2Provider.class.getName(); - - public static final String ACCESS_TOKEN_ENDPOINT_PATH = "index.php/apps/oauth2/api/v1/token"; + static final String ACCESS_TOKEN_ENDPOINT_PATH = "index.php/apps/oauth2/api/v1/token"; private static final String AUTHORIZATION_CODE_ENDPOINT_PATH = "index.php/apps/oauth2/authorize"; private String mAuthorizationServerUrl = ""; @@ -66,26 +64,26 @@ public void setAuthorizationServerUri(String authorizationServerUri) { mAuthorizationServerUrl = authorizationServerUri; } - public String getAccessTokenEndpointPath() { + String getAccessTokenEndpointPath() { return mAccessTokenEndpointPath; } public void setAccessTokenEndpointPath(String accessTokenEndpointPath) { if (accessTokenEndpointPath == null || accessTokenEndpointPath.length() <= 0) { - Log_OC.w(NAME, "Setting invalid access token endpoint path, going on with default"); + Timber.w("Setting invalid access token endpoint path, going on with default"); mAccessTokenEndpointPath = ACCESS_TOKEN_ENDPOINT_PATH; } else { mAccessTokenEndpointPath = accessTokenEndpointPath; } } - public String getAuthorizationCodeEndpointPath() { + String getAuthorizationCodeEndpointPath() { return mAuthorizationCodeEndpointPath; } public void setAuthorizationCodeEndpointPath(String authorizationCodeEndpointPath) { if (authorizationCodeEndpointPath == null || authorizationCodeEndpointPath.length() <= 0) { - Log_OC.w(NAME, "Setting invalid authorization code endpoint path, going on with default"); + Timber.w("Setting invalid authorization code endpoint path, going on with default"); mAuthorizationCodeEndpointPath = AUTHORIZATION_CODE_ENDPOINT_PATH; } else { mAuthorizationCodeEndpointPath = authorizationCodeEndpointPath; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpClient.java index 7ddd48c3e9..9a629bfe83 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpClient.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpClient.java @@ -31,12 +31,12 @@ import com.owncloud.android.lib.common.http.interceptors.RequestHeaderInterceptor; import com.owncloud.android.lib.common.network.AdvancedX509TrustManager; import com.owncloud.android.lib.common.network.NetworkUtils; -import com.owncloud.android.lib.common.utils.Log_OC; import okhttp3.Cookie; import okhttp3.CookieJar; import okhttp3.HttpUrl; import okhttp3.OkHttpClient; import okhttp3.Protocol; +import timber.log.Timber; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocketFactory; @@ -57,8 +57,6 @@ * @author David González Verdugo */ public class HttpClient { - private static final String TAG = HttpClient.class.toString(); - private static OkHttpClient sOkHttpClient; private static HttpInterceptor sOkHttpInterceptor; private static Context sContext; @@ -76,10 +74,10 @@ public static OkHttpClient getOkHttpClient() { sslContext = SSLContext.getInstance("TLSv1.2"); } catch (NoSuchAlgorithmException tlsv12Exception) { try { - Log_OC.w(TAG, "TLSv1.2 is not supported in this device; falling through TLSv1.1"); + Timber.w("TLSv1.2 is not supported in this device; falling through TLSv1.1"); sslContext = SSLContext.getInstance("TLSv1.1"); } catch (NoSuchAlgorithmException tlsv11Exception) { - Log_OC.w(TAG, "TLSv1.1 is not supported in this device; falling through TLSv1.0"); + Timber.w("TLSv1.1 is not supported in this device; falling through TLSv1.0"); sslContext = SSLContext.getInstance("TLSv1"); // should be available in any device; see reference of supported protocols in // http://developer.android.com/reference/javax/net/ssl/SSLSocket.html @@ -97,10 +95,8 @@ public static OkHttpClient getOkHttpClient() { @Override public void saveFromResponse(HttpUrl url, List cookies) { // Avoid duplicated cookies - Set nonDuplicatedCookiesSet = new HashSet<>(); - nonDuplicatedCookiesSet.addAll(cookies); - List nonDuplicatedCookiesList = new ArrayList<>(); - nonDuplicatedCookiesList.addAll(nonDuplicatedCookiesSet); + Set nonDuplicatedCookiesSet = new HashSet<>(cookies); + List nonDuplicatedCookiesList = new ArrayList<>(nonDuplicatedCookiesSet); sCookieStore.put(url.host(), nonDuplicatedCookiesList); } @@ -127,7 +123,7 @@ public List loadForRequest(HttpUrl url) { sOkHttpClient = clientBuilder.build(); } catch (Exception e) { - Log_OC.e(TAG, "Could not setup SSL system.", e); + Timber.e(e, "Could not setup SSL system."); } } return sOkHttpClient; @@ -171,22 +167,6 @@ public static void setContext(Context context) { sContext = context; } - public void disableAutomaticCookiesHandling() { - OkHttpClient.Builder clientBuilder = getOkHttpClient().newBuilder(); - clientBuilder.cookieJar(new CookieJar() { - @Override - public void saveFromResponse(HttpUrl url, List cookies) { - // DO NOTHING - } - - @Override - public List loadForRequest(HttpUrl url) { - return new ArrayList<>(); - } - }); - sOkHttpClient = clientBuilder.build(); - } - public List getCookiesFromUrl(HttpUrl httpUrl) { return sCookieStore.get(httpUrl.host()); } @@ -194,4 +174,4 @@ public List getCookiesFromUrl(HttpUrl httpUrl) { public void clearCookies() { sCookieStore.clear(); } -} \ No newline at end of file +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509TrustManager.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509TrustManager.java index f70dabd80f..f2513c3c7d 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509TrustManager.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/AdvancedX509TrustManager.java @@ -24,7 +24,7 @@ package com.owncloud.android.lib.common.network; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; @@ -136,7 +136,7 @@ public boolean isKnownServer(X509Certificate cert) { try { return (mKnownServersKeyStore.getCertificateAlias(cert) != null); } catch (KeyStoreException e) { - Log_OC.d(TAG, "Fail while checking certificate in the known-servers store"); + Timber.e(e, "Fail while checking certificate in the known-servers store"); return false; } } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/NetworkUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/NetworkUtils.java index e4461341f0..f6013cb849 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/NetworkUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/NetworkUtils.java @@ -26,8 +26,7 @@ import android.content.Context; -import com.owncloud.android.lib.common.utils.Log_OC; -import org.apache.http.conn.ssl.X509HostnameVerifier; +import timber.log.Timber; import java.io.File; import java.io.FileInputStream; @@ -42,25 +41,6 @@ public class NetworkUtils { - /** - * Default timeout for waiting data from the server - */ - public static final int DEFAULT_DATA_TIMEOUT = 60000; - /** - * Default timeout for establishing a connection - */ - public static final int DEFAULT_CONNECTION_TIMEOUT = 60000; - /** - * Standard name for protocol TLS version 1.2 in Java Secure Socket Extension (JSSE) API - */ - public static final String PROTOCOL_TLSv1_2 = "TLSv1.2"; - /** - * Standard name for protocol TLS version 1.0 in JSSE API - */ - public static final String PROTOCOL_TLSv1_0 = "TLSv1"; - final private static String TAG = NetworkUtils.class.getSimpleName(); - private static X509HostnameVerifier mHostnameVerifier = null; - private static String LOCAL_TRUSTSTORE_FILENAME = "knownServers.bks"; private static String LOCAL_TRUSTSTORE_PASSWORD = "password"; @@ -88,7 +68,7 @@ public static KeyStore getKnownServersStore(Context context) //mKnownServersStore = KeyStore.getInstance("BKS"); mKnownServersStore = KeyStore.getInstance(KeyStore.getDefaultType()); File localTrustStoreFile = new File(context.getFilesDir(), LOCAL_TRUSTSTORE_FILENAME); - Log_OC.d(TAG, "Searching known-servers store at " + localTrustStoreFile.getAbsolutePath()); + Timber.d("Searching known-servers store at %s", localTrustStoreFile.getAbsolutePath()); if (localTrustStoreFile.exists()) { InputStream in = new FileInputStream(localTrustStoreFile); try { @@ -109,22 +89,9 @@ public static void addCertToKnownServersStore(Certificate cert, Context context) KeyStore knownServers = getKnownServersStore(context); knownServers.setCertificateEntry(Integer.toString(cert.hashCode()), cert); - FileOutputStream fos = null; - try { - fos = context.openFileOutput(LOCAL_TRUSTSTORE_FILENAME, Context.MODE_PRIVATE); + try (FileOutputStream fos = context.openFileOutput(LOCAL_TRUSTSTORE_FILENAME, Context.MODE_PRIVATE)) { knownServers.store(fos, LOCAL_TRUSTSTORE_PASSWORD.toCharArray()); - } finally { - fos.close(); } } - public static boolean isCertInKnownServersStore(Certificate cert, Context context) - throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { - - KeyStore knownServers = getKnownServersStore(context); - Log_OC.d(TAG, "Certificate - HashCode: " + cert.hashCode() + " " - + Boolean.toString(knownServers.isCertificateEntry(Integer.toString(cert.hashCode())))); - return knownServers.isCertificateEntry(Integer.toString(cert.hashCode())); - } - } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ServerNameIndicator.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ServerNameIndicator.java deleted file mode 100644 index e0dabae922..0000000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ServerNameIndicator.java +++ /dev/null @@ -1,145 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2016 ownCloud GmbH. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -package com.owncloud.android.lib.common.network; - -import com.owncloud.android.lib.common.utils.Log_OC; - -import javax.net.ssl.SSLSocket; -import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.concurrent.atomic.AtomicReference; - -/** - * Enables the support of Server Name Indication if existing - * in the underlying network implementation. - *

- * Build as a singleton. - * - * @author David A. Velasco - */ -public class ServerNameIndicator { - - private static final String TAG = ServerNameIndicator.class.getSimpleName(); - - private static final AtomicReference mSingleInstance = new AtomicReference(); - - private static final String METHOD_NAME = "setHostname"; - - private final WeakReference> mSSLSocketClassRef; - private final WeakReference mSetHostnameMethodRef; - - /** - * Private constructor, class is a singleton. - * - * @param sslSocketClass Underlying implementation class of {@link SSLSocket} used to connect with the server. - * @param setHostnameMethod Name of the method to call to enable the SNI support. - */ - private ServerNameIndicator(Class sslSocketClass, Method setHostnameMethod) { - mSSLSocketClassRef = new WeakReference>(sslSocketClass); - mSetHostnameMethodRef = (setHostnameMethod == null) ? null : new WeakReference(setHostnameMethod); - } - - /** - * Calls the {@code #setHostname(String)} method of the underlying implementation - * of {@link SSLSocket} if exists. - *

- * Creates and initializes the single instance of the class when needed - * - * @param hostname The name of the server host of interest. - * @param sslSocket Client socket to connect with the server. - */ - public static void setServerNameIndication(String hostname, SSLSocket sslSocket) { - final Method setHostnameMethod = getMethod(sslSocket); - if (setHostnameMethod != null) { - try { - setHostnameMethod.invoke(sslSocket, hostname); - Log_OC.i(TAG, "SNI done, hostname: " + hostname); - - } catch (IllegalArgumentException e) { - Log_OC.e(TAG, "Call to SSLSocket#setHost(String) failed ", e); - - } catch (IllegalAccessException e) { - Log_OC.e(TAG, "Call to SSLSocket#setHost(String) failed ", e); - - } catch (InvocationTargetException e) { - Log_OC.e(TAG, "Call to SSLSocket#setHost(String) failed ", e); - } - } else { - Log_OC.i(TAG, "SNI not supported"); - } - } - - /** - * Gets the method to invoke trying to minimize the effective - * application of reflection. - * - * @param sslSocket Instance of the SSL socket to use in connection with server. - * @return Method to call to indicate the server name of interest to the server. - */ - private static Method getMethod(SSLSocket sslSocket) { - final Class sslSocketClass = sslSocket.getClass(); - final ServerNameIndicator instance = mSingleInstance.get(); - if (instance == null) { - return initFrom(sslSocketClass); - - } else if (instance.mSSLSocketClassRef.get() != sslSocketClass) { - // the underlying class changed - return initFrom(sslSocketClass); - - } else if (instance.mSetHostnameMethodRef == null) { - // SNI not supported - return null; - - } else { - final Method cachedSetHostnameMethod = instance.mSetHostnameMethodRef.get(); - return (cachedSetHostnameMethod == null) ? initFrom(sslSocketClass) : cachedSetHostnameMethod; - } - } - - /** - * Singleton initializer. - *

- * Uses reflection to extract and 'cache' the method to invoke to indicate the desited host name to the server side. - * - * @param sslSocketClass Underlying class providing the implementation of {@link SSLSocket}. - * @return Method to call to indicate the server name of interest to the server. - */ - private static Method initFrom(Class sslSocketClass) { - Log_OC.i(TAG, "SSLSocket implementation: " + sslSocketClass.getCanonicalName()); - Method setHostnameMethod = null; - try { - setHostnameMethod = sslSocketClass.getMethod(METHOD_NAME, String.class); - } catch (SecurityException e) { - Log_OC.e(TAG, "Could not access to SSLSocket#setHostname(String) method ", e); - - } catch (NoSuchMethodException e) { - Log_OC.i(TAG, "Could not find SSLSocket#setHostname(String) method - SNI not supported"); - } - mSingleInstance.set(new ServerNameIndicator(sslSocketClass, setHostnameMethod)); - return setHostnameMethod; - } - -} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/WriteTimeoutEnforcer.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/WriteTimeoutEnforcer.java deleted file mode 100644 index 19b4a79794..0000000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/WriteTimeoutEnforcer.java +++ /dev/null @@ -1,167 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2017 ownCloud GmbH. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -package com.owncloud.android.lib.common.network; - -import com.owncloud.android.lib.common.utils.Log_OC; - -import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.Socket; -import java.util.concurrent.atomic.AtomicReference; - -/** - * Enforces, if possible, a write timeout for a socket. - *

- * Built as a singleton. - *

- * Tries to hit something like this: - * https://android.googlesource.com/platform/external/conscrypt/+/lollipop-release/src/main/java/org/conscrypt/OpenSSLSocketImpl.java#1005 - *

- * Minimizes the chances of getting stalled in PUT/POST request if the network interface is lost while - * writing the entity into the outwards sockect. - *

- * It happens. See https://github.com/owncloud/android/issues/1684#issuecomment-295306015 - * - * @author David A. Velasco - */ -public class WriteTimeoutEnforcer { - - private static final String TAG = WriteTimeoutEnforcer.class.getSimpleName(); - - private static final AtomicReference mSingleInstance = new AtomicReference<>(); - - private static final String METHOD_NAME = "setSoWriteTimeout"; - - private final WeakReference> mSocketClassRef; - private final WeakReference mSetSoWriteTimeoutMethodRef; - - /** - * Private constructor, class is a singleton. - * - * @param socketClass Underlying implementation class of {@link Socket} used to connect - * with the server. - * @param setSoWriteTimeoutMethod Name of the method to call to set a write timeout in the socket. - */ - private WriteTimeoutEnforcer(Class socketClass, Method setSoWriteTimeoutMethod) { - mSocketClassRef = new WeakReference>(socketClass); - mSetSoWriteTimeoutMethodRef = - (setSoWriteTimeoutMethod == null) ? - null : - new WeakReference<>(setSoWriteTimeoutMethod) - ; - } - - /** - * Calls the {@code #setSoWrite(int)} method of the underlying implementation - * of {@link Socket} if exists. - *

- * Creates and initializes the single instance of the class when needed - * - * @param writeTimeoutMilliseconds Write timeout to set, in milliseconds. - * @param socket Client socket to connect with the server. - */ - public static void setSoWriteTimeout(int writeTimeoutMilliseconds, Socket socket) { - final Method setSoWriteTimeoutMethod = getMethod(socket); - if (setSoWriteTimeoutMethod != null) { - try { - setSoWriteTimeoutMethod.invoke(socket, writeTimeoutMilliseconds); - Log_OC.i( - TAG, - "Write timeout set in socket, writeTimeoutMilliseconds: " - + writeTimeoutMilliseconds - ); - - } catch (IllegalArgumentException e) { - Log_OC.e(TAG, "Call to (SocketImpl)#setSoWriteTimeout(int) failed ", e); - - } catch (IllegalAccessException e) { - Log_OC.e(TAG, "Call to (SocketImpl)#setSoWriteTimeout(int) failed ", e); - - } catch (InvocationTargetException e) { - Log_OC.e(TAG, "Call to (SocketImpl)#setSoWriteTimeout(int) failed ", e); - } - } else { - Log_OC.i(TAG, "Write timeout for socket not supported"); - } - } - - /** - * Gets the method to invoke trying to minimize the cost of reflection reusing objects cached - * in static members. - * - * @param socket Instance of the socket to use in connection with server. - * @return Method to call to set a write timeout in the socket. - */ - private static Method getMethod(Socket socket) { - final Class socketClass = socket.getClass(); - final WriteTimeoutEnforcer instance = mSingleInstance.get(); - if (instance == null) { - return initFrom(socketClass); - - } else if (instance.mSocketClassRef.get() != socketClass) { - // the underlying class changed - return initFrom(socketClass); - - } else if (instance.mSetSoWriteTimeoutMethodRef == null) { - // method not supported - return null; - - } else { - final Method cachedSetSoWriteTimeoutMethod = instance.mSetSoWriteTimeoutMethodRef.get(); - return (cachedSetSoWriteTimeoutMethod == null) ? - initFrom(socketClass) : - cachedSetSoWriteTimeoutMethod - ; - } - } - - /** - * Singleton initializer. - *

- * Uses reflection to extract and 'cache' the method to invoke to set a write timouet in a socket. - * - * @param socketClass Underlying class providing the implementation of {@link Socket}. - * @return Method to call to set a write timeout in the socket. - */ - private static Method initFrom(Class socketClass) { - Log_OC.i(TAG, "Socket implementation: " + socketClass.getCanonicalName()); - Method setSoWriteTimeoutMethod = null; - try { - setSoWriteTimeoutMethod = socketClass.getMethod(METHOD_NAME, int.class); - } catch (SecurityException e) { - Log_OC.e(TAG, "Could not access to (SocketImpl)#setSoWriteTimeout(int) method ", e); - - } catch (NoSuchMethodException e) { - Log_OC.i( - TAG, - "Could not find (SocketImpl)#setSoWriteTimeout(int) method - write timeout not supported" - ); - } - mSingleInstance.set(new WriteTimeoutEnforcer(socketClass, setSoWriteTimeoutMethod)); - return setSoWriteTimeoutMethod; - } - -} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperation.java index 9f009bbda5..8e1c93f2cf 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperation.java @@ -11,8 +11,8 @@ import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; import com.owncloud.android.lib.common.accounts.AccountUtils; -import com.owncloud.android.lib.common.utils.Log_OC; import okhttp3.OkHttpClient; +import timber.log.Timber; import java.io.IOException; @@ -26,7 +26,6 @@ public abstract class RemoteOperation implements Runnable { * OCS API header value */ public static final String OCS_API_HEADER_VALUE = "true"; - private static final String TAG = RemoteOperation.class.getSimpleName(); /** * ownCloud account in the remote ownCloud server to operate */ @@ -40,22 +39,22 @@ public abstract class RemoteOperation implements Runnable { /** * Object to interact with the remote server */ - protected OwnCloudClient mClient = null; + private OwnCloudClient mClient = null; /** * Object to interact with the remote server */ - protected OkHttpClient mHttpClient = null; + private OkHttpClient mHttpClient = null; /** * Callback object to notify about the execution of the remote operation */ - protected OnRemoteOperationListener mListener = null; + private OnRemoteOperationListener mListener = null; /** * Handler to the thread where mListener methods will be called */ - protected Handler mListenerHandler = null; + private Handler mListenerHandler = null; /** * Asynchronously executes the remote operation @@ -134,7 +133,7 @@ public Thread execute(OwnCloudClient client, return runnerThread; } - protected void grantOwnCloudClient() throws + private void grantOwnCloudClient() throws AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { if (mClient == null) { if (mAccount != null && mContext != null) { @@ -192,7 +191,7 @@ public RemoteOperationResult execute(Account account, Context context) { /** * Synchronously executes the remote operation - * + *

* Do not call this method from the main thread. * * @param client Client object to reach an ownCloud server during the execution of @@ -235,10 +234,6 @@ public RemoteOperationResult execute(OkHttpClient client, Context context) { /** * Run operation for asynchronous or synchronous 'onExecute' method. - *

- * Considers and performs silent refresh of account credentials if possible, and if - * {@link RemoteOperation#setSilentRefreshOfAccountCredentials(boolean)} was called with - * parameter 'true' before the execution. * * @return Remote operation result */ @@ -251,7 +246,7 @@ private RemoteOperationResult runOperation() { result = run(mClient); } catch (AccountsException | IOException e) { - Log_OC.e(TAG, "Error while trying to access to " + mAccount.name, e); + Timber.e(e, "Error while trying to access to %s", mAccount.name); result = new RemoteOperationResult<>(e); } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperationResult.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperationResult.java index b58d1b73f6..db86e6b8f9 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperationResult.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/operations/RemoteOperationResult.java @@ -33,9 +33,9 @@ import com.owncloud.android.lib.common.http.HttpConstants; import com.owncloud.android.lib.common.http.methods.HttpBaseMethod; import com.owncloud.android.lib.common.network.CertificateCombinedException; -import com.owncloud.android.lib.common.utils.Log_OC; import okhttp3.Headers; import org.json.JSONException; +import timber.log.Timber; import javax.net.ssl.SSLException; import javax.net.ssl.SSLPeerUnverifiedException; @@ -60,7 +60,6 @@ public class RemoteOperationResult */ private static final long serialVersionUID = 4968939884332372230L; - private static final String TAG = RemoteOperationResult.class.getSimpleName(); private boolean mSuccess = false; private int mHttpCode = -1; private String mHttpPhrase = null; @@ -192,7 +191,7 @@ public RemoteOperationResult(HttpBaseMethod httpMethod) throws IOException { } } catch (Exception e) { - Log_OC.w(TAG, "Error reading exception from server: " + e.getMessage()); + Timber.w("Error reading exception from server: %s", e.getMessage()); // mCode stays as set in this(success, httpCode, headers) } } @@ -293,11 +292,7 @@ private RemoteOperationResult(int httpCode, String httpPhrase) { break; default: mCode = ResultCode.UNHANDLED_HTTP_CODE; // UNKNOWN ERROR - Log_OC.d(TAG, - "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + - - mHttpCode + " " + mHttpPhrase - ); + Timber.d("RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + mHttpCode + " " + mHttpPhrase); } } } @@ -308,7 +303,6 @@ private RemoteOperationResult(int httpCode, String httpPhrase) { * * @param bodyResponse okHttp response body * @param resultCode our own custom result code - * @throws IOException */ private void parseErrorMessageAndSetCode(String bodyResponse, ResultCode resultCode) { @@ -317,12 +311,12 @@ private void parseErrorMessageAndSetCode(String bodyResponse, ResultCode resultC ErrorMessageParser xmlParser = new ErrorMessageParser(); try { String errorMessage = xmlParser.parseXMLResponse(is); - if (errorMessage != "" && errorMessage != null) { + if (errorMessage != null && !errorMessage.equals("")) { mCode = resultCode; mHttpPhrase = errorMessage; } } catch (Exception e) { - Log_OC.w(TAG, "Error reading exception from server: " + e.getMessage()); + Timber.w("Error reading exception from server: %s", e.getMessage()); // mCode stays as set in this(success, httpCode, headers) } } @@ -376,7 +370,7 @@ private CertificateCombinedException getCertificateCombinedException(Exception e previousCause = cause; cause = cause.getCause(); } - if (cause != null && cause instanceof CertificateCombinedException) { + if (cause instanceof CertificateCombinedException) { result = (CertificateCombinedException) cause; } return result; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/LoggingHelper.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/LoggingHelper.kt index edb93b66db..b2fd162740 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/LoggingHelper.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/LoggingHelper.kt @@ -13,7 +13,7 @@ object LoggingHelper { } if (!directory.exists()) directory.mkdirs() - Timber.plant(FileLoggingTree(directory, filename = storagePath, delegator = Log_OC::class.java)) + Timber.plant(FileLoggingTree(directory, filename = storagePath, delegator = Timber::class.java)) } fun stopLogging() { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java index 04a1c4bbdb..4e8ccd5204 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java @@ -33,8 +33,8 @@ import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.status.OwnCloudVersion; +import timber.log.Timber; import java.net.URL; import java.util.concurrent.TimeUnit; @@ -47,8 +47,6 @@ */ public class CreateRemoteFolderOperation extends RemoteOperation { - private static final String TAG = CreateRemoteFolderOperation.class.getSimpleName(); - private static final int READ_TIMEOUT = 30000; private static final int CONNECTION_TIMEOUT = 5000; @@ -108,12 +106,12 @@ private RemoteOperationResult createFolder(OwnCloudClient client) { result = (status == HttpConstants.HTTP_CREATED) ? new RemoteOperationResult<>(ResultCode.OK) : new RemoteOperationResult<>(mkcol); - Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage()); + Timber.d("Create directory " + mRemotePath + ": " + result.getLogMessage()); client.exhaustResponse(mkcol.getResponseBodyAsStream()); } catch (Exception e) { result = new RemoteOperationResult<>(e); - Log_OC.e(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage(), e); + Timber.e(e, "Create directory " + mRemotePath + ": " + result.getLogMessage()); } return result; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/DownloadRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/DownloadRemoteFileOperation.java index 16699e3b8e..0201dac70b 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/DownloadRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/DownloadRemoteFileOperation.java @@ -32,7 +32,7 @@ import com.owncloud.android.lib.common.operations.OperationCancelledException; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.io.BufferedInputStream; import java.io.File; @@ -53,7 +53,6 @@ public class DownloadRemoteFileOperation extends RemoteOperation { - private static final String TAG = DownloadRemoteFileOperation.class.getSimpleName(); private static final int FORBIDDEN_ERROR = 403; private static final int SERVICE_UNAVAILABLE_ERROR = 503; private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false); @@ -81,13 +80,11 @@ protected RemoteOperationResult run(OwnCloudClient client) { try { tmpFile.getParentFile().mkdirs(); result = downloadFile(client, tmpFile); - Log_OC.i(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + - result.getLogMessage()); + Timber.i("Download of " + mRemotePath + " to " + getTmpPath() + ": " + result.getLogMessage()); } catch (Exception e) { result = new RemoteOperationResult<>(e); - Log_OC.e(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + - result.getLogMessage(), e); + Timber.e(e, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + result.getLogMessage()); } return result; @@ -149,7 +146,7 @@ private RemoteOperationResult downloadFile(OwnCloudClient client, File targetFil final Date d = WebdavUtils.parseResponseDate(modificationTime); mModificationTimestamp = (d != null) ? d.getTime() : 0; } else { - Log_OC.e(TAG, "Could not read modification time from response downloading " + mRemotePath); + Timber.e("Could not read modification time from response downloading %s", mRemotePath); } mEtag = WebdavUtils.getEtagFromResponse(mGet); @@ -158,7 +155,7 @@ private RemoteOperationResult downloadFile(OwnCloudClient client, File targetFil mEtag = mEtag.replace("\"", ""); if (mEtag.length() == 0) { - Log_OC.e(TAG, "Could not read eTag from response downloading " + mRemotePath); + Timber.e("Could not read eTag from response downloading %s", mRemotePath); } } else { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java index 4bb2e760f5..a564b2a544 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ExistenceCheckRemoteOperation.java @@ -32,7 +32,7 @@ import com.owncloud.android.lib.common.network.WebdavUtils; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.net.URL; import java.util.concurrent.TimeUnit; @@ -52,8 +52,6 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { */ public static final int TIMEOUT = 10000; - private static final String TAG = ExistenceCheckRemoteOperation.class.getSimpleName(); - private String mPath; private boolean mSuccessIfAbsent; private boolean mIsLogin; @@ -103,13 +101,13 @@ protected RemoteOperationResult run(OwnCloudClient client) { status = mRedirectionPath.getLastStatus(); } - /** + /* * PROPFIND method * 404 NOT FOUND: path doesn't exist, * 207 MULTI_STATUS: path exists. */ - Log_OC.d(TAG, "Existence check for " + stringUrl + WebdavUtils.encodePath(mPath) + + Timber.d("Existence check for " + stringUrl + WebdavUtils.encodePath(mPath) + " targeting for " + (mSuccessIfAbsent ? " absence " : " existence ") + "finished with HTTP status " + status + (!isSuccess(status) ? "(FAIL)" : "")); @@ -119,10 +117,9 @@ protected RemoteOperationResult run(OwnCloudClient client) { } catch (Exception e) { final RemoteOperationResult result = new RemoteOperationResult<>(e); - Log_OC.e(TAG, "Existence check for " + client.getUserFilesWebDavUri() + - WebdavUtils.encodePath(mPath) + " targeting for " + - (mSuccessIfAbsent ? " absence " : " existence ") + ": " + - result.getLogMessage(), result.getException()); + Timber.e(result.getException(), + "Existence check for " + client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mPath) + " " + + "targeting for " + (mSuccessIfAbsent ? " absence " : " existence ") + ": " + result.getLogMessage()); return result; } finally { client.setFollowRedirects(previousFollowRedirects); diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java index d3dfcb83a2..d18be3198b 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFileOperation.java @@ -31,7 +31,7 @@ import com.owncloud.android.lib.common.network.WebdavUtils; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.net.URL; import java.util.concurrent.TimeUnit; @@ -49,7 +49,6 @@ public class ReadRemoteFileOperation extends RemoteOperation { - private static final String TAG = ReadRemoteFileOperation.class.getSimpleName(); private static final int SYNC_READ_TIMEOUT = 40000; private static final int SYNC_CONNECTION_TIMEOUT = 5000; @@ -101,8 +100,7 @@ protected RemoteOperationResult run(OwnCloudClient client) { } catch (Exception e) { result = new RemoteOperationResult<>(e); e.printStackTrace(); - Log_OC.e(TAG, "Synchronizing file " + mRemotePath + ": " + result.getLogMessage(), - result.getException()); + Timber.e(result.getException(), "Synchronizing file " + mRemotePath + ": " + result.getLogMessage()); } return result; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java index 3aee5d4029..9644d0ddba 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java @@ -34,7 +34,7 @@ import com.owncloud.android.lib.common.network.WebdavUtils; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.net.URL; import java.util.ArrayList; @@ -51,8 +51,6 @@ public class ReadRemoteFolderOperation extends RemoteOperation> { - private static final String TAG = ReadRemoteFolderOperation.class.getSimpleName(); - private String mRemotePath; /** @@ -109,13 +107,12 @@ protected RemoteOperationResult> run(OwnCloudClient client result = new RemoteOperationResult<>(e); } finally { if (result.isSuccess()) { - Log_OC.i(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage()); + Timber.i("Synchronized " + mRemotePath + ": " + result.getLogMessage()); } else { if (result.isException()) { - Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage(), - result.getException()); + Timber.e(result.getException(), "Synchronized " + mRemotePath + ": " + result.getLogMessage()); } else { - Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage()); + Timber.e("Synchronized " + mRemotePath + ": " + result.getLogMessage()); } } } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoveRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoveRemoteFileOperation.java index 20ba44cab3..1ae1140d60 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoveRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoveRemoteFileOperation.java @@ -32,7 +32,7 @@ import com.owncloud.android.lib.common.network.WebdavUtils; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.net.URL; @@ -46,7 +46,6 @@ * @author David González Verdugo */ public class RemoveRemoteFileOperation extends RemoteOperation { - private static final String TAG = RemoveRemoteFileOperation.class.getSimpleName(); private String mRemotePath; protected boolean removeChunksFolder = false; @@ -81,11 +80,11 @@ protected RemoteOperationResult run(OwnCloudClient client) { new RemoteOperationResult<>(OK) : new RemoteOperationResult<>(deleteMethod); - Log_OC.i(TAG, "Remove " + mRemotePath + ": " + result.getLogMessage()); + Timber.i("Remove " + mRemotePath + ": " + result.getLogMessage()); } catch (Exception e) { result = new RemoteOperationResult<>(e); - Log_OC.e(TAG, "Remove " + mRemotePath + ": " + result.getLogMessage(), e); + Timber.e(e, "Remove " + mRemotePath + ": " + result.getLogMessage()); } return result; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java index 56f137ffe5..a1c289fa5a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RenameRemoteFileOperation.java @@ -31,8 +31,8 @@ import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.status.OwnCloudVersion; +import timber.log.Timber; import java.io.File; import java.net.URL; @@ -46,8 +46,6 @@ */ public class RenameRemoteFileOperation extends RemoteOperation { - private static final String TAG = RenameRemoteFileOperation.class.getSimpleName(); - private static final int RENAME_READ_TIMEOUT = 600000; private static final int RENAME_CONNECTION_TIMEOUT = 5000; @@ -117,16 +115,14 @@ protected RemoteOperationResult run(OwnCloudClient client) { ? new RemoteOperationResult<>(ResultCode.OK) : new RemoteOperationResult<>(move); - Log_OC.i(TAG, "Rename " + mOldRemotePath + " to " + mNewRemotePath + ": " + - result.getLogMessage() - ); + Timber.i("Rename " + mOldRemotePath + " to " + mNewRemotePath + ": " + result.getLogMessage()); client.exhaustResponse(move.getResponseBodyAsStream()); return result; } catch (Exception e) { final RemoteOperationResult result = new RemoteOperationResult<>(e); - Log_OC.e(TAG, "Rename " + mOldRemotePath + " to " + - ((mNewRemotePath == null) ? mNewName : mNewRemotePath) + ": " + - result.getLogMessage(), e); + Timber.e(e, + "Rename " + mOldRemotePath + " to " + ((mNewRemotePath == null) ? mNewName : mNewRemotePath) + ":" + + " " + result.getLogMessage()); return result; } } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/UploadRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/UploadRemoteFileOperation.java index 46738f8bda..1adaa98942 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/UploadRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/UploadRemoteFileOperation.java @@ -33,8 +33,8 @@ import com.owncloud.android.lib.common.operations.OperationCancelledException; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; import okhttp3.MediaType; +import timber.log.Timber; import java.io.File; import java.net.URL; @@ -54,7 +54,6 @@ public class UploadRemoteFileOperation extends RemoteOperation { - private static final String TAG = UploadRemoteFileOperation.class.getSimpleName(); protected final AtomicBoolean mCancellationRequested = new AtomicBoolean(false); protected String mLocalPath; protected String mRemotePath; @@ -62,7 +61,7 @@ public class UploadRemoteFileOperation extends RemoteOperation { protected String mFileLastModifTimestamp; protected PutMethod mPutMethod = null; protected String mRequiredEtag = null; - protected Set mDataTransferListeners = new HashSet(); + protected Set mDataTransferListeners = new HashSet<>(); protected FileRequestBody mFileRequestBody = null; @@ -96,27 +95,25 @@ protected RemoteOperationResult run(OwnCloudClient client) { } else { // perform the upload result = uploadFile(client); - Log_OC.i(TAG, "Upload of " + mLocalPath + " to " + mRemotePath + ": " + - result.getLogMessage()); + Timber.i("Upload of " + mLocalPath + " to " + mRemotePath + ": " + result.getLogMessage()); } } catch (Exception e) { if (mPutMethod != null && mPutMethod.isAborted()) { result = new RemoteOperationResult<>(new OperationCancelledException()); - Log_OC.e(TAG, "Upload of " + mLocalPath + " to " + mRemotePath + ": " + - result.getLogMessage(), new OperationCancelledException()); + Timber.e(result.getException(), + "Upload of " + mLocalPath + " to " + mRemotePath + ": " + result.getLogMessage()); } else { result = new RemoteOperationResult<>(e); - Log_OC.e(TAG, "Upload of " + mLocalPath + " to " + mRemotePath + ": " + - result.getLogMessage(), e); + Timber.e(e, "Upload of " + mLocalPath + " to " + mRemotePath + ": " + result.getLogMessage()); } } return result; } - protected RemoteOperationResult uploadFile(OwnCloudClient client) throws Exception { + protected RemoteOperationResult uploadFile(OwnCloudClient client) throws Exception { File fileToUpload = new File(mLocalPath); diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/ChunkedUploadRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/ChunkedUploadRemoteFileOperation.java index 2282767c22..d9ef118024 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/ChunkedUploadRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/ChunkedUploadRemoteFileOperation.java @@ -29,10 +29,10 @@ import com.owncloud.android.lib.common.network.ChunkFromFileRequestBody; import com.owncloud.android.lib.common.operations.OperationCancelledException; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation; import okhttp3.MediaType; +import timber.log.Timber; import java.io.File; import java.io.RandomAccessFile; @@ -53,7 +53,6 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation public static final long CHUNK_SIZE = 1024000; private static final int LAST_CHUNK_TIMEOUT = 900000; //15 mins. - private static final String TAG = ChunkedUploadRemoteFileOperation.class.getSimpleName(); private String mTransferId; @@ -113,7 +112,7 @@ protected RemoteOperationResult uploadFile(OwnCloudClient client) throws Excepti status = client.executeHttpMethod(mPutMethod); - Log_OC.d(TAG, "Upload of " + mLocalPath + " to " + mRemotePath + + Timber.d("Upload of " + mLocalPath + " to " + mRemotePath + ", chunk index " + chunkIndex + ", count " + chunkCount + ", HTTP result status " + status); diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/CreateRemoteShareOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/CreateRemoteShareOperation.kt index b7080c4d61..8250422a30 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/CreateRemoteShareOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/CreateRemoteShareOperation.kt @@ -32,9 +32,9 @@ import com.owncloud.android.lib.common.http.HttpConstants import com.owncloud.android.lib.common.http.methods.nonwebdav.PostMethod import com.owncloud.android.lib.common.operations.RemoteOperation import com.owncloud.android.lib.common.operations.RemoteOperationResult -import com.owncloud.android.lib.common.utils.Log_OC import com.owncloud.android.lib.resources.shares.RemoteShare.Companion.INIT_EXPIRATION_DATE_IN_MILLIS import okhttp3.FormBody +import timber.log.Timber import java.net.URL import java.text.SimpleDateFormat import java.util.Calendar @@ -150,7 +150,7 @@ class CreateRemoteShareOperation( } catch (e: Exception) { result = RemoteOperationResult(e) - Log_OC.e(TAG, "Exception while Creating New Share", e) + Timber.e(e, "Exception while Creating New Share") } return result @@ -159,8 +159,6 @@ class CreateRemoteShareOperation( private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK companion object { - private val TAG = CreateRemoteShareOperation::class.java.simpleName - private const val PARAM_NAME = "name" private const val PARAM_PASSWORD = "password" private const val PARAM_EXPIRATION_DATE = "expireDate" diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareOperation.java index e4d4972e92..432c2d9b86 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareOperation.java @@ -33,7 +33,7 @@ import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.net.URL; @@ -46,8 +46,6 @@ public class GetRemoteShareOperation extends RemoteOperation { - private static final String TAG = GetRemoteShareOperation.class.getSimpleName(); - private long mRemoteId; public GetRemoteShareOperation(long remoteId) { @@ -85,7 +83,7 @@ protected RemoteOperationResult run(OwnCloudClient client) { } catch (Exception e) { result = new RemoteOperationResult<>(e); - Log_OC.e(TAG, "Exception while getting remote shares ", e); + Timber.e(e, "Exception while getting remote shares"); } return result; } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteSharesForFileOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteSharesForFileOperation.kt index f74a7e75cb..01b0955110 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteSharesForFileOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteSharesForFileOperation.kt @@ -32,7 +32,7 @@ import com.owncloud.android.lib.common.http.HttpConstants import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod import com.owncloud.android.lib.common.operations.RemoteOperation import com.owncloud.android.lib.common.operations.RemoteOperationResult -import com.owncloud.android.lib.common.utils.Log_OC +import timber.log.Timber import java.net.URL /** @@ -89,14 +89,14 @@ class GetRemoteSharesForFileOperation( result = parser.parse(getMethod.responseBodyAsString) if (result.isSuccess) { - Log_OC.d(TAG, "Got " + result.data.shares.size + " shares") + Timber.d("Got " + result.data.shares.size + " shares") } } else { result = RemoteOperationResult(getMethod) } } catch (e: Exception) { result = RemoteOperationResult(e) - Log_OC.e(TAG, "Exception while getting shares", e) + Timber.e(e, "Exception while getting shares") } return result @@ -105,11 +105,8 @@ class GetRemoteSharesForFileOperation( private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK companion object { - - private val TAG = GetRemoteSharesForFileOperation::class.java.simpleName - private const val PARAM_PATH = "path" private const val PARAM_RESHARES = "reshares" private const val PARAM_SUBFILES = "subfiles" } -} \ No newline at end of file +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt index df63432138..c9ef0c1299 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareXMLParser.kt @@ -130,7 +130,6 @@ class ShareXMLParser { @Throws(XmlPullParserException::class, IOException::class) private fun readMeta(parser: XmlPullParser) { parser.require(XmlPullParser.START_TAG, ns, NODE_META) - //Log_OC.d(TAG, "---- NODE META ---"); while (parser.next() != XmlPullParser.END_TAG) { if (parser.eventType != XmlPullParser.START_TAG) { continue @@ -165,7 +164,6 @@ class ShareXMLParser { var share: RemoteShare? = null parser.require(XmlPullParser.START_TAG, ns, NODE_DATA) - //Log_OC.d(TAG, "---- NODE DATA ---"); while (parser.next() != XmlPullParser.END_TAG) { if (parser.eventType != XmlPullParser.START_TAG) { continue @@ -217,7 +215,6 @@ class ShareXMLParser { val remoteShare = RemoteShare() - //Log_OC.d(TAG, "---- NODE ELEMENT ---"); while (parser.next() != XmlPullParser.END_TAG) { if (parser.eventType != XmlPullParser.START_TAG) { continue @@ -343,7 +340,6 @@ class ShareXMLParser { private fun readNode(parser: XmlPullParser, node: String): String { parser.require(XmlPullParser.START_TAG, ns, node) val value = readText(parser) - //Log_OC.d(TAG, "node= " + node + ", value= " + value); parser.require(XmlPullParser.END_TAG, ns, node) return value } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserInfoOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserInfoOperation.java index 7b94eec1cb..ec205cdd38 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserInfoOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserInfoOperation.java @@ -29,8 +29,8 @@ import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; import org.json.JSONObject; +import timber.log.Timber; import java.net.URL; @@ -46,8 +46,6 @@ public class GetRemoteUserInfoOperation extends RemoteOperation { - private static final String TAG = GetRemoteUserInfoOperation.class.getSimpleName(); - // OCS Route private static final String OCS_ROUTE = "/ocs/v2.php/cloud/user?format=json"; @@ -72,7 +70,7 @@ protected RemoteOperationResult run(OwnCloudClient client) { int status = client.executeHttpMethod(getMethod); if (isSuccess(status)) { - Log_OC.d(TAG, "Successful response"); + Timber.d("Successful response"); JSONObject respJSON = new JSONObject(getMethod.getResponseBodyAsString()); JSONObject respOCS = respJSON.getJSONObject(NODE_OCS); @@ -90,16 +88,12 @@ protected RemoteOperationResult run(OwnCloudClient client) { } else { result = new RemoteOperationResult<>(getMethod); String response = getMethod.getResponseBodyAsString(); - Log_OC.e(TAG, "Failed response while getting user information "); - if (getMethod != null) { - Log_OC.e(TAG, "*** status code: " + status + " ; response message: " + response); - } else { - Log_OC.e(TAG, "*** status code: " + status); - } + Timber.e("Failed response while getting user information "); + Timber.e("*** status code: " + status + " ; response message: " + response); } } catch (Exception e) { result = new RemoteOperationResult<>(e); - Log_OC.e(TAG, "Exception while getting OC user information", e); + Timber.e(e, "Exception while getting OC user information"); } return result; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserQuotaOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserQuotaOperation.java index 49c313be09..bc6f3964ec 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserQuotaOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserQuotaOperation.java @@ -37,7 +37,7 @@ import com.owncloud.android.lib.common.network.WebdavUtils; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.net.URL; import java.util.List; @@ -51,7 +51,6 @@ */ public class GetRemoteUserQuotaOperation extends RemoteOperation { - private static final String TAG = GetRemoteUserQuotaOperation.class.getSimpleName(); private String mRemotePath; /** @@ -94,13 +93,12 @@ protected RemoteOperationResult run(OwnCloudClient client) { } finally { if (result.isSuccess()) { - Log_OC.i(TAG, "Get quota from " + mRemotePath + ": " + result.getLogMessage()); + Timber.i("Get quota from " + mRemotePath + ": " + result.getLogMessage()); } else { if (result.isException()) { - Log_OC.e(TAG, "Get quota from " + mRemotePath + ": " + result.getLogMessage(), - result.getException()); + Timber.e(result.getException(), "Get quota from " + mRemotePath + ": " + result.getLogMessage()); } else { - Log_OC.e(TAG, "Get quota from " + mRemotePath + ": " + result.getLogMessage()); + Timber.e("Get quota from " + mRemotePath + ": " + result.getLogMessage()); } } }