mirror of
https://github.com/owncloud/android-library.git
synced 2025-09-06 07:31:50 +00:00
Apply requested changes
This commit is contained in:
parent
9944f30d3f
commit
b0fa6ae1d0
@ -21,9 +21,6 @@ dependencies {
|
||||
api 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||
api project(':dav4android')
|
||||
|
||||
// Used for network and database debuging
|
||||
debugApi 'com.facebook.stetho:stetho:1.5.0'
|
||||
debugApi 'com.facebook.stetho:stetho-okhttp3:1.5.0'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.51"
|
||||
}
|
||||
|
||||
|
@ -27,15 +27,19 @@
|
||||
package="com.owncloud.android.lib.sampleclient"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
android:targetSdkVersion="26"/>
|
||||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
||||
<activity android:name="MainActivity"
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name">
|
||||
<activity
|
||||
android:name="MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
@ -116,8 +116,7 @@ public class OwnCloudAccount {
|
||||
* @throws IOException
|
||||
* @throws OperationCanceledException
|
||||
*/
|
||||
public void loadCredentials(Context context)
|
||||
throws AccountNotFoundException, AuthenticatorException,
|
||||
public void loadCredentials(Context context) throws AuthenticatorException,
|
||||
IOException, OperationCanceledException {
|
||||
|
||||
if (context == null) {
|
||||
|
@ -25,36 +25,36 @@
|
||||
|
||||
package com.owncloud.android.lib.common;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AccountsException;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.authentication.OwnCloudCredentials;
|
||||
import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory;
|
||||
import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory.OwnCloudAnonymousCredentials;
|
||||
import com.owncloud.android.lib.common.http.HttpClient;
|
||||
import com.owncloud.android.lib.common.http.HttpConstants;
|
||||
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
|
||||
import com.owncloud.android.lib.common.http.methods.webdav.CopyMethod;
|
||||
import com.owncloud.android.lib.common.network.RedirectionPath;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import at.bitfire.dav4android.exception.HttpException;
|
||||
import at.bitfire.dav4android.exception.RedirectException;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
public class OwnCloudClient extends HttpClient {
|
||||
|
||||
public static final String WEBDAV_PATH_4_0 = "/remote.php/webdav";
|
||||
public static final String NEW_WEBDAV_FILES_PATH_4_0 = "/remote.php/dav/files/";
|
||||
public static final String NEW_WEBDAV_UPLOADS_PATH_4_0 = "/remote.php/dav/uploads/";
|
||||
public static final String STATUS_PATH = "/status.php";
|
||||
@ -63,8 +63,6 @@ public class OwnCloudClient extends HttpClient {
|
||||
private static final String TAG = OwnCloudClient.class.getSimpleName();
|
||||
private static final int MAX_REDIRECTIONS_COUNT = 3;
|
||||
private static final int MAX_REPEAT_COUNT_WITH_FRESH_CREDENTIALS = 1;
|
||||
private static final String PARAM_SINGLE_COOKIE_HEADER = "http.protocol.single-cookie-header";
|
||||
private static final boolean PARAM_SINGLE_COOKIE_HEADER_VALUE = true;
|
||||
private static final String PARAM_PROTOCOL_VERSION = "http.protocol.version";
|
||||
|
||||
private static byte[] sExhaustBuffer = new byte[1024];
|
||||
@ -101,15 +99,6 @@ public class OwnCloudClient extends HttpClient {
|
||||
mInstanceNumber = sIntanceCounter++;
|
||||
Log_OC.d(TAG + " #" + mInstanceNumber, "Creating OwnCloudClient");
|
||||
|
||||
//TODO
|
||||
// getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
|
||||
// getParams().setParameter(
|
||||
// PARAM_SINGLE_COOKIE_HEADER, // to avoid problems with some web servers
|
||||
// PARAM_SINGLE_COOKIE_HEADER_VALUE
|
||||
// );
|
||||
|
||||
// applyProxySettings();
|
||||
|
||||
clearCredentials();
|
||||
}
|
||||
|
||||
@ -198,7 +187,7 @@ public class OwnCloudClient extends HttpClient {
|
||||
|
||||
// Release the connection to avoid reach the max number of connections per host
|
||||
// due to it will be set a different url
|
||||
exhaustResponse(method.getResponseAsStream());
|
||||
exhaustResponse(method.getResponseBodyAsStream());
|
||||
|
||||
method.setUrl(HttpUrl.parse(location));
|
||||
final String destination = method.getRequestHeader("Destination") != null
|
||||
@ -206,7 +195,7 @@ public class OwnCloudClient extends HttpClient {
|
||||
: method.getRequestHeader("destination");
|
||||
|
||||
if (destination != null) {
|
||||
final int suffixIndex = location.lastIndexOf(WEBDAV_PATH_4_0);
|
||||
final int suffixIndex = location.lastIndexOf(getNewFilesWebDavUri().toString());
|
||||
final String redirectionBase = location.substring(0, suffixIndex);
|
||||
final String destinationPath = destination.substring(mBaseUri.toString().length());
|
||||
|
||||
@ -250,10 +239,6 @@ public class OwnCloudClient extends HttpClient {
|
||||
}
|
||||
}
|
||||
|
||||
public Uri getOldFilesWebdavUri() {
|
||||
return Uri.parse(mBaseUri + WEBDAV_PATH_4_0);
|
||||
}
|
||||
|
||||
public Uri getNewFilesWebDavUri() {
|
||||
return mCredentials instanceof OwnCloudAnonymousCredentials
|
||||
? Uri.parse(mBaseUri + NEW_WEBDAV_FILES_PATH_4_0)
|
||||
@ -288,6 +273,15 @@ public class OwnCloudClient extends HttpClient {
|
||||
return mCredentials;
|
||||
}
|
||||
|
||||
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")) {
|
||||
@ -331,16 +325,6 @@ public class OwnCloudClient extends HttpClient {
|
||||
getAccount().getBaseUri().toString()), cookies);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
public void setOwnCloudVersion(OwnCloudVersion version) {
|
||||
mVersion = version;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -24,9 +24,6 @@
|
||||
|
||||
package com.owncloud.android.lib.common;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
@ -40,12 +37,11 @@ import android.os.Bundle;
|
||||
import com.owncloud.android.lib.common.accounts.AccountTypeUtils;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
|
||||
import com.owncloud.android.lib.common.http.HttpClient;
|
||||
import com.owncloud.android.lib.common.network.NetworkUtils;
|
||||
import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class OwnCloudClientFactory {
|
||||
|
||||
final private static String TAG = OwnCloudClientFactory.class.getSimpleName();
|
||||
@ -123,9 +119,6 @@ public class OwnCloudClientFactory {
|
||||
|
||||
|
||||
} else {
|
||||
//String password = am.getPassword(account);
|
||||
//String password = am.blockingGetAuthToken(account, MainApp.getAuthTokenTypePass(),
|
||||
// false);
|
||||
AccountManagerFuture<Bundle> future = am.getAuthToken(
|
||||
account,
|
||||
AccountTypeUtils.getAuthTokenTypePass(account.type),
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 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
|
||||
@ -38,6 +38,7 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundExce
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* @author masensio
|
||||
* @author Christian Schabesberger
|
||||
*/
|
||||
|
||||
public interface OwnCloudClientManager {
|
||||
@ -51,5 +52,4 @@ public interface OwnCloudClientManager {
|
||||
void saveAllClients(Context context, String accountType)
|
||||
throws AccountNotFoundException, AuthenticatorException,
|
||||
IOException, OperationCanceledException;
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 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
|
||||
@ -50,6 +50,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* @author masensio
|
||||
* @author Christian Schabesberger
|
||||
*/
|
||||
|
||||
public class SingleSessionManager implements OwnCloudClientManager {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2017 ownCloud GmbH.
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
* Copyright (C) 2012 Bartek Przybylski
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@ -25,10 +25,6 @@
|
||||
|
||||
package com.owncloud.android.lib.common.accounts;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AccountsException;
|
||||
@ -43,6 +39,10 @@ import com.owncloud.android.lib.common.authentication.OwnCloudCredentialsFactory
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import okhttp3.Cookie;
|
||||
|
||||
public class AccountUtils {
|
||||
@ -59,10 +59,22 @@ public class AccountUtils {
|
||||
*/
|
||||
public static String getWebDavUrlForAccount(Context context, Account account)
|
||||
throws AccountNotFoundException {
|
||||
String webDavUrlForAccount = "";
|
||||
|
||||
return getBaseUrlForAccount(context, account) + OwnCloudClient.WEBDAV_PATH_4_0;
|
||||
try {
|
||||
OwnCloudCredentials ownCloudCredentials = getCredentialsForAccount(context, account);
|
||||
webDavUrlForAccount = getBaseUrlForAccount(context, account) + OwnCloudClient.NEW_WEBDAV_FILES_PATH_4_0
|
||||
+ ownCloudCredentials.getUsername();
|
||||
} catch (OperationCanceledException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AuthenticatorException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return webDavUrlForAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts url server from the account
|
||||
@ -84,7 +96,6 @@ public class AccountUtils {
|
||||
return baseurl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the username corresponding to an OC account.
|
||||
*
|
||||
@ -130,7 +141,7 @@ public class AccountUtils {
|
||||
public static OwnCloudCredentials getCredentialsForAccount(Context context, Account account)
|
||||
throws OperationCanceledException, AuthenticatorException, IOException {
|
||||
|
||||
OwnCloudCredentials credentials = null;
|
||||
OwnCloudCredentials credentials;
|
||||
AccountManager am = AccountManager.get(context);
|
||||
|
||||
String supportsOAuth2 = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2);
|
||||
@ -174,10 +185,8 @@ public class AccountUtils {
|
||||
}
|
||||
|
||||
return credentials;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String buildAccountNameOld(Uri serverBaseUrl, String username) {
|
||||
if (serverBaseUrl.getScheme() == null) {
|
||||
serverBaseUrl = Uri.parse("https://" + serverBaseUrl.toString());
|
||||
@ -216,7 +225,6 @@ public class AccountUtils {
|
||||
// Log_OC.d(TAG, "Saving Cookies: "+ cookiesString );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,7 +244,7 @@ public class AccountUtils {
|
||||
// Account Manager
|
||||
AccountManager am = AccountManager.get(context.getApplicationContext());
|
||||
|
||||
Uri serverUri = (client.getBaseUri() != null) ? client.getBaseUri() : client.getOldFilesWebdavUri();
|
||||
Uri serverUri = (client.getBaseUri() != null) ? client.getBaseUri() : client.getNewFilesWebDavUri();
|
||||
|
||||
String cookiesString = am.getUserData(account, Constants.KEY_COOKIES);
|
||||
if (cookiesString != null) {
|
||||
@ -275,7 +283,6 @@ public class AccountUtils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Constants {
|
||||
/**
|
||||
* Version should be 3 numbers separated by dot so it can be parsed by
|
||||
@ -316,5 +323,4 @@ public class AccountUtils {
|
||||
public static final String KEY_OAUTH2_REFRESH_TOKEN = "oc_oauth2_refresh_token";
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -24,10 +24,9 @@
|
||||
|
||||
package com.owncloud.android.lib.common.authentication.oauth;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* @author Christian Schabesberger
|
||||
*/
|
||||
public class BearerCredentials {
|
||||
|
||||
@ -96,6 +95,4 @@ public class BearerCredentials {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2017 ownCloud GmbH.
|
||||
* @author Christian Schabesberger
|
||||
* Copyright (C) 2018 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
|
||||
@ -105,8 +106,6 @@ public class OAuth2GetAccessTokenOperation extends RemoteOperation<Map<String, S
|
||||
|
||||
postMethod.setRequestBody(requestBody);
|
||||
|
||||
|
||||
// Do the B***S*** Switch and onExecute
|
||||
OwnCloudCredentials oauthCredentials =
|
||||
new OwnCloudBasicCredentials(mClientId, mClientSecret);
|
||||
OwnCloudCredentials oldCredentials = switchClientCredentials(oauthCredentials);
|
||||
@ -129,7 +128,7 @@ public class OAuth2GetAccessTokenOperation extends RemoteOperation<Map<String, S
|
||||
|
||||
} else {
|
||||
result = new RemoteOperationResult<>(ResultCode.OK);
|
||||
client.exhaustResponse(postMethod.getResponseAsStream());
|
||||
client.exhaustResponse(postMethod.getResponseBodyAsStream());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -144,5 +143,4 @@ public class OAuth2GetAccessTokenOperation extends RemoteOperation<Map<String, S
|
||||
getClient().setCredentials(newCredentials);
|
||||
return previousCredentials;
|
||||
}
|
||||
|
||||
}
|
@ -2,8 +2,9 @@
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author David González Verdugo
|
||||
* @author Christian Schabesberger
|
||||
*
|
||||
* Copyright (C) 2017 ownCloud GmbH.
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
@ -77,7 +78,6 @@ public class OAuth2RefreshAccessTokenOperation extends RemoteOperation<Map<Strin
|
||||
protected RemoteOperationResult<Map<String, String>> run(OwnCloudClient client) {
|
||||
|
||||
try {
|
||||
|
||||
final RequestBody requestBody = new MultipartBody.Builder()
|
||||
.setType(MultipartBody.FORM)
|
||||
.addFormDataPart(OAuth2Constants.KEY_GRANT_TYPE,
|
||||
@ -96,11 +96,8 @@ public class OAuth2RefreshAccessTokenOperation extends RemoteOperation<Map<Strin
|
||||
.toString()));
|
||||
postMethod.setRequestBody(requestBody);
|
||||
|
||||
final OwnCloudCredentials oauthCredentials = new OwnCloudBasicCredentials(mClientId, mClientSecret);
|
||||
|
||||
final OwnCloudCredentials oauthCredentials =
|
||||
new OwnCloudBasicCredentials(mClientId, mClientSecret);
|
||||
|
||||
// Do the B***S*** switch
|
||||
final OwnCloudCredentials oldCredentials = switchClientCredentials(oauthCredentials);
|
||||
client.executeHttpMethod(postMethod);
|
||||
switchClientCredentials(oldCredentials);
|
||||
@ -120,7 +117,6 @@ public class OAuth2RefreshAccessTokenOperation extends RemoteOperation<Map<Strin
|
||||
accessTokenResult.get(OAuth2Constants.KEY_ACCESS_TOKEN) == null)
|
||||
? new RemoteOperationResult<>(ResultCode.OAUTH2_ERROR)
|
||||
: result;
|
||||
|
||||
} else {
|
||||
return new RemoteOperationResult<>(postMethod);
|
||||
}
|
||||
@ -135,5 +131,4 @@ public class OAuth2RefreshAccessTokenOperation extends RemoteOperation<Map<Strin
|
||||
getClient().setCredentials(newCredentials);
|
||||
return previousCredentials;
|
||||
}
|
||||
|
||||
}
|
@ -25,11 +25,8 @@
|
||||
package com.owncloud.android.lib.common.http;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.facebook.stetho.okhttp3.StethoInterceptor;
|
||||
import com.owncloud.android.lib.BuildConfig;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||
import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor;
|
||||
@ -77,9 +74,6 @@ public class HttpClient {
|
||||
.hostnameVerifier((asdf, usdf) -> true);
|
||||
// TODO: Not verifying the hostname against certificate. ask owncloud security human if this is ok.
|
||||
//.hostnameVerifier(new BrowserCompatHostnameVerifier());
|
||||
if(BuildConfig.DEBUG) {
|
||||
clientBuilder.addNetworkInterceptor(new StethoInterceptor());
|
||||
}
|
||||
sOkHttpClient = clientBuilder.build();
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -93,6 +87,7 @@ public class HttpClient {
|
||||
if (sOkHttpInterceptor == null) {
|
||||
sOkHttpInterceptor = new HttpInterceptor();
|
||||
addHeaderForAllRequests(HttpConstants.USER_AGENT_HEADER, OwnCloudClientManagerFactory.getUserAgent());
|
||||
addHeaderForAllRequests(HttpConstants.PARAM_SINGLE_COOKIE_HEADER, "true");
|
||||
}
|
||||
return sOkHttpInterceptor;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public class HttpConstants {
|
||||
public static final String CONTENT_TYPE_HEADER = "Content-Type";
|
||||
public static final String OC_TOTAL_LENGTH_HEADER = "OC-Total-Length";
|
||||
public static final String OC_X_OC_MTIME_HEADER = "X-OC-Mtime";
|
||||
public static final String PARAM_SINGLE_COOKIE_HEADER = "http.protocol.single-cookie-header";
|
||||
|
||||
/***********************************************************************************************************
|
||||
************************************************ STATUS CODES *********************************************
|
||||
|
@ -74,7 +74,6 @@ public abstract class HttpBaseMethod {
|
||||
return mCall.isCanceled();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////
|
||||
// For override
|
||||
//////////////////////////////
|
||||
@ -98,7 +97,7 @@ public abstract class HttpBaseMethod {
|
||||
return mResponse.body().string();
|
||||
}
|
||||
|
||||
public InputStream getResponseAsStream() {
|
||||
public InputStream getResponseBodyAsStream() {
|
||||
return mResponse.body().byteStream();
|
||||
}
|
||||
|
||||
|
@ -1,165 +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 java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
|
||||
/**
|
||||
* A RequestEntity that represents a PIECE of a file.
|
||||
*
|
||||
* @author David A. Velasco
|
||||
*/
|
||||
public class ChunkFromFileChannelRequestEntity implements ProgressiveDataTransferer {
|
||||
|
||||
private static final String TAG = ChunkFromFileChannelRequestEntity.class.getSimpleName();
|
||||
|
||||
//private final File mFile;
|
||||
private final FileChannel mChannel;
|
||||
private final String mContentType;
|
||||
private final long mChunkSize;
|
||||
private final File mFile;
|
||||
private long mOffset;
|
||||
private long mTransferred;
|
||||
Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<>();
|
||||
private ByteBuffer mBuffer = ByteBuffer.allocate(4096);
|
||||
|
||||
public ChunkFromFileChannelRequestEntity(
|
||||
final FileChannel channel, final String contentType, long chunkSize, final File file
|
||||
) {
|
||||
super();
|
||||
if (channel == null) {
|
||||
throw new IllegalArgumentException("File may not be null");
|
||||
}
|
||||
if (chunkSize <= 0) {
|
||||
throw new IllegalArgumentException("Chunk size must be greater than zero");
|
||||
}
|
||||
mChannel = channel;
|
||||
mContentType = contentType;
|
||||
mChunkSize = chunkSize;
|
||||
mFile = file;
|
||||
mOffset = 0;
|
||||
mTransferred = 0;
|
||||
}
|
||||
|
||||
public void setOffset(long offset) {
|
||||
mOffset = offset;
|
||||
}
|
||||
|
||||
public long getContentLength() {
|
||||
try {
|
||||
return Math.min(mChunkSize, mChannel.size() - mChannel.position());
|
||||
} catch (IOException e) {
|
||||
return mChunkSize;
|
||||
}
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return mContentType;
|
||||
}
|
||||
|
||||
public boolean isRepeatable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDatatransferProgressListener(OnDatatransferProgressListener listener) {
|
||||
synchronized (mDataTransferListeners) {
|
||||
mDataTransferListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDatatransferProgressListeners(Collection<OnDatatransferProgressListener> listeners) {
|
||||
synchronized (mDataTransferListeners) {
|
||||
mDataTransferListeners.addAll(listeners);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDatatransferProgressListener(OnDatatransferProgressListener listener) {
|
||||
synchronized (mDataTransferListeners) {
|
||||
mDataTransferListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeRequest(final OutputStream out) throws IOException {
|
||||
int readCount;
|
||||
Iterator<OnDatatransferProgressListener> it;
|
||||
|
||||
try {
|
||||
mChannel.position(mOffset);
|
||||
long size = mFile.length();
|
||||
if (size == 0) size = -1;
|
||||
long maxCount = Math.min(mOffset + mChunkSize, mChannel.size());
|
||||
while (mChannel.position() < maxCount) {
|
||||
readCount = mChannel.read(mBuffer);
|
||||
try {
|
||||
out.write(mBuffer.array(), 0, readCount);
|
||||
} catch (IOException io) {
|
||||
// work-around try catch to filter exception in writing
|
||||
throw new FileRequestEntity.WriteException(io);
|
||||
}
|
||||
mBuffer.clear();
|
||||
if (mTransferred < maxCount) { // condition to avoid accumulate progress for repeated chunks
|
||||
mTransferred += readCount;
|
||||
}
|
||||
synchronized (mDataTransferListeners) {
|
||||
it = mDataTransferListeners.iterator();
|
||||
while (it.hasNext()) {
|
||||
it.next().onTransferProgress(readCount, mTransferred, size, mFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException io) {
|
||||
// any read problem will be handled as if the file is not there
|
||||
if (io instanceof FileNotFoundException) {
|
||||
throw io;
|
||||
} else {
|
||||
FileNotFoundException fnf = new FileNotFoundException("Exception reading source file");
|
||||
fnf.initCause(io);
|
||||
throw fnf;
|
||||
}
|
||||
|
||||
} catch (FileRequestEntity.WriteException we) {
|
||||
throw we.getWrapped();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2012 Bartek Przybylski
|
||||
*
|
||||
* 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 java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A RequestEntity that represents a File.
|
||||
*
|
||||
*/
|
||||
public class FileRequestEntity implements ProgressiveDataTransferer {
|
||||
|
||||
final File mFile;
|
||||
final String mContentType;
|
||||
Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<>();
|
||||
|
||||
public FileRequestEntity(final File file, final String contentType) {
|
||||
super();
|
||||
this.mFile = file;
|
||||
this.mContentType = contentType;
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("File may not be null");
|
||||
}
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return mContentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDatatransferProgressListener(OnDatatransferProgressListener listener) {
|
||||
synchronized (mDataTransferListeners) {
|
||||
mDataTransferListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDatatransferProgressListeners(Collection<OnDatatransferProgressListener> listeners) {
|
||||
synchronized (mDataTransferListeners) {
|
||||
mDataTransferListeners.addAll(listeners);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDatatransferProgressListener(OnDatatransferProgressListener listener) {
|
||||
synchronized (mDataTransferListeners) {
|
||||
mDataTransferListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
protected static class WriteException extends Exception {
|
||||
IOException mWrapped;
|
||||
|
||||
WriteException(IOException wrapped) {
|
||||
mWrapped = wrapped;
|
||||
}
|
||||
|
||||
public IOException getWrapped() {
|
||||
return mWrapped;
|
||||
}
|
||||
}
|
||||
}
|
@ -81,10 +81,10 @@ public abstract class RemoteOperation<T extends Object> implements Runnable {
|
||||
|
||||
if (account == null)
|
||||
throw new IllegalArgumentException
|
||||
("Trying to onExecute a remote operation with a NULL Account");
|
||||
("Trying to execute a remote operation with a NULL Account");
|
||||
if (context == null)
|
||||
throw new IllegalArgumentException
|
||||
("Trying to onExecute 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 = account;
|
||||
mContext = context.getApplicationContext();
|
||||
@ -114,7 +114,7 @@ public abstract class RemoteOperation<T extends Object> implements Runnable {
|
||||
OnRemoteOperationListener listener, Handler listenerHandler) {
|
||||
if (client == null) {
|
||||
throw new IllegalArgumentException
|
||||
("Trying to onExecute a remote operation with a NULL OwnCloudClient");
|
||||
("Trying to execute a remote operation with a NULL OwnCloudClient");
|
||||
}
|
||||
mClient = client;
|
||||
if (client.getAccount() != null) {
|
||||
@ -124,7 +124,7 @@ public abstract class RemoteOperation<T extends Object> implements Runnable {
|
||||
|
||||
if (listener == null) {
|
||||
throw new IllegalArgumentException
|
||||
("Trying to onExecute a remote operation asynchronously " +
|
||||
("Trying to execute a remote operation asynchronously " +
|
||||
"without a listener to notiy the result");
|
||||
}
|
||||
mListener = listener;
|
||||
@ -182,10 +182,10 @@ public abstract class RemoteOperation<T extends Object> implements Runnable {
|
||||
*/
|
||||
public RemoteOperationResult<T> execute(Account account, Context context) {
|
||||
if (account == null)
|
||||
throw new IllegalArgumentException("Trying to onExecute a remote operation with a NULL " +
|
||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
||||
"Account");
|
||||
if (context == null)
|
||||
throw new IllegalArgumentException("Trying to onExecute a remote operation with a NULL " +
|
||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
||||
"Context");
|
||||
mAccount = account;
|
||||
mContext = context.getApplicationContext();
|
||||
@ -205,7 +205,7 @@ public abstract class RemoteOperation<T extends Object> implements Runnable {
|
||||
*/
|
||||
public RemoteOperationResult<T> execute(OwnCloudClient client) {
|
||||
if (client == null)
|
||||
throw new IllegalArgumentException("Trying to onExecute a remote operation with a NULL " +
|
||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
||||
"OwnCloudClient");
|
||||
mClient = client;
|
||||
if (client.getAccount() != null) {
|
||||
@ -227,7 +227,7 @@ public abstract class RemoteOperation<T extends Object> implements Runnable {
|
||||
*/
|
||||
public RemoteOperationResult<T> execute(OkHttpClient client, Context context) {
|
||||
if (client == null)
|
||||
throw new IllegalArgumentException("Trying to onExecute a remote operation with a NULL " +
|
||||
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL " +
|
||||
"OwnCloudClient");
|
||||
mHttpClient = client;
|
||||
mContext = context;
|
||||
@ -283,5 +283,4 @@ public abstract class RemoteOperation<T extends Object> implements Runnable {
|
||||
mListener.onRemoteOperationFinish(RemoteOperation.this, resultToSend);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,27 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2018 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.operations;
|
||||
|
||||
import android.accounts.Account;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 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
|
||||
@ -45,6 +45,7 @@ import java.util.concurrent.TimeUnit;
|
||||
* Allows renaming the moving file/folder at the same time.
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* @author Christian Schabesberger
|
||||
*/
|
||||
public class CopyRemoteFileOperation extends RemoteOperation {
|
||||
|
||||
@ -116,7 +117,7 @@ public class CopyRemoteFileOperation extends RemoteOperation {
|
||||
} else if (status == HttpConstants.HTTP_PRECONDITION_FAILED && !mOverwrite) {
|
||||
|
||||
result = new RemoteOperationResult<>(ResultCode.INVALID_OVERWRITE);
|
||||
client.exhaustResponse(copyMethod.getResponseAsStream());
|
||||
client.exhaustResponse(copyMethod.getResponseBodyAsStream());
|
||||
|
||||
|
||||
/// for other errors that could be explicitly handled, check first:
|
||||
@ -124,7 +125,7 @@ public class CopyRemoteFileOperation extends RemoteOperation {
|
||||
|
||||
} else {
|
||||
result = new RemoteOperationResult<>(copyMethod);
|
||||
client.exhaustResponse(copyMethod.getResponseAsStream());
|
||||
client.exhaustResponse(copyMethod.getResponseBodyAsStream());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Copy " + mSrcRemotePath + " to " + mTargetRemotePath + ": " +
|
||||
|
@ -90,7 +90,6 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||
result = createFolder(client); // second (and last) try
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
result = new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||
}
|
||||
@ -98,7 +97,6 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private RemoteOperationResult createFolder(OwnCloudClient client) {
|
||||
RemoteOperationResult result;
|
||||
try {
|
||||
@ -112,7 +110,7 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
||||
? new RemoteOperationResult<>(ResultCode.OK)
|
||||
: new RemoteOperationResult<>(mkcol);
|
||||
Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
|
||||
client.exhaustResponse(mkcol.getResponseAsStream());
|
||||
client.exhaustResponse(mkcol.getResponseBodyAsStream());
|
||||
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult<>(e);
|
||||
|
@ -110,7 +110,7 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
||||
status = client.executeHttpMethod(mGet);
|
||||
if (isSuccess(status)) {
|
||||
targetFile.createNewFile();
|
||||
bis = new BufferedInputStream(mGet.getResponseAsStream());
|
||||
bis = new BufferedInputStream(mGet.getResponseBodyAsStream());
|
||||
fos = new FileOutputStream(targetFile);
|
||||
long transferred = 0;
|
||||
|
||||
@ -160,12 +160,12 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
|
||||
}
|
||||
|
||||
} else {
|
||||
client.exhaustResponse(mGet.getResponseAsStream());
|
||||
client.exhaustResponse(mGet.getResponseBodyAsStream());
|
||||
// TODO some kind of error control!
|
||||
}
|
||||
|
||||
} else if (status != FORBIDDEN_ERROR && status != SERVICE_UNAVAILABLE_ERROR) {
|
||||
client.exhaustResponse(mGet.getResponseAsStream());
|
||||
client.exhaustResponse(mGet.getResponseBodyAsStream());
|
||||
|
||||
} // else, body read by RemoteOperationResult constructor
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -24,10 +24,9 @@
|
||||
|
||||
package com.owncloud.android.lib.resources.files;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
|
@ -126,7 +126,6 @@ public class MoveRemoteFileOperation extends RemoteOperation {
|
||||
move.setReadTimeout(MOVE_READ_TIMEOUT, TimeUnit.SECONDS);
|
||||
move.setConnectionTimeout(MOVE_CONNECTION_TIMEOUT, TimeUnit.SECONDS);
|
||||
|
||||
//int status = client.executeMethod(move, MOVE_READ_TIMEOUT, MOVE_CONNECTION_TIMEOUT);
|
||||
final int status = client.executeHttpMethod(move);
|
||||
/// process response
|
||||
if(isSuccess(status)) {
|
||||
@ -134,14 +133,14 @@ public class MoveRemoteFileOperation extends RemoteOperation {
|
||||
} else if (status == HttpConstants.HTTP_PRECONDITION_FAILED && !mOverwrite) {
|
||||
|
||||
result = new RemoteOperationResult<>(ResultCode.INVALID_OVERWRITE);
|
||||
client.exhaustResponse(move.getResponseAsStream());
|
||||
client.exhaustResponse(move.getResponseBodyAsStream());
|
||||
|
||||
/// for other errors that could be explicitly handled, check first:
|
||||
/// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4
|
||||
|
||||
} else {
|
||||
result = new RemoteOperationResult<>(move);
|
||||
client.exhaustResponse(move.getResponseAsStream());
|
||||
client.exhaustResponse(move.getResponseBodyAsStream());
|
||||
}
|
||||
|
||||
Log.i(TAG, "Move " + mSrcRemotePath + " to " + mTargetRemotePath + ": " +
|
||||
|
@ -35,8 +35,6 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import at.bitfire.dav4android.DavResource;
|
||||
|
||||
import static com.owncloud.android.lib.common.http.methods.webdav.DavConstants.DEPTH_0;
|
||||
import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK;
|
||||
|
||||
@ -96,7 +94,7 @@ public class ReadRemoteFileOperation extends RemoteOperation<RemoteFile> {
|
||||
|
||||
} else {
|
||||
result = new RemoteOperationResult<>(propfind);
|
||||
client.exhaustResponse(propfind.getResponseAsStream());
|
||||
client.exhaustResponse(propfind.getResponseBodyAsStream());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -37,7 +37,6 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import at.bitfire.dav4android.DavResource;
|
||||
import at.bitfire.dav4android.Response;
|
||||
|
||||
import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 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
|
||||
@ -53,6 +53,7 @@ import static com.owncloud.android.lib.common.OwnCloudClient.NEW_WEBDAV_FILES_PA
|
||||
* Contains the data of a Remote File from a WebDavEntry
|
||||
*
|
||||
* @author masensio
|
||||
* @author Christian Schabesberger
|
||||
*/
|
||||
|
||||
public class RemoteFile implements Parcelable, Serializable {
|
||||
|
@ -57,7 +57,6 @@ public class RenameRemoteFileOperation extends RemoteOperation {
|
||||
private String mNewName;
|
||||
private String mNewRemotePath;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -121,7 +120,7 @@ public class RenameRemoteFileOperation extends RemoteOperation {
|
||||
Log_OC.i(TAG, "Rename " + mOldRemotePath + " to " + mNewRemotePath + ": " +
|
||||
result.getLogMessage()
|
||||
);
|
||||
client.exhaustResponse(move.getResponseAsStream());
|
||||
client.exhaustResponse(move.getResponseBodyAsStream());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
final RemoteOperationResult result = new RemoteOperationResult<>(e);
|
||||
@ -143,5 +142,4 @@ public class RenameRemoteFileOperation extends RemoteOperation {
|
||||
RemoteOperationResult exists = existenceCheckRemoteOperation.run(client);
|
||||
return exists.isSuccess();
|
||||
}
|
||||
|
||||
}
|
@ -136,7 +136,6 @@ public class UploadRemoteFileOperation extends RemoteOperation {
|
||||
}
|
||||
|
||||
mPutMethod.addRequestHeader(HttpConstants.OC_TOTAL_LENGTH_HEADER, String.valueOf(fileToUpload.length()));
|
||||
|
||||
mPutMethod.addRequestHeader(HttpConstants.OC_X_OC_MTIME_HEADER, mFileLastModifTimestamp);
|
||||
|
||||
mPutMethod.setRequestBody(mFileRequestBody);
|
||||
|
@ -43,7 +43,6 @@ import okhttp3.MediaType;
|
||||
|
||||
import static com.owncloud.android.lib.common.http.HttpConstants.IF_MATCH_HEADER;
|
||||
import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK;
|
||||
import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK;
|
||||
|
||||
/**
|
||||
* Remote operation performing the chunked upload of a remote file to the ownCloud server.
|
||||
|
@ -1,3 +1,28 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* @author David González Verdugo
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.lib.resources.files.chunks;
|
||||
|
||||
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation;
|
||||
|
@ -1,3 +1,28 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* @author Christian Schabesberger
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.lib.resources.shares;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* @author David A. Velasco
|
||||
* @author David González Verdugo
|
||||
* @author Christian Schabesberger
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@ -138,5 +139,4 @@ public class ShareToRemoteOperationResultParser {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -31,7 +31,6 @@ import android.net.Uri;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.http.HttpConstants;
|
||||
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
|
||||
import com.owncloud.android.lib.common.network.CertificateCombinedException;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
@ -41,10 +40,7 @@ import org.json.JSONObject;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.net.ssl.SSLHandshakeException;
|
||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
|
||||
import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK;
|
||||
|
||||
|
@ -33,7 +33,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -42,7 +41,6 @@ import java.net.URL;
|
||||
|
||||
import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK;
|
||||
|
||||
|
||||
/**
|
||||
* Gets avatar about the user logged in, if available
|
||||
* @author David A. Velasco
|
||||
@ -113,7 +111,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA
|
||||
mimeType = contentType;
|
||||
|
||||
/// download will be performed to a buffer
|
||||
inputStream = getMethod.getResponseAsStream();
|
||||
inputStream = getMethod.getResponseBodyAsStream();
|
||||
bis = new BufferedInputStream(inputStream);
|
||||
bos = new ByteArrayOutputStream(totalToTransfer);
|
||||
|
||||
@ -138,7 +136,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation<GetRemoteUserA
|
||||
|
||||
} else {
|
||||
result = new RemoteOperationResult<>(getMethod);
|
||||
client.exhaustResponse(getMethod.getResponseAsStream());
|
||||
client.exhaustResponse(getMethod.getResponseBodyAsStream());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -35,11 +35,8 @@ import org.json.JSONObject;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import okhttp3.Request;
|
||||
|
||||
import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK;
|
||||
|
||||
|
||||
/**
|
||||
* Gets information (id, display name, and e-mail address) about the user logged in.
|
||||
*
|
||||
@ -71,11 +68,6 @@ public class GetRemoteUserInfoOperation extends RemoteOperation<GetRemoteUserInf
|
||||
|
||||
//Get the user
|
||||
try {
|
||||
final Request request = new Request.Builder()
|
||||
.url(client.getBaseUri() + OCS_ROUTE)
|
||||
.addHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE)
|
||||
.build();
|
||||
|
||||
GetMethod getMethod = new GetMethod(new URL(client.getBaseUri() + OCS_ROUTE));
|
||||
|
||||
int status = client.executeHttpMethod(getMethod);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2016 ownCloud GmbH.
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -41,7 +41,6 @@ import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
|
||||
/**
|
||||
* SelfSignedConfidentSslSocketFactory allows to create SSL {@link Socket}s
|
||||
* that accepts self-signed server certificates.
|
||||
@ -49,6 +48,7 @@ import javax.net.ssl.X509TrustManager;
|
||||
* WARNING: this SHOULD NOT be used in productive environments.
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* @author Christian Schabesberger
|
||||
*/
|
||||
|
||||
public class SelfSignedConfidentSslSocketFactory implements SecureProtocolSocketFactory {
|
||||
@ -182,6 +182,4 @@ public class SelfSignedConfidentSslSocketFactory implements SecureProtocolSocket
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user