1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Refactor wrapper constructors and start to implement uploadoperations in library

This commit is contained in:
davigonz 2018-06-12 17:42:32 +02:00
parent c676f694d6
commit 524dc587db
24 changed files with 172 additions and 130 deletions

@ -1 +1 @@
Subproject commit 054d7b57b27d7c258d717c8a326eed89e195d168
Subproject commit 466380e9bb8414d919391dbb14de7926dbfd387e

View File

@ -33,7 +33,7 @@ import android.net.Uri;
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.HttpBaseMethod;
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
import com.owncloud.android.lib.common.network.RedirectionPath;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

View File

@ -22,7 +22,9 @@
*
*/
package com.owncloud.android.lib.common.http;
package com.owncloud.android.lib.common.http.methods;
import com.owncloud.android.lib.common.http.HttpClient;
import java.io.IOException;
import java.io.InputStream;
@ -46,7 +48,7 @@ public abstract class HttpBaseMethod {
protected Request mRequest;
protected Response mResponse;
public HttpBaseMethod (HttpUrl httpUrl) {
protected HttpBaseMethod (HttpUrl httpUrl) {
mOkHttpClient = HttpClient.getOkHttpClient();
mRequest = new Request.Builder()
.url(httpUrl)
@ -58,7 +60,6 @@ public abstract class HttpBaseMethod {
return mRequest.headers();
}
// Request headers
public void addRequestHeader(String name, String value) {
mRequest.newBuilder()
.addHeader(name, value)

View File

@ -24,22 +24,26 @@
package com.owncloud.android.lib.common.http.methods.nonwebdav;
import java.io.IOException;
import okhttp3.HttpUrl;
/**
* OkHttp delete calls wrapper
* @author David González Verdugo
*/
public class DeleteMethod extends HttpMethod{
public DeleteMethod(String httpUrl) {
public DeleteMethod(HttpUrl httpUrl) {
super(httpUrl);
}
@Override
public int execute() throws Exception {
mRequest.newBuilder()
public int execute() throws IOException {
mRequest = mRequest.newBuilder()
.delete()
.build();
return super.executeRequest();
return super.execute();
}
}

View File

@ -34,20 +34,16 @@ import okhttp3.HttpUrl;
*/
public class GetMethod extends HttpMethod {
public GetMethod(String httpUrl) {
super(httpUrl);
}
public GetMethod(HttpUrl httpUrl) {
super(httpUrl);
}
@Override
public int execute() throws IOException {
mRequest.newBuilder()
mRequest = mRequest.newBuilder()
.get()
.build();
return super.executeRequest();
return super.execute();
}
}

View File

@ -24,12 +24,11 @@
package com.owncloud.android.lib.common.http.methods.nonwebdav;
import com.owncloud.android.lib.common.http.HttpBaseMethod;
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
import java.io.IOException;
import okhttp3.HttpUrl;
import okhttp3.Request;
/**
* Wrapper to perform OkHttp calls
@ -42,7 +41,8 @@ public abstract class HttpMethod extends HttpBaseMethod {
super(httpUrl);
}
public int executeRequest() throws IOException {
@Override
public int execute() throws IOException {
mResponse = mOkHttpClient.newCall(mRequest).execute();
return super.getStatusCode();
}

View File

@ -24,6 +24,9 @@
package com.owncloud.android.lib.common.http.methods.nonwebdav;
import java.io.IOException;
import okhttp3.HttpUrl;
import okhttp3.RequestBody;
/**
@ -34,17 +37,17 @@ public class PostMethod extends HttpMethod {
private RequestBody mRequestBody;
public PostMethod(String httpUrl, RequestBody requestBody){
public PostMethod(HttpUrl httpUrl, RequestBody requestBody){
super(httpUrl);
mRequestBody = requestBody;
}
@Override
public int execute() throws Exception {
mRequest.newBuilder()
public int execute() throws IOException {
mRequest = mRequest.newBuilder()
.post(mRequestBody)
.build();
return super.executeRequest();
return super.execute();
}
}

View File

@ -24,23 +24,26 @@
package com.owncloud.android.lib.common.http.methods.nonwebdav;
import java.io.IOException;
import okhttp3.HttpUrl;
import okhttp3.RequestBody;
public class PutMethod extends HttpMethod{
private RequestBody mRequestBody;
public PutMethod(String httpUrl, RequestBody requestBody){
public PutMethod(HttpUrl httpUrl, RequestBody requestBody){
super(httpUrl);
mRequestBody = requestBody;
}
@Override
public int execute() throws Exception {
mRequest.newBuilder()
public int execute() throws IOException {
mRequest = mRequest.newBuilder()
.put(mRequestBody)
.build();
return super.executeRequest();
return super.execute();
}
}

View File

@ -24,7 +24,7 @@
package com.owncloud.android.lib.common.http.methods.webdav;
import com.owncloud.android.lib.common.http.HttpBaseMethod;
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
import at.bitfire.dav4android.DavOCResource;
import at.bitfire.dav4android.DavResource;
@ -38,8 +38,8 @@ public abstract class DavMethod extends HttpBaseMethod {
protected DavOCResource mDavResource;
public DavMethod(HttpUrl httpUrl) {
super();
protected DavMethod(HttpUrl httpUrl) {
super(httpUrl);
mDavResource = new DavOCResource(
mOkHttpClient,
httpUrl

View File

@ -50,7 +50,7 @@ public class PutMethod extends DavMethod {
};
@Override
public int execute() throws IOException, HttpException, DavException {
public int execute() throws IOException, HttpException {
try {
mDavResource.put(
mRequestBody,

View File

@ -32,16 +32,12 @@ import java.util.Locale;
import android.net.Uri;
import com.owncloud.android.lib.common.http.HttpBaseMethod;
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.jackrabbit.webdav.property.DavPropertyName;
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
import org.apache.jackrabbit.webdav.xml.Namespace;
import okhttp3.Response;
public class WebdavUtils {
public static final SimpleDateFormat DISPLAY_DATE_FORMAT = new SimpleDateFormat(
"dd.MM.yyyy hh:mm");

View File

@ -28,7 +28,7 @@ import android.accounts.Account;
import android.accounts.AccountsException;
import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
import com.owncloud.android.lib.common.http.HttpBaseMethod;
import com.owncloud.android.lib.common.http.methods.HttpBaseMethod;
import com.owncloud.android.lib.common.network.CertificateCombinedException;
import com.owncloud.android.lib.common.utils.Log_OC;

View File

@ -72,79 +72,81 @@ public class ChunkedUploadRemoteFileOperation extends UploadRemoteFileOperation
FileChannel channel = null;
RandomAccessFile raf = null;
try {
File file = new File(mLocalPath);
raf = new RandomAccessFile(file, "r");
channel = raf.getChannel();
mEntity = new ChunkFromFileChannelRequestEntity(channel, mMimeType, CHUNK_SIZE, file);
synchronized (mDataTransferListeners) {
((ProgressiveDataTransferer) mEntity)
.addDatatransferProgressListeners(mDataTransferListeners);
}
long offset = 0;
String uriPrefix = client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath) +
"-chunking-" + Math.abs((new Random()).nextInt(9000) + 1000) + "-";
long totalLength = file.length();
long chunkCount = (long) Math.ceil((double) totalLength / CHUNK_SIZE);
String chunkSizeStr = String.valueOf(CHUNK_SIZE);
String totalLengthStr = String.valueOf(file.length());
for (int chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++, offset += CHUNK_SIZE) {
if (chunkIndex == chunkCount - 1) {
chunkSizeStr = String.valueOf(CHUNK_SIZE * chunkCount - totalLength);
}
if (mPutMethod != null) {
mPutMethod.releaseConnection(); // let the connection available
// for other methods
}
mPutMethod = new PutMethod(uriPrefix + chunkCount + "-" + chunkIndex);
if (mRequiredEtag != null && mRequiredEtag.length() > 0) {
mPutMethod.addRequestHeader(IF_MATCH_HEADER, "\"" + mRequiredEtag + "\"");
}
mPutMethod.addRequestHeader(OC_CHUNKED_HEADER, OC_CHUNKED_HEADER);
mPutMethod.addRequestHeader(OC_CHUNK_SIZE_HEADER, chunkSizeStr);
mPutMethod.addRequestHeader(OC_TOTAL_LENGTH_HEADER, totalLengthStr);
mPutMethod.addRequestHeader(OC_CHUNK_X_OC_MTIME_HEADER, mFileLastModifTimestamp);
((ChunkFromFileChannelRequestEntity) mEntity).setOffset(offset);
mPutMethod.setRequestEntity(mEntity);
if (mCancellationRequested.get()) {
mPutMethod.abort();
// next method will throw an exception
}
if (chunkIndex == chunkCount - 1) {
// Added a high timeout to the last chunk due to when the last chunk
// arrives to the server with the last PUT, all chunks get assembled
// within that PHP request, so last one takes longer.
mPutMethod.getParams().setSoTimeout(LAST_CHUNK_TIMEOUT);
}
status = client.executeMethod(mPutMethod);
result = new RemoteOperationResult(
isSuccess(status),
mPutMethod
);
client.exhaustResponse(mPutMethod.getResponseBodyAsStream());
Log_OC.d(TAG, "Upload of " + mLocalPath + " to " + mRemotePath +
", chunk index " + chunkIndex + ", count " + chunkCount +
", HTTP result status " + status);
if (!isSuccess(status))
break;
}
} finally {
if (channel != null)
channel.close();
if (raf != null)
raf.close();
if (mPutMethod != null)
mPutMethod.releaseConnection(); // let the connection available for other methods
}
//TODO
// try {
// File file = new File(mLocalPath);
// raf = new RandomAccessFile(file, "r");
// channel = raf.getChannel();
// mEntity = new ChunkFromFileChannelRequestEntity(channel, mMimeType, CHUNK_SIZE, file);
// synchronized (mDataTransferListeners) {
// ((ProgressiveDataTransferer) mEntity)
// .addDatatransferProgressListeners(mDataTransferListeners);
// }
//
// long offset = 0;
// String uriPrefix = client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath) +
// "-chunking-" + Math.abs((new Random()).nextInt(9000) + 1000) + "-";
// long totalLength = file.length();
// long chunkCount = (long) Math.ceil((double) totalLength / CHUNK_SIZE);
// String chunkSizeStr = String.valueOf(CHUNK_SIZE);
// String totalLengthStr = String.valueOf(file.length());
// for (int chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++, offset += CHUNK_SIZE) {
// if (chunkIndex == chunkCount - 1) {
// chunkSizeStr = String.valueOf(CHUNK_SIZE * chunkCount - totalLength);
// }
// if (mPutMethod != null) {
// mPutMethod.releaseConnection(); // let the connection available
// // for other methods
// }
// mPutMethod = new PutMethod(uriPrefix + chunkCount + "-" + chunkIndex);
// if (mRequiredEtag != null && mRequiredEtag.length() > 0) {
// mPutMethod.addRequestHeader(IF_MATCH_HEADER, "\"" + mRequiredEtag + "\"");
// }
// mPutMethod.addRequestHeader(OC_CHUNKED_HEADER, OC_CHUNKED_HEADER);
// mPutMethod.addRequestHeader(OC_CHUNK_SIZE_HEADER, chunkSizeStr);
// mPutMethod.addRequestHeader(OC_TOTAL_LENGTH_HEADER, totalLengthStr);
//
// mPutMethod.addRequestHeader(OC_CHUNK_X_OC_MTIME_HEADER, mFileLastModifTimestamp);
//
// ((ChunkFromFileChannelRequestEntity) mEntity).setOffset(offset);
// mPutMethod.setRequestEntity(mEntity);
// if (mCancellationRequested.get()) {
// mPutMethod.abort();
// // next method will throw an exception
// }
//
// if (chunkIndex == chunkCount - 1) {
// // Added a high timeout to the last chunk due to when the last chunk
// // arrives to the server with the last PUT, all chunks get assembled
// // within that PHP request, so last one takes longer.
// mPutMethod.getParams().setSoTimeout(LAST_CHUNK_TIMEOUT);
// }
//
// status = client.executeMethod(mPutMethod);
//
// result = new RemoteOperationResult(
// isSuccess(status),
// mPutMethod
// );
//
// client.exhaustResponse(mPutMethod.getResponseBodyAsStream());
// Log_OC.d(TAG, "Upload of " + mLocalPath + " to " + mRemotePath +
// ", chunk index " + chunkIndex + ", count " + chunkCount +
// ", HTTP result status " + status);
//
// if (!isSuccess(status))
// break;
// }
//
// } finally {
// if (channel != null)
// channel.close();
// if (raf != null)
// raf.close();
// if (mPutMethod != null)
// mPutMethod.releaseConnection(); // let the connection available for other methods
// }
return result;
}

View File

@ -25,6 +25,7 @@
package com.owncloud.android.lib.resources.files;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.http.HttpConstants;
import com.owncloud.android.lib.common.http.HttpUtils;
import com.owncloud.android.lib.common.network.FileRequestEntity;
import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
@ -134,11 +135,6 @@ public class UploadRemoteFileOperation extends RemoteOperation {
return result;
}
public boolean isSuccess(int status) {
return ((status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED ||
status == HttpStatus.SC_NO_CONTENT));
}
protected RemoteOperationResult uploadFile(OwnCloudClient client) throws IOException {
RemoteOperationResult result;
try {
@ -204,4 +200,9 @@ public class UploadRemoteFileOperation extends RemoteOperation {
// mPutMethod.abort();
// }
}
public boolean isSuccess(int status) {
return ((status == HttpConstants.HTTP_OK || status == HttpConstants.HTTP_CREATED ||
status == HttpConstants.HTTP_NO_CONTENT));
}
}

View File

@ -31,6 +31,7 @@ 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.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.PostMethod;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@ -231,7 +232,11 @@ public class CreateRemoteShareOperation extends RemoteOperation {
Uri.Builder uriBuilder = requestUri.buildUpon();
uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH);
PostMethod postMethod = new PostMethod(uriBuilder.build().toString(), formBody);
PostMethod postMethod = new PostMethod(
HttpUtils.stringUrlToHttpUrl(uriBuilder.build().toString()),
formBody
);
postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
postMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);

View File

@ -30,6 +30,7 @@ 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.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@ -63,7 +64,11 @@ public class GetRemoteShareOperation extends RemoteOperation {
uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH);
uriBuilder.appendEncodedPath(Long.toString(mRemoteId));
GetMethod getMethod = new GetMethod(uriBuilder.build().toString());
GetMethod getMethod = new GetMethod(
HttpUtils.stringUrlToHttpUrl(uriBuilder.build().toString())
);
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
int status = client.executeHttpMethod(getMethod);

View File

@ -32,6 +32,7 @@ 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.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@ -130,7 +131,10 @@ public class GetRemoteShareesOperation extends RemoteOperation{
uriBuilder.appendQueryParameter(PARAM_PAGE, String.valueOf(mPage));
uriBuilder.appendQueryParameter(PARAM_PER_PAGE, String.valueOf(mPerPage));
GetMethod getMethod = new GetMethod(uriBuilder.build().toString());
GetMethod getMethod = new GetMethod(
HttpUtils.stringUrlToHttpUrl(uriBuilder.build().toString())
);
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
int status = client.executeHttpMethod(getMethod);

View File

@ -29,6 +29,7 @@ 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.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@ -57,7 +58,10 @@ public class GetRemoteSharesOperation extends RemoteOperation {
Uri.Builder uriBuilder = requestUri.buildUpon();
uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH);
GetMethod getMethod = new GetMethod(uriBuilder.build().toString());
GetMethod getMethod = new GetMethod(
HttpUtils.stringUrlToHttpUrl(client.getBaseUri() + ShareUtils.SHARING_API_PATH)
);
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
int status = client.executeHttpMethod(getMethod);

View File

@ -31,6 +31,7 @@ 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.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.DeleteMethod;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@ -72,7 +73,8 @@ public class RemoveRemoteShareOperation extends RemoteOperation {
uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH);
uriBuilder.appendEncodedPath(String.valueOf(mRemoteShareId));
DeleteMethod deleteMethod = new DeleteMethod(uriBuilder.build().toString());
DeleteMethod deleteMethod = new DeleteMethod(
HttpUtils.stringUrlToHttpUrl(uriBuilder.build().toString()));
deleteMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);

View File

@ -29,6 +29,7 @@ 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.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.PutMethod;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@ -204,7 +205,11 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
uriBuilder.appendEncodedPath(ShareUtils.SHARING_API_PATH.substring(1));
uriBuilder.appendEncodedPath(Long.toString(mRemoteId));
PutMethod putMethod = new PutMethod(uriBuilder.build().toString(), formBody);
PutMethod putMethod = new PutMethod(
HttpUtils.stringUrlToHttpUrl(uriBuilder.build().toString()),
formBody
);
putMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
putMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);

View File

@ -31,6 +31,7 @@ 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.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@ -128,9 +129,10 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation {
uriBuilder.appendEncodedPath(OCS_ROUTE); // avoid starting "/" in this method
uriBuilder.appendQueryParameter(PARAM_FORMAT, VALUE_FORMAT);
String url = uriBuilder.build().toString();
GetMethod getMethod = new GetMethod(
HttpUtils.stringUrlToHttpUrl(uriBuilder.build().toString())
);
GetMethod getMethod = new GetMethod(url);
getMethod.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE);
int status = client.executeHttpMethod(getMethod);

View File

@ -31,6 +31,7 @@ import android.net.Uri;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.http.HttpClient;
import com.owncloud.android.lib.common.http.HttpConstants;
import com.owncloud.android.lib.common.http.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@ -77,13 +78,13 @@ public class GetRemoteStatusOperation extends RemoteOperation {
boolean retval = false;
String baseUrlSt = client.getBaseUri().toString();
try {
String url = baseUrlSt + OwnCloudClient.STATUS_PATH;
HttpClient.getOkHttpClient()
.newBuilder()
.followRedirects(false);
GetMethod getMethod = new GetMethod(url);
GetMethod getMethod = new GetMethod(
HttpUtils.stringUrlToHttpUrl(baseUrlSt + OwnCloudClient.STATUS_PATH)
);
int status = client.executeHttpMethod(getMethod);

View File

@ -26,6 +26,7 @@
package com.owncloud.android.lib.resources.users;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.http.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.RemoteOperation;
@ -86,7 +87,10 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation {
;
Log_OC.d(TAG, "avatar URI: " + url);
getMethod = new GetMethod(url);
getMethod = new GetMethod(
HttpUtils.stringUrlToHttpUrl(url)
);
int status = client.executeHttpMethod(getMethod);
if (isSuccess(status)) {

View File

@ -24,14 +24,17 @@
package com.owncloud.android.lib.resources.users;
import java.util.ArrayList;
import org.json.JSONObject;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.http.HttpConstants;
import com.owncloud.android.lib.common.http.HttpUtils;
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod;
import org.json.JSONObject;
import java.util.ArrayList;
import okhttp3.Request;
@ -74,9 +77,10 @@ public class GetRemoteUserInfoOperation extends RemoteOperation {
.addHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE)
.build();
String url = client.getBaseUri() + OCS_ROUTE;
GetMethod getMethod = new GetMethod(
HttpUtils.stringUrlToHttpUrl(client.getBaseUri() + OCS_ROUTE)
);
GetMethod getMethod = new GetMethod(url);
int status = client.executeHttpMethod(getMethod);
if (isSuccess(status)) {