mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Replace log_oc with timber
Finish replacing logOC with timber
This commit is contained in:
parent
2778762217
commit
c5ac449fed
@ -26,8 +26,7 @@ public class DynamicSessionManager implements OwnCloudClientManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context)
|
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context)
|
||||||
throws AccountUtils.AccountNotFoundException,
|
throws OperationCanceledException, AuthenticatorException, IOException {
|
||||||
OperationCanceledException, AuthenticatorException, IOException {
|
|
||||||
|
|
||||||
OwnCloudVersion ownCloudVersion = null;
|
OwnCloudVersion ownCloudVersion = null;
|
||||||
if (account.getSavedAccount() != null) {
|
if (account.getSavedAccount() != null) {
|
||||||
|
@ -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.HttpConstants;
|
||||||
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
|
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
|
||||||
import com.owncloud.android.lib.common.network.RedirectionPath;
|
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.common.utils.RandomUtils;
|
||||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||||
import okhttp3.Cookie;
|
import okhttp3.Cookie;
|
||||||
import okhttp3.Headers;
|
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
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 STATUS_PATH = "/status.php";
|
||||||
public static final String FILES_WEB_PATH = "/index.php/apps/files";
|
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_REDIRECTIONS_COUNT = 3;
|
||||||
private static final int MAX_REPEAT_COUNT_WITH_FRESH_CREDENTIALS = 1;
|
private static final int MAX_REPEAT_COUNT_WITH_FRESH_CREDENTIALS = 1;
|
||||||
|
|
||||||
@ -86,7 +84,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
mBaseUri = baseUri;
|
mBaseUri = baseUri;
|
||||||
|
|
||||||
mInstanceNumber = sIntanceCounter++;
|
mInstanceNumber = sIntanceCounter++;
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber, "Creating OwnCloudClient");
|
Timber.d(" #" + mInstanceNumber + "Creating OwnCloudClient");
|
||||||
|
|
||||||
clearCredentials();
|
clearCredentials();
|
||||||
clearCookies();
|
clearCookies();
|
||||||
@ -163,7 +161,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
// Header to allow tracing requests in apache and ownCloud logs
|
// Header to allow tracing requests in apache and ownCloud logs
|
||||||
addHeaderForAllRequests(OC_X_REQUEST_ID, requestId);
|
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 {
|
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_PERMANENTLY ||
|
||||||
status == HttpConstants.HTTP_MOVED_TEMPORARILY ||
|
status == HttpConstants.HTTP_MOVED_TEMPORARILY ||
|
||||||
status == HttpConstants.HTTP_TEMPORARY_REDIRECT)
|
status == HttpConstants.HTTP_TEMPORARY_REDIRECT)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
final String location = method.getResponseHeader(HttpConstants.LOCATION_HEADER) != null
|
final String location = method.getResponseHeader(HttpConstants.LOCATION_HEADER) != null
|
||||||
? method.getResponseHeader(HttpConstants.LOCATION_HEADER)
|
? method.getResponseHeader(HttpConstants.LOCATION_HEADER)
|
||||||
: method.getResponseHeader(HttpConstants.LOCATION_HEADER_LOWER);
|
: method.getResponseHeader(HttpConstants.LOCATION_HEADER_LOWER);
|
||||||
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber,
|
Timber.d("#" + mInstanceNumber + "Location to redirect: " + location);
|
||||||
"Location to redirect: " + location);
|
|
||||||
|
|
||||||
redirectionPath.addLocation(location);
|
redirectionPath.addLocation(location);
|
||||||
|
|
||||||
@ -216,7 +213,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
redirectionsCount++;
|
redirectionsCount++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log_OC.d(TAG + " #" + mInstanceNumber, "No location to redirect!");
|
Timber.d(" #" + mInstanceNumber + "No location to redirect!");
|
||||||
status = HttpConstants.HTTP_NOT_FOUND;
|
status = HttpConstants.HTTP_NOT_FOUND;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,8 +234,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
responseBodyAsStream.close();
|
responseBodyAsStream.close();
|
||||||
|
|
||||||
} catch (IOException io) {
|
} catch (IOException io) {
|
||||||
Log_OC.e(TAG, "Unexpected exception while exhausting not interesting HTTP response;" +
|
Timber.e(io, "Unexpected exception while exhausting not interesting HTTP response; will be IGNORED");
|
||||||
" will be IGNORED", io);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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() {
|
public String getCookiesString() {
|
||||||
StringBuilder cookiesString = new StringBuilder();
|
StringBuilder cookiesString = new StringBuilder();
|
||||||
List<Cookie> cookieList = getCookiesFromUrl(HttpUrl.parse(mBaseUri.toString()));
|
List<Cookie> cookieList = getCookiesFromUrl(HttpUrl.parse(mBaseUri.toString()));
|
||||||
@ -392,11 +356,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
credentialsWereRefreshed = true;
|
credentialsWereRefreshed = true;
|
||||||
|
|
||||||
} catch (AccountsException | IOException e) {
|
} catch (AccountsException | IOException e) {
|
||||||
Log_OC.e(
|
Timber.e(e, "Error while trying to refresh auth token for %s", mAccount.getSavedAccount().name);
|
||||||
TAG,
|
|
||||||
"Error while trying to refresh auth token for " + mAccount.getSavedAccount().name,
|
|
||||||
e
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,10 +411,6 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OwnCloudClientManager getOwnCloudClientManager() {
|
|
||||||
return mOwnCloudClientManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOwnCloudClientManager(OwnCloudClientManager clientManager) {
|
void setOwnCloudClientManager(OwnCloudClientManager clientManager) {
|
||||||
mOwnCloudClientManager = clientManager;
|
mOwnCloudClientManager = clientManager;
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,6 @@ import android.net.Uri;
|
|||||||
|
|
||||||
public class OwnCloudClientFactory {
|
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
|
* Creates a OwnCloudClient to access a URL and sets the desired parameters for ownCloud
|
||||||
* client connections.
|
* client connections.
|
||||||
@ -49,4 +47,4 @@ public class OwnCloudClientFactory {
|
|||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,31 +29,25 @@ import android.accounts.OperationCanceledException;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
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;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class SimpleFactoryManager implements OwnCloudClientManager {
|
public class SimpleFactoryManager implements OwnCloudClientManager {
|
||||||
|
|
||||||
private static final String TAG = SimpleFactoryManager.class.getSimpleName();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws
|
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws
|
||||||
OperationCanceledException, AuthenticatorException, IOException {
|
OperationCanceledException, AuthenticatorException, IOException {
|
||||||
|
|
||||||
Log_OC.d(TAG, "getClientFor(OwnCloudAccount ... : ");
|
Timber.d("getClientFor(OwnCloudAccount ... : ");
|
||||||
|
|
||||||
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(
|
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(
|
||||||
account.getBaseUri(),
|
account.getBaseUri(),
|
||||||
context.getApplicationContext(),
|
context.getApplicationContext(),
|
||||||
true);
|
true);
|
||||||
|
|
||||||
Log_OC.v(TAG, " new client {" +
|
Timber.v(" new client {" + (account.getName() != null ? account.getName() :
|
||||||
(account.getName() != null ?
|
AccountUtils.buildAccountName(account.getBaseUri(), "")) + ", " + client.hashCode() + "}");
|
||||||
account.getName() :
|
|
||||||
AccountUtils.buildAccountName(account.getBaseUri(), "")
|
|
||||||
|
|
||||||
) + ", " + client.hashCode() + "}");
|
|
||||||
|
|
||||||
if (account.getCredentials() == null) {
|
if (account.getCredentials() == null) {
|
||||||
account.loadCredentials(context);
|
account.loadCredentials(context);
|
||||||
@ -75,5 +69,4 @@ public class SimpleFactoryManager implements OwnCloudClientManager {
|
|||||||
public void saveAllClients(Context context, String accountType) {
|
public void saveAllClients(Context context, String accountType) {
|
||||||
// nothing to do - not taking care of tracking instances!
|
// nothing to do - not taking care of tracking instances!
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,10 @@ import android.accounts.AuthenticatorException;
|
|||||||
import android.accounts.OperationCanceledException;
|
import android.accounts.OperationCanceledException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||||
import com.owncloud.android.lib.common.http.HttpClient;
|
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.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -54,8 +53,6 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
|
|
||||||
public class SingleSessionManager implements OwnCloudClientManager {
|
public class SingleSessionManager implements OwnCloudClientManager {
|
||||||
|
|
||||||
private static final String TAG = SingleSessionManager.class.getSimpleName();
|
|
||||||
|
|
||||||
private ConcurrentMap<String, OwnCloudClient> mClientsWithKnownUsername = new ConcurrentHashMap<>();
|
private ConcurrentMap<String, OwnCloudClient> mClientsWithKnownUsername = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private ConcurrentMap<String, OwnCloudClient> mClientsWithUnknownUsername = new ConcurrentHashMap<>();
|
private ConcurrentMap<String, OwnCloudClient> mClientsWithUnknownUsername = new ConcurrentHashMap<>();
|
||||||
@ -64,9 +61,7 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
|||||||
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws OperationCanceledException,
|
public OwnCloudClient getClientFor(OwnCloudAccount account, Context context) throws OperationCanceledException,
|
||||||
AuthenticatorException, IOException {
|
AuthenticatorException, IOException {
|
||||||
|
|
||||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
Timber.d("getClientFor starting ");
|
||||||
Log_OC.d(TAG, "getClientFor starting ");
|
|
||||||
}
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
throw new IllegalArgumentException("Cannot get an OwnCloudClient for a null account");
|
throw new IllegalArgumentException("Cannot get an OwnCloudClient for a null account");
|
||||||
}
|
}
|
||||||
@ -84,21 +79,16 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
|||||||
if (accountName != null) {
|
if (accountName != null) {
|
||||||
client = mClientsWithUnknownUsername.remove(sessionName);
|
client = mClientsWithUnknownUsername.remove(sessionName);
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
Timber.v("reusing client for session %s", sessionName);
|
||||||
Log_OC.v(TAG, "reusing client for session " + sessionName);
|
|
||||||
}
|
|
||||||
mClientsWithKnownUsername.put(accountName, client);
|
mClientsWithKnownUsername.put(accountName, client);
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
Timber.v("moved client to account %s", accountName);
|
||||||
Log_OC.v(TAG, "moved client to account " + accountName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
client = mClientsWithUnknownUsername.get(sessionName);
|
client = mClientsWithUnknownUsername.get(sessionName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
Timber.v("reusing client for account %s", accountName);
|
||||||
Log_OC.v(TAG, "reusing client for account " + accountName);
|
|
||||||
}
|
|
||||||
reusingKnown = true;
|
reusingKnown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,37 +107,28 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
|||||||
|
|
||||||
if (accountName != null) {
|
if (accountName != null) {
|
||||||
mClientsWithKnownUsername.put(accountName, client);
|
mClientsWithKnownUsername.put(accountName, client);
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
Timber.v("new client for account %s", accountName);
|
||||||
Log_OC.v(TAG, "new client for account " + accountName);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
mClientsWithUnknownUsername.put(sessionName, client);
|
mClientsWithUnknownUsername.put(sessionName, client);
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
Timber.v("new client for session %s", sessionName);
|
||||||
Log_OC.v(TAG, "new client for session " + sessionName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!reusingKnown && Log.isLoggable(TAG, Log.VERBOSE)) {
|
if (!reusingKnown) {
|
||||||
Log_OC.v(TAG, "reusing client for session " + sessionName);
|
Timber.v("reusing client for session %s", sessionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
keepCredentialsUpdated(client);
|
keepCredentialsUpdated(client);
|
||||||
keepCookiesUpdated(context, account, client);
|
keepCookiesUpdated(context, account, client);
|
||||||
keepUriUpdated(account, client);
|
keepUriUpdated(account, client);
|
||||||
}
|
}
|
||||||
|
Timber.d("getClientFor finishing ");
|
||||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
|
||||||
Log_OC.d(TAG, "getClientFor finishing ");
|
|
||||||
}
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OwnCloudClient removeClientFor(OwnCloudAccount account) {
|
public OwnCloudClient removeClientFor(OwnCloudAccount account) {
|
||||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
Timber.d("removeClientFor starting ");
|
||||||
Log_OC.d(TAG, "removeClientFor starting ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -158,31 +139,22 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
|||||||
if (accountName != null) {
|
if (accountName != null) {
|
||||||
client = mClientsWithKnownUsername.remove(accountName);
|
client = mClientsWithKnownUsername.remove(accountName);
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
Timber.v("Removed client for account %s", accountName);
|
||||||
Log_OC.v(TAG, "Removed client for account " + accountName);
|
|
||||||
}
|
|
||||||
return client;
|
return client;
|
||||||
} else {
|
} else {
|
||||||
if (Log.isLoggable(TAG, Log.VERBOSE)) {
|
Timber.v("No client tracked for account %s", accountName);
|
||||||
Log_OC.v(TAG, "No client tracked for account " + accountName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mClientsWithUnknownUsername.clear();
|
mClientsWithUnknownUsername.clear();
|
||||||
|
|
||||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
Timber.d("removeClientFor finishing ");
|
||||||
Log_OC.d(TAG, "removeClientFor finishing ");
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveAllClients(Context context, String accountType) {
|
public void saveAllClients(Context context, String accountType) {
|
||||||
|
Timber.d("Saving sessions... ");
|
||||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
|
||||||
Log_OC.d(TAG, "Saving sessions... ");
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator<String> accountNames = mClientsWithKnownUsername.keySet().iterator();
|
Iterator<String> accountNames = mClientsWithKnownUsername.keySet().iterator();
|
||||||
String accountName;
|
String accountName;
|
||||||
@ -193,9 +165,7 @@ public class SingleSessionManager implements OwnCloudClientManager {
|
|||||||
AccountUtils.saveClient(mClientsWithKnownUsername.get(accountName), account, context);
|
AccountUtils.saveClient(mClientsWithKnownUsername.get(accountName), account, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Log.isLoggable(TAG, Log.DEBUG)) {
|
Timber.d("All sessions saved");
|
||||||
Log_OC.d(TAG, "All sessions saved");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void keepCredentialsUpdated(OwnCloudClient reusedClient) {
|
private void keepCredentialsUpdated(OwnCloudClient reusedClient) {
|
||||||
|
@ -36,10 +36,10 @@ import android.net.Uri;
|
|||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.authentication.OwnCloudCredentials;
|
import com.owncloud.android.lib.common.authentication.OwnCloudCredentials;
|
||||||
import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory;
|
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.files.FileUtils;
|
||||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||||
import okhttp3.Cookie;
|
import okhttp3.Cookie;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -47,8 +47,6 @@ import java.util.List;
|
|||||||
|
|
||||||
public class AccountUtils {
|
public class AccountUtils {
|
||||||
|
|
||||||
private static final String TAG = AccountUtils.class.getSimpleName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs full url to host and webdav resource basing on host version
|
* Constructs full url to host and webdav resource basing on host version
|
||||||
*
|
*
|
||||||
@ -104,7 +102,7 @@ public class AccountUtils {
|
|||||||
try {
|
try {
|
||||||
username = account.name.substring(0, account.name.lastIndexOf('@'));
|
username = account.name.substring(0, account.name.lastIndexOf('@'));
|
||||||
} catch (Exception e) {
|
} 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;
|
return username;
|
||||||
}
|
}
|
||||||
@ -124,7 +122,7 @@ public class AccountUtils {
|
|||||||
version = new OwnCloudVersion(versionString);
|
version = new OwnCloudVersion(versionString);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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;
|
return version;
|
||||||
}
|
}
|
||||||
@ -216,7 +214,7 @@ public class AccountUtils {
|
|||||||
String cookiesString = client.getCookiesString();
|
String cookiesString = client.getCookiesString();
|
||||||
if (!"".equals(cookiesString)) {
|
if (!"".equals(cookiesString)) {
|
||||||
ac.setUserData(savedAccount, Constants.KEY_COOKIES, 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) {
|
public static void restoreCookies(Account account, OwnCloudClient client, Context context) {
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
Log_OC.d(TAG, "Cannot restore cookie for null account");
|
Timber.d("Cannot restore cookie for null account");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log_OC.d(TAG, "Restoring cookies for " + account.name);
|
Timber.d("Restoring cookies for %s", account.name);
|
||||||
|
|
||||||
// Account Manager
|
// Account Manager
|
||||||
AccountManager am = AccountManager.get(context.getApplicationContext());
|
AccountManager am = AccountManager.get(context.getApplicationContext());
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.common.authentication.oauth;
|
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.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -61,7 +61,7 @@ public class OAuth2QueryParser {
|
|||||||
mOAuth2ParsedAuthorizationResponse.put(key, value);
|
mOAuth2ParsedAuthorizationResponse.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_OC.v(TAG, "[" + i + "," + j + "] = " + p);
|
Timber.v("[" + i + "," + j + "] = " + p);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
@ -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.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class OAuth2RefreshAccessTokenOperation extends RemoteOperation<Map<String, String>> {
|
public class OAuth2RefreshAccessTokenOperation extends RemoteOperation<Map<String, String>> {
|
||||||
|
|
||||||
private static final String TAG = OAuth2RefreshAccessTokenOperation.class.getSimpleName();
|
|
||||||
private final String mAccessTokenEndpointPath;
|
private final String mAccessTokenEndpointPath;
|
||||||
private final OAuth2ResponseParser mResponseParser;
|
private final OAuth2ResponseParser mResponseParser;
|
||||||
private String mClientId;
|
private String mClientId;
|
||||||
@ -96,7 +95,7 @@ public class OAuth2RefreshAccessTokenOperation extends RemoteOperation<Map<Strin
|
|||||||
switchClientCredentials(oldCredentials);
|
switchClientCredentials(oldCredentials);
|
||||||
|
|
||||||
final String responseData = postMethod.getResponseBodyAsString();
|
final String responseData = postMethod.getResponseBodyAsString();
|
||||||
Log_OC.d(TAG, "OAUTH2: raw response from POST TOKEN: " + responseData);
|
Timber.d("OAUTH2: raw response from POST TOKEN: %s", responseData);
|
||||||
|
|
||||||
if (responseData != null && responseData.length() > 0) {
|
if (responseData != null && responseData.length() > 0) {
|
||||||
final JSONObject tokenJson = new JSONObject(responseData);
|
final JSONObject tokenJson = new JSONObject(responseData);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.common.authentication.oauth;
|
package com.owncloud.android.lib.common.authentication.oauth;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class OwnCloudOAuth2Provider implements OAuth2Provider {
|
public class OwnCloudOAuth2Provider implements OAuth2Provider {
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public class OwnCloudOAuth2Provider implements OAuth2Provider {
|
|||||||
|
|
||||||
public void setAccessTokenEndpointPath(String accessTokenEndpointPath) {
|
public void setAccessTokenEndpointPath(String accessTokenEndpointPath) {
|
||||||
if (accessTokenEndpointPath == null || accessTokenEndpointPath.length() <= 0) {
|
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;
|
mAccessTokenEndpointPath = ACCESS_TOKEN_ENDPOINT_PATH;
|
||||||
} else {
|
} else {
|
||||||
mAccessTokenEndpointPath = accessTokenEndpointPath;
|
mAccessTokenEndpointPath = accessTokenEndpointPath;
|
||||||
@ -85,7 +85,7 @@ public class OwnCloudOAuth2Provider implements OAuth2Provider {
|
|||||||
|
|
||||||
public void setAuthorizationCodeEndpointPath(String authorizationCodeEndpointPath) {
|
public void setAuthorizationCodeEndpointPath(String authorizationCodeEndpointPath) {
|
||||||
if (authorizationCodeEndpointPath == null || authorizationCodeEndpointPath.length() <= 0) {
|
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;
|
mAuthorizationCodeEndpointPath = AUTHORIZATION_CODE_ENDPOINT_PATH;
|
||||||
} else {
|
} else {
|
||||||
mAuthorizationCodeEndpointPath = authorizationCodeEndpointPath;
|
mAuthorizationCodeEndpointPath = authorizationCodeEndpointPath;
|
||||||
|
@ -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.http.interceptors.RequestHeaderInterceptor;
|
||||||
import com.owncloud.android.lib.common.network.AdvancedX509TrustManager;
|
import com.owncloud.android.lib.common.network.AdvancedX509TrustManager;
|
||||||
import com.owncloud.android.lib.common.network.NetworkUtils;
|
import com.owncloud.android.lib.common.network.NetworkUtils;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import okhttp3.Cookie;
|
import okhttp3.Cookie;
|
||||||
import okhttp3.CookieJar;
|
import okhttp3.CookieJar;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Protocol;
|
import okhttp3.Protocol;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
@ -57,8 +57,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @author David González Verdugo
|
* @author David González Verdugo
|
||||||
*/
|
*/
|
||||||
public class HttpClient {
|
public class HttpClient {
|
||||||
private static final String TAG = HttpClient.class.toString();
|
|
||||||
|
|
||||||
private static OkHttpClient sOkHttpClient;
|
private static OkHttpClient sOkHttpClient;
|
||||||
private static HttpInterceptor sOkHttpInterceptor;
|
private static HttpInterceptor sOkHttpInterceptor;
|
||||||
private static Context sContext;
|
private static Context sContext;
|
||||||
@ -76,10 +74,10 @@ public class HttpClient {
|
|||||||
sslContext = SSLContext.getInstance("TLSv1.2");
|
sslContext = SSLContext.getInstance("TLSv1.2");
|
||||||
} catch (NoSuchAlgorithmException tlsv12Exception) {
|
} catch (NoSuchAlgorithmException tlsv12Exception) {
|
||||||
try {
|
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");
|
sslContext = SSLContext.getInstance("TLSv1.1");
|
||||||
} catch (NoSuchAlgorithmException tlsv11Exception) {
|
} 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");
|
sslContext = SSLContext.getInstance("TLSv1");
|
||||||
// should be available in any device; see reference of supported protocols in
|
// should be available in any device; see reference of supported protocols in
|
||||||
// http://developer.android.com/reference/javax/net/ssl/SSLSocket.html
|
// http://developer.android.com/reference/javax/net/ssl/SSLSocket.html
|
||||||
@ -97,10 +95,8 @@ public class HttpClient {
|
|||||||
@Override
|
@Override
|
||||||
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
|
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
|
||||||
// Avoid duplicated cookies
|
// Avoid duplicated cookies
|
||||||
Set<Cookie> nonDuplicatedCookiesSet = new HashSet<>();
|
Set<Cookie> nonDuplicatedCookiesSet = new HashSet<>(cookies);
|
||||||
nonDuplicatedCookiesSet.addAll(cookies);
|
List<Cookie> nonDuplicatedCookiesList = new ArrayList<>(nonDuplicatedCookiesSet);
|
||||||
List<Cookie> nonDuplicatedCookiesList = new ArrayList<>();
|
|
||||||
nonDuplicatedCookiesList.addAll(nonDuplicatedCookiesSet);
|
|
||||||
|
|
||||||
sCookieStore.put(url.host(), nonDuplicatedCookiesList);
|
sCookieStore.put(url.host(), nonDuplicatedCookiesList);
|
||||||
}
|
}
|
||||||
@ -127,7 +123,7 @@ public class HttpClient {
|
|||||||
sOkHttpClient = clientBuilder.build();
|
sOkHttpClient = clientBuilder.build();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log_OC.e(TAG, "Could not setup SSL system.", e);
|
Timber.e(e, "Could not setup SSL system.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sOkHttpClient;
|
return sOkHttpClient;
|
||||||
@ -171,22 +167,6 @@ public class HttpClient {
|
|||||||
sContext = context;
|
sContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableAutomaticCookiesHandling() {
|
|
||||||
OkHttpClient.Builder clientBuilder = getOkHttpClient().newBuilder();
|
|
||||||
clientBuilder.cookieJar(new CookieJar() {
|
|
||||||
@Override
|
|
||||||
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
|
|
||||||
// DO NOTHING
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Cookie> loadForRequest(HttpUrl url) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
sOkHttpClient = clientBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Cookie> getCookiesFromUrl(HttpUrl httpUrl) {
|
public List<Cookie> getCookiesFromUrl(HttpUrl httpUrl) {
|
||||||
return sCookieStore.get(httpUrl.host());
|
return sCookieStore.get(httpUrl.host());
|
||||||
}
|
}
|
||||||
@ -194,4 +174,4 @@ public class HttpClient {
|
|||||||
public void clearCookies() {
|
public void clearCookies() {
|
||||||
sCookieStore.clear();
|
sCookieStore.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.common.network;
|
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.TrustManager;
|
||||||
import javax.net.ssl.TrustManagerFactory;
|
import javax.net.ssl.TrustManagerFactory;
|
||||||
@ -136,7 +136,7 @@ public class AdvancedX509TrustManager implements X509TrustManager {
|
|||||||
try {
|
try {
|
||||||
return (mKnownServersKeyStore.getCertificateAlias(cert) != null);
|
return (mKnownServersKeyStore.getCertificateAlias(cert) != null);
|
||||||
} catch (KeyStoreException e) {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.common.network;
|
package com.owncloud.android.lib.common.network;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -84,17 +84,17 @@ public class ChunkFromFileRequestBody extends FileRequestBody {
|
|||||||
long maxCount = Math.min(mOffset + mChunkSize, mChannel.size());
|
long maxCount = Math.min(mOffset + mChunkSize, mChannel.size());
|
||||||
while (mChannel.position() < maxCount) {
|
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);
|
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.buffer().write(mBuffer.array(), 0, readCount);
|
||||||
|
|
||||||
sink.flush();
|
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();
|
mBuffer.clear();
|
||||||
if (mTransferred < maxCount) { // condition to avoid accumulate progress for repeated chunks
|
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) {
|
} catch (Exception exception) {
|
||||||
Log_OC.e(exception.getMessage());
|
Timber.e(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,7 @@ package com.owncloud.android.lib.common.network;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import timber.log.Timber;
|
||||||
import org.apache.http.conn.ssl.X509HostnameVerifier;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -42,25 +41,6 @@ import java.security.cert.CertificateException;
|
|||||||
|
|
||||||
public class NetworkUtils {
|
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_FILENAME = "knownServers.bks";
|
||||||
|
|
||||||
private static String LOCAL_TRUSTSTORE_PASSWORD = "password";
|
private static String LOCAL_TRUSTSTORE_PASSWORD = "password";
|
||||||
@ -88,7 +68,7 @@ public class NetworkUtils {
|
|||||||
//mKnownServersStore = KeyStore.getInstance("BKS");
|
//mKnownServersStore = KeyStore.getInstance("BKS");
|
||||||
mKnownServersStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
mKnownServersStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||||
File localTrustStoreFile = new File(context.getFilesDir(), LOCAL_TRUSTSTORE_FILENAME);
|
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()) {
|
if (localTrustStoreFile.exists()) {
|
||||||
InputStream in = new FileInputStream(localTrustStoreFile);
|
InputStream in = new FileInputStream(localTrustStoreFile);
|
||||||
try {
|
try {
|
||||||
@ -109,22 +89,9 @@ public class NetworkUtils {
|
|||||||
|
|
||||||
KeyStore knownServers = getKnownServersStore(context);
|
KeyStore knownServers = getKnownServersStore(context);
|
||||||
knownServers.setCertificateEntry(Integer.toString(cert.hashCode()), cert);
|
knownServers.setCertificateEntry(Integer.toString(cert.hashCode()), cert);
|
||||||
FileOutputStream fos = null;
|
try (FileOutputStream fos = context.openFileOutput(LOCAL_TRUSTSTORE_FILENAME, Context.MODE_PRIVATE)) {
|
||||||
try {
|
|
||||||
fos = context.openFileOutput(LOCAL_TRUSTSTORE_FILENAME, Context.MODE_PRIVATE);
|
|
||||||
knownServers.store(fos, LOCAL_TRUSTSTORE_PASSWORD.toCharArray());
|
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()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.
|
|
||||||
* <p>
|
|
||||||
* Build as a singleton.
|
|
||||||
*
|
|
||||||
* @author David A. Velasco
|
|
||||||
*/
|
|
||||||
public class ServerNameIndicator {
|
|
||||||
|
|
||||||
private static final String TAG = ServerNameIndicator.class.getSimpleName();
|
|
||||||
|
|
||||||
private static final AtomicReference<ServerNameIndicator> mSingleInstance = new AtomicReference<ServerNameIndicator>();
|
|
||||||
|
|
||||||
private static final String METHOD_NAME = "setHostname";
|
|
||||||
|
|
||||||
private final WeakReference<Class<?>> mSSLSocketClassRef;
|
|
||||||
private final WeakReference<Method> 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<Class<?>>(sslSocketClass);
|
|
||||||
mSetHostnameMethodRef = (setHostnameMethod == null) ? null : new WeakReference<Method>(setHostnameMethod);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls the {@code #setHostname(String)} method of the underlying implementation
|
|
||||||
* of {@link SSLSocket} if exists.
|
|
||||||
* <p>
|
|
||||||
* 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.
|
|
||||||
* <p>
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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.
|
|
||||||
* <p>
|
|
||||||
* Built as a singleton.
|
|
||||||
* <p>
|
|
||||||
* Tries to hit something like this:
|
|
||||||
* https://android.googlesource.com/platform/external/conscrypt/+/lollipop-release/src/main/java/org/conscrypt/OpenSSLSocketImpl.java#1005
|
|
||||||
* <p>
|
|
||||||
* Minimizes the chances of getting stalled in PUT/POST request if the network interface is lost while
|
|
||||||
* writing the entity into the outwards sockect.
|
|
||||||
* <p>
|
|
||||||
* 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<WriteTimeoutEnforcer> mSingleInstance = new AtomicReference<>();
|
|
||||||
|
|
||||||
private static final String METHOD_NAME = "setSoWriteTimeout";
|
|
||||||
|
|
||||||
private final WeakReference<Class<?>> mSocketClassRef;
|
|
||||||
private final WeakReference<Method> 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<Class<?>>(socketClass);
|
|
||||||
mSetSoWriteTimeoutMethodRef =
|
|
||||||
(setSoWriteTimeoutMethod == null) ?
|
|
||||||
null :
|
|
||||||
new WeakReference<>(setSoWriteTimeoutMethod)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls the {@code #setSoWrite(int)} method of the underlying implementation
|
|
||||||
* of {@link Socket} if exists.
|
|
||||||
* <p>
|
|
||||||
* 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.
|
|
||||||
* <p>
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -11,8 +11,8 @@ import com.owncloud.android.lib.common.OwnCloudAccount;
|
|||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -27,7 +27,6 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
* OCS API header value
|
* OCS API header value
|
||||||
*/
|
*/
|
||||||
public static final String OCS_API_HEADER_VALUE = "true";
|
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
|
* ownCloud account in the remote ownCloud server to operate
|
||||||
*/
|
*/
|
||||||
@ -41,22 +40,22 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Object to interact with the remote server
|
* Object to interact with the remote server
|
||||||
*/
|
*/
|
||||||
protected OwnCloudClient mClient = null;
|
private OwnCloudClient mClient = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object to interact with the remote server
|
* 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
|
* 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
|
* Handler to the thread where mListener methods will be called
|
||||||
*/
|
*/
|
||||||
protected Handler mListenerHandler = null;
|
private Handler mListenerHandler = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asynchronously executes the remote operation
|
* Asynchronously executes the remote operation
|
||||||
@ -76,12 +75,10 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
OnRemoteOperationListener listener, Handler listenerHandler) {
|
OnRemoteOperationListener listener, Handler listenerHandler) {
|
||||||
|
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
throw new IllegalArgumentException
|
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account");
|
||||||
("Trying to execute a remote operation with a NULL Account");
|
|
||||||
}
|
}
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
throw new IllegalArgumentException
|
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Context");
|
||||||
("Trying to execute a remote operation with a NULL Context");
|
|
||||||
}
|
}
|
||||||
// mAccount and mContext in the runnerThread to create below
|
// mAccount and mContext in the runnerThread to create below
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
@ -109,8 +106,7 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public Thread execute(OwnCloudClient client, OnRemoteOperationListener listener, Handler listenerHandler) {
|
public Thread execute(OwnCloudClient client, OnRemoteOperationListener listener, Handler listenerHandler) {
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
throw new IllegalArgumentException
|
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient");
|
||||||
("Trying to execute a remote operation with a NULL OwnCloudClient");
|
|
||||||
}
|
}
|
||||||
mClient = client;
|
mClient = client;
|
||||||
if (client.getAccount() != null) {
|
if (client.getAccount() != null) {
|
||||||
@ -120,8 +116,7 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
|
|
||||||
if (listener == null) {
|
if (listener == null) {
|
||||||
throw new IllegalArgumentException
|
throw new IllegalArgumentException
|
||||||
("Trying to execute a remote operation asynchronously " +
|
("Trying to execute a remote operation asynchronously without a listener to notify the result");
|
||||||
"without a listener to notify the result");
|
|
||||||
}
|
}
|
||||||
mListener = listener;
|
mListener = listener;
|
||||||
|
|
||||||
@ -134,7 +129,7 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
return runnerThread;
|
return runnerThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void grantOwnCloudClient() throws
|
private void grantOwnCloudClient() throws
|
||||||
AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException {
|
AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException {
|
||||||
if (mClient == null) {
|
if (mClient == null) {
|
||||||
if (mAccount != null && mContext != null) {
|
if (mAccount != null && mContext != null) {
|
||||||
@ -177,12 +172,10 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public RemoteOperationResult<T> execute(Account account, Context context) {
|
public RemoteOperationResult<T> execute(Account account, Context context) {
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account");
|
||||||
"Account");
|
|
||||||
}
|
}
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Context");
|
||||||
"Context");
|
|
||||||
}
|
}
|
||||||
mAccount = account;
|
mAccount = account;
|
||||||
mContext = context.getApplicationContext();
|
mContext = context.getApplicationContext();
|
||||||
@ -192,7 +185,7 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronously executes the remote operation
|
* Synchronously executes the remote operation
|
||||||
*
|
* <p>
|
||||||
* Do not call this method from the main thread.
|
* Do not call this method from the main thread.
|
||||||
*
|
*
|
||||||
* @param client Client object to reach an ownCloud server during the execution of
|
* @param client Client object to reach an ownCloud server during the execution of
|
||||||
@ -201,8 +194,7 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public RemoteOperationResult<T> execute(OwnCloudClient client) {
|
public RemoteOperationResult<T> execute(OwnCloudClient client) {
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient");
|
||||||
"OwnCloudClient");
|
|
||||||
}
|
}
|
||||||
mClient = client;
|
mClient = client;
|
||||||
if (client.getAccount() != null) {
|
if (client.getAccount() != null) {
|
||||||
@ -224,8 +216,7 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public RemoteOperationResult<T> execute(OkHttpClient client, Context context) {
|
public RemoteOperationResult<T> execute(OkHttpClient client, Context context) {
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient");
|
||||||
"OwnCloudClient");
|
|
||||||
}
|
}
|
||||||
mHttpClient = client;
|
mHttpClient = client;
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@ -249,7 +240,7 @@ public abstract class RemoteOperation<T> implements Runnable {
|
|||||||
result = run(mClient);
|
result = run(mClient);
|
||||||
|
|
||||||
} catch (AccountsException | IOException e) {
|
} 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);
|
result = new RemoteOperationResult<>(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.HttpConstants;
|
||||||
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
|
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
|
||||||
import com.owncloud.android.lib.common.network.CertificateCombinedException;
|
import com.owncloud.android.lib.common.network.CertificateCombinedException;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import okhttp3.Headers;
|
import okhttp3.Headers;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import javax.net.ssl.SSLException;
|
import javax.net.ssl.SSLException;
|
||||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||||
@ -60,7 +60,6 @@ public class RemoteOperationResult<T>
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 4968939884332372230L;
|
private static final long serialVersionUID = 4968939884332372230L;
|
||||||
|
|
||||||
private static final String TAG = RemoteOperationResult.class.getSimpleName();
|
|
||||||
private boolean mSuccess = false;
|
private boolean mSuccess = false;
|
||||||
private int mHttpCode = -1;
|
private int mHttpCode = -1;
|
||||||
private String mHttpPhrase = null;
|
private String mHttpPhrase = null;
|
||||||
@ -192,7 +191,7 @@ public class RemoteOperationResult<T>
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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)
|
// mCode stays as set in this(success, httpCode, headers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,11 +292,7 @@ public class RemoteOperationResult<T>
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
mCode = ResultCode.UNHANDLED_HTTP_CODE; // UNKNOWN ERROR
|
mCode = ResultCode.UNHANDLED_HTTP_CODE; // UNKNOWN ERROR
|
||||||
Log_OC.d(TAG,
|
Timber.d("RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + mHttpCode + " " + mHttpPhrase);
|
||||||
"RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " +
|
|
||||||
|
|
||||||
mHttpCode + " " + mHttpPhrase
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,7 +303,6 @@ public class RemoteOperationResult<T>
|
|||||||
*
|
*
|
||||||
* @param bodyResponse okHttp response body
|
* @param bodyResponse okHttp response body
|
||||||
* @param resultCode our own custom result code
|
* @param resultCode our own custom result code
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
private void parseErrorMessageAndSetCode(String bodyResponse, ResultCode resultCode) {
|
private void parseErrorMessageAndSetCode(String bodyResponse, ResultCode resultCode) {
|
||||||
|
|
||||||
@ -317,12 +311,12 @@ public class RemoteOperationResult<T>
|
|||||||
ErrorMessageParser xmlParser = new ErrorMessageParser();
|
ErrorMessageParser xmlParser = new ErrorMessageParser();
|
||||||
try {
|
try {
|
||||||
String errorMessage = xmlParser.parseXMLResponse(is);
|
String errorMessage = xmlParser.parseXMLResponse(is);
|
||||||
if (errorMessage != "" && errorMessage != null) {
|
if (errorMessage != null && !errorMessage.equals("")) {
|
||||||
mCode = resultCode;
|
mCode = resultCode;
|
||||||
mHttpPhrase = errorMessage;
|
mHttpPhrase = errorMessage;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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)
|
// mCode stays as set in this(success, httpCode, headers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,7 +370,7 @@ public class RemoteOperationResult<T>
|
|||||||
previousCause = cause;
|
previousCause = cause;
|
||||||
cause = cause.getCause();
|
cause = cause.getCause();
|
||||||
}
|
}
|
||||||
if (cause != null && cause instanceof CertificateCombinedException) {
|
if (cause instanceof CertificateCombinedException) {
|
||||||
result = (CertificateCombinedException) cause;
|
result = (CertificateCombinedException) cause;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -13,7 +13,7 @@ object LoggingHelper {
|
|||||||
}
|
}
|
||||||
if (!directory.exists())
|
if (!directory.exists())
|
||||||
directory.mkdirs()
|
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() {
|
fun stopLogging() {
|
||||||
|
@ -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.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
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 com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -47,8 +47,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class CreateRemoteFolderOperation extends RemoteOperation {
|
public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||||
|
|
||||||
private static final String TAG = CreateRemoteFolderOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
private static final int READ_TIMEOUT = 30000;
|
private static final int READ_TIMEOUT = 30000;
|
||||||
private static final int CONNECTION_TIMEOUT = 5000;
|
private static final int CONNECTION_TIMEOUT = 5000;
|
||||||
|
|
||||||
@ -108,12 +106,12 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
|||||||
result = (status == HttpConstants.HTTP_CREATED)
|
result = (status == HttpConstants.HTTP_CREATED)
|
||||||
? new RemoteOperationResult<>(ResultCode.OK)
|
? new RemoteOperationResult<>(ResultCode.OK)
|
||||||
: new RemoteOperationResult<>(mkcol);
|
: new RemoteOperationResult<>(mkcol);
|
||||||
Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
|
Timber.d("Create directory " + mRemotePath + ": " + result.getLogMessage());
|
||||||
client.exhaustResponse(mkcol.getResponseBodyAsStream());
|
client.exhaustResponse(mkcol.getResponseBodyAsStream());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(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;
|
return result;
|
||||||
|
@ -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.OperationCancelledException;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
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.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -53,7 +53,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
public class DownloadRemoteFileOperation extends RemoteOperation {
|
public class DownloadRemoteFileOperation extends RemoteOperation {
|
||||||
|
|
||||||
private static final String TAG = DownloadRemoteFileOperation.class.getSimpleName();
|
|
||||||
private static final int FORBIDDEN_ERROR = 403;
|
private static final int FORBIDDEN_ERROR = 403;
|
||||||
private static final int SERVICE_UNAVAILABLE_ERROR = 503;
|
private static final int SERVICE_UNAVAILABLE_ERROR = 503;
|
||||||
private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
|
private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
|
||||||
@ -81,13 +80,11 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
|||||||
try {
|
try {
|
||||||
tmpFile.getParentFile().mkdirs();
|
tmpFile.getParentFile().mkdirs();
|
||||||
result = downloadFile(client, tmpFile);
|
result = downloadFile(client, tmpFile);
|
||||||
Log_OC.i(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " +
|
Timber.i("Download of " + mRemotePath + " to " + getTmpPath() + ": " + result.getLogMessage());
|
||||||
result.getLogMessage());
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(e);
|
result = new RemoteOperationResult<>(e);
|
||||||
Log_OC.e(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " +
|
Timber.e(e, "Download of " + mRemotePath + " to " + getTmpPath() + ": " + result.getLogMessage());
|
||||||
result.getLogMessage(), e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -149,7 +146,7 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
|||||||
final Date d = WebdavUtils.parseResponseDate(modificationTime);
|
final Date d = WebdavUtils.parseResponseDate(modificationTime);
|
||||||
mModificationTimestamp = (d != null) ? d.getTime() : 0;
|
mModificationTimestamp = (d != null) ? d.getTime() : 0;
|
||||||
} else {
|
} 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);
|
mEtag = WebdavUtils.getEtagFromResponse(mGet);
|
||||||
@ -158,7 +155,7 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
|||||||
mEtag = mEtag.replace("\"", "");
|
mEtag = mEtag.replace("\"", "");
|
||||||
|
|
||||||
if (mEtag.length() == 0) {
|
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 {
|
} else {
|
||||||
|
@ -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.network.WebdavUtils;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
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.net.URL;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -52,8 +52,6 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation {
|
|||||||
*/
|
*/
|
||||||
public static final int TIMEOUT = 10000;
|
public static final int TIMEOUT = 10000;
|
||||||
|
|
||||||
private static final String TAG = ExistenceCheckRemoteOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
private String mPath;
|
private String mPath;
|
||||||
private boolean mSuccessIfAbsent;
|
private boolean mSuccessIfAbsent;
|
||||||
private boolean mIsLogin;
|
private boolean mIsLogin;
|
||||||
@ -103,13 +101,13 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation {
|
|||||||
status = mRedirectionPath.getLastStatus();
|
status = mRedirectionPath.getLastStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* PROPFIND method
|
* PROPFIND method
|
||||||
* 404 NOT FOUND: path doesn't exist,
|
* 404 NOT FOUND: path doesn't exist,
|
||||||
* 207 MULTI_STATUS: path exists.
|
* 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 ") +
|
" targeting for " + (mSuccessIfAbsent ? " absence " : " existence ") +
|
||||||
"finished with HTTP status " + status + (!isSuccess(status) ? "(FAIL)" : ""));
|
"finished with HTTP status " + status + (!isSuccess(status) ? "(FAIL)" : ""));
|
||||||
|
|
||||||
@ -119,10 +117,9 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
final RemoteOperationResult result = new RemoteOperationResult<>(e);
|
final RemoteOperationResult result = new RemoteOperationResult<>(e);
|
||||||
Log_OC.e(TAG, "Existence check for " + client.getUserFilesWebDavUri() +
|
Timber.e(result.getException(),
|
||||||
WebdavUtils.encodePath(mPath) + " targeting for " +
|
"Existence check for " + client.getUserFilesWebDavUri() + WebdavUtils.encodePath(mPath) + " " +
|
||||||
(mSuccessIfAbsent ? " absence " : " existence ") + ": " +
|
"targeting for " + (mSuccessIfAbsent ? " absence " : " existence ") + ": " + result.getLogMessage());
|
||||||
result.getLogMessage(), result.getException());
|
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
client.setFollowRedirects(previousFollowRedirects);
|
client.setFollowRedirects(previousFollowRedirects);
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
package com.owncloud.android.lib.resources.files;
|
package com.owncloud.android.lib.resources.files;
|
||||||
|
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@ -32,7 +32,6 @@ public class FileUtils {
|
|||||||
|
|
||||||
public static final String PATH_SEPARATOR = "/";
|
public static final String PATH_SEPARATOR = "/";
|
||||||
public static final String FINAL_CHUNKS_FILE = ".file";
|
public static final String FINAL_CHUNKS_FILE = ".file";
|
||||||
private static final String TAG = FileUtils.class.getSimpleName();
|
|
||||||
|
|
||||||
public static String getParentPath(String remotePath) {
|
public static String getParentPath(String remotePath) {
|
||||||
String parentPath = new File(remotePath).getParent();
|
String parentPath = new File(remotePath).getParent();
|
||||||
@ -43,15 +42,11 @@ public class FileUtils {
|
|||||||
/**
|
/**
|
||||||
* Validate the fileName to detect if contains any forbidden character: / , \ , < , > ,
|
* Validate the fileName to detect if contains any forbidden character: / , \ , < , > ,
|
||||||
* : , " , | , ? , *
|
* : , " , | , ? , *
|
||||||
*
|
|
||||||
* @param fileName
|
|
||||||
* @param versionSupportsForbiddenChars
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static boolean isValidName(String fileName, boolean versionSupportsForbiddenChars) {
|
public static boolean isValidName(String fileName, boolean versionSupportsForbiddenChars) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
|
||||||
Log_OC.d(TAG, "fileName =======" + fileName);
|
Timber.d("fileName =======%s", fileName);
|
||||||
if ((versionSupportsForbiddenChars && fileName.contains(PATH_SEPARATOR)) ||
|
if ((versionSupportsForbiddenChars && fileName.contains(PATH_SEPARATOR)) ||
|
||||||
(!versionSupportsForbiddenChars && (fileName.contains(PATH_SEPARATOR) ||
|
(!versionSupportsForbiddenChars && (fileName.contains(PATH_SEPARATOR) ||
|
||||||
fileName.contains("\\") || fileName.contains("<") || fileName.contains(">") ||
|
fileName.contains("\\") || fileName.contains("<") || fileName.contains(">") ||
|
||||||
@ -66,14 +61,11 @@ public class FileUtils {
|
|||||||
/**
|
/**
|
||||||
* Validate the path to detect if contains any forbidden character: \ , < , > , : , " , | ,
|
* Validate the path to detect if contains any forbidden character: \ , < , > , : , " , | ,
|
||||||
* ? , *
|
* ? , *
|
||||||
*
|
|
||||||
* @param path
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static boolean isValidPath(String path, boolean versionSupportsForbidenChars) {
|
public static boolean isValidPath(String path, boolean versionSupportsForbidenChars) {
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
|
||||||
Log_OC.d(TAG, "path ....... " + path);
|
Timber.d("path ....... %s", path);
|
||||||
if (!versionSupportsForbidenChars &&
|
if (!versionSupportsForbidenChars &&
|
||||||
(path.contains("\\") || path.contains("<") || path.contains(">") ||
|
(path.contains("\\") || path.contains("<") || path.contains(">") ||
|
||||||
path.contains(":") || path.contains("\"") || path.contains("|") ||
|
path.contains(":") || path.contains("\"") || path.contains("|") ||
|
||||||
|
@ -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.network.WebdavUtils;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
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.net.URL;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -49,7 +49,6 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R
|
|||||||
|
|
||||||
public class ReadRemoteFileOperation extends RemoteOperation<RemoteFile> {
|
public class ReadRemoteFileOperation extends RemoteOperation<RemoteFile> {
|
||||||
|
|
||||||
private static final String TAG = ReadRemoteFileOperation.class.getSimpleName();
|
|
||||||
private static final int SYNC_READ_TIMEOUT = 40000;
|
private static final int SYNC_READ_TIMEOUT = 40000;
|
||||||
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
private static final int SYNC_CONNECTION_TIMEOUT = 5000;
|
||||||
|
|
||||||
@ -101,8 +100,7 @@ public class ReadRemoteFileOperation extends RemoteOperation<RemoteFile> {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(e);
|
result = new RemoteOperationResult<>(e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log_OC.e(TAG, "Synchronizing file " + mRemotePath + ": " + result.getLogMessage(),
|
Timber.e(result.getException(), "Synchronizing file " + mRemotePath + ": " + result.getLogMessage());
|
||||||
result.getException());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -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.network.WebdavUtils;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
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.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -51,8 +51,6 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R
|
|||||||
|
|
||||||
public class ReadRemoteFolderOperation extends RemoteOperation<ArrayList<RemoteFile>> {
|
public class ReadRemoteFolderOperation extends RemoteOperation<ArrayList<RemoteFile>> {
|
||||||
|
|
||||||
private static final String TAG = ReadRemoteFolderOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
private String mRemotePath;
|
private String mRemotePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,13 +107,12 @@ public class ReadRemoteFolderOperation extends RemoteOperation<ArrayList<RemoteF
|
|||||||
result = new RemoteOperationResult<>(e);
|
result = new RemoteOperationResult<>(e);
|
||||||
} finally {
|
} finally {
|
||||||
if (result.isSuccess()) {
|
if (result.isSuccess()) {
|
||||||
Log_OC.i(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage());
|
Timber.i("Synchronized " + mRemotePath + ": " + result.getLogMessage());
|
||||||
} else {
|
} else {
|
||||||
if (result.isException()) {
|
if (result.isException()) {
|
||||||
Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage(),
|
Timber.e(result.getException(), "Synchronized " + mRemotePath + ": " + result.getLogMessage());
|
||||||
result.getException());
|
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage());
|
Timber.e("Synchronized " + mRemotePath + ": " + result.getLogMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.network.WebdavUtils;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
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.net.URL;
|
||||||
|
|
||||||
@ -46,7 +46,6 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R
|
|||||||
* @author David González Verdugo
|
* @author David González Verdugo
|
||||||
*/
|
*/
|
||||||
public class RemoveRemoteFileOperation extends RemoteOperation {
|
public class RemoveRemoteFileOperation extends RemoteOperation {
|
||||||
private static final String TAG = RemoveRemoteFileOperation.class.getSimpleName();
|
|
||||||
private String mRemotePath;
|
private String mRemotePath;
|
||||||
|
|
||||||
protected boolean removeChunksFolder = false;
|
protected boolean removeChunksFolder = false;
|
||||||
@ -81,11 +80,11 @@ public class RemoveRemoteFileOperation extends RemoteOperation {
|
|||||||
new RemoteOperationResult<>(OK) :
|
new RemoteOperationResult<>(OK) :
|
||||||
new RemoteOperationResult<>(deleteMethod);
|
new RemoteOperationResult<>(deleteMethod);
|
||||||
|
|
||||||
Log_OC.i(TAG, "Remove " + mRemotePath + ": " + result.getLogMessage());
|
Timber.i("Remove " + mRemotePath + ": " + result.getLogMessage());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(e);
|
result = new RemoteOperationResult<>(e);
|
||||||
Log_OC.e(TAG, "Remove " + mRemotePath + ": " + result.getLogMessage(), e);
|
Timber.e(e, "Remove " + mRemotePath + ": " + result.getLogMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -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.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
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 com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -46,8 +46,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class RenameRemoteFileOperation extends RemoteOperation {
|
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_READ_TIMEOUT = 600000;
|
||||||
private static final int RENAME_CONNECTION_TIMEOUT = 5000;
|
private static final int RENAME_CONNECTION_TIMEOUT = 5000;
|
||||||
|
|
||||||
@ -117,16 +115,14 @@ public class RenameRemoteFileOperation extends RemoteOperation {
|
|||||||
? new RemoteOperationResult<>(ResultCode.OK)
|
? new RemoteOperationResult<>(ResultCode.OK)
|
||||||
: new RemoteOperationResult<>(move);
|
: new RemoteOperationResult<>(move);
|
||||||
|
|
||||||
Log_OC.i(TAG, "Rename " + mOldRemotePath + " to " + mNewRemotePath + ": " +
|
Timber.i("Rename " + mOldRemotePath + " to " + mNewRemotePath + ": " + result.getLogMessage());
|
||||||
result.getLogMessage()
|
|
||||||
);
|
|
||||||
client.exhaustResponse(move.getResponseBodyAsStream());
|
client.exhaustResponse(move.getResponseBodyAsStream());
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
final RemoteOperationResult result = new RemoteOperationResult<>(e);
|
final RemoteOperationResult result = new RemoteOperationResult<>(e);
|
||||||
Log_OC.e(TAG, "Rename " + mOldRemotePath + " to " +
|
Timber.e(e,
|
||||||
((mNewRemotePath == null) ? mNewName : mNewRemotePath) + ": " +
|
"Rename " + mOldRemotePath + " to " + ((mNewRemotePath == null) ? mNewName : mNewRemotePath) + ":" +
|
||||||
result.getLogMessage(), e);
|
" " + result.getLogMessage());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.OperationCancelledException;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -54,7 +54,6 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R
|
|||||||
|
|
||||||
public class UploadRemoteFileOperation extends RemoteOperation {
|
public class UploadRemoteFileOperation extends RemoteOperation {
|
||||||
|
|
||||||
private static final String TAG = UploadRemoteFileOperation.class.getSimpleName();
|
|
||||||
protected final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
|
protected final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
|
||||||
protected String mLocalPath;
|
protected String mLocalPath;
|
||||||
protected String mRemotePath;
|
protected String mRemotePath;
|
||||||
@ -62,7 +61,7 @@ public class UploadRemoteFileOperation extends RemoteOperation {
|
|||||||
protected String mFileLastModifTimestamp;
|
protected String mFileLastModifTimestamp;
|
||||||
protected PutMethod mPutMethod = null;
|
protected PutMethod mPutMethod = null;
|
||||||
protected String mRequiredEtag = null;
|
protected String mRequiredEtag = null;
|
||||||
protected Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>();
|
protected Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<>();
|
||||||
|
|
||||||
protected FileRequestBody mFileRequestBody = null;
|
protected FileRequestBody mFileRequestBody = null;
|
||||||
|
|
||||||
@ -96,27 +95,25 @@ public class UploadRemoteFileOperation extends RemoteOperation {
|
|||||||
} else {
|
} else {
|
||||||
// perform the upload
|
// perform the upload
|
||||||
result = uploadFile(client);
|
result = uploadFile(client);
|
||||||
Log_OC.i(TAG, "Upload of " + mLocalPath + " to " + mRemotePath + ": " +
|
Timber.i("Upload of " + mLocalPath + " to " + mRemotePath + ": " + result.getLogMessage());
|
||||||
result.getLogMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (mPutMethod != null && mPutMethod.isAborted()) {
|
if (mPutMethod != null && mPutMethod.isAborted()) {
|
||||||
result = new RemoteOperationResult<>(new OperationCancelledException());
|
result = new RemoteOperationResult<>(new OperationCancelledException());
|
||||||
Log_OC.e(TAG, "Upload of " + mLocalPath + " to " + mRemotePath + ": " +
|
Timber.e(result.getException(),
|
||||||
result.getLogMessage(), new OperationCancelledException());
|
"Upload of " + mLocalPath + " to " + mRemotePath + ": " + result.getLogMessage());
|
||||||
} else {
|
} else {
|
||||||
result = new RemoteOperationResult<>(e);
|
result = new RemoteOperationResult<>(e);
|
||||||
Log_OC.e(TAG, "Upload of " + mLocalPath + " to " + mRemotePath + ": " +
|
Timber.e(e, "Upload of " + mLocalPath + " to " + mRemotePath + ": " + result.getLogMessage());
|
||||||
result.getLogMessage(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RemoteOperationResult<? extends Object> uploadFile(OwnCloudClient client) throws Exception {
|
protected RemoteOperationResult<?> uploadFile(OwnCloudClient client) throws Exception {
|
||||||
|
|
||||||
File fileToUpload = new File(mLocalPath);
|
File fileToUpload = new File(mLocalPath);
|
||||||
|
|
||||||
|
@ -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.network.ChunkFromFileRequestBody;
|
||||||
import com.owncloud.android.lib.common.operations.OperationCancelledException;
|
import com.owncloud.android.lib.common.operations.OperationCancelledException;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
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.FileUtils;
|
||||||
import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
|
import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
@ -53,7 +53,6 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
|
|||||||
|
|
||||||
public static final long CHUNK_SIZE = 1024000;
|
public static final long CHUNK_SIZE = 1024000;
|
||||||
private static final int LAST_CHUNK_TIMEOUT = 900000; //15 mins.
|
private static final int LAST_CHUNK_TIMEOUT = 900000; //15 mins.
|
||||||
private static final String TAG = ChunkedUploadRemoteFileOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
private String mTransferId;
|
private String mTransferId;
|
||||||
|
|
||||||
@ -113,7 +112,7 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
|
|||||||
|
|
||||||
status = client.executeHttpMethod(mPutMethod);
|
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 +
|
", chunk index " + chunkIndex + ", count " + chunkCount +
|
||||||
", HTTP result status " + status);
|
", HTTP result status " + status);
|
||||||
|
|
||||||
|
@ -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.http.methods.nonwebdav.PostMethod
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation
|
import com.owncloud.android.lib.common.operations.RemoteOperation
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
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 com.owncloud.android.lib.resources.shares.RemoteShare.Companion.INIT_EXPIRATION_DATE_IN_MILLIS
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
|
import timber.log.Timber
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
@ -150,7 +150,7 @@ class CreateRemoteShareOperation(
|
|||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
result = RemoteOperationResult(e)
|
result = RemoteOperationResult(e)
|
||||||
Log_OC.e(TAG, "Exception while Creating New Share", e)
|
Timber.e(e, "Exception while Creating New Share")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -159,8 +159,6 @@ class CreateRemoteShareOperation(
|
|||||||
private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK
|
private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val TAG = CreateRemoteShareOperation::class.java.simpleName
|
|
||||||
|
|
||||||
private const val PARAM_NAME = "name"
|
private const val PARAM_NAME = "name"
|
||||||
private const val PARAM_PASSWORD = "password"
|
private const val PARAM_PASSWORD = "password"
|
||||||
private const val PARAM_EXPIRATION_DATE = "expireDate"
|
private const val PARAM_EXPIRATION_DATE = "expireDate"
|
||||||
|
@ -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.http.methods.nonwebdav.GetMethod;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
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.net.URL;
|
||||||
|
|
||||||
@ -46,8 +46,6 @@ import java.net.URL;
|
|||||||
|
|
||||||
public class GetRemoteShareOperation extends RemoteOperation<ShareParserResult> {
|
public class GetRemoteShareOperation extends RemoteOperation<ShareParserResult> {
|
||||||
|
|
||||||
private static final String TAG = GetRemoteShareOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
private long mRemoteId;
|
private long mRemoteId;
|
||||||
|
|
||||||
public GetRemoteShareOperation(long remoteId) {
|
public GetRemoteShareOperation(long remoteId) {
|
||||||
@ -85,7 +83,7 @@ public class GetRemoteShareOperation extends RemoteOperation<ShareParserResult>
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(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;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -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.RemoteOperation
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import timber.log.Timber
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
@ -95,13 +95,13 @@ class GetRemoteShareesOperation
|
|||||||
|
|
||||||
val getMethod = GetMethod(URL(uriBuilder.build().toString()))
|
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 status = client.executeHttpMethod(getMethod)
|
||||||
val response = getMethod.responseBodyAsString
|
val response = getMethod.responseBodyAsString
|
||||||
|
|
||||||
if (isSuccess(status)) {
|
if (isSuccess(status)) {
|
||||||
Log_OC.d(TAG, "Successful response: " + response!!)
|
Timber.d("Successful response: $response")
|
||||||
|
|
||||||
// Parse the response
|
// Parse the response
|
||||||
val respJSON = JSONObject(response)
|
val respJSON = JSONObject(response)
|
||||||
@ -128,65 +128,61 @@ class GetRemoteShareesOperation
|
|||||||
for (j in 0 until jsonResults[i].length()) {
|
for (j in 0 until jsonResults[i].length()) {
|
||||||
val jsonResult = jsonResults[i].getJSONObject(j)
|
val jsonResult = jsonResults[i].getJSONObject(j)
|
||||||
data.add(jsonResult)
|
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 = RemoteOperationResult(OK)
|
||||||
result.data = data
|
result.data = data
|
||||||
|
|
||||||
Log_OC.d(TAG, "*** Get Users or groups completed ")
|
Timber.d("*** Get Users or groups completed ")
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result = RemoteOperationResult(getMethod)
|
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) {
|
if (response != null) {
|
||||||
Log_OC.e(TAG, "*** status code: $status; response message: $response")
|
Timber.e("*** status code: $status; response message: $response")
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "*** status code: $status")
|
Timber.e("*** status code: $status")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
result = RemoteOperationResult(e)
|
result = RemoteOperationResult(e)
|
||||||
Log_OC.e(TAG, "Exception while getting users/groups", e)
|
Timber.e(e, "Exception while getting users/groups")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isSuccess(status: Int): Boolean {
|
private fun isSuccess(status: Int) = status == HttpConstants.HTTP_OK
|
||||||
return status == HttpConstants.HTTP_OK
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val TAG = GetRemoteShareesOperation::class.java.simpleName
|
|
||||||
|
|
||||||
// OCS Routes
|
// 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
|
// Arguments - names
|
||||||
private val PARAM_FORMAT = "format"
|
private const val PARAM_FORMAT = "format"
|
||||||
private val PARAM_ITEM_TYPE = "itemType"
|
private const val PARAM_ITEM_TYPE = "itemType"
|
||||||
private val PARAM_SEARCH = "search"
|
private const val PARAM_SEARCH = "search"
|
||||||
private val PARAM_PAGE = "page" // default = 1
|
private const val PARAM_PAGE = "page" // default = 1
|
||||||
private val PARAM_PER_PAGE = "perPage" // default = 200
|
private const val PARAM_PER_PAGE = "perPage" // default = 200
|
||||||
|
|
||||||
// Arguments - constant values
|
// Arguments - constant values
|
||||||
private val VALUE_FORMAT = "json"
|
private const val VALUE_FORMAT = "json"
|
||||||
private val VALUE_ITEM_TYPE = "file" // to get the server search for users / groups
|
private const val VALUE_ITEM_TYPE = "file" // to get the server search for users / groups
|
||||||
|
|
||||||
// JSON Node names
|
// JSON Node names
|
||||||
private val NODE_OCS = "ocs"
|
private const val NODE_OCS = "ocs"
|
||||||
private val NODE_DATA = "data"
|
private const val NODE_DATA = "data"
|
||||||
private val NODE_EXACT = "exact"
|
private const val NODE_EXACT = "exact"
|
||||||
private val NODE_USERS = "users"
|
private const val NODE_USERS = "users"
|
||||||
private val NODE_GROUPS = "groups"
|
private const val NODE_GROUPS = "groups"
|
||||||
private val NODE_REMOTES = "remotes"
|
private const val NODE_REMOTES = "remotes"
|
||||||
val NODE_VALUE = "value"
|
const val NODE_VALUE = "value"
|
||||||
val PROPERTY_LABEL = "label"
|
const val PROPERTY_LABEL = "label"
|
||||||
val PROPERTY_SHARE_TYPE = "shareType"
|
const val PROPERTY_SHARE_TYPE = "shareType"
|
||||||
val PROPERTY_SHARE_WITH = "shareWith"
|
const val PROPERTY_SHARE_WITH = "shareWith"
|
||||||
val PROPERTY_SHARE_WITH_ADDITIONAL_INFO = "shareWithAdditionalInfo"
|
const val PROPERTY_SHARE_WITH_ADDITIONAL_INFO = "shareWithAdditionalInfo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.http.methods.nonwebdav.GetMethod
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation
|
import com.owncloud.android.lib.common.operations.RemoteOperation
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
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.net.URL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,14 +89,14 @@ class GetRemoteSharesForFileOperation(
|
|||||||
result = parser.parse(getMethod.responseBodyAsString)
|
result = parser.parse(getMethod.responseBodyAsString)
|
||||||
|
|
||||||
if (result.isSuccess) {
|
if (result.isSuccess) {
|
||||||
Log_OC.d(TAG, "Got " + result.data.shares.size + " shares")
|
Timber.d("Got " + result.data.shares.size + " shares")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = RemoteOperationResult(getMethod)
|
result = RemoteOperationResult(getMethod)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
result = RemoteOperationResult(e)
|
result = RemoteOperationResult(e)
|
||||||
Log_OC.e(TAG, "Exception while getting shares", e)
|
Timber.e(e, "Exception while getting shares")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -105,11 +105,8 @@ class GetRemoteSharesForFileOperation(
|
|||||||
private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK
|
private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val TAG = GetRemoteSharesForFileOperation::class.java.simpleName
|
|
||||||
|
|
||||||
private const val PARAM_PATH = "path"
|
private const val PARAM_PATH = "path"
|
||||||
private const val PARAM_RESHARES = "reshares"
|
private const val PARAM_RESHARES = "reshares"
|
||||||
private const val PARAM_SUBFILES = "subfiles"
|
private const val PARAM_SUBFILES = "subfiles"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.http.methods.nonwebdav.DeleteMethod
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation
|
import com.owncloud.android.lib.common.operations.RemoteOperation
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
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.net.URL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,7 +75,7 @@ class RemoveRemoteShareOperation(private val remoteShareId: Long) : RemoteOperat
|
|||||||
)
|
)
|
||||||
result = parser.parse(deleteMethod.responseBodyAsString)
|
result = parser.parse(deleteMethod.responseBodyAsString)
|
||||||
|
|
||||||
Log_OC.d(TAG, "Unshare " + remoteShareId + ": " + result.logMessage)
|
Timber.d("Unshare " + remoteShareId + ": " + result.logMessage)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result = RemoteOperationResult(deleteMethod)
|
result = RemoteOperationResult(deleteMethod)
|
||||||
@ -83,16 +83,11 @@ class RemoveRemoteShareOperation(private val remoteShareId: Long) : RemoteOperat
|
|||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
result = RemoteOperationResult(e)
|
result = RemoteOperationResult(e)
|
||||||
Log_OC.e(TAG, "Unshare Link Exception " + result.logMessage, e)
|
Timber.e(e, "Unshare Link Exception " + result.logMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK
|
private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK
|
||||||
|
}
|
||||||
companion object {
|
|
||||||
|
|
||||||
private val TAG = RemoveRemoteShareOperation::class.java.simpleName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -29,9 +29,9 @@ package com.owncloud.android.lib.resources.shares
|
|||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
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 com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||||
import org.xmlpull.v1.XmlPullParserException
|
import org.xmlpull.v1.XmlPullParserException
|
||||||
|
import timber.log.Timber
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
@ -53,7 +53,7 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar
|
|||||||
// Parse xml response and obtain the list of shares
|
// Parse xml response and obtain the list of shares
|
||||||
val byteArrayServerResponse = ByteArrayInputStream(serverResponse.toByteArray())
|
val byteArrayServerResponse = ByteArrayInputStream(serverResponse.toByteArray())
|
||||||
if (shareXmlParser == null) {
|
if (shareXmlParser == null) {
|
||||||
Log_OC.w(TAG, "No ShareXmlParser provided, creating new instance ")
|
Timber.w("No ShareXmlParser provided, creating new instance")
|
||||||
shareXmlParser = ShareXMLParser()
|
shareXmlParser = ShareXMLParser()
|
||||||
}
|
}
|
||||||
val shares = shareXmlParser?.parseXMLResponse(byteArrayServerResponse)
|
val shares = shareXmlParser?.parseXMLResponse(byteArrayServerResponse)
|
||||||
@ -75,7 +75,7 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar
|
|||||||
val sharingLinkPath = ShareUtils.getSharingLinkPath(ownCloudVersion)
|
val sharingLinkPath = ShareUtils.getSharingLinkPath(ownCloudVersion)
|
||||||
share.shareLink = serverBaseUri.toString() + sharingLinkPath + share.token
|
share.shareLink = serverBaseUri.toString() + sharingLinkPath + share.token
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "Couldn't build link for public share :(")
|
Timber.e("Couldn't build link for public share :(")
|
||||||
}
|
}
|
||||||
|
|
||||||
share
|
share
|
||||||
@ -87,7 +87,7 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE)
|
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!! -> {
|
shareXmlParser?.isWrongParameter!! -> {
|
||||||
@ -107,18 +107,14 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: XmlPullParserException) {
|
} 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)
|
result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE)
|
||||||
|
|
||||||
} catch (e: IOException) {
|
} 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)
|
result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val TAG = ShareToRemoteOperationResultParser::class.java.simpleName
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,6 @@ class ShareXMLParser {
|
|||||||
@Throws(XmlPullParserException::class, IOException::class)
|
@Throws(XmlPullParserException::class, IOException::class)
|
||||||
private fun readMeta(parser: XmlPullParser) {
|
private fun readMeta(parser: XmlPullParser) {
|
||||||
parser.require(XmlPullParser.START_TAG, ns, NODE_META)
|
parser.require(XmlPullParser.START_TAG, ns, NODE_META)
|
||||||
//Log_OC.d(TAG, "---- NODE META ---");
|
|
||||||
while (parser.next() != XmlPullParser.END_TAG) {
|
while (parser.next() != XmlPullParser.END_TAG) {
|
||||||
if (parser.eventType != XmlPullParser.START_TAG) {
|
if (parser.eventType != XmlPullParser.START_TAG) {
|
||||||
continue
|
continue
|
||||||
@ -165,7 +164,6 @@ class ShareXMLParser {
|
|||||||
var share: RemoteShare? = null
|
var share: RemoteShare? = null
|
||||||
|
|
||||||
parser.require(XmlPullParser.START_TAG, ns, NODE_DATA)
|
parser.require(XmlPullParser.START_TAG, ns, NODE_DATA)
|
||||||
//Log_OC.d(TAG, "---- NODE DATA ---");
|
|
||||||
while (parser.next() != XmlPullParser.END_TAG) {
|
while (parser.next() != XmlPullParser.END_TAG) {
|
||||||
if (parser.eventType != XmlPullParser.START_TAG) {
|
if (parser.eventType != XmlPullParser.START_TAG) {
|
||||||
continue
|
continue
|
||||||
@ -217,7 +215,6 @@ class ShareXMLParser {
|
|||||||
|
|
||||||
val remoteShare = RemoteShare()
|
val remoteShare = RemoteShare()
|
||||||
|
|
||||||
//Log_OC.d(TAG, "---- NODE ELEMENT ---");
|
|
||||||
while (parser.next() != XmlPullParser.END_TAG) {
|
while (parser.next() != XmlPullParser.END_TAG) {
|
||||||
if (parser.eventType != XmlPullParser.START_TAG) {
|
if (parser.eventType != XmlPullParser.START_TAG) {
|
||||||
continue
|
continue
|
||||||
@ -343,7 +340,6 @@ class ShareXMLParser {
|
|||||||
private fun readNode(parser: XmlPullParser, node: String): String {
|
private fun readNode(parser: XmlPullParser, node: String): String {
|
||||||
parser.require(XmlPullParser.START_TAG, ns, node)
|
parser.require(XmlPullParser.START_TAG, ns, node)
|
||||||
val value = readText(parser)
|
val value = readText(parser)
|
||||||
//Log_OC.d(TAG, "node= " + node + ", value= " + value);
|
|
||||||
parser.require(XmlPullParser.END_TAG, ns, node)
|
parser.require(XmlPullParser.END_TAG, ns, node)
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
@ -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.http.methods.nonwebdav.PutMethod
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation
|
import com.owncloud.android.lib.common.operations.RemoteOperation
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
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 com.owncloud.android.lib.resources.shares.RemoteShare.Companion.DEFAULT_PERMISSION
|
||||||
import okhttp3.FormBody
|
import okhttp3.FormBody
|
||||||
|
import timber.log.Timber
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
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
|
* 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.
|
* Empty string clears the current name.
|
||||||
* Null results in no update applied to the name.
|
* Null results in no update applied to the name.
|
||||||
*/
|
*/
|
||||||
@ -70,7 +69,6 @@ class UpdateRemoteShareOperation
|
|||||||
/**
|
/**
|
||||||
* Password to update in Share resource.
|
* Password to update in Share resource.
|
||||||
*
|
*
|
||||||
* @param password Password to set to the target share.
|
|
||||||
* Empty string clears the current password.
|
* Empty string clears the current password.
|
||||||
* Null results in no update applied to the password.
|
* Null results in no update applied to the password.
|
||||||
*/
|
*/
|
||||||
@ -79,7 +77,6 @@ class UpdateRemoteShareOperation
|
|||||||
/**
|
/**
|
||||||
* Expiration date to update in Share resource.
|
* 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.
|
* A negative value clears the current expiration date.
|
||||||
* Zero value (start-of-epoch) results in no update done on
|
* Zero value (start-of-epoch) results in no update done on
|
||||||
* the expiration date.
|
* the expiration date.
|
||||||
@ -89,7 +86,6 @@ class UpdateRemoteShareOperation
|
|||||||
/**
|
/**
|
||||||
* Permissions to update in Share resource.
|
* 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.
|
* Values <= 0 result in no update applied to the permissions.
|
||||||
*/
|
*/
|
||||||
var permissions: Int = DEFAULT_PERMISSION
|
var permissions: Int = DEFAULT_PERMISSION
|
||||||
@ -97,7 +93,6 @@ class UpdateRemoteShareOperation
|
|||||||
/**
|
/**
|
||||||
* Enable upload permissions to update in Share resource.
|
* 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.
|
* Null results in no update applied to the upload permission.
|
||||||
*/
|
*/
|
||||||
var publicUpload: Boolean? = null
|
var publicUpload: Boolean? = null
|
||||||
@ -181,7 +176,7 @@ class UpdateRemoteShareOperation
|
|||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
result = RemoteOperationResult(e)
|
result = RemoteOperationResult(e)
|
||||||
Log_OC.e(TAG, "Exception while Creating New Share", e)
|
Timber.e(e, "Exception while Creating New Share")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -190,7 +185,6 @@ class UpdateRemoteShareOperation
|
|||||||
private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK
|
private fun isSuccess(status: Int): Boolean = status == HttpConstants.HTTP_OK
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val TAG = GetRemoteShareOperation::class.java.simpleName
|
|
||||||
|
|
||||||
private const val PARAM_NAME = "name"
|
private const val PARAM_NAME = "name"
|
||||||
private const val PARAM_PASSWORD = "password"
|
private const val PARAM_PASSWORD = "password"
|
||||||
|
@ -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.RemoteOperation
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import com.owncloud.android.lib.resources.status.RemoteCapability.CapabilityBooleanType
|
import com.owncloud.android.lib.resources.status.RemoteCapability.CapabilityBooleanType
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Capabilities from the server
|
* Get the Capabilities from the server
|
||||||
@ -69,17 +69,17 @@ class GetRemoteCapabilitiesOperation : RemoteOperation<RemoteCapability>() {
|
|||||||
|
|
||||||
if (!isSuccess(status)) {
|
if (!isSuccess(status)) {
|
||||||
result = RemoteOperationResult(getMethod)
|
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) {
|
if (response != null) {
|
||||||
Log_OC.e(TAG, "*** status code: $status; response message: $response")
|
Timber.e("*** status code: $status; response message: $response")
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "*** status code: $status")
|
Timber.e("*** status code: $status")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
Log_OC.d(TAG, "Successful response: " + response!!)
|
Timber.d("Successful response: " + response!!)
|
||||||
|
|
||||||
// Parse the response
|
// Parse the response
|
||||||
val respJSON = JSONObject(response)
|
val respJSON = JSONObject(response)
|
||||||
@ -102,7 +102,7 @@ class GetRemoteCapabilitiesOperation : RemoteOperation<RemoteCapability>() {
|
|||||||
capability.versionMicro = respVersion.getInt(PROPERTY_MICRO)
|
capability.versionMicro = respVersion.getInt(PROPERTY_MICRO)
|
||||||
capability.versionString = respVersion.getString(PROPERTY_STRING)
|
capability.versionString = respVersion.getString(PROPERTY_STRING)
|
||||||
capability.versionEdition = respVersion.getString(PROPERTY_EDITION)
|
capability.versionEdition = respVersion.getString(PROPERTY_EDITION)
|
||||||
Log_OC.d(TAG, "*** Added $NODE_VERSION")
|
Timber.d("*** Added $NODE_VERSION")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capabilities Object
|
// Capabilities Object
|
||||||
@ -113,7 +113,7 @@ class GetRemoteCapabilitiesOperation : RemoteOperation<RemoteCapability>() {
|
|||||||
if (respCapabilities.has(NODE_CORE)) {
|
if (respCapabilities.has(NODE_CORE)) {
|
||||||
val respCore = respCapabilities.getJSONObject(NODE_CORE)
|
val respCore = respCapabilities.getJSONObject(NODE_CORE)
|
||||||
capability.corePollinterval = respCore.getInt(PROPERTY_POLLINTERVAL)
|
capability.corePollinterval = respCore.getInt(PROPERTY_POLLINTERVAL)
|
||||||
Log_OC.d(TAG, "*** Added $NODE_CORE")
|
Timber.d("*** Added $NODE_CORE")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add files_sharing: public, user, resharing
|
// Add files_sharing: public, user, resharing
|
||||||
@ -124,9 +124,10 @@ class GetRemoteCapabilitiesOperation : RemoteOperation<RemoteCapability>() {
|
|||||||
respFilesSharing.getBoolean(PROPERTY_API_ENABLED)
|
respFilesSharing.getBoolean(PROPERTY_API_ENABLED)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (respFilesSharing.has(PROPERTY_SEARCH_MIN_LENGTH)){
|
if (respFilesSharing.has(PROPERTY_SEARCH_MIN_LENGTH)) {
|
||||||
capability.filesSharingSearchMinLength = respFilesSharing.getInt(
|
capability.filesSharingSearchMinLength = respFilesSharing.getInt(
|
||||||
PROPERTY_SEARCH_MIN_LENGTH)
|
PROPERTY_SEARCH_MIN_LENGTH
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (respFilesSharing.has(NODE_PUBLIC)) {
|
if (respFilesSharing.has(NODE_PUBLIC)) {
|
||||||
@ -218,7 +219,7 @@ class GetRemoteCapabilitiesOperation : RemoteOperation<RemoteCapability>() {
|
|||||||
respFederation.getBoolean(PROPERTY_INCOMING)
|
respFederation.getBoolean(PROPERTY_INCOMING)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Log_OC.d(TAG, "*** Added $NODE_FILES_SHARING")
|
Timber.d("*** Added $NODE_FILES_SHARING")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (respCapabilities.has(NODE_FILES)) {
|
if (respCapabilities.has(NODE_FILES)) {
|
||||||
@ -237,23 +238,23 @@ class GetRemoteCapabilitiesOperation : RemoteOperation<RemoteCapability>() {
|
|||||||
respFiles.getBoolean(PROPERTY_VERSIONING)
|
respFiles.getBoolean(PROPERTY_VERSIONING)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Log_OC.d(TAG, "*** Added $NODE_FILES")
|
Timber.d("*** Added $NODE_FILES")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Result
|
// Result
|
||||||
result = RemoteOperationResult(OK)
|
result = RemoteOperationResult(OK)
|
||||||
result.data = capability
|
result.data = capability
|
||||||
|
|
||||||
Log_OC.d(TAG, "*** Get Capabilities completed ")
|
Timber.d("*** Get Capabilities completed ")
|
||||||
} else {
|
} else {
|
||||||
result = RemoteOperationResult(statuscode, message, null)
|
result = RemoteOperationResult(statuscode, message, null)
|
||||||
Log_OC.e(TAG, "Failed response while getting capabilities from the server ")
|
Timber.e("Failed response while getting capabilities from the server ")
|
||||||
Log_OC.e(TAG, "*** status: $statusProp; message: $message")
|
Timber.e("*** status: $statusProp; message: $message")
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
result = RemoteOperationResult(e)
|
result = RemoteOperationResult(e)
|
||||||
Log_OC.e(TAG, "Exception while getting capabilities", e)
|
Timber.e(e, "Exception while getting capabilities")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@ -265,8 +266,6 @@ class GetRemoteCapabilitiesOperation : RemoteOperation<RemoteCapability>() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val TAG = GetRemoteCapabilitiesOperation::class.java.simpleName
|
|
||||||
|
|
||||||
// OCS Routes
|
// OCS Routes
|
||||||
private const val OCS_ROUTE = "ocs/v2.php/cloud/capabilities"
|
private const val OCS_ROUTE = "ocs/v2.php/cloud/capabilities"
|
||||||
|
|
||||||
|
@ -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.http.methods.nonwebdav.GetMethod;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import javax.net.ssl.SSLException;
|
import javax.net.ssl.SSLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -59,8 +59,6 @@ public class GetRemoteStatusOperation extends RemoteOperation<OwnCloudVersion> {
|
|||||||
*/
|
*/
|
||||||
public static final long TRY_CONNECTION_TIMEOUT = 5000;
|
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_INSTALLED = "installed";
|
||||||
private static final String NODE_VERSION = "version";
|
private static final String NODE_VERSION = "version";
|
||||||
private static final String HTTPS_PREFIX = "https://";
|
private static final String HTTPS_PREFIX = "https://";
|
||||||
@ -117,8 +115,7 @@ public class GetRemoteStatusOperation extends RemoteOperation<OwnCloudVersion> {
|
|||||||
|
|
||||||
JSONObject respJSON = new JSONObject(getMethod.getResponseBodyAsString());
|
JSONObject respJSON = new JSONObject(getMethod.getResponseBodyAsString());
|
||||||
if (!respJSON.getBoolean(NODE_INSTALLED)) {
|
if (!respJSON.getBoolean(NODE_INSTALLED)) {
|
||||||
mLatestResult = new RemoteOperationResult(
|
mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
|
||||||
RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
|
|
||||||
} else {
|
} else {
|
||||||
String version = respJSON.getString(NODE_VERSION);
|
String version = respJSON.getString(NODE_VERSION);
|
||||||
OwnCloudVersion ocVersion = new OwnCloudVersion(version);
|
OwnCloudVersion ocVersion = new OwnCloudVersion(version);
|
||||||
@ -153,14 +150,13 @@ public class GetRemoteStatusOperation extends RemoteOperation<OwnCloudVersion> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mLatestResult.isSuccess()) {
|
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) {
|
} else if (mLatestResult.getException() != null) {
|
||||||
Log_OC.e(TAG, "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage(),
|
Timber.e(mLatestResult.getException(), "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage());
|
||||||
mLatestResult.getException());
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage());
|
Timber.e("Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
@ -186,7 +182,7 @@ public class GetRemoteStatusOperation extends RemoteOperation<OwnCloudVersion> {
|
|||||||
client.setBaseUri(Uri.parse(HTTPS_PREFIX + baseUriStr));
|
client.setBaseUri(Uri.parse(HTTPS_PREFIX + baseUriStr));
|
||||||
boolean httpsSuccess = tryConnection(client);
|
boolean httpsSuccess = tryConnection(client);
|
||||||
if (!httpsSuccess && !mLatestResult.isSslRecoverableException()) {
|
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));
|
client.setBaseUri(Uri.parse(HTTP_PREFIX + baseUriStr));
|
||||||
tryConnection(client);
|
tryConnection(client);
|
||||||
}
|
}
|
||||||
|
@ -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.network.WebdavUtils;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
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.BufferedInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -49,8 +49,6 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R
|
|||||||
*/
|
*/
|
||||||
public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserAvatarOperation.ResultData> {
|
public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserAvatarOperation.ResultData> {
|
||||||
|
|
||||||
private static final String TAG = GetRemoteUserAvatarOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
private static final String NON_OFFICIAL_AVATAR_PATH = "/index.php/avatar/";
|
private static final String NON_OFFICIAL_AVATAR_PATH = "/index.php/avatar/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,11 +56,6 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA
|
|||||||
*/
|
*/
|
||||||
private int mDimension;
|
private int mDimension;
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public GetRemoteUserAvatarOperation(int dimension, String currentEtag) {
|
|
||||||
this(dimension);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GetRemoteUserAvatarOperation(int dimension) {
|
public GetRemoteUserAvatarOperation(int dimension) {
|
||||||
mDimension = dimension;
|
mDimension = dimension;
|
||||||
}
|
}
|
||||||
@ -77,7 +70,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final String url = client.getBaseUri() + NON_OFFICIAL_AVATAR_PATH + client.getCredentials().getUsername() + "/" + mDimension;
|
final String url = client.getBaseUri() + NON_OFFICIAL_AVATAR_PATH + client.getCredentials().getUsername() + "/" + mDimension;
|
||||||
Log_OC.d(TAG, "avatar URI: " + url);
|
Timber.d("avatar URI: %s", url);
|
||||||
|
|
||||||
getMethod = new GetMethod(new URL(url));
|
getMethod = new GetMethod(new URL(url));
|
||||||
|
|
||||||
@ -97,7 +90,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA
|
|||||||
String contentType = getMethod.getResponseHeader(HttpConstants.CONTENT_TYPE_HEADER);
|
String contentType = getMethod.getResponseHeader(HttpConstants.CONTENT_TYPE_HEADER);
|
||||||
|
|
||||||
if (contentType == null || !contentType.startsWith("image")) {
|
if (contentType == null || !contentType.startsWith("image")) {
|
||||||
Log_OC.e(TAG, "Not an image, failing with no avatar");
|
Timber.w("Not an image, failing with no avatar");
|
||||||
result = new RemoteOperationResult<>(RemoteOperationResult.ResultCode.FILE_NOT_FOUND);
|
result = new RemoteOperationResult<>(RemoteOperationResult.ResultCode.FILE_NOT_FOUND);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -119,7 +112,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA
|
|||||||
// find out etag
|
// find out etag
|
||||||
String etag = WebdavUtils.getEtagFromResponse(getMethod);
|
String etag = WebdavUtils.getEtagFromResponse(getMethod);
|
||||||
if (etag.length() == 0) {
|
if (etag.length() == 0) {
|
||||||
Log_OC.w(TAG, "Could not read Etag from avatar");
|
Timber.w("Could not read Etag from avatar");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
@ -133,7 +126,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(e);
|
result = new RemoteOperationResult<>(e);
|
||||||
Log_OC.e(TAG, "Exception while getting OC user avatar", e);
|
Timber.e(e, "Exception while getting OC user avatar");
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (getMethod != null) {
|
if (getMethod != null) {
|
||||||
@ -147,14 +140,14 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException i) {
|
} catch (IOException i) {
|
||||||
Log_OC.e(TAG, "Unexpected exception closing input stream ", i);
|
Timber.e(i, "Unexpected exception closing input stream");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (bos != null) {
|
if (bos != null) {
|
||||||
bos.close();
|
bos.close();
|
||||||
}
|
}
|
||||||
} catch (IOException o) {
|
} catch (IOException o) {
|
||||||
Log_OC.e(TAG, "Unexpected exception closing output stream ", o);
|
Timber.e(o, "Unexpected exception closing output stream");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ import com.owncloud.android.lib.common.http.HttpConstants;
|
|||||||
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
|
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.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
@ -46,8 +46,6 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R
|
|||||||
|
|
||||||
public class GetRemoteUserInfoOperation extends RemoteOperation<GetRemoteUserInfoOperation.UserInfo> {
|
public class GetRemoteUserInfoOperation extends RemoteOperation<GetRemoteUserInfoOperation.UserInfo> {
|
||||||
|
|
||||||
private static final String TAG = GetRemoteUserInfoOperation.class.getSimpleName();
|
|
||||||
|
|
||||||
// OCS Route
|
// OCS Route
|
||||||
private static final String OCS_ROUTE = "/ocs/v2.php/cloud/user?format=json";
|
private static final String OCS_ROUTE = "/ocs/v2.php/cloud/user?format=json";
|
||||||
|
|
||||||
@ -72,7 +70,7 @@ public class GetRemoteUserInfoOperation extends RemoteOperation<GetRemoteUserInf
|
|||||||
int status = client.executeHttpMethod(getMethod);
|
int status = client.executeHttpMethod(getMethod);
|
||||||
|
|
||||||
if (isSuccess(status)) {
|
if (isSuccess(status)) {
|
||||||
Log_OC.d(TAG, "Successful response");
|
Timber.d("Successful response");
|
||||||
|
|
||||||
JSONObject respJSON = new JSONObject(getMethod.getResponseBodyAsString());
|
JSONObject respJSON = new JSONObject(getMethod.getResponseBodyAsString());
|
||||||
JSONObject respOCS = respJSON.getJSONObject(NODE_OCS);
|
JSONObject respOCS = respJSON.getJSONObject(NODE_OCS);
|
||||||
@ -90,16 +88,12 @@ public class GetRemoteUserInfoOperation extends RemoteOperation<GetRemoteUserInf
|
|||||||
} else {
|
} else {
|
||||||
result = new RemoteOperationResult<>(getMethod);
|
result = new RemoteOperationResult<>(getMethod);
|
||||||
String response = getMethod.getResponseBodyAsString();
|
String response = getMethod.getResponseBodyAsString();
|
||||||
Log_OC.e(TAG, "Failed response while getting user information ");
|
Timber.e("Failed response while getting user information ");
|
||||||
if (getMethod != null) {
|
Timber.e("*** status code: " + status + " ; response message: " + response);
|
||||||
Log_OC.e(TAG, "*** status code: " + status + " ; response message: " + response);
|
|
||||||
} else {
|
|
||||||
Log_OC.e(TAG, "*** status code: " + status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult<>(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;
|
return result;
|
||||||
|
@ -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.network.WebdavUtils;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
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.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -51,7 +51,6 @@ import static com.owncloud.android.lib.common.operations.RemoteOperationResult.R
|
|||||||
*/
|
*/
|
||||||
public class GetRemoteUserQuotaOperation extends RemoteOperation<GetRemoteUserQuotaOperation.RemoteQuota> {
|
public class GetRemoteUserQuotaOperation extends RemoteOperation<GetRemoteUserQuotaOperation.RemoteQuota> {
|
||||||
|
|
||||||
private static final String TAG = GetRemoteUserQuotaOperation.class.getSimpleName();
|
|
||||||
private String mRemotePath;
|
private String mRemotePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,13 +93,12 @@ public class GetRemoteUserQuotaOperation extends RemoteOperation<GetRemoteUserQu
|
|||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (result.isSuccess()) {
|
if (result.isSuccess()) {
|
||||||
Log_OC.i(TAG, "Get quota from " + mRemotePath + ": " + result.getLogMessage());
|
Timber.i("Get quota from " + mRemotePath + ": " + result.getLogMessage());
|
||||||
} else {
|
} else {
|
||||||
if (result.isException()) {
|
if (result.isException()) {
|
||||||
Log_OC.e(TAG, "Get quota from " + mRemotePath + ": " + result.getLogMessage(),
|
Timber.e(result.getException(), "Get quota from " + mRemotePath + ": " + result.getLogMessage());
|
||||||
result.getException());
|
|
||||||
} else {
|
} else {
|
||||||
Log_OC.e(TAG, "Get quota from " + mRemotePath + ": " + result.getLogMessage());
|
Timber.e("Get quota from " + mRemotePath + ": " + result.getLogMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user