From 3d9d943825c421c065f0c70582263c184cf2fad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Tue, 3 Dec 2019 14:39:27 +0100 Subject: [PATCH 01/75] Remove kitkat support --- owncloudComLibrary/build.gradle | 2 +- .../owncloud/android/lib/common/http/HttpClient.java | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/owncloudComLibrary/build.gradle b/owncloudComLibrary/build.gradle index 384dacf3..32f3d8d7 100644 --- a/owncloudComLibrary/build.gradle +++ b/owncloudComLibrary/build.gradle @@ -19,7 +19,7 @@ android { compileSdkVersion 28 defaultConfig { - minSdkVersion 19 + minSdkVersion 21 targetSdkVersion 28 versionCode = 10000300 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 9564922d..7ddd48c3 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 @@ -26,7 +26,6 @@ package com.owncloud.android.lib.common.http; import android.content.Context; -import android.os.Build; import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor; import com.owncloud.android.lib.common.http.interceptors.RequestHeaderInterceptor; @@ -91,12 +90,7 @@ public class HttpClient { SSLSocketFactory sslSocketFactory; - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { - // TLS v1.2 is disabled by default in API 19, use custom SSLSocketFactory to enable it - sslSocketFactory = new TLSSocketFactory(sslContext.getSocketFactory()); - } else { - sslSocketFactory = sslContext.getSocketFactory(); - } + sslSocketFactory = sslContext.getSocketFactory(); // Automatic cookie handling, NOT PERSISTENT CookieJar cookieJar = new CookieJar() { @@ -158,7 +152,7 @@ public class HttpClient { public static void addHeaderForAllRequests(String headerName, String headerValue) { HttpInterceptor httpInterceptor = getOkHttpInterceptor(); - if(getOkHttpInterceptor() != null) { + if (getOkHttpInterceptor() != null) { httpInterceptor.addRequestInterceptor( new RequestHeaderInterceptor(headerName, headerValue) ); From 90210949b55183f0d3239073ad65358109262b09 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Sun, 1 Dec 2019 08:16:09 +0100 Subject: [PATCH 02/75] Reduce logging in ChunkFromFileRequestBody (cherry picked from commit 53a8ce122c7f0d4ef6d47e76a29b15fc68197135) --- .../network/ChunkFromFileRequestBody.java | 24 ++++--------------- .../lib/common/network/FileRequestBody.java | 2 +- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java index 776bce2a..9c57f547 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java @@ -24,8 +24,6 @@ package com.owncloud.android.lib.common.network; -import android.util.Log; - import com.owncloud.android.lib.common.utils.Log_OC; import okhttp3.MediaType; import okio.BufferedSink; @@ -43,9 +41,6 @@ import java.util.Iterator; */ public class ChunkFromFileRequestBody extends FileRequestBody { - private static final String TAG = ChunkFromFileRequestBody.class.getSimpleName(); - - //private final File mFile; private final FileChannel mChannel; private final long mChunkSize; private long mOffset; @@ -89,17 +84,17 @@ public class ChunkFromFileRequestBody extends FileRequestBody { long maxCount = Math.min(mOffset + mChunkSize, mChannel.size()); while (mChannel.position() < maxCount) { - Log_OC.d(TAG, "Sink buffer size: " + sink.buffer().size()); + Log_OC.v("Sink buffer size: " + sink.buffer().size()); readCount = mChannel.read(mBuffer); - Log_OC.d(TAG, "Read " + readCount + " bytes from file channel to " + mBuffer.toString()); + Log_OC.v("Read " + readCount + " bytes from file channel to " + mBuffer.toString()); sink.buffer().write(mBuffer.array(), 0, readCount); sink.flush(); - Log_OC.d(TAG, "Write " + readCount + " bytes to sink buffer with size " + sink.buffer().size()); + Log_OC.v("Write " + readCount + " bytes to sink buffer with size " + sink.buffer().size()); mBuffer.clear(); if (mTransferred < maxCount) { // condition to avoid accumulate progress for repeated chunks @@ -113,19 +108,10 @@ public class ChunkFromFileRequestBody extends FileRequestBody { } } - Log.d(TAG, "Chunk with size " + mChunkSize + " written in request body"); + Log_OC.v("Chunk with size " + mChunkSize + " written in request body"); } catch (Exception exception) { - - Log.e(TAG, exception.toString()); - // // any read problem will be handled as if the file is not there - // if (io instanceof FileNotFoundException) { - // throw io; - // } else { - // FileNotFoundException fnf = new FileNotFoundException("Exception reading source file"); - // fnf.initCause(io); - // throw fnf; - // } + Log_OC.e(exception.getMessage()); } } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java index 21934a2b..520d9a37 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java @@ -49,7 +49,7 @@ public class FileRequestBody extends RequestBody implements ProgressiveDataTrans protected File mFile; private MediaType mContentType; - Set mDataTransferListeners = new HashSet<>(); + final Set mDataTransferListeners = new HashSet<>(); public FileRequestBody(File file, MediaType contentType) { mFile = file; From 094e698e95d5592f754e23dc491a6177f6000e13 Mon Sep 17 00:00:00 2001 From: davigonz Date: Wed, 18 Dec 2019 17:54:09 +0100 Subject: [PATCH 03/75] Include field to know servers lower than 10 --- .../owncloud/android/lib/resources/status/OwnCloudVersion.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt index dae5b91a..b7e9f2f6 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt @@ -79,6 +79,9 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable val isPreemptiveAuthenticationPreferred: Boolean get() = mVersion < MINIMUM_VERSION_WITH_SESSION_MONITORING || mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE + val isVersionLowerThan10: Boolean + get() = mVersion < VERSION_LOWER_THAN_10 + val isMultiplePublicSharingSupported: Boolean get() = mVersion >= MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING @@ -199,6 +202,8 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable private const val MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301 // 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd + private const val VERSION_LOWER_THAN_10 = 0xA000000 // 10.0.0 + private const val MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING = 0xA000000 // 10.0.0 private const val MINIMUN_MAJOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0xA000000 // 10.0.0 From 169836683e3f62c9c5640941b01066ee1069cd8d Mon Sep 17 00:00:00 2001 From: davigonz Date: Wed, 18 Dec 2019 17:56:53 +0100 Subject: [PATCH 04/75] Update versionName and versionCode --- owncloudComLibrary/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/owncloudComLibrary/build.gradle b/owncloudComLibrary/build.gradle index 151d3926..a9a1825c 100644 --- a/owncloudComLibrary/build.gradle +++ b/owncloudComLibrary/build.gradle @@ -22,8 +22,8 @@ android { minSdkVersion 21 targetSdkVersion 28 - versionCode = 10000400 - versionName = "1.0.4" + versionCode = 10000401 + versionName = "1.0.4.1" } lintOptions { From 9a806469c5a0289494fbf8dae3491d632ae8c53e Mon Sep 17 00:00:00 2001 From: davigonz Date: Thu, 19 Dec 2019 09:10:38 +0100 Subject: [PATCH 05/75] Rename 10 version constant --- .../owncloud/android/lib/resources/status/OwnCloudVersion.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt index b7e9f2f6..e395e5ab 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt @@ -80,7 +80,7 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable get() = mVersion < MINIMUM_VERSION_WITH_SESSION_MONITORING || mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE val isVersionLowerThan10: Boolean - get() = mVersion < VERSION_LOWER_THAN_10 + get() = mVersion < VERSION_10 val isMultiplePublicSharingSupported: Boolean get() = mVersion >= MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING @@ -202,7 +202,7 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable private const val MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301 // 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd - private const val VERSION_LOWER_THAN_10 = 0xA000000 // 10.0.0 + private const val VERSION_10 = 0xA000000 // 10.0.0 private const val MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING = 0xA000000 // 10.0.0 From a1d4c781aeb3f40b1f4c570af9708214054d22ac Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 19 Dec 2019 07:25:29 +0100 Subject: [PATCH 06/75] Finish remove Android 4.4 support --- sample_client/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample_client/build.gradle b/sample_client/build.gradle index 7f865ceb..b41ff109 100644 --- a/sample_client/build.gradle +++ b/sample_client/build.gradle @@ -8,7 +8,7 @@ android { compileSdkVersion 28 defaultConfig { - minSdkVersion 19 + minSdkVersion 21 targetSdkVersion 28 } From 3204d5e60e7a6547a926d02d4255068f84b042db Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 2 Jan 2020 12:25:38 +0100 Subject: [PATCH 07/75] fix a typo and some lint warnings --- .../android/lib/common/operations/RemoteOperation.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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 9f009bbd..703decca 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 @@ -16,6 +16,7 @@ import okhttp3.OkHttpClient; import java.io.IOException; +@SuppressWarnings("WeakerAccess") public abstract class RemoteOperation implements Runnable { /** @@ -106,8 +107,7 @@ public abstract class RemoteOperation implements Runnable { * the listener objects must be called. * @return Thread were the remote operation is executed. */ - public Thread execute(OwnCloudClient client, - OnRemoteOperationListener listener, Handler listenerHandler) { + public Thread execute(OwnCloudClient client, OnRemoteOperationListener listener, Handler listenerHandler) { if (client == null) { throw new IllegalArgumentException ("Trying to execute a remote operation with a NULL OwnCloudClient"); @@ -121,7 +121,7 @@ public abstract class RemoteOperation implements Runnable { if (listener == null) { throw new IllegalArgumentException ("Trying to execute a remote operation asynchronously " + - "without a listener to notiy the result"); + "without a listener to notify the result"); } mListener = listener; @@ -236,9 +236,7 @@ public abstract class RemoteOperation implements Runnable { /** * 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. + * Considers and performs silent refresh of account credentials if possible * * @return Remote operation result */ From 277876221744cbf37e8918819e0db8ea198785e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Fri, 20 Dec 2019 14:27:21 +0100 Subject: [PATCH 08/75] Remove logging initialization from Log_OC --- .../android/lib/common/utils/Log_OC.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/Log_OC.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/Log_OC.java index 831076b6..618e7dbf 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/Log_OC.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/Log_OC.java @@ -6,12 +6,6 @@ import java.io.File; public class Log_OC { - private static String mOwncloudDataFolderLog; - - public static void setLogDataFolder(String logFolder) { - mOwncloudDataFolderLog = logFolder; - } - public static void i(String message) { Timber.i(message); } @@ -74,14 +68,4 @@ public class Log_OC { public static void w(String TAG, String message) { Timber.w(message); } - - public static void startLogging(String storagePath) { - LoggingHelper.INSTANCE.startLogging( - new File(storagePath+ File.separator + mOwncloudDataFolderLog), mOwncloudDataFolderLog); - } - - public static void stopLogging() { - LoggingHelper.INSTANCE.stopLogging(); - } - } From c5ac449fed735e21d86ab41d2fc0fac5d416448b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Wed, 8 Jan 2020 09:27:37 +0100 Subject: [PATCH 09/75] Replace log_oc with timber Finish replacing logOC with timber --- .../lib/common/DynamicSessionManager.java | 3 +- .../android/lib/common/OwnCloudClient.java | 60 +------ .../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 | 6 +- .../android/lib/common/http/HttpClient.java | 34 +--- .../network/AdvancedX509TrustManager.java | 4 +- .../network/ChunkFromFileRequestBody.java | 12 +- .../lib/common/network/NetworkUtils.java | 39 +--- .../common/network/ServerNameIndicator.java | 145 --------------- .../common/network/WriteTimeoutEnforcer.java | 167 ------------------ .../common/operations/RemoteOperation.java | 41 ++--- .../operations/RemoteOperationResult.java | 18 +- .../android/lib/common/utils/LoggingHelper.kt | 2 +- .../files/CreateRemoteFolderOperation.java | 8 +- .../files/DownloadRemoteFileOperation.java | 13 +- .../files/ExistenceCheckRemoteOperation.java | 15 +- .../lib/resources/files/FileUtils.java | 14 +- .../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/GetRemoteShareesOperation.kt | 62 +++---- .../shares/GetRemoteSharesForFileOperation.kt | 11 +- .../shares/RemoveRemoteShareOperation.kt | 13 +- .../ShareToRemoteOperationResultParser.kt | 16 +- .../lib/resources/shares/ShareXMLParser.kt | 4 - .../shares/UpdateRemoteShareOperation.kt | 10 +- .../status/GetRemoteCapabilitiesOperation.kt | 33 ++-- .../status/GetRemoteStatusOperation.java | 16 +- .../users/GetRemoteUserAvatarOperation.java | 21 +-- .../users/GetRemoteUserInfoOperation.java | 16 +- .../users/GetRemoteUserQuotaOperation.java | 10 +- 41 files changed, 212 insertions(+), 759 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 38fb11e4..4a69fac4 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/OwnCloudClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java index d036214d..cbe88718 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java @@ -38,12 +38,11 @@ import com.owncloud.android.lib.common.http.HttpClient; import com.owncloud.android.lib.common.http.HttpConstants; import com.owncloud.android.lib.common.http.methods.HttpBaseMethod; import com.owncloud.android.lib.common.network.RedirectionPath; -import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.common.utils.RandomUtils; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import okhttp3.Cookie; -import okhttp3.Headers; import okhttp3.HttpUrl; +import timber.log.Timber; import java.io.IOException; import java.io.InputStream; @@ -58,7 +57,6 @@ public class OwnCloudClient extends HttpClient { public static final String STATUS_PATH = "/status.php"; public static final String FILES_WEB_PATH = "/index.php/apps/files"; - private static final String TAG = OwnCloudClient.class.getSimpleName(); private static final int MAX_REDIRECTIONS_COUNT = 3; private static final int MAX_REPEAT_COUNT_WITH_FRESH_CREDENTIALS = 1; @@ -86,7 +84,7 @@ public class OwnCloudClient extends HttpClient { mBaseUri = baseUri; mInstanceNumber = sIntanceCounter++; - Log_OC.d(TAG + " #" + mInstanceNumber, "Creating OwnCloudClient"); + Timber.d(" #" + mInstanceNumber + "Creating OwnCloudClient"); clearCredentials(); clearCookies(); @@ -163,7 +161,7 @@ public class OwnCloudClient extends HttpClient { // Header to allow tracing requests in apache and ownCloud logs addHeaderForAllRequests(OC_X_REQUEST_ID, requestId); - Log_OC.d(TAG, "Executing " + method.getClass().getSimpleName() + " in request with id " + requestId); + Timber.d("Executing " + method.getClass().getSimpleName() + " in request with id " + requestId); } public RedirectionPath followRedirection(HttpBaseMethod method) throws Exception { @@ -175,15 +173,14 @@ public class OwnCloudClient extends HttpClient { (status == HttpConstants.HTTP_MOVED_PERMANENTLY || status == HttpConstants.HTTP_MOVED_TEMPORARILY || status == HttpConstants.HTTP_TEMPORARY_REDIRECT) - ) { + ) { final String location = method.getResponseHeader(HttpConstants.LOCATION_HEADER) != null ? method.getResponseHeader(HttpConstants.LOCATION_HEADER) : method.getResponseHeader(HttpConstants.LOCATION_HEADER_LOWER); if (location != null) { - Log_OC.d(TAG + " #" + mInstanceNumber, - "Location to redirect: " + location); + Timber.d("#" + mInstanceNumber + "Location to redirect: " + location); redirectionPath.addLocation(location); @@ -216,7 +213,7 @@ public class OwnCloudClient extends HttpClient { redirectionsCount++; } else { - Log_OC.d(TAG + " #" + mInstanceNumber, "No location to redirect!"); + Timber.d(" #" + mInstanceNumber + "No location to redirect!"); status = HttpConstants.HTTP_NOT_FOUND; } } @@ -237,8 +234,7 @@ public class OwnCloudClient extends HttpClient { responseBodyAsStream.close(); } catch (IOException io) { - Log_OC.e(TAG, "Unexpected exception while exhausting not interesting HTTP response;" + - " will be IGNORED", io); + Timber.e(io, "Unexpected exception while exhausting not interesting HTTP response; will be IGNORED"); } } } @@ -296,38 +292,6 @@ public class OwnCloudClient extends HttpClient { } } - private void logCookie(Cookie cookie) { - Log_OC.d(TAG, "Cookie name: " + cookie.name()); - Log_OC.d(TAG, " value: " + cookie.value()); - Log_OC.d(TAG, " domain: " + cookie.domain()); - Log_OC.d(TAG, " path: " + cookie.path()); - Log_OC.d(TAG, " expiryDate: " + cookie.expiresAt()); - Log_OC.d(TAG, " secure: " + cookie.secure()); - } - - private void logCookiesAtRequest(Headers headers, String when) { - int counter = 0; - for (final String cookieHeader : headers.toMultimap().get("cookie")) { - Log_OC.d(TAG + " #" + mInstanceNumber, - "Cookies at request (" + when + ") (" + counter++ + "): " - + cookieHeader); - } - if (counter == 0) { - Log_OC.d(TAG + " #" + mInstanceNumber, "No cookie at request before"); - } - } - - private void logSetCookiesAtResponse(Headers headers) { - int counter = 0; - for (final String cookieHeader : headers.toMultimap().get("set-cookie")) { - Log_OC.d(TAG + " #" + mInstanceNumber, - "Set-Cookie (" + counter++ + "): " + cookieHeader); - } - if (counter == 0) { - Log_OC.d(TAG + " #" + mInstanceNumber, "No set-cookie"); - } - } - public String getCookiesString() { StringBuilder cookiesString = new StringBuilder(); List cookieList = getCookiesFromUrl(HttpUrl.parse(mBaseUri.toString())); @@ -392,11 +356,7 @@ public class OwnCloudClient extends HttpClient { credentialsWereRefreshed = true; } catch (AccountsException | IOException e) { - Log_OC.e( - TAG, - "Error while trying to refresh auth token for " + mAccount.getSavedAccount().name, - e - ); + Timber.e(e, "Error while trying to refresh auth token for %s", mAccount.getSavedAccount().name); } } @@ -451,10 +411,6 @@ public class OwnCloudClient extends HttpClient { return true; } - public OwnCloudClientManager getOwnCloudClientManager() { - return mOwnCloudClientManager; - } - void setOwnCloudClientManager(OwnCloudClientManager clientManager) { mOwnCloudClientManager = clientManager; } 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 6fb5345f..94a44c26 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 @@ import android.net.Uri; 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 class OwnCloudClientFactory { 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 46f722e9..d039162e 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.accounts.OperationCanceledException; 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 class SimpleFactoryManager implements OwnCloudClientManager { 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 21bdf925..e4b190a4 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.AuthenticatorException; 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 @@ import java.util.concurrent.ConcurrentMap; 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 class SingleSessionManager implements OwnCloudClientManager { 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 class SingleSessionManager implements OwnCloudClientManager { 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 class SingleSessionManager implements OwnCloudClientManager { 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 class SingleSessionManager implements OwnCloudClientManager { 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 2be339d8..0b5911b2 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 android.net.Uri; 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 @@ import java.util.List; 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 class AccountUtils { 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 class AccountUtils { 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 class AccountUtils { 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 class AccountUtils { */ 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 aacd8bab..152ffdbe 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 class OAuth2QueryParser { 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 5f788831..9b3337b7 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.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.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 @@ public class OAuth2RefreshAccessTokenOperation extends RemoteOperation 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 58f149c7..f393d430 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,7 +26,7 @@ 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 { @@ -72,7 +72,7 @@ public class OwnCloudOAuth2Provider implements OAuth2Provider { 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; @@ -85,7 +85,7 @@ public class OwnCloudOAuth2Provider implements OAuth2Provider { 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 7ddd48c3..9a629bfe 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.HttpInterceptor; 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 @@ import java.util.concurrent.TimeUnit; * @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 class HttpClient { 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 class HttpClient { @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 class HttpClient { 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 class HttpClient { 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 class HttpClient { 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 f70dabd8..f2513c3c 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 class AdvancedX509TrustManager implements X509TrustManager { 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/ChunkFromFileRequestBody.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java index 9c57f547..bf58fa94 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java @@ -24,9 +24,9 @@ package com.owncloud.android.lib.common.network; -import com.owncloud.android.lib.common.utils.Log_OC; import okhttp3.MediaType; import okio.BufferedSink; +import timber.log.Timber; import java.io.File; import java.io.IOException; @@ -84,17 +84,17 @@ public class ChunkFromFileRequestBody extends FileRequestBody { long maxCount = Math.min(mOffset + mChunkSize, mChannel.size()); while (mChannel.position() < maxCount) { - Log_OC.v("Sink buffer size: " + sink.buffer().size()); + Timber.v("Sink buffer size: %s", sink.buffer().size()); readCount = mChannel.read(mBuffer); - Log_OC.v("Read " + readCount + " bytes from file channel to " + mBuffer.toString()); + Timber.v("Read " + readCount + " bytes from file channel to " + mBuffer.toString()); sink.buffer().write(mBuffer.array(), 0, readCount); sink.flush(); - Log_OC.v("Write " + readCount + " bytes to sink buffer with size " + sink.buffer().size()); + Timber.v("Write " + readCount + " bytes to sink buffer with size " + sink.buffer().size()); mBuffer.clear(); if (mTransferred < maxCount) { // condition to avoid accumulate progress for repeated chunks @@ -108,10 +108,10 @@ public class ChunkFromFileRequestBody extends FileRequestBody { } } - Log_OC.v("Chunk with size " + mChunkSize + " written in request body"); + Timber.v("Chunk with size " + mChunkSize + " written in request body"); } catch (Exception exception) { - Log_OC.e(exception.getMessage()); + Timber.e(exception); } } 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 e4461341..f6013cb8 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 @@ package com.owncloud.android.lib.common.network; 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 @@ import java.security.cert.CertificateException; 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 class NetworkUtils { //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 class NetworkUtils { 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 e0dabae9..00000000 --- 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 19b4a797..00000000 --- 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 703decca..bcf57dc7 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.OwnCloudAccount; 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; @@ -27,7 +27,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 */ @@ -41,22 +40,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 @@ -76,12 +75,10 @@ public abstract class RemoteOperation implements Runnable { OnRemoteOperationListener listener, Handler listenerHandler) { if (account == null) { - throw new IllegalArgumentException - ("Trying to execute a remote operation with a NULL Account"); + throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account"); } if (context == null) { - throw new IllegalArgumentException - ("Trying to execute a remote operation with a NULL Context"); + throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Context"); } // mAccount and mContext in the runnerThread to create below mAccount = account; @@ -109,8 +106,7 @@ public abstract class RemoteOperation implements Runnable { */ public Thread execute(OwnCloudClient client, OnRemoteOperationListener listener, Handler listenerHandler) { if (client == null) { - throw new IllegalArgumentException - ("Trying to execute a remote operation with a NULL OwnCloudClient"); + throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient"); } mClient = client; if (client.getAccount() != null) { @@ -120,8 +116,7 @@ public abstract class RemoteOperation implements Runnable { if (listener == null) { throw new IllegalArgumentException - ("Trying to execute a remote operation asynchronously " + - "without a listener to notify the result"); + ("Trying to execute a remote operation asynchronously without a listener to notify the result"); } mListener = listener; @@ -134,7 +129,7 @@ public abstract class RemoteOperation implements Runnable { return runnerThread; } - protected void grantOwnCloudClient() throws + private void grantOwnCloudClient() throws AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { if (mClient == null) { if (mAccount != null && mContext != null) { @@ -177,12 +172,10 @@ public abstract class RemoteOperation implements Runnable { */ public RemoteOperationResult execute(Account account, Context context) { if (account == null) { - throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " + - "Account"); + throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account"); } if (context == null) { - throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " + - "Context"); + throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Context"); } mAccount = account; mContext = context.getApplicationContext(); @@ -192,7 +185,7 @@ public abstract class RemoteOperation implements Runnable { /** * 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 @@ -201,8 +194,7 @@ public abstract class RemoteOperation implements Runnable { */ public RemoteOperationResult execute(OwnCloudClient client) { if (client == null) { - throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " + - "OwnCloudClient"); + throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient"); } mClient = client; if (client.getAccount() != null) { @@ -224,8 +216,7 @@ public abstract class RemoteOperation implements Runnable { */ public RemoteOperationResult execute(OkHttpClient client, Context context) { if (client == null) { - throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " + - "OwnCloudClient"); + throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient"); } mHttpClient = client; mContext = context; @@ -249,7 +240,7 @@ public abstract class RemoteOperation implements Runnable { 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 b58d1b73..db86e6b8 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.accounts.AccountUtils; 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 class RemoteOperationResult } } 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 @@ public class RemoteOperationResult 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 @@ public class RemoteOperationResult * * @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 @@ public class RemoteOperationResult 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 @@ public class RemoteOperationResult 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 edb93b66..b2fd1627 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 04a1c4bb..4e8ccd52 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.network.WebdavUtils; 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 @@ import java.util.concurrent.TimeUnit; */ 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 @@ public class CreateRemoteFolderOperation extends RemoteOperation { 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 16699e3b..0201dac7 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.network.WebdavUtils; 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 @@ import java.util.concurrent.atomic.AtomicBoolean; 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 @@ public class DownloadRemoteFileOperation extends RemoteOperation { 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 @@ public class DownloadRemoteFileOperation extends RemoteOperation { 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 @@ public class DownloadRemoteFileOperation extends RemoteOperation { 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 4bb2e760..a564b2a5 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.RedirectionPath; 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 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { 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 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation { } 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/FileUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java index c9c424d3..48969f90 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java @@ -24,7 +24,7 @@ package com.owncloud.android.lib.resources.files; -import com.owncloud.android.lib.common.utils.Log_OC; +import timber.log.Timber; import java.io.File; @@ -32,7 +32,6 @@ public class FileUtils { public static final String PATH_SEPARATOR = "/"; public static final String FINAL_CHUNKS_FILE = ".file"; - private static final String TAG = FileUtils.class.getSimpleName(); public static String getParentPath(String remotePath) { String parentPath = new File(remotePath).getParent(); @@ -43,15 +42,11 @@ public class FileUtils { /** * Validate the fileName to detect if contains any forbidden character: / , \ , < , > , * : , " , | , ? , * - * - * @param fileName - * @param versionSupportsForbiddenChars - * @return */ public static boolean isValidName(String fileName, boolean versionSupportsForbiddenChars) { boolean result = true; - Log_OC.d(TAG, "fileName =======" + fileName); + Timber.d("fileName =======%s", fileName); if ((versionSupportsForbiddenChars && fileName.contains(PATH_SEPARATOR)) || (!versionSupportsForbiddenChars && (fileName.contains(PATH_SEPARATOR) || fileName.contains("\\") || fileName.contains("<") || fileName.contains(">") || @@ -66,14 +61,11 @@ public class FileUtils { /** * Validate the path to detect if contains any forbidden character: \ , < , > , : , " , | , * ? , * - * - * @param path - * @return */ public static boolean isValidPath(String path, boolean versionSupportsForbidenChars) { boolean result = true; - Log_OC.d(TAG, "path ....... " + path); + Timber.d("path ....... %s", path); if (!versionSupportsForbidenChars && (path.contains("\\") || path.contains("<") || path.contains(">") || path.contains(":") || path.contains("\"") || path.contains("|") || 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 d3dfcb83..d18be319 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.http.methods.webdav.PropfindMethod; 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 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R 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 @@ public class ReadRemoteFileOperation extends RemoteOperation { } 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 3aee5d40..9644d0dd 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.http.methods.webdav.PropfindMethod; 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 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R public class ReadRemoteFolderOperation extends RemoteOperation> { - private static final String TAG = ReadRemoteFolderOperation.class.getSimpleName(); - private String mRemotePath; /** @@ -109,13 +107,12 @@ public class ReadRemoteFolderOperation extends RemoteOperation(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 20ba44ca..1ae1140d 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.http.methods.nonwebdav.DeleteMethod; 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 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R * @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 @@ public class RemoveRemoteFileOperation extends RemoteOperation { 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 56f137ff..a1c289fa 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.network.WebdavUtils; 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 @@ import java.util.concurrent.TimeUnit; */ 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 @@ public class RenameRemoteFileOperation extends RemoteOperation { ? 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 46738f8b..1adaa989 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.network.WebdavUtils; 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 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R 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 @@ public class UploadRemoteFileOperation extends RemoteOperation { } 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 2282767c..d9ef1180 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.http.methods.webdav.PutMethod; 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 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation 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 b7080c4d..8250422a 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 e4d4972e..432c2d9b 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.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; @@ -46,8 +46,6 @@ import java.net.URL; public class GetRemoteShareOperation extends RemoteOperation { - private static final String TAG = GetRemoteShareOperation.class.getSimpleName(); - private long mRemoteId; public GetRemoteShareOperation(long remoteId) { @@ -85,7 +83,7 @@ public class GetRemoteShareOperation extends RemoteOperation } 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/GetRemoteShareesOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt index 1419ff7e..af3d85c2 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt @@ -34,8 +34,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.operations.RemoteOperationResult.ResultCode.OK -import com.owncloud.android.lib.common.utils.Log_OC import org.json.JSONObject +import timber.log.Timber import java.net.URL import java.util.ArrayList @@ -95,13 +95,13 @@ class GetRemoteShareesOperation val getMethod = GetMethod(URL(uriBuilder.build().toString())) - getMethod.addRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE) + getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE) val status = client.executeHttpMethod(getMethod) val response = getMethod.responseBodyAsString if (isSuccess(status)) { - Log_OC.d(TAG, "Successful response: " + response!!) + Timber.d("Successful response: $response") // Parse the response val respJSON = JSONObject(response) @@ -128,65 +128,61 @@ class GetRemoteShareesOperation for (j in 0 until jsonResults[i].length()) { val jsonResult = jsonResults[i].getJSONObject(j) data.add(jsonResult) - Log_OC.d(TAG, "*** Added item: " + jsonResult.getString(PROPERTY_LABEL)) + Timber.d("*** Added item: ${jsonResult.getString(PROPERTY_LABEL)}") } } result = RemoteOperationResult(OK) result.data = data - Log_OC.d(TAG, "*** Get Users or groups completed ") + Timber.d("*** Get Users or groups completed ") } else { result = RemoteOperationResult(getMethod) - Log_OC.e(TAG, "Failed response while getting users/groups from the server ") + Timber.e("Failed response while getting users/groups from the server ") if (response != null) { - Log_OC.e(TAG, "*** status code: $status; response message: $response") + Timber.e("*** status code: $status; response message: $response") } else { - Log_OC.e(TAG, "*** status code: $status") + Timber.e("*** status code: $status") } } } catch (e: Exception) { result = RemoteOperationResult(e) - Log_OC.e(TAG, "Exception while getting users/groups", e) + Timber.e(e, "Exception while getting users/groups") } return result } - private fun isSuccess(status: Int): Boolean { - return status == HttpConstants.HTTP_OK - } + private fun isSuccess(status: Int) = status == HttpConstants.HTTP_OK companion object { - private val TAG = GetRemoteShareesOperation::class.java.simpleName - // OCS Routes - private val OCS_ROUTE = "ocs/v2.php/apps/files_sharing/api/v1/sharees" // from OC 8.2 + private const val OCS_ROUTE = "ocs/v2.php/apps/files_sharing/api/v1/sharees" // from OC 8.2 // Arguments - names - private val PARAM_FORMAT = "format" - private val PARAM_ITEM_TYPE = "itemType" - private val PARAM_SEARCH = "search" - private val PARAM_PAGE = "page" // default = 1 - private val PARAM_PER_PAGE = "perPage" // default = 200 + private const val PARAM_FORMAT = "format" + private const val PARAM_ITEM_TYPE = "itemType" + private const val PARAM_SEARCH = "search" + private const val PARAM_PAGE = "page" // default = 1 + private const val PARAM_PER_PAGE = "perPage" // default = 200 // Arguments - constant values - private val VALUE_FORMAT = "json" - private val VALUE_ITEM_TYPE = "file" // to get the server search for users / groups + private const val VALUE_FORMAT = "json" + private const val VALUE_ITEM_TYPE = "file" // to get the server search for users / groups // JSON Node names - private val NODE_OCS = "ocs" - private val NODE_DATA = "data" - private val NODE_EXACT = "exact" - private val NODE_USERS = "users" - private val NODE_GROUPS = "groups" - private val NODE_REMOTES = "remotes" - val NODE_VALUE = "value" - val PROPERTY_LABEL = "label" - val PROPERTY_SHARE_TYPE = "shareType" - val PROPERTY_SHARE_WITH = "shareWith" - val PROPERTY_SHARE_WITH_ADDITIONAL_INFO = "shareWithAdditionalInfo" + private const val NODE_OCS = "ocs" + private const val NODE_DATA = "data" + private const val NODE_EXACT = "exact" + private const val NODE_USERS = "users" + private const val NODE_GROUPS = "groups" + private const val NODE_REMOTES = "remotes" + const val NODE_VALUE = "value" + const val PROPERTY_LABEL = "label" + const val PROPERTY_SHARE_TYPE = "shareType" + const val PROPERTY_SHARE_WITH = "shareWith" + const val PROPERTY_SHARE_WITH_ADDITIONAL_INFO = "shareWithAdditionalInfo" } } 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 f74a7e75..01b09551 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/RemoveRemoteShareOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt index d4deda06..59eb8d6e 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt @@ -32,7 +32,7 @@ import com.owncloud.android.lib.common.http.HttpConstants import com.owncloud.android.lib.common.http.methods.nonwebdav.DeleteMethod 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 /** @@ -75,7 +75,7 @@ class RemoveRemoteShareOperation(private val remoteShareId: Long) : RemoteOperat ) result = parser.parse(deleteMethod.responseBodyAsString) - Log_OC.d(TAG, "Unshare " + remoteShareId + ": " + result.logMessage) + Timber.d("Unshare " + remoteShareId + ": " + result.logMessage) } else { result = RemoteOperationResult(deleteMethod) @@ -83,16 +83,11 @@ class RemoveRemoteShareOperation(private val remoteShareId: Long) : RemoteOperat } catch (e: Exception) { result = RemoteOperationResult(e) - Log_OC.e(TAG, "Unshare Link Exception " + result.logMessage, e) + Timber.e(e, "Unshare Link Exception " + result.logMessage) } return result } private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK - - companion object { - - private val TAG = RemoveRemoteShareOperation::class.java.simpleName - } -} \ No newline at end of file +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt index 09fc03ab..490f9c2b 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt @@ -29,9 +29,9 @@ package com.owncloud.android.lib.resources.shares import android.net.Uri import com.owncloud.android.lib.common.operations.RemoteOperationResult -import com.owncloud.android.lib.common.utils.Log_OC import com.owncloud.android.lib.resources.status.OwnCloudVersion import org.xmlpull.v1.XmlPullParserException +import timber.log.Timber import java.io.ByteArrayInputStream import java.io.IOException import java.util.ArrayList @@ -53,7 +53,7 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar // Parse xml response and obtain the list of shares val byteArrayServerResponse = ByteArrayInputStream(serverResponse.toByteArray()) if (shareXmlParser == null) { - Log_OC.w(TAG, "No ShareXmlParser provided, creating new instance ") + Timber.w("No ShareXmlParser provided, creating new instance") shareXmlParser = ShareXMLParser() } val shares = shareXmlParser?.parseXMLResponse(byteArrayServerResponse) @@ -75,7 +75,7 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar val sharingLinkPath = ShareUtils.getSharingLinkPath(ownCloudVersion) share.shareLink = serverBaseUri.toString() + sharingLinkPath + share.token } else { - Log_OC.e(TAG, "Couldn't build link for public share :(") + Timber.e("Couldn't build link for public share :(") } share @@ -87,7 +87,7 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar } else { result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE) - Log_OC.e(TAG, "Successful status with no share in the response") + Timber.e("Successful status with no share in the response") } } shareXmlParser?.isWrongParameter!! -> { @@ -107,18 +107,14 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar } } } catch (e: XmlPullParserException) { - Log_OC.e(TAG, "Error parsing response from server ", e) + Timber.e(e, "Error parsing response from server") result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE) } catch (e: IOException) { - Log_OC.e(TAG, "Error reading response from server ", e) + Timber.e(e, "Error reading response from server") result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE) } return result } - - companion object { - private val TAG = ShareToRemoteOperationResultParser::class.java.simpleName - } } 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 df634321..c9ef0c12 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/shares/UpdateRemoteShareOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/UpdateRemoteShareOperation.kt index 16f34e2d..41416b1e 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/UpdateRemoteShareOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/UpdateRemoteShareOperation.kt @@ -30,9 +30,9 @@ import com.owncloud.android.lib.common.http.HttpConstants import com.owncloud.android.lib.common.http.methods.nonwebdav.PutMethod 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.DEFAULT_PERMISSION import okhttp3.FormBody +import timber.log.Timber import java.net.URL import java.text.SimpleDateFormat import java.util.Calendar @@ -61,7 +61,6 @@ class UpdateRemoteShareOperation /** * Name to update in Share resource. Ignored by servers previous to version 10.0.0 * - * @param name Name to set to the target share. * Empty string clears the current name. * Null results in no update applied to the name. */ @@ -70,7 +69,6 @@ class UpdateRemoteShareOperation /** * Password to update in Share resource. * - * @param password Password to set to the target share. * Empty string clears the current password. * Null results in no update applied to the password. */ @@ -79,7 +77,6 @@ class UpdateRemoteShareOperation /** * Expiration date to update in Share resource. * - * @param expirationDateInMillis Expiration date to set to the target share. * A negative value clears the current expiration date. * Zero value (start-of-epoch) results in no update done on * the expiration date. @@ -89,7 +86,6 @@ class UpdateRemoteShareOperation /** * Permissions to update in Share resource. * - * @param permissions Permissions to set to the target share. * Values <= 0 result in no update applied to the permissions. */ var permissions: Int = DEFAULT_PERMISSION @@ -97,7 +93,6 @@ class UpdateRemoteShareOperation /** * Enable upload permissions to update in Share resource. * - * @param publicUpload Upload permission to set to the target share. * Null results in no update applied to the upload permission. */ var publicUpload: Boolean? = null @@ -181,7 +176,7 @@ class UpdateRemoteShareOperation } 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 @@ -190,7 +185,6 @@ class UpdateRemoteShareOperation private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK companion object { - private val TAG = GetRemoteShareOperation::class.java.simpleName private const val PARAM_NAME = "name" private const val PARAM_PASSWORD = "password" diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.kt index e5cd965b..e3cfc421 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.kt @@ -33,10 +33,10 @@ 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.operations.RemoteOperationResult.ResultCode.OK -import com.owncloud.android.lib.common.utils.Log_OC import org.json.JSONObject import java.net.URL import com.owncloud.android.lib.resources.status.RemoteCapability.CapabilityBooleanType +import timber.log.Timber /** * Get the Capabilities from the server @@ -69,17 +69,17 @@ class GetRemoteCapabilitiesOperation : RemoteOperation() { if (!isSuccess(status)) { result = RemoteOperationResult(getMethod) - Log_OC.e(TAG, "Failed response while getting capabilities from the server ") + Timber.e("Failed response while getting capabilities from the server ") if (response != null) { - Log_OC.e(TAG, "*** status code: $status; response message: $response") + Timber.e("*** status code: $status; response message: $response") } else { - Log_OC.e(TAG, "*** status code: $status") + Timber.e("*** status code: $status") } return result } - Log_OC.d(TAG, "Successful response: " + response!!) + Timber.d("Successful response: " + response!!) // Parse the response val respJSON = JSONObject(response) @@ -102,7 +102,7 @@ class GetRemoteCapabilitiesOperation : RemoteOperation() { capability.versionMicro = respVersion.getInt(PROPERTY_MICRO) capability.versionString = respVersion.getString(PROPERTY_STRING) capability.versionEdition = respVersion.getString(PROPERTY_EDITION) - Log_OC.d(TAG, "*** Added $NODE_VERSION") + Timber.d("*** Added $NODE_VERSION") } // Capabilities Object @@ -113,7 +113,7 @@ class GetRemoteCapabilitiesOperation : RemoteOperation() { if (respCapabilities.has(NODE_CORE)) { val respCore = respCapabilities.getJSONObject(NODE_CORE) capability.corePollinterval = respCore.getInt(PROPERTY_POLLINTERVAL) - Log_OC.d(TAG, "*** Added $NODE_CORE") + Timber.d("*** Added $NODE_CORE") } // Add files_sharing: public, user, resharing @@ -124,9 +124,10 @@ class GetRemoteCapabilitiesOperation : RemoteOperation() { respFilesSharing.getBoolean(PROPERTY_API_ENABLED) ) } - if (respFilesSharing.has(PROPERTY_SEARCH_MIN_LENGTH)){ + if (respFilesSharing.has(PROPERTY_SEARCH_MIN_LENGTH)) { capability.filesSharingSearchMinLength = respFilesSharing.getInt( - PROPERTY_SEARCH_MIN_LENGTH) + PROPERTY_SEARCH_MIN_LENGTH + ) } if (respFilesSharing.has(NODE_PUBLIC)) { @@ -218,7 +219,7 @@ class GetRemoteCapabilitiesOperation : RemoteOperation() { respFederation.getBoolean(PROPERTY_INCOMING) ) } - Log_OC.d(TAG, "*** Added $NODE_FILES_SHARING") + Timber.d("*** Added $NODE_FILES_SHARING") } if (respCapabilities.has(NODE_FILES)) { @@ -237,23 +238,23 @@ class GetRemoteCapabilitiesOperation : RemoteOperation() { respFiles.getBoolean(PROPERTY_VERSIONING) ) } - Log_OC.d(TAG, "*** Added $NODE_FILES") + Timber.d("*** Added $NODE_FILES") } } // Result result = RemoteOperationResult(OK) result.data = capability - Log_OC.d(TAG, "*** Get Capabilities completed ") + Timber.d("*** Get Capabilities completed ") } else { result = RemoteOperationResult(statuscode, message, null) - Log_OC.e(TAG, "Failed response while getting capabilities from the server ") - Log_OC.e(TAG, "*** status: $statusProp; message: $message") + Timber.e("Failed response while getting capabilities from the server ") + Timber.e("*** status: $statusProp; message: $message") } } catch (e: Exception) { result = RemoteOperationResult(e) - Log_OC.e(TAG, "Exception while getting capabilities", e) + Timber.e(e, "Exception while getting capabilities") } return result @@ -265,8 +266,6 @@ class GetRemoteCapabilitiesOperation : RemoteOperation() { companion object { - private val TAG = GetRemoteCapabilitiesOperation::class.java.simpleName - // OCS Routes private const val OCS_ROUTE = "ocs/v2.php/cloud/capabilities" diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java index 9917186a..493e2466 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java @@ -33,9 +33,9 @@ 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 org.json.JSONException; import org.json.JSONObject; +import timber.log.Timber; import javax.net.ssl.SSLException; import java.net.URL; @@ -59,8 +59,6 @@ public class GetRemoteStatusOperation extends RemoteOperation { */ public static final long TRY_CONNECTION_TIMEOUT = 5000; - private static final String TAG = GetRemoteStatusOperation.class.getSimpleName(); - private static final String NODE_INSTALLED = "installed"; private static final String NODE_VERSION = "version"; private static final String HTTPS_PREFIX = "https://"; @@ -117,8 +115,7 @@ public class GetRemoteStatusOperation extends RemoteOperation { JSONObject respJSON = new JSONObject(getMethod.getResponseBodyAsString()); if (!respJSON.getBoolean(NODE_INSTALLED)) { - mLatestResult = new RemoteOperationResult( - RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); + mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); } else { String version = respJSON.getString(NODE_VERSION); OwnCloudVersion ocVersion = new OwnCloudVersion(version); @@ -153,14 +150,13 @@ public class GetRemoteStatusOperation extends RemoteOperation { } if (mLatestResult.isSuccess()) { - Log_OC.i(TAG, "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage()); + Timber.i("Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage()); } else if (mLatestResult.getException() != null) { - Log_OC.e(TAG, "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage(), - mLatestResult.getException()); + Timber.e(mLatestResult.getException(), "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage()); } else { - Log_OC.e(TAG, "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage()); + Timber.e("Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage()); } return retval; @@ -186,7 +182,7 @@ public class GetRemoteStatusOperation extends RemoteOperation { client.setBaseUri(Uri.parse(HTTPS_PREFIX + baseUriStr)); boolean httpsSuccess = tryConnection(client); if (!httpsSuccess && !mLatestResult.isSslRecoverableException()) { - Log_OC.d(TAG, "establishing secure connection failed, trying non secure connection"); + Timber.d("Establishing secure connection failed, trying non secure connection"); client.setBaseUri(Uri.parse(HTTP_PREFIX + baseUriStr)); tryConnection(client); } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java index 06b0e120..41d38d0e 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java @@ -31,7 +31,7 @@ import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod; 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.io.BufferedInputStream; import java.io.ByteArrayOutputStream; @@ -49,8 +49,6 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R */ public class GetRemoteUserAvatarOperation extends RemoteOperation { - private static final String TAG = GetRemoteUserAvatarOperation.class.getSimpleName(); - private static final String NON_OFFICIAL_AVATAR_PATH = "/index.php/avatar/"; /** @@ -58,11 +56,6 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation(RemoteOperationResult.ResultCode.FILE_NOT_FOUND); return result; } @@ -119,7 +112,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation(e); - Log_OC.e(TAG, "Exception while getting OC user avatar", e); + Timber.e(e, "Exception while getting OC user avatar"); } finally { if (getMethod != null) { @@ -147,14 +140,14 @@ public class GetRemoteUserAvatarOperation 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 @@ public class GetRemoteUserInfoOperation extends RemoteOperation(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 49c313be..bc6f3964 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.http.methods.webdav.PropfindMethod; 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 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R */ public class GetRemoteUserQuotaOperation extends RemoteOperation { - private static final String TAG = GetRemoteUserQuotaOperation.class.getSimpleName(); private String mRemotePath; /** @@ -94,13 +93,12 @@ public class GetRemoteUserQuotaOperation extends RemoteOperation Date: Fri, 10 Jan 2020 13:07:11 +0100 Subject: [PATCH 10/75] Remove Log_OC file --- .../android/lib/common/utils/Log_OC.java | 71 ------------------- 1 file changed, 71 deletions(-) delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/Log_OC.java diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/Log_OC.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/Log_OC.java deleted file mode 100644 index 618e7dbf..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/Log_OC.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.owncloud.android.lib.common.utils; - -import timber.log.Timber; - -import java.io.File; - -public class Log_OC { - - public static void i(String message) { - Timber.i(message); - } - - public static void d(String message) { - Timber.d(message); - } - - public static void d(String message, Exception e) { - Timber.d(e, message); - } - - public static void e(String message) { - Timber.e(message); - } - - public static void e(String message, Throwable e) { - Timber.e(e, message); - } - - public static void v(String message) { - Timber.v(message); - } - - public static void w(String message) { - Timber.w(message); - } - - @Deprecated - public static void i(String tag, String message) { - Timber.i(message); - } - - @Deprecated - public static void d(String TAG, String message) { - Timber.d(message); - } - - @Deprecated - public static void d(String TAG, String message, Exception e) { - Timber.d(e, message); - } - - @Deprecated - public static void e(String TAG, String message) { - Timber.e(message); - } - - @Deprecated - public static void e(String TAG, String message, Throwable e) { - Timber.e(e, message); - } - - @Deprecated - public static void v(String TAG, String message) { - Timber.v(message); - } - - @Deprecated - public static void w(String TAG, String message) { - Timber.w(message); - } -} From 073a91c58031fa18c62ce328d597f9ac5697e061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Mon, 13 Jan 2020 14:17:48 +0100 Subject: [PATCH 11/75] Update logcat library --- owncloudComLibrary/build.gradle | 2 +- .../java/com/owncloud/android/lib/common/OwnCloudClient.java | 4 ++-- .../com/owncloud/android/lib/common/SimpleFactoryManager.java | 2 +- .../com/owncloud/android/lib/common/utils/LoggingHelper.kt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/owncloudComLibrary/build.gradle b/owncloudComLibrary/build.gradle index a9a1825c..031b5383 100644 --- a/owncloudComLibrary/build.gradle +++ b/owncloudComLibrary/build.gradle @@ -7,7 +7,7 @@ dependencies { api 'com.squareup.okhttp3:okhttp:3.12.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" api 'com.gitlab.ownclouders:dav4android:oc_support_1.0.1' - api 'com.github.hannesa2:Logcat:1.5.6' + api 'com.github.hannesa2:Logcat:1.6.0' } allOpen { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java index cbe88718..fc970891 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java @@ -84,7 +84,7 @@ public class OwnCloudClient extends HttpClient { mBaseUri = baseUri; mInstanceNumber = sIntanceCounter++; - Timber.d(" #" + mInstanceNumber + "Creating OwnCloudClient"); + Timber.d("#" + mInstanceNumber + "Creating OwnCloudClient"); clearCredentials(); clearCookies(); @@ -161,7 +161,7 @@ public class OwnCloudClient extends HttpClient { // Header to allow tracing requests in apache and ownCloud logs addHeaderForAllRequests(OC_X_REQUEST_ID, requestId); - Timber.d("Executing " + method.getClass().getSimpleName() + " in request with id " + requestId); + Timber.d("Executing in request with id %s", requestId); } public RedirectionPath followRedirection(HttpBaseMethod method) throws Exception { 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 d039162e..4d5ebfa3 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 @@ -46,7 +46,7 @@ public class SimpleFactoryManager implements OwnCloudClientManager { context.getApplicationContext(), true); - Timber.v(" new client {" + (account.getName() != null ? account.getName() : + Timber.v("new client {" + (account.getName() != null ? account.getName() : AccountUtils.buildAccountName(account.getBaseUri(), "")) + ", " + client.hashCode() + "}"); if (account.getCredentials() == null) { 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 b2fd1627..1418f500 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 = Timber::class.java)) + Timber.plant(FileLoggingTree(directory, filename = storagePath)) } fun stopLogging() { From bcc5a0633511aef88da14213a7a63104d94596ed Mon Sep 17 00:00:00 2001 From: davigonz Date: Thu, 29 Aug 2019 10:55:48 +0200 Subject: [PATCH 12/75] Get rid of conditions for <10 servers --- .../lib/common/DynamicSessionManager.java | 62 ------------- .../common/OwnCloudClientManagerFactory.java | 14 ++- .../lib/common/accounts/AccountUtils.java | 8 +- .../OwnCloudCredentialsFactory.java | 6 -- .../files/CopyRemoteFileOperation.java | 14 +-- .../files/CreateRemoteFolderOperation.java | 25 +----- .../files/MoveRemoteFileOperation.java | 11 --- .../files/RenameRemoteFileOperation.java | 12 +-- .../lib/resources/shares/RemoteShare.kt | 10 +-- .../ShareToRemoteOperationResultParser.kt | 2 +- .../lib/resources/shares/ShareUtils.java | 13 +-- .../lib/resources/status/OwnCloudVersion.kt | 86 +++---------------- 12 files changed, 31 insertions(+), 232 deletions(-) delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/DynamicSessionManager.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 deleted file mode 100644 index 4a69fac4..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/DynamicSessionManager.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.owncloud.android.lib.common; - -import android.accounts.AuthenticatorException; -import android.accounts.OperationCanceledException; -import android.content.Context; - -import com.owncloud.android.lib.common.accounts.AccountUtils; -import com.owncloud.android.lib.resources.status.OwnCloudVersion; - -import java.io.IOException; - -/** - * Dynamic implementation of {@link OwnCloudClientManager}. - * - * Wraps instances of {@link SingleSessionManager} and {@link SimpleFactoryManager} and delegates on one - * or the other depending on the known version of the server corresponding to the {@link OwnCloudAccount} - * - * @author David A. Velasco - */ - -public class DynamicSessionManager implements OwnCloudClientManager { - - private SimpleFactoryManager mSimpleFactoryManager = new SimpleFactoryManager(); - - private SingleSessionManager mSingleSessionManager = new SingleSessionManager(); - - @Override - public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) - throws OperationCanceledException, AuthenticatorException, IOException { - - OwnCloudVersion ownCloudVersion = null; - if (account.getSavedAccount() != null) { - ownCloudVersion = AccountUtils.getServerVersionForAccount( - account.getSavedAccount(), context - ); - } - - if (ownCloudVersion != null && ownCloudVersion.isSessionMonitoringSupported()) { - return mSingleSessionManager.getClientFor(account, context); - } else { - return mSimpleFactoryManager.getClientFor(account, context); - } - } - - @Override - public OwnCloudClient removeClientFor(OwnCloudAccount account) { - OwnCloudClient clientRemovedFromFactoryManager = mSimpleFactoryManager.removeClientFor(account); - OwnCloudClient clientRemovedFromSingleSessionManager = mSingleSessionManager.removeClientFor(account); - if (clientRemovedFromSingleSessionManager != null) { - return clientRemovedFromSingleSessionManager; - } else { - return clientRemovedFromFactoryManager; - } - // clientRemoved and clientRemoved2 should not be != null at the same time - } - - @Override - public void saveAllClients(Context context, String accountType) { - mSimpleFactoryManager.saveAllClients(context, accountType); - mSingleSessionManager.saveAllClients(context, accountType); - } -} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java index 14944a15..02304502 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java @@ -29,17 +29,17 @@ public class OwnCloudClientManagerFactory { private static OwnCloudClientManager sDefaultSingleton; private static String sUserAgent; - public static OwnCloudClientManager newDefaultOwnCloudClientManager() { + private static OwnCloudClientManager newDefaultOwnCloudClientManager() { return newOwnCloudClientManager(sDefaultPolicy); } - public static OwnCloudClientManager newOwnCloudClientManager(Policy policy) { + private static OwnCloudClientManager newOwnCloudClientManager(Policy policy) { switch (policy) { case ALWAYS_NEW_CLIENT: return new SimpleFactoryManager(); - case SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING: - return new DynamicSessionManager(); + case SINGLE_SESSION_PER_ACCOUNT: + return new SingleSessionManager(); default: throw new IllegalArgumentException("Unknown policy"); @@ -53,10 +53,6 @@ public class OwnCloudClientManagerFactory { return sDefaultSingleton; } - public static Policy getDefaultPolicy() { - return sDefaultPolicy; - } - public static void setDefaultPolicy(Policy policy) { if (policy == null) { throw new IllegalArgumentException("Default policy cannot be NULL"); @@ -84,6 +80,6 @@ public class OwnCloudClientManagerFactory { public enum Policy { ALWAYS_NEW_CLIENT, - SINGLE_SESSION_PER_ACCOUNT_IF_SERVER_SUPPORTS_SERVER_MONITORING + SINGLE_SESSION_PER_ACCOUNT } } 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 0b5911b2..649fb630 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 @@ -143,7 +143,6 @@ public class AccountUtils { boolean isOauth2 = supportsOAuth2 != null && supportsOAuth2.equals("TRUE"); String username = AccountUtils.getUsernameForAccount(account); - OwnCloudVersion version = new OwnCloudVersion(am.getUserData(account, Constants.KEY_OC_VERSION)); if (isOauth2) { String accessToken = am.blockingGetAuthToken( @@ -152,7 +151,6 @@ public class AccountUtils { false); credentials = OwnCloudCredentialsFactory.newBearerCredentials(username, accessToken); - } else { String password = am.blockingGetAuthToken( account, @@ -161,8 +159,7 @@ public class AccountUtils { credentials = OwnCloudCredentialsFactory.newBasicCredentials( username, - password, - version.isPreemptiveAuthenticationPreferred() + password ); } @@ -201,9 +198,8 @@ public class AccountUtils { if (url.contains("://")) { url = url.substring(serverBaseUrl.toString().indexOf("://") + 3); } - String accountName = username + "@" + url; - return accountName; + return username + "@" + url; } public static void saveClient(OwnCloudClient client, Account savedAccount, Context context) { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java index 822ef760..6e1172fa 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java @@ -38,12 +38,6 @@ public class OwnCloudCredentialsFactory { return new OwnCloudBasicCredentials(username, password); } - public static OwnCloudCredentials newBasicCredentials( - String username, String password, boolean preemptiveMode - ) { - return new OwnCloudBasicCredentials(username, password, preemptiveMode); - } - public static OwnCloudCredentials newBearerCredentials(String username, String authToken) { return new OwnCloudBearerCredentials(username, authToken); } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java index 79852444..f41c8220 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java @@ -33,7 +33,6 @@ 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.operations.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.resources.status.OwnCloudVersion; import java.net.URL; import java.util.concurrent.TimeUnit; @@ -41,11 +40,12 @@ import java.util.concurrent.TimeUnit; /** * Remote operation moving a remote file or folder in the ownCloud server to a different folder * in the same account. - *

+ * * Allows renaming the moving file/folder at the same time. * * @author David A. Velasco * @author Christian Schabesberger + * @author David González V. */ public class CopyRemoteFileOperation extends RemoteOperation { @@ -81,14 +81,6 @@ public class CopyRemoteFileOperation extends RemoteOperation { */ @Override protected RemoteOperationResult run(OwnCloudClient client) { - OwnCloudVersion version = client.getOwnCloudVersion(); - boolean versionWithForbiddenChars = - (version != null && version.isVersionWithForbiddenCharacters()); - - /// check parameters - if (!FileUtils.isValidPath(mTargetRemotePath, versionWithForbiddenChars)) { - return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME); - } if (mTargetRemotePath.equals(mSrcRemotePath)) { // nothing to do! @@ -100,7 +92,7 @@ public class CopyRemoteFileOperation extends RemoteOperation { } /// perform remote operation - RemoteOperationResult result; + RemoteOperationResult result; try { CopyMethod copyMethod = new CopyMethod(new URL(client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mSrcRemotePath)), 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 4e8ccd52..becb85e4 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2016 ownCloud GmbH. + * Copyright (C) 2019 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 @@ -33,7 +33,6 @@ 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.operations.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.resources.status.OwnCloudVersion; import timber.log.Timber; import java.net.URL; @@ -73,25 +72,7 @@ public class CreateRemoteFolderOperation extends RemoteOperation { */ @Override protected RemoteOperationResult run(OwnCloudClient client) { - RemoteOperationResult result; - OwnCloudVersion version = client.getOwnCloudVersion(); - boolean versionWithForbiddenChars = - (version != null && version.isVersionWithForbiddenCharacters()); - boolean noInvalidChars = FileUtils.isValidPath(mRemotePath, versionWithForbiddenChars); - if (noInvalidChars) { - result = createFolder(client); - if (!result.isSuccess() && mCreateFullPath && - RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) { - result = createParentFolder(FileUtils.getParentPath(mRemotePath), client); - if (result.isSuccess()) { - result = createFolder(client); // second (and last) try - } - } - } else { - result = new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME); - } - - return result; + return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME); } private RemoteOperationResult createFolder(OwnCloudClient client) { @@ -121,4 +102,4 @@ public class CreateRemoteFolderOperation extends RemoteOperation { RemoteOperation operation = new CreateRemoteFolderOperation(parentPath, mCreateFullPath); return operation.execute(client); } -} \ No newline at end of file +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java index 2bebe540..d6275c1d 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java @@ -34,7 +34,6 @@ 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.operations.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.resources.status.OwnCloudVersion; import java.net.URL; import java.util.concurrent.TimeUnit; @@ -87,16 +86,6 @@ public class MoveRemoteFileOperation extends RemoteOperation { */ @Override protected RemoteOperationResult run(OwnCloudClient client) { - - OwnCloudVersion version = client.getOwnCloudVersion(); - boolean versionWithForbiddenChars = - (version != null && version.isVersionWithForbiddenCharacters()); - - /// check parameters - if (!FileUtils.isValidPath(mTargetRemotePath, versionWithForbiddenChars)) { - return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME); - } - if (mTargetRemotePath.equals(mSrcRemotePath)) { // nothing to do! return new RemoteOperationResult<>(ResultCode.OK); 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 a1c289fa..221a133c 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2016 ownCloud GmbH. + * Copyright (C) 2019 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 @@ -31,7 +31,6 @@ 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.operations.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.resources.status.OwnCloudVersion; import timber.log.Timber; import java.io.File; @@ -84,15 +83,6 @@ public class RenameRemoteFileOperation extends RemoteOperation { */ @Override protected RemoteOperationResult run(OwnCloudClient client) { - - final OwnCloudVersion version = client.getOwnCloudVersion(); - final boolean versionWithForbiddenChars = - (version != null && version.isVersionWithForbiddenCharacters()); - - if (!FileUtils.isValidPath(mNewRemotePath, versionWithForbiddenChars)) { - return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME); - } - try { if (mNewName.equals(mOldName)) { return new RemoteOperationResult<>(ResultCode.OK); diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt index a0a4afea..47184f4a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt @@ -66,16 +66,14 @@ data class RemoteShare( const val MAXIMUM_PERMISSIONS_FOR_FOLDER = MAXIMUM_PERMISSIONS_FOR_FILE + CREATE_PERMISSION_FLAG + DELETE_PERMISSION_FLAG - const val FEDERATED_PERMISSIONS_FOR_FILE_UP_TO_OC9 = READ_PERMISSION_FLAG + UPDATE_PERMISSION_FLAG - const val FEDERATED_PERMISSIONS_FOR_FILE_AFTER_OC9 = READ_PERMISSION_FLAG + + const val FEDERATED_PERMISSIONS_FOR_FILE = READ_PERMISSION_FLAG + UPDATE_PERMISSION_FLAG + SHARE_PERMISSION_FLAG - const val FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 = READ_PERMISSION_FLAG + + const val FEDERATED_PERMISSIONS_FOR_FOLDER = READ_PERMISSION_FLAG + UPDATE_PERMISSION_FLAG + CREATE_PERMISSION_FLAG + - DELETE_PERMISSION_FLAG - const val FEDERATED_PERMISSIONS_FOR_FOLDER_AFTER_OC9 = - FEDERATED_PERMISSIONS_FOR_FOLDER_UP_TO_OC9 + SHARE_PERMISSION_FLAG + DELETE_PERMISSION_FLAG + + SHARE_PERMISSION_FLAG const val INIT_EXPIRATION_DATE_IN_MILLIS: Long = 0 const val INIT_SHARED_DATE: Long = 0 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt index 490f9c2b..31fcff51 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt @@ -72,7 +72,7 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar } if (serverBaseUri != null) { - val sharingLinkPath = ShareUtils.getSharingLinkPath(ownCloudVersion) + val sharingLinkPath = ShareUtils.SHARING_LINK_PATH share.shareLink = serverBaseUri.toString() + sharingLinkPath + share.token } else { Timber.e("Couldn't build link for public share :(") diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java index 4d4b80ae..f09642de 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java @@ -39,14 +39,5 @@ public class ShareUtils { public static final String SHARING_API_PATH = "ocs/v2.php/apps/files_sharing/api/v1/shares"; // String to build the link with the token of a share: - public static final String SHARING_LINK_PATH_BEFORE_VERSION_8 = "/public.php?service=files&t="; - public static final String SHARING_LINK_PATH_AFTER_VERSION_8 = "/index.php/s/"; - - public static String getSharingLinkPath(OwnCloudVersion version) { - if (version != null && version.isAfter8Version()) { - return SHARING_LINK_PATH_AFTER_VERSION_8; - } else { - return SHARING_LINK_PATH_BEFORE_VERSION_8; - } - } -} \ No newline at end of file + public static final String SHARING_LINK_PATH = "/index.php/s/"; +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt index e395e5ab..d71114fb 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt @@ -45,46 +45,9 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable INVALID_ZERO_VERSION } - val isChunkedUploadSupported: Boolean - get() = mVersion >= MINIMUN_VERSION_FOR_CHUNKED_UPLOADS - - val isSharedSupported: Boolean - get() = mVersion >= MINIMUM_VERSION_FOR_SHARING_API - - val isVersionWithForbiddenCharacters: Boolean - get() = mVersion >= MINIMUM_VERSION_WITH_FORBIDDEN_CHARS - - val isAfter8Version: Boolean - get() = mVersion >= VERSION_8 - - val isSearchUsersSupported: Boolean - get() = mVersion >= MINIMUM_VERSION_FOR_SEARCHING_USERS - - val isVersionWithCapabilitiesAPI: Boolean - get() = mVersion >= MINIMUM_VERSION_CAPABILITIES_API - - val isNotReshareableFederatedSupported: Boolean - get() = mVersion >= MINIMUM_VERSION_WITH_NOT_RESHAREABLE_FEDERATED - - val isSessionMonitoringSupported: Boolean - get() = mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING - - /** - * From OC 9.1 session tracking is a feature, but to get it working in the OC app we need the preemptive - * mode of basic authentication is disabled. This changes in OC 9.1.3, where preemptive mode is compatible - * with session tracking again. - * - * @return True for every version before 9.1 and from 9.1.3, false otherwise - */ - val isPreemptiveAuthenticationPreferred: Boolean - get() = mVersion < MINIMUM_VERSION_WITH_SESSION_MONITORING || mVersion >= MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE - val isVersionLowerThan10: Boolean get() = mVersion < VERSION_10 - val isMultiplePublicSharingSupported: Boolean - get() = mVersion >= MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING - val isPublicSharingWriteOnlySupported: Boolean get() = mVersion >= MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING @@ -94,17 +57,17 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable mVersion > MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION) init { - var version = version + var versionToParse = version mVersion = 0 isVersionValid = false - val countDots = version.length - version.replace(".", "").length + val countDots = versionToParse.length - versionToParse.replace(".", "").length // Complete the version. Version must have 3 dots for (i in countDots until MAX_DOTS) { - version = "$version.0" + versionToParse = "$versionToParse.0" } - parseVersion(version) + parseVersion(versionToParse) } @@ -122,10 +85,10 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable return versionToString } - override fun compareTo(another: OwnCloudVersion): Int { - return if (another.mVersion == mVersion) + override fun compareTo(other: OwnCloudVersion): Int { + return if (other.mVersion == mVersion) 0 - else if (another.mVersion < mVersion) 1 else -1 + else if (other.mVersion < mVersion) 1 else -1 } private fun parseVersion(version: String) { @@ -137,20 +100,18 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable isVersionValid = false // if invalid, the instance will respond as if server is 8.1, minimum with capabilities API, // and "dead" : https://github.com/owncloud/core/wiki/Maintenance-and-Release-Schedule - mVersion = MINIMUM_VERSION_CAPABILITIES_API } - } @Throws(NumberFormatException::class) private fun getParsedVersion(version: String): Int { - var version = version + var versionToParse = version var versionValue = 0 // get only numeric part - version = version.replace("[^\\d.]".toRegex(), "") + versionToParse = versionToParse.replace("[^\\d.]".toRegex(), "") - val nums = version.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() + val nums = versionToParse.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() var i = 0 while (i < nums.size && i <= MAX_DOTS) { versionValue += Integer.parseInt(nums[i]) @@ -163,10 +124,6 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable return versionValue } - fun supportsRemoteThumbnails(): Boolean { - return mVersion >= MINIMUM_SERVER_VERSION_FOR_REMOTE_THUMBNAILS - } - override fun describeContents(): Int { return super.hashCode() } @@ -181,31 +138,8 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable private const val MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0x03000000 // 3.0.0 - const val MINIMUN_VERSION_FOR_CHUNKED_UPLOADS = 0x04050000 // 4.5 - - const val MINIMUM_VERSION_FOR_SHARING_API = 0x05001B00 // 5.0.27 - - const val MINIMUM_VERSION_WITH_FORBIDDEN_CHARS = 0x08010000 // 8.1 - - const val MINIMUM_SERVER_VERSION_FOR_REMOTE_THUMBNAILS = 0x07080000 // 7.8.0 - - const val MINIMUM_VERSION_FOR_SEARCHING_USERS = 0x08020000 //8.2 - - const val VERSION_8 = 0x08000000 // 8.0 - - const val MINIMUM_VERSION_CAPABILITIES_API = 0x08010000 // 8.1 - - private const val MINIMUM_VERSION_WITH_NOT_RESHAREABLE_FEDERATED = 0x09010000 // 9.1 - - private const val MINIMUM_VERSION_WITH_SESSION_MONITORING = 0x09010000 // 9.1 - - private const val MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301 - // 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd - private const val VERSION_10 = 0xA000000 // 10.0.0 - private const val MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING = 0xA000000 // 10.0.0 - private const val MINIMUN_MAJOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0xA000000 // 10.0.0 private const val MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING = 0xA000100 // 10.0.1 From 234add959a7d2c537e5a2fd550616174684c8ccb Mon Sep 17 00:00:00 2001 From: davigonz Date: Mon, 2 Sep 2019 10:02:47 +0200 Subject: [PATCH 13/75] Apply changes requested in PR --- .../owncloud/android/lib/resources/files/FileUtils.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java index 48969f90..fbf5a359 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java @@ -26,19 +26,10 @@ package com.owncloud.android.lib.resources.files; import timber.log.Timber; -import java.io.File; - public class FileUtils { - public static final String PATH_SEPARATOR = "/"; public static final String FINAL_CHUNKS_FILE = ".file"; - public static String getParentPath(String remotePath) { - String parentPath = new File(remotePath).getParent(); - parentPath = parentPath.endsWith(PATH_SEPARATOR) ? parentPath : parentPath + PATH_SEPARATOR; - return parentPath; - } - /** * Validate the fileName to detect if contains any forbidden character: / , \ , < , > , * : , " , | , ? , * From 495e3321e2bb961465da76aaec963995216b33cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Gonz=C3=A1lez?= Date: Tue, 10 Sep 2019 15:24:50 +0200 Subject: [PATCH 14/75] Fix folder creation --- .../files/CreateRemoteFolderOperation.java | 10 +++++++++- .../android/lib/resources/files/FileUtils.java | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) 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 becb85e4..3985ab2c 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 @@ -72,7 +72,15 @@ public class CreateRemoteFolderOperation extends RemoteOperation { */ @Override protected RemoteOperationResult run(OwnCloudClient client) { - return new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME); + RemoteOperationResult result = createFolder(client); + if (!result.isSuccess() && mCreateFullPath && + RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) { + result = createParentFolder(FileUtils.getParentPath(mRemotePath), client); + if (result.isSuccess()) { + result = createFolder(client); // second (and last) try + } + } + return result; } private RemoteOperationResult createFolder(OwnCloudClient client) { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java index fbf5a359..0fb8248a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java @@ -66,4 +66,21 @@ public class FileUtils { } return result; } + + /** + * Validate the fileName to detect if contains any forbidden character: / , \ , < , > , + * : , " , | , ? , * + * + * @param fileName + * @return + */ + public static boolean isValidName(String fileName) { + boolean result = true; + + Log_OC.d(TAG, "fileName =======" + fileName); + if (fileName.contains(PATH_SEPARATOR)) { + result = false; + } + return result; + } } From 8ba4fa5960cb3f5f756a3cba6ff0af31d2ee4fa9 Mon Sep 17 00:00:00 2001 From: davigonz Date: Mon, 23 Sep 2019 09:32:04 +0200 Subject: [PATCH 15/75] Handle specific bad request error --- .../lib/common/operations/RemoteOperationResult.java | 12 ++++++++---- .../android/lib/resources/files/FileUtils.java | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) 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 db86e6b8..eacb4e69 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 @@ -188,8 +188,12 @@ public class RemoteOperationResult try { if (xmlParser.parseXMLResponse(is)) { mCode = ResultCode.INVALID_CHARACTER_DETECT_IN_SERVER; + } else { + parseErrorMessageAndSetCode( + httpMethod.getResponseBodyAsString(), + ResultCode.SPECIFIC_BAD_REQUEST + ); } - } catch (Exception e) { Timber.w("Error reading exception from server: %s", e.getMessage()); // mCode stays as set in this(success, httpCode, headers) @@ -305,13 +309,12 @@ public class RemoteOperationResult * @param resultCode our own custom result code */ private void parseErrorMessageAndSetCode(String bodyResponse, ResultCode resultCode) { - if (bodyResponse != null && bodyResponse.length() > 0) { InputStream is = new ByteArrayInputStream(bodyResponse.getBytes()); ErrorMessageParser xmlParser = new ErrorMessageParser(); try { String errorMessage = xmlParser.parseXMLResponse(is); - if (errorMessage != null && !errorMessage.equals("")) { + if (!errorMessage.equals("")) { mCode = resultCode; mHttpPhrase = errorMessage; } @@ -566,6 +569,7 @@ public class RemoteOperationResult SERVICE_UNAVAILABLE, SPECIFIC_SERVICE_UNAVAILABLE, SPECIFIC_UNSUPPORTED_MEDIA_TYPE, - SPECIFIC_METHOD_NOT_ALLOWED + SPECIFIC_METHOD_NOT_ALLOWED, + SPECIFIC_BAD_REQUEST } } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java index 0fb8248a..8a6c9f67 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java @@ -77,7 +77,7 @@ public class FileUtils { public static boolean isValidName(String fileName) { boolean result = true; - Log_OC.d(TAG, "fileName =======" + fileName); + Timber.d("fileName =======%s", fileName); if (fileName.contains(PATH_SEPARATOR)) { result = false; } From 20e4317bd9153bc7ba7a917c96fae8dd5823a2c5 Mon Sep 17 00:00:00 2001 From: davigonz Date: Tue, 3 Dec 2019 18:14:09 +0100 Subject: [PATCH 16/75] Include new isServerVersionSupported parameter to log out <10 accounts --- .../owncloud/android/lib/common/OwnCloudClient.java | 11 +++++++---- .../android/lib/resources/status/OwnCloudVersion.kt | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java index fc970891..dd4fdf37 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java @@ -381,16 +381,19 @@ public class OwnCloudClient extends HttpClient { * cannot be invalidated with the given arguments. */ private boolean shouldInvalidateAccountCredentials(int httpStatusCode) { + boolean isServerVersionSupported = AccountUtils.getServerVersionForAccount(getAccount().getSavedAccount(), + getContext()).isServerVersionSupported(); - boolean should = (httpStatusCode == HttpConstants.HTTP_UNAUTHORIZED); // invalid credentials + boolean shouldInvalidateAccountCredentials = + (httpStatusCode == HttpConstants.HTTP_UNAUTHORIZED || !isServerVersionSupported); - should &= (mCredentials != null && // real credentials + shouldInvalidateAccountCredentials &= (mCredentials != null && // real credentials !(mCredentials instanceof OwnCloudCredentialsFactory.OwnCloudAnonymousCredentials)); // test if have all the needed to effectively invalidate ... - should &= (mAccount != null && mAccount.getSavedAccount() != null && getContext() != null); + shouldInvalidateAccountCredentials &= (mAccount != null && mAccount.getSavedAccount() != null && getContext() != null); - return should; + return shouldInvalidateAccountCredentials; } /** diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt index d71114fb..5cadbcf9 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt @@ -45,8 +45,8 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable INVALID_ZERO_VERSION } - val isVersionLowerThan10: Boolean - get() = mVersion < VERSION_10 + val isServerVersionSupported: Boolean + get() = mVersion >= MINIMUN_VERSION_SUPPORTED val isPublicSharingWriteOnlySupported: Boolean get() = mVersion >= MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING @@ -144,6 +144,8 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable private const val MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING = 0xA000100 // 10.0.1 + private const val MINIMUN_VERSION_SUPPORTED = 0xA000000 // 10.0.0 + private const val INVALID_ZERO_VERSION = "0.0.0" private const val MAX_DOTS = 3 From 52463707c7c8a2b21972580839182a4f08c83287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Fri, 20 Dec 2019 13:24:04 +0100 Subject: [PATCH 17/75] Remove unused constants --- .../lib/resources/status/OwnCloudVersion.kt | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt index 5cadbcf9..c8c75653 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/OwnCloudVersion.kt @@ -51,11 +51,6 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable val isPublicSharingWriteOnlySupported: Boolean get() = mVersion >= MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING - val isPublicUploadPermissionNeeded: Boolean - get() = mVersion >= MINIMUN_MAJOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION && - (mVersion > MINIMUN_MINOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION || - mVersion > MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION) - init { var versionToParse = version mVersion = 0 @@ -134,18 +129,10 @@ class OwnCloudVersion(version: String) : Comparable, Parcelable } companion object { - private const val MINIMUN_MINOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0x01000000 // 1.0.0 - - private const val MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0x03000000 // 3.0.0 - - private const val VERSION_10 = 0xA000000 // 10.0.0 - - private const val MINIMUN_MAJOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0xA000000 // 10.0.0 + private const val MINIMUN_VERSION_SUPPORTED = 0xA000000 // 10.0.0 private const val MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING = 0xA000100 // 10.0.1 - private const val MINIMUN_VERSION_SUPPORTED = 0xA000000 // 10.0.0 - private const val INVALID_ZERO_VERSION = "0.0.0" private const val MAX_DOTS = 3 From 03e30ae6983bb6f269643912d82466a7559e84a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Fri, 20 Dec 2019 13:25:00 +0100 Subject: [PATCH 18/75] Fix log with old server version --- .../java/com/owncloud/android/lib/common/OwnCloudClient.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java index dd4fdf37..ccfb8ebf 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java @@ -381,11 +381,8 @@ public class OwnCloudClient extends HttpClient { * cannot be invalidated with the given arguments. */ private boolean shouldInvalidateAccountCredentials(int httpStatusCode) { - boolean isServerVersionSupported = AccountUtils.getServerVersionForAccount(getAccount().getSavedAccount(), - getContext()).isServerVersionSupported(); - boolean shouldInvalidateAccountCredentials = - (httpStatusCode == HttpConstants.HTTP_UNAUTHORIZED || !isServerVersionSupported); + (httpStatusCode == HttpConstants.HTTP_UNAUTHORIZED); shouldInvalidateAccountCredentials &= (mCredentials != null && // real credentials !(mCredentials instanceof OwnCloudCredentialsFactory.OwnCloudAnonymousCredentials)); From 4cd317d929af90034370e5183cd6322ee64435af Mon Sep 17 00:00:00 2001 From: davigonz Date: Fri, 17 Jan 2020 11:13:21 +0100 Subject: [PATCH 19/75] Fix build after rebasing with master --- .../lib/resources/files/FileUtils.java | 41 +++---------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java index 8a6c9f67..b3bbb844 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java @@ -26,45 +26,16 @@ package com.owncloud.android.lib.resources.files; import timber.log.Timber; +import java.io.File; + public class FileUtils { public static final String PATH_SEPARATOR = "/"; public static final String FINAL_CHUNKS_FILE = ".file"; - /** - * Validate the fileName to detect if contains any forbidden character: / , \ , < , > , - * : , " , | , ? , * - */ - public static boolean isValidName(String fileName, boolean versionSupportsForbiddenChars) { - boolean result = true; - - Timber.d("fileName =======%s", fileName); - if ((versionSupportsForbiddenChars && fileName.contains(PATH_SEPARATOR)) || - (!versionSupportsForbiddenChars && (fileName.contains(PATH_SEPARATOR) || - fileName.contains("\\") || fileName.contains("<") || fileName.contains(">") || - fileName.contains(":") || fileName.contains("\"") || fileName.contains("|") || - fileName.contains("?") || fileName.contains("*")))) { - - result = false; - } - return result; - } - - /** - * Validate the path to detect if contains any forbidden character: \ , < , > , : , " , | , - * ? , * - */ - public static boolean isValidPath(String path, boolean versionSupportsForbidenChars) { - boolean result = true; - - Timber.d("path ....... %s", path); - if (!versionSupportsForbidenChars && - (path.contains("\\") || path.contains("<") || path.contains(">") || - path.contains(":") || path.contains("\"") || path.contains("|") || - path.contains("?") || path.contains("*"))) { - - result = false; - } - return result; + static String getParentPath(String remotePath) { + String parentPath = new File(remotePath).getParent(); + parentPath = parentPath.endsWith(PATH_SEPARATOR) ? parentPath : parentPath + PATH_SEPARATOR; + return parentPath; } /** From 2aec82b5e218bafc5375cda8c6560f245be631f9 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 16 Jan 2020 07:22:31 +0100 Subject: [PATCH 20/75] cleanup .gitignore --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index 491cdfc4..172bedd2 100644 --- a/.gitignore +++ b/.gitignore @@ -19,11 +19,6 @@ gen/ # Local configuration files (sdk path, etc) .gradle/ local.properties -sample_client/local.properties # Mac .DS_Store files .DS_Store - -# Proguard README -proguard-project.txt -sample_client/proguard-project.txt \ No newline at end of file From b72353f0253a936eb17ed06b9cbf7d8581e516e6 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 16 Jan 2020 07:22:59 +0100 Subject: [PATCH 21/75] Android Studio 3.5.3 --- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 8461dad5..27226ce5 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ buildscript { ext { // Libraries - kotlinVersion = '1.3.50' + kotlinVersion = '1.3.61' } repositories { @@ -9,7 +9,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.2' + classpath 'com.android.tools.build:gradle:3.5.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ce011295..45ef8ef3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip From 4e0307064120bd42ff791638b9a5bdcde7165577 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 16 Jan 2020 07:23:49 +0100 Subject: [PATCH 22/75] delete old maven relict --- pom.xml | 69 --------------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 pom.xml diff --git a/pom.xml b/pom.xml deleted file mode 100644 index a72688d2..00000000 --- a/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - 4.0.0 - com.owncloud.android - owncloud-android-library - ${owncloud.version} - jar - owncloud-android-library for Owncloud Android - - - 1.5.1-SNAPSHOT - 1.6 - - 4.4.2_r4 - - 19 - - - owncloud-android-library for Owncloud for Android - - - - - android - android - ${google.android-version} - provided - - - - - - ${project.artifactId} - - src - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - ${java-version} - ${java-version} - - - - - com.jayway.maven.plugins.android.generation2 - android-maven-plugin - 3.8.0 - - - ${env.ANDROID_HOME} - ${google.android-api} - - - true - - - - - - - - From a47d6fd882442b6bc78a29d318bf48e6497aa9cf Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 16 Jan 2020 07:25:20 +0100 Subject: [PATCH 23/75] switch to Timber --- .../lib/sampleclient/MainActivity.java | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java index 953699ab..e5c60272 100644 --- a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java +++ b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java @@ -33,7 +33,6 @@ import android.graphics.drawable.BitmapDrawable; import android.net.Uri; import android.os.Bundle; import android.os.Handler; -import android.util.Log; import android.view.View; import android.widget.ListView; import android.widget.TextView; @@ -47,13 +46,14 @@ import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; import com.owncloud.android.lib.common.operations.OnRemoteOperationListener; 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.files.DownloadRemoteFileOperation; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation; import com.owncloud.android.lib.resources.files.RemoteFile; import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation; import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation; +import info.hannes.timber.DebugTree; +import timber.log.Timber; import java.io.File; import java.io.FileOutputStream; @@ -63,12 +63,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import static android.content.ContentValues.TAG; - public class MainActivity extends Activity implements OnRemoteOperationListener, OnDatatransferProgressListener { - private static String LOG_TAG = MainActivity.class.getCanonicalName(); - private Handler mHandler; private OwnCloudClient mClient; private FilesArrayAdapter mFilesAdapter; @@ -82,6 +78,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, super.onCreate(savedInstanceState); setContentView(R.layout.main); + Timber.plant(new DebugTree()); mHandler = new Handler(); final Uri serverUri = Uri.parse(getString(R.string.server_base_url)); @@ -117,7 +114,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, fos.close(); } catch (IOException e) { Toast.makeText(this, R.string.error_copying_sample_file, Toast.LENGTH_SHORT).show(); - Log.e(LOG_TAG, getString(R.string.error_copying_sample_file), e); + Timber.e(e, getString(R.string.error_copying_sample_file)); } mFrame = findViewById(R.id.frame); @@ -212,7 +209,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { if (!result.isSuccess()) { Toast.makeText(this, R.string.todo_operation_finished_in_fail, Toast.LENGTH_SHORT).show(); - Log.e(LOG_TAG, result.getLogMessage(), result.getException()); + Timber.e(result.getException(), result.getLogMessage()); } else if (operation instanceof ReadRemoteFolderOperation) { onSuccessfulRefresh((ReadRemoteFolderOperation) operation, result); @@ -266,23 +263,21 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, mFrame.setBackgroundDrawable(bDraw); } + @SuppressLint("SetTextI18n") @Override public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String fileName) { final long percentage = (totalToTransfer > 0 ? totalTransferredSoFar * 100 / totalToTransfer : 0); final boolean upload = fileName.contains(getString(R.string.upload_folder_path)); - Log.d(LOG_TAG, "progressRate " + percentage); - mHandler.post(new Runnable() { - @Override - public void run() { - TextView progressView = null; - if (upload) { - progressView = findViewById(R.id.upload_progress); - } else { - progressView = findViewById(R.id.download_progress); - } - if (progressView != null) { - progressView.setText(Long.toString(percentage) + "%"); - } + Timber.d("progressRate %s", percentage); + mHandler.post(() -> { + TextView progressView; + if (upload) { + progressView = findViewById(R.id.upload_progress); + } else { + progressView = findViewById(R.id.download_progress); + } + if (progressView != null) { + progressView.setText(percentage + "%"); } }); } @@ -301,7 +296,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, version = pInfo.versionName; } } catch (PackageManager.NameNotFoundException e) { - Log_OC.e(TAG, "Trying to get packageName", e.getCause()); + Timber.e(e); } // Mozilla/5.0 (Android) ownCloud-android/1.7.0 From 9beb25d019f54f14a8f6d3fca05ce06bc2526624 Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 16 Jan 2020 07:25:33 +0100 Subject: [PATCH 24/75] fix lint issues --- .../lib/sampleclient/MainActivity.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java index e5c60272..eeec3947 100644 --- a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java +++ b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java @@ -60,7 +60,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; public class MainActivity extends Activity implements OnRemoteOperationListener, OnDatatransferProgressListener { @@ -105,7 +104,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, File upFile = new File(upFolder, sampleFileName); FileOutputStream fos = new FileOutputStream(upFile); InputStream is = assets.open(sampleFileName); - int count = 0; + int count; byte[] buffer = new byte[1024]; while ((count = is.read(buffer, 0, buffer.length)) >= 0) { fos.write(buffer, 0, count); @@ -163,8 +162,8 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, String mimeType = getString(R.string.sample_file_mimetype); // Get the last modification date of the file from the file system - Long timeStampLong = fileToUpload.lastModified() / 1000; - String timeStamp = timeStampLong.toString(); + long timeStampLong = fileToUpload.lastModified() / 1000; + String timeStamp = Long.toString(timeStampLong); UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType, timeStamp); @@ -212,13 +211,13 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, Timber.e(result.getException(), result.getLogMessage()); } else if (operation instanceof ReadRemoteFolderOperation) { - onSuccessfulRefresh((ReadRemoteFolderOperation) operation, result); + onSuccessfulRefresh(result); } else if (operation instanceof com.owncloud.android.lib.resources.files.UploadRemoteFileOperation) { - onSuccessfulUpload((com.owncloud.android.lib.resources.files.UploadRemoteFileOperation) operation, result); + onSuccessfulUpload(); } else if (operation instanceof RemoveRemoteFileOperation) { - onSuccessfulRemoteDeletion((RemoveRemoteFileOperation) operation, result); + onSuccessfulRemoteDeletion(); } else if (operation instanceof DownloadRemoteFileOperation) { onSuccessfulDownload(); @@ -228,29 +227,26 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, } } - private void onSuccessfulRefresh(ReadRemoteFolderOperation operation, RemoteOperationResult result) { + private void onSuccessfulRefresh(RemoteOperationResult result) { mFilesAdapter.clear(); List files = new ArrayList<>(); for (RemoteFile remoteFile : (List) result.getData()) { files.add(remoteFile); } - if (files != null) { - Iterator it = files.iterator(); - while (it.hasNext()) { - mFilesAdapter.add(it.next()); - } - mFilesAdapter.remove(mFilesAdapter.getItem(0)); + for (RemoteFile file : files) { + mFilesAdapter.add(file); } + mFilesAdapter.remove(mFilesAdapter.getItem(0)); mFilesAdapter.notifyDataSetChanged(); } - private void onSuccessfulUpload(com.owncloud.android.lib.resources.files.UploadRemoteFileOperation operation, RemoteOperationResult result) { + private void onSuccessfulUpload() { startRefresh(); } - private void onSuccessfulRemoteDeletion(RemoveRemoteFileOperation operation, RemoteOperationResult result) { + private void onSuccessfulRemoteDeletion() { startRefresh(); - TextView progressView = (TextView) findViewById(R.id.upload_progress); + TextView progressView = findViewById(R.id.upload_progress); if (progressView != null) { progressView.setText("0%"); } From 11a2ec1d3ed3e3dcd182e30ded3bd93e2286795e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garc=C3=ADa=20de=20Prada?= Date: Thu, 16 Jan 2020 13:00:12 +0100 Subject: [PATCH 25/75] Replace stacktrace with timber log --- .../android/lib/common/accounts/AccountUtils.java | 2 +- .../authentication/OwnCloudBasicCredentials.java | 2 -- .../authentication/oauth/OAuth2QueryParser.java | 2 -- .../lib/common/network/AdvancedX509TrustManager.java | 3 --- .../android/lib/common/network/FileRequestBody.java | 10 +++------- .../lib/resources/files/CopyRemoteFileOperation.java | 11 +++-------- .../lib/resources/files/MoveRemoteFileOperation.java | 12 ++++-------- .../lib/resources/files/ReadRemoteFileOperation.java | 3 +-- .../android/lib/resources/shares/ShareXMLParser.kt | 2 -- 9 files changed, 12 insertions(+), 35 deletions(-) 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 649fb630..309344fa 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 @@ -64,7 +64,7 @@ public class AccountUtils { webDavUrlForAccount = getBaseUrlForAccount(context, account) + OwnCloudClient.WEBDAV_FILES_PATH_4_0 + ownCloudCredentials.getUsername(); } catch (OperationCanceledException | AuthenticatorException | IOException e) { - e.printStackTrace(); + Timber.e(e); } return webDavUrlForAccount; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java index ab1ba3ef..29c5ee54 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java @@ -31,8 +31,6 @@ import okhttp3.internal.Util; public class OwnCloudBasicCredentials implements OwnCloudCredentials { - private static final String TAG = OwnCloudCredentials.class.getSimpleName(); - private String mUsername; private String mPassword; 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 152ffdbe..6ef50447 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 @@ -33,8 +33,6 @@ import java.util.Map; public class OAuth2QueryParser { - private static final String TAG = OAuth2QueryParser.class.getName(); - private Map mOAuth2ParsedAuthorizationResponse; public OAuth2QueryParser() { 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 f2513c3c..d76ecbca 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 @@ -43,11 +43,8 @@ import java.security.cert.X509Certificate; */ public class AdvancedX509TrustManager implements X509TrustManager { - private static final String TAG = AdvancedX509TrustManager.class.getSimpleName(); - private X509TrustManager mStandardTrustManager; private KeyStore mKnownServersKeyStore; - /** * Constructor for AdvancedX509TrustManager * diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java index 520d9a37..c7456ca5 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java @@ -24,13 +24,12 @@ package com.owncloud.android.lib.common.network; -import android.util.Log; - import okhttp3.MediaType; import okhttp3.RequestBody; import okio.BufferedSink; import okio.Okio; import okio.Source; +import timber.log.Timber; import java.io.File; import java.util.Collection; @@ -45,8 +44,6 @@ import java.util.Set; */ public class FileRequestBody extends RequestBody implements ProgressiveDataTransferer { - private static final String TAG = FileRequestBody.class.getSimpleName(); - protected File mFile; private MediaType mContentType; final Set mDataTransferListeners = new HashSet<>(); @@ -87,11 +84,10 @@ public class FileRequestBody extends RequestBody implements ProgressiveDataTrans } } - Log.d(TAG, "File with name " + mFile.getName() + " and size " + mFile.length() + - " written in request body"); + Timber.d("File with name " + mFile.getName() + " and size " + mFile.length() + " written in request body"); } catch (Exception e) { - e.printStackTrace(); + Timber.e(e); } } diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java index f41c8220..258f44bc 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java @@ -24,8 +24,6 @@ package com.owncloud.android.lib.resources.files; -import android.util.Log; - import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.http.HttpConstants; import com.owncloud.android.lib.common.http.methods.webdav.CopyMethod; @@ -33,6 +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.operations.RemoteOperationResult.ResultCode; +import timber.log.Timber; import java.net.URL; import java.util.concurrent.TimeUnit; @@ -49,8 +48,6 @@ import java.util.concurrent.TimeUnit; */ public class CopyRemoteFileOperation extends RemoteOperation { - private static final String TAG = CopyRemoteFileOperation.class.getSimpleName(); - private static final int COPY_READ_TIMEOUT = 600000; private static final int COPY_CONNECTION_TIMEOUT = 5000; @@ -120,13 +117,11 @@ public class CopyRemoteFileOperation extends RemoteOperation { client.exhaustResponse(copyMethod.getResponseBodyAsStream()); } - Log.i(TAG, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + - result.getLogMessage()); + Timber.i("Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage()); } catch (Exception e) { result = new RemoteOperationResult<>(e); - Log.e(TAG, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + - result.getLogMessage(), e); + Timber.e(e, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage()); } return result; diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java index d6275c1d..d131fe67 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java @@ -25,7 +25,6 @@ package com.owncloud.android.lib.resources.files; import android.net.Uri; -import android.util.Log; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.http.HttpConstants; @@ -34,6 +33,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.operations.RemoteOperationResult.ResultCode; +import timber.log.Timber; import java.net.URL; import java.util.concurrent.TimeUnit; @@ -49,8 +49,6 @@ import java.util.concurrent.TimeUnit; */ public class MoveRemoteFileOperation extends RemoteOperation { - private static final String TAG = MoveRemoteFileOperation.class.getSimpleName(); - private static final int MOVE_READ_TIMEOUT = 600000; private static final int MOVE_CONNECTION_TIMEOUT = 5000; @@ -132,13 +130,11 @@ public class MoveRemoteFileOperation extends RemoteOperation { client.exhaustResponse(move.getResponseBodyAsStream()); } - Log.i(TAG, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + - result.getLogMessage()); + Timber.i("Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage()); } catch (Exception e) { result = new RemoteOperationResult<>(e); - Log.e(TAG, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + - result.getLogMessage(), e); + Timber.e(e, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " + result.getLogMessage()); } return result; @@ -147,4 +143,4 @@ public class MoveRemoteFileOperation extends RemoteOperation { protected boolean isSuccess(int status) { return status == HttpConstants.HTTP_CREATED || status == HttpConstants.HTTP_NO_CONTENT; } -} \ No newline at end of file +} 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 d18be319..9149e6d3 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 @@ -99,8 +99,7 @@ public class ReadRemoteFileOperation extends RemoteOperation { } catch (Exception e) { result = new RemoteOperationResult<>(e); - e.printStackTrace(); - Timber.e(result.getException(), "Synchronizing file " + mRemotePath + ": " + result.getLogMessage()); + Timber.e(e, "Synchronizing file %s", mRemotePath); } return result; 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 c9ef0c12..105fb4d6 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 @@ -383,8 +383,6 @@ class ShareXMLParser { companion object { - //private static final String TAG = ShareXMLParser.class.getSimpleName(); - // No namespaces private val ns: String? = null From ffbd4e91283029a139a2d193f0e1be3ccb0591dc Mon Sep 17 00:00:00 2001 From: davigonz Date: Tue, 28 Jan 2020 17:33:16 +0100 Subject: [PATCH 26/75] Use latest gradle version --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 45ef8ef3..ea147fbb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip From e2be78c8f8ec3468d7ef161a730a9546249e892c Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Thu, 2 Jan 2020 12:25:03 +0100 Subject: [PATCH 27/75] prevent a crash --- .../lib/resources/files/ReadRemoteFolderOperation.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 9644d0dd..c9046bf5 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 @@ -106,7 +106,9 @@ public class ReadRemoteFolderOperation extends RemoteOperation(e); } finally { - if (result.isSuccess()) { + if (result == null) { + Timber.e("Synchronized " + mRemotePath + ": result is null"); + } else if (result.isSuccess()) { Timber.i("Synchronized " + mRemotePath + ": " + result.getLogMessage()); } else { if (result.isException()) { From 5b3c21ba822d8b1ddc2690e9c2394481ff725bd3 Mon Sep 17 00:00:00 2001 From: davigonz Date: Tue, 4 Feb 2020 15:32:53 +0100 Subject: [PATCH 28/75] Change policy name in ownCloudClientManagerFactory --- .../android/lib/common/OwnCloudClientManagerFactory.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java index 02304502..31383d3d 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java @@ -25,7 +25,7 @@ package com.owncloud.android.lib.common; public class OwnCloudClientManagerFactory { - private static Policy sDefaultPolicy = Policy.ALWAYS_NEW_CLIENT; + private static Policy sDefaultPolicy = Policy.NEW_CLIENT; private static OwnCloudClientManager sDefaultSingleton; private static String sUserAgent; @@ -35,7 +35,7 @@ public class OwnCloudClientManagerFactory { private static OwnCloudClientManager newOwnCloudClientManager(Policy policy) { switch (policy) { - case ALWAYS_NEW_CLIENT: + case NEW_CLIENT: return new SimpleFactoryManager(); case SINGLE_SESSION_PER_ACCOUNT: @@ -75,11 +75,11 @@ public class OwnCloudClientManagerFactory { if (sDefaultSingleton == null) { return false; } - return policy == Policy.ALWAYS_NEW_CLIENT && !(sDefaultSingleton instanceof SimpleFactoryManager); + return policy == Policy.NEW_CLIENT && !(sDefaultSingleton instanceof SimpleFactoryManager); } public enum Policy { - ALWAYS_NEW_CLIENT, + NEW_CLIENT, SINGLE_SESSION_PER_ACCOUNT } } From c7f9c9d2014b88e31b583dea2f2e38c27880e149 Mon Sep 17 00:00:00 2001 From: davigonz Date: Tue, 4 Feb 2020 17:26:10 +0100 Subject: [PATCH 29/75] Clean up owncloud client factories --- .../android/lib/common/OwnCloudClient.java | 29 ++----- .../lib/common/OwnCloudClientManager.java | 52 ------------ .../common/OwnCloudClientManagerFactory.java | 85 ------------------- .../lib/common/SimpleFactoryManager.java | 72 ---------------- .../lib/common/SingleSessionManager.java | 38 +++++---- .../android/lib/common/http/HttpClient.java | 6 +- .../common/operations/RemoteOperation.java | 4 +- 7 files changed, 36 insertions(+), 250 deletions(-) delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManager.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SimpleFactoryManager.java diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java index ccfb8ebf..6f5bca83 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 ownCloud GmbH. * Copyright (C) 2012 Bartek Przybylski * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -53,9 +53,8 @@ import static com.owncloud.android.lib.common.http.HttpConstants.OC_X_REQUEST_ID public class OwnCloudClient extends HttpClient { public static final String WEBDAV_FILES_PATH_4_0 = "/remote.php/dav/files/"; - public static final String WEBDAV_UPLOADS_PATH_4_0 = "/remote.php/dav/uploads/"; + private static final String WEBDAV_UPLOADS_PATH_4_0 = "/remote.php/dav/uploads/"; public static final String STATUS_PATH = "/status.php"; - public static final String FILES_WEB_PATH = "/index.php/apps/files"; private static final int MAX_REDIRECTIONS_COUNT = 3; private static final int MAX_REPEAT_COUNT_WITH_FRESH_CREDENTIALS = 1; @@ -68,13 +67,8 @@ public class OwnCloudClient extends HttpClient { private OwnCloudVersion mVersion = null; private OwnCloudAccount mAccount; - /** - * {@link @OwnCloudClientManager} holding a reference to this object and delivering it to callers; might be - * NULL - */ - private OwnCloudClientManager mOwnCloudClientManager = null; + private SingleSessionManager mSingleSessionManager = null; - private String mRedirectedLocation; private boolean mFollowRedirects; public OwnCloudClient(Uri baseUri) { @@ -97,7 +91,7 @@ public class OwnCloudClient extends HttpClient { mCredentials.applyTo(this); } - public void applyCredentials() { + void applyCredentials() { mCredentials.applyTo(this); } @@ -127,9 +121,6 @@ public class OwnCloudClient extends HttpClient { private void checkFirstRedirection(HttpBaseMethod method) { final String location = method.getResponseHeader(HttpConstants.LOCATION_HEADER_LOWER); - if (location != null && !location.isEmpty()) { - mRedirectedLocation = location; - } } private int executeRedirectedHttpMethod(HttpBaseMethod method) throws Exception { @@ -360,10 +351,10 @@ public class OwnCloudClient extends HttpClient { } } - if (!credentialsWereRefreshed && mOwnCloudClientManager != null) { + if (!credentialsWereRefreshed && mSingleSessionManager != null) { // if credentials are not refreshed, client must be removed // from the OwnCloudClientManager to prevent it is reused once and again - mOwnCloudClientManager.removeClientFor(mAccount); + mSingleSessionManager.removeClientFor(mAccount); } } // else: onExecute will finish with status 401 @@ -395,7 +386,7 @@ public class OwnCloudClient extends HttpClient { /** * Invalidates credentials stored for the given account in the system {@link AccountManager} and in - * current {@link OwnCloudClientManagerFactory#getDefaultSingleton()} instance. + * current {@link SingleSessionManager#getDefaultSingleton()} instance. *

* {@link #shouldInvalidateAccountCredentials(int)} should be called first. * @@ -411,10 +402,6 @@ public class OwnCloudClient extends HttpClient { return true; } - void setOwnCloudClientManager(OwnCloudClientManager clientManager) { - mOwnCloudClientManager = clientManager; - } - public boolean followRedirects() { return mFollowRedirects; } @@ -422,4 +409,4 @@ public class OwnCloudClient extends HttpClient { public void setFollowRedirects(boolean followRedirects) { this.mFollowRedirects = followRedirects; } -} \ No newline at end of file +} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManager.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManager.java deleted file mode 100644 index fe793863..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManager.java +++ /dev/null @@ -1,52 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 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; - -import android.accounts.AuthenticatorException; -import android.accounts.OperationCanceledException; -import android.content.Context; - -import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; - -import java.io.IOException; - -/** - * Manager to create and reuse OwnCloudClient instances to access remote OC servers. - * - * @author David A. Velasco - * @author masensio - * @author Christian Schabesberger - */ - -public interface OwnCloudClientManager { - - OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws AccountNotFoundException, - OperationCanceledException, AuthenticatorException, IOException; - - OwnCloudClient removeClientFor(OwnCloudAccount account); - - void saveAllClients(Context context, String accountType) throws AccountNotFoundException, AuthenticatorException, IOException, - OperationCanceledException; -} \ No newline at end of file diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java deleted file mode 100644 index 31383d3d..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClientManagerFactory.java +++ /dev/null @@ -1,85 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 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; - -public class OwnCloudClientManagerFactory { - - private static Policy sDefaultPolicy = Policy.NEW_CLIENT; - private static OwnCloudClientManager sDefaultSingleton; - private static String sUserAgent; - - private static OwnCloudClientManager newDefaultOwnCloudClientManager() { - return newOwnCloudClientManager(sDefaultPolicy); - } - - private static OwnCloudClientManager newOwnCloudClientManager(Policy policy) { - switch (policy) { - case NEW_CLIENT: - return new SimpleFactoryManager(); - - case SINGLE_SESSION_PER_ACCOUNT: - return new SingleSessionManager(); - - default: - throw new IllegalArgumentException("Unknown policy"); - } - } - - public static OwnCloudClientManager getDefaultSingleton() { - if (sDefaultSingleton == null) { - sDefaultSingleton = newDefaultOwnCloudClientManager(); - } - return sDefaultSingleton; - } - - public static void setDefaultPolicy(Policy policy) { - if (policy == null) { - throw new IllegalArgumentException("Default policy cannot be NULL"); - } - if (defaultSingletonMustBeUpdated(policy)) { - sDefaultSingleton = null; - } - sDefaultPolicy = policy; - } - - public static String getUserAgent() { - return sUserAgent; - } - - public static void setUserAgent(String userAgent) { - sUserAgent = userAgent; - } - - private static boolean defaultSingletonMustBeUpdated(Policy policy) { - if (sDefaultSingleton == null) { - return false; - } - return policy == Policy.NEW_CLIENT && !(sDefaultSingleton instanceof SimpleFactoryManager); - } - - public enum Policy { - NEW_CLIENT, - SINGLE_SESSION_PER_ACCOUNT - } -} 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 deleted file mode 100644 index 4d5ebfa3..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/SimpleFactoryManager.java +++ /dev/null @@ -1,72 +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; - -import android.accounts.AuthenticatorException; -import android.accounts.OperationCanceledException; -import android.content.Context; - -import com.owncloud.android.lib.common.accounts.AccountUtils; -import timber.log.Timber; - -import java.io.IOException; - -public class SimpleFactoryManager implements OwnCloudClientManager { - - @Override - public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws - OperationCanceledException, AuthenticatorException, IOException { - - Timber.d("getClientFor(OwnCloudAccount ... : "); - - OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient( - account.getBaseUri(), - context.getApplicationContext(), - true); - - Timber.v("new client {" + (account.getName() != null ? account.getName() : - AccountUtils.buildAccountName(account.getBaseUri(), "")) + ", " + client.hashCode() + "}"); - - if (account.getCredentials() == null) { - account.loadCredentials(context); - } - client.setCredentials(account.getCredentials()); - client.setAccount(account); - client.setContext(context); - client.setOwnCloudClientManager(this); - return client; - } - - @Override - public OwnCloudClient removeClientFor(OwnCloudAccount account) { - // nothing to do - not taking care of tracking instances! - return null; - } - - @Override - 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 e4b190a4..f448e45b 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 @@ -41,23 +41,35 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; /** - * Implementation of {@link OwnCloudClientManager} - *

- * TODO check multithreading safety - * * @author David A. Velasco * @author masensio * @author Christian Schabesberger * @author David González Verdugo */ -public class SingleSessionManager implements OwnCloudClientManager { +public class SingleSessionManager { + + private static SingleSessionManager sDefaultSingleton; + private static String sUserAgent; private ConcurrentMap mClientsWithKnownUsername = new ConcurrentHashMap<>(); - private ConcurrentMap mClientsWithUnknownUsername = new ConcurrentHashMap<>(); - @Override + public static SingleSessionManager getDefaultSingleton() { + if (sDefaultSingleton == null) { + sDefaultSingleton = new SingleSessionManager(); + } + return sDefaultSingleton; + } + + public static String getUserAgent() { + return sUserAgent; + } + + public static void setUserAgent(String userAgent) { + sUserAgent = userAgent; + } + public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws OperationCanceledException, AuthenticatorException, IOException { @@ -100,7 +112,6 @@ public class SingleSessionManager implements OwnCloudClientManager { true); // TODO remove dependency on OwnCloudClientFactory client.setAccount(account); HttpClient.setContext(context); - client.setOwnCloudClientManager(this); account.loadCredentials(context); client.setCredentials(account.getCredentials()); @@ -126,12 +137,11 @@ public class SingleSessionManager implements OwnCloudClientManager { return client; } - @Override - public OwnCloudClient removeClientFor(OwnCloudAccount account) { + public void removeClientFor(OwnCloudAccount account) { Timber.d("removeClientFor starting "); if (account == null) { - return null; + return; } OwnCloudClient client; @@ -140,7 +150,7 @@ public class SingleSessionManager implements OwnCloudClientManager { client = mClientsWithKnownUsername.remove(accountName); if (client != null) { Timber.v("Removed client for account %s", accountName); - return client; + return; } else { Timber.v("No client tracked for account %s", accountName); } @@ -149,10 +159,8 @@ public class SingleSessionManager implements OwnCloudClientManager { mClientsWithUnknownUsername.clear(); Timber.d("removeClientFor finishing "); - return null; } - @Override public void saveAllClients(Context context, String accountType) { Timber.d("Saving sessions... "); 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 9a629bfe..27e83e62 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 @@ -26,7 +26,7 @@ package com.owncloud.android.lib.common.http; import android.content.Context; -import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; +import com.owncloud.android.lib.common.SingleSessionManager; import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor; import com.owncloud.android.lib.common.http.interceptors.RequestHeaderInterceptor; import com.owncloud.android.lib.common.network.AdvancedX509TrustManager; @@ -132,7 +132,7 @@ public class HttpClient { private static HttpInterceptor getOkHttpInterceptor() { if (sOkHttpInterceptor == null) { sOkHttpInterceptor = new HttpInterceptor(); - addHeaderForAllRequests(HttpConstants.USER_AGENT_HEADER, OwnCloudClientManagerFactory.getUserAgent()); + addHeaderForAllRequests(HttpConstants.USER_AGENT_HEADER, SingleSessionManager.getUserAgent()); addHeaderForAllRequests(HttpConstants.PARAM_SINGLE_COOKIE_HEADER, "true"); addHeaderForAllRequests(HttpConstants.ACCEPT_ENCODING_HEADER, HttpConstants.ACCEPT_ENCODING_IDENTITY); } 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 bcf57dc7..321907b6 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 @@ -9,7 +9,7 @@ import android.os.Handler; import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.OwnCloudClient; -import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; +import com.owncloud.android.lib.common.SingleSessionManager; import com.owncloud.android.lib.common.accounts.AccountUtils; import okhttp3.OkHttpClient; import timber.log.Timber; @@ -134,7 +134,7 @@ public abstract class RemoteOperation implements Runnable { if (mClient == null) { if (mAccount != null && mContext != null) { OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, mContext); - mClient = OwnCloudClientManagerFactory.getDefaultSingleton(). + mClient = SingleSessionManager.getDefaultSingleton(). getClientFor(ocAccount, mContext); } else { throw new IllegalStateException("Trying to run a remote operation " + From b04a3144784e2446cf859ab555091c818bebc096 Mon Sep 17 00:00:00 2001 From: davigonz Date: Wed, 5 Feb 2020 08:49:24 +0100 Subject: [PATCH 30/75] Remove unnecessary method --- .../java/com/owncloud/android/lib/common/OwnCloudClient.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java index 6f5bca83..835f50e6 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java @@ -104,7 +104,6 @@ public class OwnCloudClient extends HttpClient { setRequestId(method); status = method.execute(); - checkFirstRedirection(method); if (mFollowRedirects) { status = followRedirection(method).getLastStatus(); @@ -119,10 +118,6 @@ public class OwnCloudClient extends HttpClient { return status; } - private void checkFirstRedirection(HttpBaseMethod method) { - final String location = method.getResponseHeader(HttpConstants.LOCATION_HEADER_LOWER); - } - private int executeRedirectedHttpMethod(HttpBaseMethod method) throws Exception { boolean repeatWithFreshCredentials; int repeatCounter = 0; From b7033e53bf3d185d44178b523405a7a27fd44084 Mon Sep 17 00:00:00 2001 From: davigonz Date: Fri, 24 Jan 2020 12:18:29 +0100 Subject: [PATCH 31/75] Use custom connection builder to work with http requests along with AppAuth library --- owncloudComLibrary/build.gradle | 1 + .../oauth/OAuthConnectionBuilder.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.java diff --git a/owncloudComLibrary/build.gradle b/owncloudComLibrary/build.gradle index 031b5383..cb504523 100644 --- a/owncloudComLibrary/build.gradle +++ b/owncloudComLibrary/build.gradle @@ -8,6 +8,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" api 'com.gitlab.ownclouders:dav4android:oc_support_1.0.1' api 'com.github.hannesa2:Logcat:1.6.0' + api 'net.openid:appauth:0.7.1' } allOpen { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.java new file mode 100644 index 00000000..f191ce92 --- /dev/null +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.java @@ -0,0 +1,38 @@ +package com.owncloud.android.lib.common.authentication.oauth; + +import android.net.Uri; + +import androidx.annotation.NonNull; +import net.openid.appauth.Preconditions; +import net.openid.appauth.connectivity.ConnectionBuilder; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.concurrent.TimeUnit; + +/** + * Based on {@link net.openid.appauth.connectivity.DefaultConnectionBuilder} but permitting http connections in addition + * to https connections + */ +public final class OAuthConnectionBuilder implements ConnectionBuilder { + + /** + * The singleton instance of the default connection builder. + */ + public static final OAuthConnectionBuilder INSTANCE = new OAuthConnectionBuilder(); + + private static final int CONNECTION_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(15); + private static final int READ_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(10); + + @NonNull + @Override + public HttpURLConnection openConnection(@NonNull Uri uri) throws IOException { + Preconditions.checkNotNull(uri, "url must not be null"); + HttpURLConnection conn = (HttpURLConnection) new URL(uri.toString()).openConnection(); + conn.setConnectTimeout(CONNECTION_TIMEOUT_MS); + conn.setReadTimeout(READ_TIMEOUT_MS); + conn.setInstanceFollowRedirects(false); + return conn; + } +} From 261be8bf8522cd4acfc3b03f8484673479571657 Mon Sep 17 00:00:00 2001 From: davigonz Date: Wed, 5 Feb 2020 14:40:34 +0100 Subject: [PATCH 32/75] Create OAuth scope param to save it in AccountManager during OAuth process --- gradle.properties | 3 +++ owncloudComLibrary/build.gradle | 2 ++ .../owncloud/android/lib/common/accounts/AccountUtils.java | 5 +++++ 3 files changed, 10 insertions(+) create mode 100644 gradle.properties diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..946d709d --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +android.enableJetifier=true +android.useAndroidX=true +org.gradle.jvmargs=-Xmx1536M \ No newline at end of file diff --git a/owncloudComLibrary/build.gradle b/owncloudComLibrary/build.gradle index cb504523..6f2f40cd 100644 --- a/owncloudComLibrary/build.gradle +++ b/owncloudComLibrary/build.gradle @@ -25,6 +25,8 @@ android { versionCode = 10000401 versionName = "1.0.4.1" + + manifestPlaceholders = [appAuthRedirectScheme: 'oc'] } lintOptions { 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 309344fa..a408de8e 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 @@ -319,5 +319,10 @@ public class AccountUtils { * OAuth2 refresh token **/ public static final String KEY_OAUTH2_REFRESH_TOKEN = "oc_oauth2_refresh_token"; + + /** + * OAuth2 scope + */ + public static final String KEY_OAUTH2_SCOPE = "oc_oauth2_scope"; } } From 4153ee4e35706b710804928262954dcf2609955e Mon Sep 17 00:00:00 2001 From: davigonz Date: Wed, 5 Feb 2020 17:16:06 +0100 Subject: [PATCH 33/75] Remove no longer used OAuth classes --- .../lib/common/accounts/AccountUtils.java | 5 + .../oauth/BearerCredentials.java | 95 ----------- .../oauth/OAuth2ClientConfiguration.java | 66 -------- .../authentication/oauth/OAuth2Constants.java | 68 -------- .../oauth/OAuth2GetAccessTokenOperation.java | 141 ---------------- .../authentication/oauth/OAuth2GrantType.java | 46 ------ .../authentication/oauth/OAuth2Provider.java | 65 -------- .../oauth/OAuth2ProvidersRegistry.java | 121 -------------- .../oauth/OAuth2QueryParser.java | 72 -------- .../OAuth2RefreshAccessTokenOperation.java | 126 -------------- .../oauth/OAuth2RequestBuilder.java | 48 ------ .../oauth/OAuth2ResponseParser.java | 75 --------- .../oauth/OwnCloudOAuth2Provider.java | 94 ----------- .../oauth/OwnCloudOAuth2RequestBuilder.java | 155 ------------------ 14 files changed, 5 insertions(+), 1172 deletions(-) delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Constants.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GrantType.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Provider.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ProvidersRegistry.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RefreshAccessTokenOperation.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RequestBuilder.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ResponseParser.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2Provider.java delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2RequestBuilder.java 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 a408de8e..47107653 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 @@ -315,6 +315,11 @@ public class AccountUtils { */ public static final String KEY_DISPLAY_NAME = "oc_display_name"; + /** + * OAuth2 user id + **/ + public static final String KEY_USER_ID = "user_id"; + /** * OAuth2 refresh token **/ diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java deleted file mode 100644 index 6f7e9a6e..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java +++ /dev/null @@ -1,95 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 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.authentication.oauth; - -/** - * @author David A. Velasco - * @author Christian Schabesberger - */ -public class BearerCredentials { - - public static final int HASH_SEED = 17; - public static final int HASH_OFFSET = 37; - - private String mAccessToken; - - /** - * The constructor with the bearer token - * - * @param token The bearer token - */ - public BearerCredentials(String token) { - mAccessToken = (token == null) ? "" : token; - } - - /** - * Returns the access token - * - * @return The access token - */ - public String getAccessToken() { - return mAccessToken; - } - - /** - * Get this object string. - * - * @return The access token - */ - public String toString() { - return mAccessToken; - } - - /** - * Does a hash of the access token. - * - * @return The hash code of the access token - */ - public int hashCode() { - return HASH_SEED * HASH_OFFSET + mAccessToken.hashCode(); - } - - /** - * These credentials are assumed equal if accessToken is the same. - * - * @param o The other object to compare with. - * @return 'True' if the object is equivalent. - */ - public boolean equals(Object o) { - if (o == null) { - return false; - } - if (this == o) { - return true; - } - if (this.getClass().equals(o.getClass())) { - BearerCredentials that = (BearerCredentials) o; - if (mAccessToken.equals(that.mAccessToken)) { - return true; - } - } - return false; - } -} \ No newline at end of file diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java deleted file mode 100644 index 24814167..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ClientConfiguration.java +++ /dev/null @@ -1,66 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * 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.authentication.oauth; - -public class OAuth2ClientConfiguration { - - private String mClientId; - - private String mClientSecret; - - private String mRedirectUri; - - public OAuth2ClientConfiguration(String clientId, String clientSecret, String redirectUri) { - mClientId = (clientId == null) ? "" : clientId; - mClientSecret = (clientSecret == null) ? "" : clientSecret; - mRedirectUri = (redirectUri == null) ? "" : redirectUri; - } - - public String getClientId() { - return mClientId; - } - - public void setClientId(String clientId) { - mClientId = (clientId == null) ? "" : clientId; - } - - public String getClientSecret() { - return mClientSecret; - } - - public void setClientSecret(String clientSecret) { - mClientSecret = (clientSecret == null) ? "" : clientSecret; - } - - public String getRedirectUri() { - return mRedirectUri; - } - - public void setRedirectUri(String redirectUri) { - this.mRedirectUri = (redirectUri == null) ? "" : redirectUri; - } -} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Constants.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Constants.java deleted file mode 100644 index 97dbfc41..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Constants.java +++ /dev/null @@ -1,68 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * 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.authentication.oauth; - -/** - * Constant values for OAuth 2 protocol. - *

- * Includes required and optional parameter NAMES used in the 'authorization code' grant type. - */ - -public class OAuth2Constants { - - /// Parameters to send to the Authorization Endpoint - public static final String KEY_RESPONSE_TYPE = "response_type"; - public static final String KEY_REDIRECT_URI = "redirect_uri"; - public static final String KEY_CLIENT_ID = "client_id"; - public static final String KEY_SCOPE = "scope"; - public static final String KEY_STATE = "state"; - - /// Additional parameters to send to the Token Endpoint - public static final String KEY_GRANT_TYPE = "grant_type"; - public static final String KEY_CODE = "code"; - - // Used to get the Access Token using Refresh Token - public static final String OAUTH2_REFRESH_TOKEN_GRANT_TYPE = "refresh_token"; - - /// Parameters received in an OK response from the Token Endpoint - public static final String KEY_ACCESS_TOKEN = "access_token"; - public static final String KEY_TOKEN_TYPE = "token_type"; - public static final String KEY_EXPIRES_IN = "expires_in"; - public static final String KEY_REFRESH_TOKEN = "refresh_token"; - - /// Parameters in an ERROR response - public static final String KEY_ERROR = "error"; - public static final String KEY_ERROR_DESCRIPTION = "error_description"; - public static final String KEY_ERROR_URI = "error_uri"; - public static final String VALUE_ERROR_ACCESS_DENIED = "access_denied"; - - /// Extra not standard - public static final String KEY_USER_ID = "user_id"; - - /// Depends on oauth2 grant type - public static final String OAUTH2_RESPONSE_TYPE_CODE = "code"; -} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java deleted file mode 100644 index c5273215..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GetAccessTokenOperation.java +++ /dev/null @@ -1,141 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * @author Christian Schabesberger - * Copyright (C) 2019 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.authentication.oauth; - -import android.net.Uri; - -import com.owncloud.android.lib.common.OwnCloudClient; -import com.owncloud.android.lib.common.authentication.OwnCloudBasicCredentials; -import com.owncloud.android.lib.common.authentication.OwnCloudCredentials; -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.operations.RemoteOperationResult.ResultCode; -import okhttp3.MultipartBody; -import okhttp3.RequestBody; -import org.json.JSONObject; - -import java.net.URL; -import java.util.Map; - -public class OAuth2GetAccessTokenOperation extends RemoteOperation> { - - private final String mAccessTokenEndpointPath; - private final OAuth2ResponseParser mResponseParser; - private String mGrantType; - private String mCode; - private String mClientId; - private String mClientSecret; - private String mRedirectUri; - - public OAuth2GetAccessTokenOperation( - String grantType, - String code, - String clientId, - String secretId, - String redirectUri, - String accessTokenEndpointPath - ) { - mClientId = clientId; - mClientSecret = secretId; - mRedirectUri = redirectUri; - mGrantType = grantType; - mCode = code; - - mAccessTokenEndpointPath = - accessTokenEndpointPath != null ? - accessTokenEndpointPath : - OwnCloudOAuth2Provider.ACCESS_TOKEN_ENDPOINT_PATH - ; - - mResponseParser = new OAuth2ResponseParser(); - } - - @Override - protected RemoteOperationResult run(OwnCloudClient client) { - RemoteOperationResult> result = null; - - try { - - final RequestBody requestBody = new MultipartBody.Builder() - .setType(MultipartBody.FORM) - .addFormDataPart(OAuth2Constants.KEY_GRANT_TYPE, mGrantType) - .addFormDataPart(OAuth2Constants.KEY_CODE, mCode) - .addFormDataPart(OAuth2Constants.KEY_REDIRECT_URI, mRedirectUri) - .addFormDataPart(OAuth2Constants.KEY_CLIENT_ID, mClientId) - .build(); - - Uri.Builder uriBuilder = client.getBaseUri().buildUpon(); - uriBuilder.appendEncodedPath(mAccessTokenEndpointPath); - - final PostMethod postMethod = new PostMethod(new URL( - client.getBaseUri().buildUpon() - .appendEncodedPath(mAccessTokenEndpointPath) - .build() - .toString())); - - postMethod.setRequestBody(requestBody); - - OwnCloudCredentials oauthCredentials = - new OwnCloudBasicCredentials(mClientId, mClientSecret); - OwnCloudCredentials oldCredentials = switchClientCredentials(oauthCredentials); - client.executeHttpMethod(postMethod); - switchClientCredentials(oldCredentials); - - String response = postMethod.getResponseBodyAsString(); - if (response != null && response.length() > 0) { - JSONObject tokenJson = new JSONObject(response); - Map accessTokenResult = - mResponseParser.parseAccessTokenResult(tokenJson); - if (accessTokenResult.get(OAuth2Constants.KEY_ERROR) != null || - accessTokenResult.get(OAuth2Constants.KEY_ACCESS_TOKEN) == null) { - result = new RemoteOperationResult<>(ResultCode.OAUTH2_ERROR); - - } else { - result = new RemoteOperationResult<>(ResultCode.OK); - result.setData(accessTokenResult); - } - - } else { - result = new RemoteOperationResult<>(ResultCode.OK); - client.exhaustResponse(postMethod.getResponseBodyAsStream()); - } - - } catch (Exception e) { - result = new RemoteOperationResult<>(e); - - } - return result; - } - - private OwnCloudCredentials switchClientCredentials(OwnCloudCredentials newCredentials) { - OwnCloudCredentials previousCredentials = getClient().getCredentials(); - getClient().setCredentials(newCredentials); - return previousCredentials; - } -} \ No newline at end of file diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GrantType.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GrantType.java deleted file mode 100644 index b9923994..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2GrantType.java +++ /dev/null @@ -1,46 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * 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.authentication.oauth; - -public enum OAuth2GrantType { - AUTHORIZATION_CODE("authorization_code"), - IMPLICIT("implicit"), - PASSWORD("password"), - CLIENT_CREDENTIAL("client_credentials"), - REFRESH_TOKEN("refresh_token") // not a grant type conceptually, but used as such to refresh access tokens - ; - - private String mValue; - - OAuth2GrantType(String value) { - mValue = value; - } - - public String getValue() { - return mValue; - } -} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Provider.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Provider.java deleted file mode 100644 index e8f598cd..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2Provider.java +++ /dev/null @@ -1,65 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * 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.authentication.oauth; - -public interface OAuth2Provider { - - /** - * {@link OAuth2RequestBuilder} implementation for this provider. - * - * @return {@link OAuth2RequestBuilder} implementation. - */ - OAuth2RequestBuilder getOperationBuilder(); - - /** - * Configuration of the client that is using this {@link OAuth2Provider} - * return Configuration of the client that is usinng this {@link OAuth2Provider} - */ - OAuth2ClientConfiguration getClientConfiguration(); - - /** - * Set configuration of the client that will use this {@link OAuth2Provider} - * - * @param oAuth2ClientConfiguration Configuration of the client that will use this {@link OAuth2Provider} - */ - void setClientConfiguration(OAuth2ClientConfiguration oAuth2ClientConfiguration); - - /** - * base URI to authorization server. - * - * @return Base URL to authorization server. - */ - String getAuthorizationServerUri(); - - /** - * Set base URI to authorization server. - * - * @param authorizationServerUri Set base URL to authorization server. - */ - void setAuthorizationServerUri(String authorizationServerUri); - -} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ProvidersRegistry.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ProvidersRegistry.java deleted file mode 100644 index 16e3b9ac..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ProvidersRegistry.java +++ /dev/null @@ -1,121 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * 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.authentication.oauth; - -import java.util.HashMap; -import java.util.Map; - -public class OAuth2ProvidersRegistry { - - private Map mProviders = new HashMap<>(); - - private OAuth2Provider mDefaultProvider = null; - - private OAuth2ProvidersRegistry() { - } - - /** - * Singleton accesor. - * - * @return Singleton isntance of {@link OAuth2ProvidersRegistry} - */ - public static OAuth2ProvidersRegistry getInstance() { - return LazyHolder.INSTANCE; - } - - /** - * Register an {@link OAuth2Provider} with the name passed as parameter. - * - * @param name Name to bind 'oAuthProvider' in the registry. - * @param oAuth2Provider An {@link OAuth2Provider} instance to keep in the registry. - * @throws IllegalArgumentException if 'name' or 'oAuthProvider' are null. - */ - public void registerProvider(String name, OAuth2Provider oAuth2Provider) { - if (name == null) { - throw new IllegalArgumentException("Name must not be NULL"); - } - if (oAuth2Provider == null) { - throw new IllegalArgumentException("oAuth2Provider must not be NULL"); - } - - mProviders.put(name, oAuth2Provider); - if (mProviders.size() == 1) { - mDefaultProvider = oAuth2Provider; - } - } - - public OAuth2Provider unregisterProvider(String name) { - OAuth2Provider unregisteredProvider = mProviders.remove(name); - if (mProviders.size() == 0) { - mDefaultProvider = null; - } else if (unregisteredProvider != null && unregisteredProvider == mDefaultProvider) { - mDefaultProvider = mProviders.values().iterator().next(); - } - return unregisteredProvider; - } - - /** - * Get default {@link OAuth2Provider}. - * - * @return Default provider, or NULL if there is no provider. - */ - public OAuth2Provider getProvider() { - return mDefaultProvider; - } - - /** - * Get {@link OAuth2Provider} registered with the name passed as parameter. - * - * @param name Name used to register the desired {@link OAuth2Provider} - * @return {@link OAuth2Provider} registered with the name 'name' - */ - public OAuth2Provider getProvider(String name) { - return mProviders.get(name); - } - - /** - * Sets the {@link OAuth2Provider} registered with the name passed as parameter as the default provider - * - * @param name Name used to register the {@link OAuth2Provider} to set as default. - * @return {@link OAuth2Provider} set as default, or NULL if no provider was registered with 'name'. - */ - public OAuth2Provider setDefaultProvider(String name) { - OAuth2Provider toDefault = mProviders.get(name); - if (toDefault != null) { - mDefaultProvider = toDefault; - } - return toDefault; - } - - /** - * See https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom - */ - private static class LazyHolder { - private static final OAuth2ProvidersRegistry INSTANCE = new OAuth2ProvidersRegistry(); - } - -} 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 deleted file mode 100644 index 6ef50447..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2QueryParser.java +++ /dev/null @@ -1,72 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * 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.authentication.oauth; - -import timber.log.Timber; - -import java.util.HashMap; -import java.util.Map; - -public class OAuth2QueryParser { - - private Map mOAuth2ParsedAuthorizationResponse; - - public OAuth2QueryParser() { - mOAuth2ParsedAuthorizationResponse = new HashMap<>(); - } - - public Map parse(String query) { - mOAuth2ParsedAuthorizationResponse.clear(); - - if (query != null) { - String[] pairs = query.split("&"); - int i = 0; - String key = ""; - String value; - while (pairs.length > i) { - int j = 0; - String[] part = pairs[i].split("="); - while (part.length > j) { - String p = part[j]; - if (j == 0) { - key = p; - } else if (j == 1) { - value = p; - mOAuth2ParsedAuthorizationResponse.put(key, value); - } - - Timber.v("[" + i + "," + j + "] = " + p); - j++; - } - i++; - } - } - - return mOAuth2ParsedAuthorizationResponse; - } - -} 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 deleted file mode 100644 index 9b3337b7..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RefreshAccessTokenOperation.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * ownCloud Android client application - * - * @author David González Verdugo - * @author Christian Schabesberger - *

- * Copyright (C) 2019 ownCloud GmbH. - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.owncloud.android.lib.common.authentication.oauth; - -import android.net.Uri; - -import com.owncloud.android.lib.common.OwnCloudClient; -import com.owncloud.android.lib.common.authentication.OwnCloudBasicCredentials; -import com.owncloud.android.lib.common.authentication.OwnCloudCredentials; -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.operations.RemoteOperationResult.ResultCode; -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 final String mAccessTokenEndpointPath; - private final OAuth2ResponseParser mResponseParser; - private String mClientId; - private String mClientSecret; - private String mRefreshToken; - - public OAuth2RefreshAccessTokenOperation( - String clientId, - String secretId, - String refreshToken, - String accessTokenEndpointPath - ) { - - mClientId = clientId; - mClientSecret = secretId; - mRefreshToken = refreshToken; - - mAccessTokenEndpointPath = - accessTokenEndpointPath != null ? - accessTokenEndpointPath : - OwnCloudOAuth2Provider.ACCESS_TOKEN_ENDPOINT_PATH - ; - - mResponseParser = new OAuth2ResponseParser(); - } - - @Override - protected RemoteOperationResult> run(OwnCloudClient client) { - - try { - final RequestBody requestBody = new MultipartBody.Builder() - .setType(MultipartBody.FORM) - .addFormDataPart(OAuth2Constants.KEY_GRANT_TYPE, - OAuth2GrantType.REFRESH_TOKEN.getValue()) - .addFormDataPart(OAuth2Constants.KEY_CLIENT_ID, mClientId) - .addFormDataPart(OAuth2Constants.KEY_REFRESH_TOKEN, mRefreshToken) - .build(); - - Uri.Builder uriBuilder = client.getBaseUri().buildUpon(); - uriBuilder.appendEncodedPath(mAccessTokenEndpointPath); - - final PostMethod postMethod = new PostMethod(new URL( - client.getBaseUri().buildUpon() - .appendEncodedPath(mAccessTokenEndpointPath) - .build() - .toString())); - postMethod.setRequestBody(requestBody); - - final OwnCloudCredentials oauthCredentials = new OwnCloudBasicCredentials(mClientId, mClientSecret); - - final OwnCloudCredentials oldCredentials = switchClientCredentials(oauthCredentials); - client.executeHttpMethod(postMethod); - switchClientCredentials(oldCredentials); - - final String responseData = postMethod.getResponseBodyAsString(); - Timber.d("OAUTH2: raw response from POST TOKEN: %s", responseData); - - if (responseData != null && responseData.length() > 0) { - final JSONObject tokenJson = new JSONObject(responseData); - - final Map accessTokenResult = - mResponseParser.parseAccessTokenResult(tokenJson); - - final RemoteOperationResult> result = new RemoteOperationResult<>(ResultCode.OK); - result.setData(accessTokenResult); - return (accessTokenResult.get(OAuth2Constants.KEY_ERROR) != null || - accessTokenResult.get(OAuth2Constants.KEY_ACCESS_TOKEN) == null) - ? new RemoteOperationResult<>(ResultCode.OAUTH2_ERROR) - : result; - } else { - return new RemoteOperationResult<>(postMethod); - } - - } catch (Exception e) { - return new RemoteOperationResult<>(e); - } - } - - private OwnCloudCredentials switchClientCredentials(OwnCloudCredentials newCredentials) { - OwnCloudCredentials previousCredentials = getClient().getCredentials(); - getClient().setCredentials(newCredentials); - return previousCredentials; - } -} \ No newline at end of file diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RequestBuilder.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RequestBuilder.java deleted file mode 100644 index edda5d6b..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2RequestBuilder.java +++ /dev/null @@ -1,48 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * 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.authentication.oauth; - -import com.owncloud.android.lib.common.operations.RemoteOperation; - -public interface OAuth2RequestBuilder { - - void setRequest(OAuthRequest operation); - - void setGrantType(OAuth2GrantType grantType); - - void setAuthorizationCode(String code); - - void setRefreshToken(String refreshToken); - - RemoteOperation buildOperation(); - - String buildUri(); - - enum OAuthRequest { - GET_AUTHORIZATION_CODE, CREATE_ACCESS_TOKEN, REFRESH_ACCESS_TOKEN - } -} \ No newline at end of file diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ResponseParser.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ResponseParser.java deleted file mode 100644 index 0d377c9e..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuth2ResponseParser.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * ownCloud Android client application - * - * @author David A. Velasco - *

- * Copyright (C) 2017 ownCloud GmbH. - *

- * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.owncloud.android.lib.common.authentication.oauth; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.util.HashMap; -import java.util.Map; - -class OAuth2ResponseParser { - - Map parseAccessTokenResult(JSONObject tokenJson) throws JSONException { - Map resultTokenMap = new HashMap<>(); - - if (tokenJson.has(OAuth2Constants.KEY_ACCESS_TOKEN)) { - resultTokenMap.put(OAuth2Constants.KEY_ACCESS_TOKEN, tokenJson. - getString(OAuth2Constants.KEY_ACCESS_TOKEN)); - } - if (tokenJson.has(OAuth2Constants.KEY_TOKEN_TYPE)) { - resultTokenMap.put(OAuth2Constants.KEY_TOKEN_TYPE, tokenJson. - getString(OAuth2Constants.KEY_TOKEN_TYPE)); - } - if (tokenJson.has(OAuth2Constants.KEY_EXPIRES_IN)) { - resultTokenMap.put(OAuth2Constants.KEY_EXPIRES_IN, tokenJson. - getString(OAuth2Constants.KEY_EXPIRES_IN)); - } - if (tokenJson.has(OAuth2Constants.KEY_REFRESH_TOKEN)) { - resultTokenMap.put(OAuth2Constants.KEY_REFRESH_TOKEN, tokenJson. - getString(OAuth2Constants.KEY_REFRESH_TOKEN)); - } - if (tokenJson.has(OAuth2Constants.KEY_SCOPE)) { - resultTokenMap.put(OAuth2Constants.KEY_SCOPE, tokenJson. - getString(OAuth2Constants.KEY_SCOPE)); - } - if (tokenJson.has(OAuth2Constants.KEY_ERROR)) { - resultTokenMap.put(OAuth2Constants.KEY_ERROR, tokenJson. - getString(OAuth2Constants.KEY_ERROR)); - } - if (tokenJson.has(OAuth2Constants.KEY_ERROR_DESCRIPTION)) { - resultTokenMap.put(OAuth2Constants.KEY_ERROR_DESCRIPTION, tokenJson. - getString(OAuth2Constants.KEY_ERROR_DESCRIPTION)); - } - if (tokenJson.has(OAuth2Constants.KEY_ERROR_URI)) { - resultTokenMap.put(OAuth2Constants.KEY_ERROR_URI, tokenJson. - getString(OAuth2Constants.KEY_ERROR_URI)); - } - - if (tokenJson.has(OAuth2Constants.KEY_USER_ID)) { // not standard - resultTokenMap.put(OAuth2Constants.KEY_USER_ID, tokenJson. - getString(OAuth2Constants.KEY_USER_ID)); - } - - return resultTokenMap; - } - -} 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 deleted file mode 100644 index f393d430..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2Provider.java +++ /dev/null @@ -1,94 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * 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.authentication.oauth; - -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"; - private static final String AUTHORIZATION_CODE_ENDPOINT_PATH = "index.php/apps/oauth2/authorize"; - - private String mAuthorizationServerUrl = ""; - private String mAccessTokenEndpointPath = ACCESS_TOKEN_ENDPOINT_PATH; - private String mAuthorizationCodeEndpointPath = AUTHORIZATION_CODE_ENDPOINT_PATH; - - private OAuth2ClientConfiguration mClientConfiguration; - - @Override - public OAuth2RequestBuilder getOperationBuilder() { - return new OwnCloudOAuth2RequestBuilder(this); - } - - @Override - public OAuth2ClientConfiguration getClientConfiguration() { - return mClientConfiguration; - } - - @Override - public void setClientConfiguration(OAuth2ClientConfiguration oAuth2ClientConfiguration) { - mClientConfiguration = oAuth2ClientConfiguration; - } - - @Override - public String getAuthorizationServerUri() { - return mAuthorizationServerUrl; - } - - @Override - public void setAuthorizationServerUri(String authorizationServerUri) { - mAuthorizationServerUrl = authorizationServerUri; - } - - public String getAccessTokenEndpointPath() { - return mAccessTokenEndpointPath; - } - - public void setAccessTokenEndpointPath(String accessTokenEndpointPath) { - if (accessTokenEndpointPath == null || accessTokenEndpointPath.length() <= 0) { - Timber.w("Setting invalid access token endpoint path, going on with default"); - mAccessTokenEndpointPath = ACCESS_TOKEN_ENDPOINT_PATH; - } else { - mAccessTokenEndpointPath = accessTokenEndpointPath; - } - } - - public String getAuthorizationCodeEndpointPath() { - return mAuthorizationCodeEndpointPath; - } - - public void setAuthorizationCodeEndpointPath(String authorizationCodeEndpointPath) { - if (authorizationCodeEndpointPath == null || authorizationCodeEndpointPath.length() <= 0) { - 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/authentication/oauth/OwnCloudOAuth2RequestBuilder.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2RequestBuilder.java deleted file mode 100644 index 935004dd..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OwnCloudOAuth2RequestBuilder.java +++ /dev/null @@ -1,155 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * - * @author David A. Velasco - * 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.authentication.oauth; - -import android.net.Uri; - -import com.owncloud.android.lib.common.operations.RemoteOperation; - -public class OwnCloudOAuth2RequestBuilder implements OAuth2RequestBuilder { - - private OwnCloudOAuth2Provider mOAuth2Provider; - - private OAuthRequest mRequest; - private OAuth2GrantType mGrantType = OAuth2GrantType.AUTHORIZATION_CODE; - private String mCode; - private String mRefreshToken; - - public OwnCloudOAuth2RequestBuilder(OwnCloudOAuth2Provider ownCloudOAuth2Provider) { - mOAuth2Provider = ownCloudOAuth2Provider; - } - - @Override - public void setRequest(OAuthRequest request) { - mRequest = request; - } - - @Override - public void setGrantType(OAuth2GrantType grantType) { - mGrantType = grantType; - } - - @Override - public void setAuthorizationCode(String code) { - mCode = code; - } - - @Override - public void setRefreshToken(String refreshToken) { - mRefreshToken = refreshToken; - } - - @Override - public RemoteOperation buildOperation() { - if (mGrantType != OAuth2GrantType.AUTHORIZATION_CODE && - mGrantType != OAuth2GrantType.REFRESH_TOKEN) { - throw new UnsupportedOperationException( - "Unsupported grant type. Only " + - OAuth2GrantType.AUTHORIZATION_CODE.getValue() + " and " + - OAuth2GrantType.REFRESH_TOKEN + " are supported" - ); - } - OAuth2ClientConfiguration clientConfiguration = mOAuth2Provider.getClientConfiguration(); - - switch (mRequest) { - case CREATE_ACCESS_TOKEN: - return new OAuth2GetAccessTokenOperation( - mGrantType.getValue(), - mCode, - clientConfiguration.getClientId(), - clientConfiguration.getClientSecret(), - clientConfiguration.getRedirectUri(), - mOAuth2Provider.getAccessTokenEndpointPath() - ); - - case REFRESH_ACCESS_TOKEN: - return new OAuth2RefreshAccessTokenOperation( - clientConfiguration.getClientId(), - clientConfiguration.getClientSecret(), - mRefreshToken, - mOAuth2Provider.getAccessTokenEndpointPath() - ); - default: - throw new UnsupportedOperationException( - "Unsupported request" - ); - } - } - - @Override - public String buildUri() { - if (OAuth2GrantType.AUTHORIZATION_CODE != mGrantType) { - throw new UnsupportedOperationException( - "Unsupported grant type. Only " + - OAuth2GrantType.AUTHORIZATION_CODE.getValue() + " is supported by this provider" - ); - } - OAuth2ClientConfiguration clientConfiguration = mOAuth2Provider.getClientConfiguration(); - Uri uri; - Uri.Builder uriBuilder; - switch (mRequest) { - case GET_AUTHORIZATION_CODE: - uri = Uri.parse(mOAuth2Provider.getAuthorizationServerUri()); - uriBuilder = uri.buildUpon(); - uriBuilder.appendEncodedPath(mOAuth2Provider.getAuthorizationCodeEndpointPath()); - uriBuilder.appendQueryParameter( - OAuth2Constants.KEY_RESPONSE_TYPE, OAuth2Constants.OAUTH2_RESPONSE_TYPE_CODE - ); - uriBuilder.appendQueryParameter( - OAuth2Constants.KEY_REDIRECT_URI, clientConfiguration.getRedirectUri() - ); - uriBuilder.appendQueryParameter( - OAuth2Constants.KEY_CLIENT_ID, clientConfiguration.getClientId() - ); - - uri = uriBuilder.build(); - return uri.toString(); - - case CREATE_ACCESS_TOKEN: - uri = Uri.parse(mOAuth2Provider.getAuthorizationServerUri()); - uriBuilder = uri.buildUpon(); - uriBuilder.appendEncodedPath(mOAuth2Provider.getAccessTokenEndpointPath()); - uriBuilder.appendQueryParameter( - OAuth2Constants.KEY_RESPONSE_TYPE, OAuth2Constants.OAUTH2_RESPONSE_TYPE_CODE - ); - uriBuilder.appendQueryParameter( - OAuth2Constants.KEY_REDIRECT_URI, clientConfiguration.getRedirectUri() - ); - uriBuilder.appendQueryParameter( - OAuth2Constants.KEY_CLIENT_ID, clientConfiguration.getClientId() - ); - - uri = uriBuilder.build(); - return uri.toString(); - - default: - throw new UnsupportedOperationException( - "Unsupported request" - ); - } - } -} From 1b4ce388b386dec659005c44bb35dfec5ff1269b Mon Sep 17 00:00:00 2001 From: davigonz Date: Thu, 6 Feb 2020 15:03:50 +0100 Subject: [PATCH 34/75] Apply changes requested in code review --- owncloudComLibrary/build.gradle | 4 +- .../oauth/OAuthConnectionBuilder.java | 38 ------------------- .../oauth/OAuthConnectionBuilder.kt | 31 +++++++++++++++ 3 files changed, 34 insertions(+), 39 deletions(-) delete mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.java create mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.kt diff --git a/owncloudComLibrary/build.gradle b/owncloudComLibrary/build.gradle index 6f2f40cd..82949174 100644 --- a/owncloudComLibrary/build.gradle +++ b/owncloudComLibrary/build.gradle @@ -26,7 +26,9 @@ android { versionCode = 10000401 versionName = "1.0.4.1" - manifestPlaceholders = [appAuthRedirectScheme: 'oc'] + // This is pretty ugly but manifest placeholders don't seem to work very well when using different modules + // See https://github.com/openid/AppAuth-Android/issues/325 + manifestPlaceholders = [appAuthRedirectScheme: ''] } lintOptions { diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.java deleted file mode 100644 index f191ce92..00000000 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.owncloud.android.lib.common.authentication.oauth; - -import android.net.Uri; - -import androidx.annotation.NonNull; -import net.openid.appauth.Preconditions; -import net.openid.appauth.connectivity.ConnectionBuilder; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.concurrent.TimeUnit; - -/** - * Based on {@link net.openid.appauth.connectivity.DefaultConnectionBuilder} but permitting http connections in addition - * to https connections - */ -public final class OAuthConnectionBuilder implements ConnectionBuilder { - - /** - * The singleton instance of the default connection builder. - */ - public static final OAuthConnectionBuilder INSTANCE = new OAuthConnectionBuilder(); - - private static final int CONNECTION_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(15); - private static final int READ_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(10); - - @NonNull - @Override - public HttpURLConnection openConnection(@NonNull Uri uri) throws IOException { - Preconditions.checkNotNull(uri, "url must not be null"); - HttpURLConnection conn = (HttpURLConnection) new URL(uri.toString()).openConnection(); - conn.setConnectTimeout(CONNECTION_TIMEOUT_MS); - conn.setReadTimeout(READ_TIMEOUT_MS); - conn.setInstanceFollowRedirects(false); - return conn; - } -} diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.kt new file mode 100644 index 00000000..8eedcf58 --- /dev/null +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.kt @@ -0,0 +1,31 @@ +package com.owncloud.android.lib.common.authentication.oauth + +import android.net.Uri +import net.openid.appauth.Preconditions +import net.openid.appauth.connectivity.ConnectionBuilder +import java.io.IOException +import java.net.HttpURLConnection +import java.net.URL +import java.util.concurrent.TimeUnit + +/** + * Based on [net.openid.appauth.connectivity.DefaultConnectionBuilder] but permitting http connections in addition + * to https connections + */ +class OAuthConnectionBuilder : ConnectionBuilder { + @Throws(IOException::class) + override fun openConnection(uri: Uri): HttpURLConnection { + Preconditions.checkNotNull(uri, "url must not be null") + val conn = URL(uri.toString()).openConnection() as HttpURLConnection + return conn.apply { + connectTimeout = CONNECTION_TIMEOUT_MS + readTimeout = READ_TIMEOUT_MS + instanceFollowRedirects = false + } + } + + companion object { + private val CONNECTION_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(15).toInt() + private val READ_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10).toInt() + } +} From 4a9eb24d6907789d19e57d5b7afa7800989047d9 Mon Sep 17 00:00:00 2001 From: davigonz Date: Tue, 11 Feb 2020 16:46:15 +0100 Subject: [PATCH 35/75] Include hostname verifier --- .../oauth/OAuthConnectionBuilder.kt | 60 ++++++++++++++++--- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.kt index 8eedcf58..f243624b 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/oauth/OAuthConnectionBuilder.kt @@ -1,31 +1,73 @@ package com.owncloud.android.lib.common.authentication.oauth +import android.content.Context import android.net.Uri -import net.openid.appauth.Preconditions +import com.owncloud.android.lib.common.network.AdvancedX509TrustManager +import com.owncloud.android.lib.common.network.NetworkUtils import net.openid.appauth.connectivity.ConnectionBuilder +import timber.log.Timber import java.io.IOException import java.net.HttpURLConnection import java.net.URL +import java.security.NoSuchAlgorithmException +import java.util.Objects import java.util.concurrent.TimeUnit +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.HttpsURLConnection +import javax.net.ssl.SSLContext +import javax.net.ssl.TrustManager +import javax.net.ssl.X509TrustManager /** * Based on [net.openid.appauth.connectivity.DefaultConnectionBuilder] but permitting http connections in addition * to https connections */ -class OAuthConnectionBuilder : ConnectionBuilder { +class OAuthConnectionBuilder(val context: Context) : ConnectionBuilder { + /** + * The singleton instance of the default connection builder. + */ + private val CONNECTION_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(15).toInt() + private val READ_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10).toInt() + private val HTTPS_SCHEME = "https" + @Throws(IOException::class) override fun openConnection(uri: Uri): HttpURLConnection { - Preconditions.checkNotNull(uri, "url must not be null") - val conn = URL(uri.toString()).openConnection() as HttpURLConnection + val conn: HttpURLConnection + + if (Objects.equals(uri.scheme, HTTPS_SCHEME)) { + conn = URL(uri.toString()).openConnection() as HttpsURLConnection + try { + val trustManager: X509TrustManager = AdvancedX509TrustManager( + NetworkUtils.getKnownServersStore(context) + ) + val sslContext: SSLContext + sslContext = try { + SSLContext.getInstance("TLSv1.2") + } catch (tlsv12Exception: NoSuchAlgorithmException) { + try { + Timber.w("TLSv1.2 is not supported in this device; falling through TLSv1.1") + SSLContext.getInstance("TLSv1.1") + } catch (tlsv11Exception: NoSuchAlgorithmException) { + Timber.w("TLSv1.1 is not supported in this device; falling through TLSv1.0") + 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 + } + } + sslContext.init(null, arrayOf(trustManager), null) + conn.hostnameVerifier = HostnameVerifier { _, _ -> true } // Do not verify the host for now + conn.sslSocketFactory = sslContext.socketFactory + } catch (e: Exception) { + Timber.e(e, "Could not setup SSL system") + } + } else { + conn = URL(uri.toString()).openConnection() as HttpURLConnection + } + return conn.apply { connectTimeout = CONNECTION_TIMEOUT_MS readTimeout = READ_TIMEOUT_MS instanceFollowRedirects = false } } - - companion object { - private val CONNECTION_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(15).toInt() - private val READ_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10).toInt() - } } From 0f1f232c16aac180ca3062fcdddb265e2e877d5c Mon Sep 17 00:00:00 2001 From: davigonz Date: Wed, 12 Feb 2020 10:51:49 +0100 Subject: [PATCH 36/75] Fix crash when client is revoked from web UI --- .../java/com/owncloud/android/lib/common/OwnCloudClient.java | 5 +++-- .../owncloud/android/lib/common/OwnCloudClientFactory.java | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java index 835f50e6..5c4ae8e6 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/OwnCloudClient.java @@ -334,7 +334,6 @@ public class OwnCloudClient extends HttpClient { if (invalidated) { if (getCredentials().authTokenCanBeRefreshed() && repeatCounter < MAX_REPEAT_COUNT_WITH_FRESH_CREDENTIALS) { - try { mAccount.loadCredentials(getContext()); // if mAccount.getCredentials().length() == 0 --> refresh failed @@ -342,7 +341,9 @@ public class OwnCloudClient extends HttpClient { credentialsWereRefreshed = true; } catch (AccountsException | IOException e) { - Timber.e(e, "Error while trying to refresh auth token for %s", mAccount.getSavedAccount().name); + Timber.e(e, "Error while trying to refresh auth token for %s", + mAccount.getSavedAccount().name + ); } } 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 94a44c26..99c5641a 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 @@ -37,8 +37,7 @@ public class OwnCloudClientFactory { * @param context Android context where the OwnCloudClient is being created. * @return A OwnCloudClient object ready to be used */ - public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, - boolean followRedirects) { + public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects) { OwnCloudClient client = new OwnCloudClient(uri); client.setFollowRedirects(followRedirects); From e343a720f70e7abafc47ff66038fad35e72856e3 Mon Sep 17 00:00:00 2001 From: davigonz Date: Tue, 18 Feb 2020 12:07:33 +0100 Subject: [PATCH 37/75] Fix sample client --- sample_client/build.gradle | 4 ++++ .../lib/sampleclient/MainActivity.java | 4 ++-- wait_for_emulator.sh | 19 ------------------- 3 files changed, 6 insertions(+), 21 deletions(-) delete mode 100644 wait_for_emulator.sh diff --git a/sample_client/build.gradle b/sample_client/build.gradle index b41ff109..4d0c1d4b 100644 --- a/sample_client/build.gradle +++ b/sample_client/build.gradle @@ -10,6 +10,10 @@ android { defaultConfig { minSdkVersion 21 targetSdkVersion 28 + + // This is pretty ugly but manifest placeholders don't seem to work very well when using different modules + // See https://github.com/openid/AppAuth-Android/issues/325 + manifestPlaceholders = [appAuthRedirectScheme: ''] } lintOptions { diff --git a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java index eeec3947..5439e0ca 100644 --- a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java +++ b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java @@ -40,7 +40,7 @@ import android.widget.Toast; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientFactory; -import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; +import com.owncloud.android.lib.common.SingleSessionManager; import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory; import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; import com.owncloud.android.lib.common.operations.OnRemoteOperationListener; @@ -82,7 +82,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener, final Uri serverUri = Uri.parse(getString(R.string.server_base_url)); - OwnCloudClientManagerFactory.setUserAgent(getUserAgent()); + SingleSessionManager.setUserAgent(getUserAgent()); mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true); mClient.setCredentials( diff --git a/wait_for_emulator.sh b/wait_for_emulator.sh deleted file mode 100644 index 7f6443c7..00000000 --- a/wait_for_emulator.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -bootanim="" -failcounter=0 -checkcounter=0 -until [[ "$bootanim" =~ "stopped" ]]; do - bootanim=`adb -e shell getprop init.svc.bootanim 2>&1` - echo "($checkcounter) $bootanim" - if [[ "$bootanim" =~ "not found" ]]; then - let "failcounter += 1" - if [[ $failcounter -gt 30 ]]; then - echo "Failed to start emulator" - exit 1 - fi - fi - let "checkcounter += 1" - sleep 10 -done -echo "Done" From 8d5524da75be1ab0a802a3835b8e3a951d6760a0 Mon Sep 17 00:00:00 2001 From: agarcia Date: Tue, 10 Mar 2020 14:19:40 +0100 Subject: [PATCH 38/75] Support for usernames with character + --- .../lib/resources/files/RemoteFile.java | 23 +-------- .../lib/resources/files/RemoteFileUtil.kt | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFileUtil.kt diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java index e8892e6e..740641aa 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFile.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 @@ -24,7 +24,6 @@ package com.owncloud.android.lib.resources.files; -import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; @@ -41,14 +40,11 @@ import at.bitfire.dav4android.property.owncloud.OCId; import at.bitfire.dav4android.property.owncloud.OCPermissions; import at.bitfire.dav4android.property.owncloud.OCPrivatelink; import at.bitfire.dav4android.property.owncloud.OCSize; -import okhttp3.HttpUrl; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; -import static com.owncloud.android.lib.common.OwnCloudClient.WEBDAV_FILES_PATH_4_0; - /** * Contains the data of a Remote File from a WebDavEntry * @@ -115,7 +111,7 @@ public class RemoteFile implements Parcelable, Serializable { } public RemoteFile(final Response davResource, String userId) { - this(getRemotePathFromUrl(davResource.getHref(), userId)); + this(RemoteFileUtil.Companion.getRemotePathFromUrl(davResource.getHref(), userId)); final List properties = davResource.getProperties(); for (Property property : properties) { @@ -167,21 +163,6 @@ public class RemoteFile implements Parcelable, Serializable { readFromParcel(source); } - /** - * Retrieves a relative path from a remote file url - *

- * Example: url:port/remote.php/dav/files/username/Documents/text.txt => /Documents/text.txt - * - * @param url remote file url - * @param userId file owner - * @return remote relative path of the file - */ - private static String getRemotePathFromUrl(HttpUrl url, String userId) { - final String davFilesPath = WEBDAV_FILES_PATH_4_0 + userId; - final String absoluteDavPath = Uri.decode(url.encodedPath()); - final String pathToOc = absoluteDavPath.split(davFilesPath)[0]; - return absoluteDavPath.replace(pathToOc + davFilesPath, ""); - } /** * Getters and Setters diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFileUtil.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFileUtil.kt new file mode 100644 index 00000000..ace0675b --- /dev/null +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/RemoteFileUtil.kt @@ -0,0 +1,49 @@ +/* ownCloud Android Library is available under MIT license + * Copyright (C) 2020 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.resources.files + +import android.net.Uri +import com.owncloud.android.lib.common.OwnCloudClient +import okhttp3.HttpUrl + +class RemoteFileUtil { + companion object { + /** + * Retrieves a relative path from a remote file url + * + * + * Example: url:port/remote.php/dav/files/username/Documents/text.txt => /Documents/text.txt + * + * @param url remote file url + * @param userId file owner + * @return remote relative path of the file + */ + fun getRemotePathFromUrl(url: HttpUrl, userId: String): String? { + val davFilesPath = OwnCloudClient.WEBDAV_FILES_PATH_4_0 + userId + val absoluteDavPath = Uri.decode(url.encodedPath()) + val pathToOc = absoluteDavPath.split(davFilesPath)[0] + return absoluteDavPath.replace(pathToOc + davFilesPath, "") + } + } +} From 6803a347bf0716b2b98c7769eb48e8d5ba849daa Mon Sep 17 00:00:00 2001 From: Hannes Achleitner Date: Sun, 5 Jan 2020 12:42:25 +0100 Subject: [PATCH 39/75] Update Copyright year to 2020 --- LICENSE.md | 2 +- .../com/owncloud/android/lib/common/OwnCloudClientFactory.java | 2 +- .../owncloud/android/lib/common/accounts/AccountTypeUtils.java | 2 +- .../com/owncloud/android/lib/common/accounts/AccountUtils.java | 2 +- .../lib/common/authentication/OwnCloudBasicCredentials.java | 2 +- .../lib/common/authentication/OwnCloudBearerCredentials.java | 2 +- .../lib/common/authentication/OwnCloudCredentialsFactory.java | 2 +- .../com/owncloud/android/lib/common/http/HttpConstants.java | 2 +- .../com/owncloud/android/lib/common/http/TLSSocketFactory.java | 2 +- .../android/lib/common/http/interceptors/HttpInterceptor.java | 2 +- .../lib/common/http/interceptors/RequestHeaderInterceptor.java | 2 +- .../android/lib/common/http/methods/HttpBaseMethod.java | 2 +- .../android/lib/common/http/methods/nonwebdav/DeleteMethod.java | 2 +- .../android/lib/common/http/methods/nonwebdav/GetMethod.java | 2 +- .../android/lib/common/http/methods/nonwebdav/HttpMethod.java | 2 +- .../android/lib/common/http/methods/nonwebdav/PostMethod.java | 2 +- .../android/lib/common/http/methods/nonwebdav/PutMethod.java | 2 +- .../android/lib/common/http/methods/webdav/CopyMethod.java | 2 +- .../android/lib/common/http/methods/webdav/DavConstants.java | 2 +- .../android/lib/common/http/methods/webdav/DavMethod.java | 2 +- .../android/lib/common/http/methods/webdav/MkColMethod.java | 2 +- .../android/lib/common/http/methods/webdav/MoveMethod.java | 2 +- .../android/lib/common/http/methods/webdav/PropfindMethod.java | 2 +- .../android/lib/common/http/methods/webdav/PutMethod.java | 2 +- .../android/lib/common/network/ChunkFromFileRequestBody.java | 2 +- .../owncloud/android/lib/common/network/FileRequestBody.java | 2 +- .../android/lib/common/operations/RemoteOperationResult.java | 2 +- .../java/com/owncloud/android/lib/common/utils/RandomUtils.java | 2 +- .../src/main/java/com/owncloud/android/lib/resources/Service.kt | 2 +- .../android/lib/resources/files/CopyRemoteFileOperation.java | 2 +- .../lib/resources/files/ExistenceCheckRemoteOperation.java | 2 +- .../com/owncloud/android/lib/resources/files/FileUtils.java | 2 +- .../android/lib/resources/files/MoveRemoteFileOperation.java | 2 +- .../android/lib/resources/files/ReadRemoteFolderOperation.java | 2 +- .../android/lib/resources/files/RemoveRemoteFileOperation.java | 2 +- .../android/lib/resources/files/UploadRemoteFileOperation.java | 2 +- .../files/chunks/ChunkedUploadRemoteFileOperation.java | 2 +- .../files/chunks/CreateRemoteChunkFolderOperation.java | 2 +- .../resources/files/chunks/MoveRemoteChunksFileOperation.java | 2 +- .../files/chunks/RemoveRemoteChunksFolderOperation.java | 2 +- .../android/lib/resources/shares/CreateRemoteShareOperation.kt | 2 +- .../android/lib/resources/shares/GetRemoteShareOperation.java | 2 +- .../android/lib/resources/shares/GetRemoteShareesOperation.kt | 2 +- .../lib/resources/shares/GetRemoteSharesForFileOperation.kt | 2 +- .../com/owncloud/android/lib/resources/shares/RemoteShare.kt | 2 +- .../android/lib/resources/shares/RemoveRemoteShareOperation.kt | 2 +- .../owncloud/android/lib/resources/shares/ShareParserResult.kt | 2 +- .../android/lib/resources/shares/SharePermissionsBuilder.kt | 2 +- .../com/owncloud/android/lib/resources/shares/ShareService.kt | 2 +- .../lib/resources/shares/ShareToRemoteOperationResultParser.kt | 2 +- .../com/owncloud/android/lib/resources/shares/ShareUtils.java | 2 +- .../com/owncloud/android/lib/resources/shares/ShareXMLParser.kt | 2 +- .../com/owncloud/android/lib/resources/shares/ShareeService.kt | 2 +- .../android/lib/resources/shares/UpdateRemoteShareOperation.kt | 2 +- .../owncloud/android/lib/resources/status/CapabilityService.kt | 2 +- .../lib/resources/status/GetRemoteCapabilitiesOperation.kt | 2 +- .../android/lib/resources/status/GetRemoteStatusOperation.java | 2 +- .../owncloud/android/lib/resources/status/RemoteCapability.kt | 2 +- .../lib/resources/users/GetRemoteUserAvatarOperation.java | 2 +- .../android/lib/resources/users/GetRemoteUserInfoOperation.java | 2 +- .../lib/resources/users/GetRemoteUserQuotaOperation.java | 2 +- .../owncloud/android/lib/sampleclient/FilesArrayAdapter.java | 2 +- .../com/owncloud/android/lib/sampleclient/MainActivity.java | 2 +- sample_client/src/main/res/values/setup.xml | 2 +- 64 files changed, 64 insertions(+), 64 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index dd4c419d..d3a33d59 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -2,7 +2,7 @@ ownCloud Android Library is available under MIT license -Copyright (C) 2019 ownCloud GmbH. +Copyright (C) 2020 ownCloud GmbH. Copyright (C) 2012 Bartek Przybylski Permission is hereby granted, free of charge, to any person obtaining a copy 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 99c5641a..d78e4d6a 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountTypeUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountTypeUtils.java index 1d40884e..2c2f2397 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountTypeUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/accounts/AccountTypeUtils.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 47107653..b2ab1880 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 ownCloud GmbH. * Copyright (C) 2012 Bartek Przybylski * * Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java index 29c5ee54..af3e9d75 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java index 573307a0..e455cb39 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java index 6e1172fa..75b523cc 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/authentication/OwnCloudCredentialsFactory.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpConstants.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpConstants.java index 2cd4df0d..aa00a797 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpConstants.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/HttpConstants.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/TLSSocketFactory.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/TLSSocketFactory.java index 9ec8815e..5cff6b43 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/TLSSocketFactory.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/TLSSocketFactory.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/HttpInterceptor.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/HttpInterceptor.java index 55abe84d..b9965548 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/HttpInterceptor.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/HttpInterceptor.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/RequestHeaderInterceptor.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/RequestHeaderInterceptor.java index 5066d607..d7cb6dc4 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/RequestHeaderInterceptor.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/interceptors/RequestHeaderInterceptor.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.java index 1d12c6e1..9dc8de97 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/HttpBaseMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/DeleteMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/DeleteMethod.java index 2d7153f9..42039dde 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/DeleteMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/DeleteMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/GetMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/GetMethod.java index afcf45e5..55022bbe 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/GetMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/GetMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/HttpMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/HttpMethod.java index 30e8c52c..971923b7 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/HttpMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/HttpMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/PostMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/PostMethod.java index a6cc7fc9..1efb26d0 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/PostMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/PostMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/PutMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/PutMethod.java index 67eb4f00..c51a1958 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/PutMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/nonwebdav/PutMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/CopyMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/CopyMethod.java index a3daeba3..718f948c 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/CopyMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/CopyMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/DavConstants.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/DavConstants.java index c1ceacd9..67fd90ba 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/DavConstants.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/DavConstants.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/DavMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/DavMethod.java index a132f528..2e9dee81 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/DavMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/DavMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/MkColMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/MkColMethod.java index 07b6fbfb..9c4a3e34 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/MkColMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/MkColMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/MoveMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/MoveMethod.java index c6e281c1..a57a86b1 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/MoveMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/MoveMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/PropfindMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/PropfindMethod.java index 3e5bb087..6a48fc80 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/PropfindMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/PropfindMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/PutMethod.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/PutMethod.java index 52e33c75..243a4d5a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/PutMethod.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/http/methods/webdav/PutMethod.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java index bf58fa94..53abaf9a 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/ChunkFromFileRequestBody.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java index c7456ca5..63d07bec 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/network/FileRequestBody.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 eacb4e69..0673fc0a 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/RandomUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/RandomUtils.java index be6cd880..f98aad7f 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/RandomUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/common/utils/RandomUtils.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/Service.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/Service.kt index 0fa90756..7b4a62df 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/Service.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/Service.kt @@ -3,7 +3,7 @@ * * @author David González Verdugo * - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 ownCloud GmbH. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java index 258f44bc..2f9e5431 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/CopyRemoteFileOperation.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 a564b2a5..1a21fbf1 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java index b3bbb844..0843783f 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/FileUtils.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java index d131fe67..46181e8f 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/MoveRemoteFileOperation.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 c9046bf5..730bd86b 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 1ae1140d..4789d015 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 1adaa989..939eafee 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 d9ef1180..bbc297c8 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/CreateRemoteChunkFolderOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/CreateRemoteChunkFolderOperation.java index 2c9557e1..fc2d797f 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/CreateRemoteChunkFolderOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/CreateRemoteChunkFolderOperation.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/MoveRemoteChunksFileOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/MoveRemoteChunksFileOperation.java index c60ec12f..767a20b8 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/MoveRemoteChunksFileOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/MoveRemoteChunksFileOperation.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/RemoveRemoteChunksFolderOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/RemoveRemoteChunksFolderOperation.java index e515cd04..16d2b8bd 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/RemoveRemoteChunksFolderOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/files/chunks/RemoveRemoteChunksFolderOperation.java @@ -1,6 +1,6 @@ /* ownCloud Android Library is available under MIT license * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 8250422a..5d5eeb39 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 @@ -2,7 +2,7 @@ * @author masensio * @author David A. Velasco * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH + * Copyright (C) 2020 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 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 432c2d9b..4b815df1 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 @@ -1,7 +1,7 @@ /* ownCloud Android Library is available under MIT license * @author David A. Velasco * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt index af3d85c2..11449fb0 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/GetRemoteShareesOperation.kt @@ -3,7 +3,7 @@ * @author masensio * @author David A. Velasco * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 01b09551..ae09166b 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 @@ -2,7 +2,7 @@ * @author masensio * @author David A. Velasco * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt index 47184f4a..4a306ce1 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoteShare.kt @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt index 59eb8d6e..034be286 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/RemoveRemoteShareOperation.kt @@ -2,7 +2,7 @@ * @author masensio * @author David A. Velasco * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareParserResult.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareParserResult.kt index bd0920a6..dd5f19df 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareParserResult.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareParserResult.kt @@ -1,6 +1,6 @@ /* ownCloud Android Library is available under MIT license * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/SharePermissionsBuilder.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/SharePermissionsBuilder.kt index 2f503ac1..ec166134 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/SharePermissionsBuilder.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/SharePermissionsBuilder.kt @@ -1,6 +1,6 @@ /* ownCloud Android Library is available under MIT license * @author David A. Velasco - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareService.kt index e8b728b3..c0047fa8 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareService.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareService.kt @@ -3,7 +3,7 @@ * * @author David González Verdugo * - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 ownCloud GmbH. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt index 31fcff51..6e55fd51 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareToRemoteOperationResultParser.kt @@ -2,7 +2,7 @@ * @author David A. Velasco * @author David González Verdugo * @author Christian Schabesberger - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java index f09642de..998271ed 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareUtils.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 105fb4d6..ec04a6dd 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareeService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareeService.kt index ba6426dc..8e7c8964 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareeService.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/ShareeService.kt @@ -3,7 +3,7 @@ * * @author David González Verdugo * - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 ownCloud GmbH. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/UpdateRemoteShareOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/UpdateRemoteShareOperation.kt index 41416b1e..0b4a08e5 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/UpdateRemoteShareOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/shares/UpdateRemoteShareOperation.kt @@ -1,6 +1,6 @@ /* ownCloud Android Library is available under MIT license * - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/CapabilityService.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/CapabilityService.kt index 1253f9ca..fab4f301 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/CapabilityService.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/CapabilityService.kt @@ -3,7 +3,7 @@ * * @author David González Verdugo * - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 ownCloud GmbH. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.kt index e3cfc421..12f4a41b 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteCapabilitiesOperation.kt @@ -2,7 +2,7 @@ * @author masensio * @author Semih Serhat Karakaya * @author David González Verdugo - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java index 493e2466..bab59562 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/RemoteCapability.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/RemoteCapability.kt index 6bd51efe..608c3c6f 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/RemoteCapability.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/status/RemoteCapability.kt @@ -2,7 +2,7 @@ * @author masensio * @author David González Verdugo * @author Abel García de Prada - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java index 41d38d0e..e9e78df6 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java @@ -1,6 +1,6 @@ /* ownCloud Android Library is available under MIT license * - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 ec205cdd..dce2096a 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 @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 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 bc6f3964..e4d834d8 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 @@ -1,6 +1,6 @@ /* ownCloud Android Library is available under MIT license * - * Copyright (C) 2019 ownCloud Inc. + * Copyright (C) 2020 ownCloud Inc. * Copyright (C) 2015 Bartosz Przybylski * Copyright (C) 2014 Marcello Steiner * diff --git a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/FilesArrayAdapter.java b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/FilesArrayAdapter.java index 4e942719..29219f21 100644 --- a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/FilesArrayAdapter.java +++ b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/FilesArrayAdapter.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2016 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java index 5439e0ca..bff10fed 100644 --- a/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java +++ b/sample_client/src/main/java/com/owncloud/android/lib/sampleclient/MainActivity.java @@ -1,5 +1,5 @@ /* ownCloud Android Library is available under MIT license - * Copyright (C) 2019 ownCloud GmbH. + * Copyright (C) 2020 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 diff --git a/sample_client/src/main/res/values/setup.xml b/sample_client/src/main/res/values/setup.xml index 1acc5d6e..44734305 100644 --- a/sample_client/src/main/res/values/setup.xml +++ b/sample_client/src/main/res/values/setup.xml @@ -1,6 +1,6 @@