mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Move webdav path constant and refactor some Remote operation methods
This commit is contained in:
parent
2ba891df15
commit
2ef51dd5f6
@ -15,7 +15,7 @@ public abstract class RemoteOperation {
|
|||||||
private final OCContext mContext;
|
private final OCContext mContext;
|
||||||
// TODO Move to a constants file
|
// TODO Move to a constants file
|
||||||
private static final String USER_AGENT_HEADER = "User-Agent";
|
private static final String USER_AGENT_HEADER = "User-Agent";
|
||||||
private static final String WEBDAV_PATH_4_0 = "remote.php/dav/files";
|
public static final String WEBDAV_PATH_4_0 = "remote.php/dav/files";
|
||||||
private static OkHttpClient mClient = null;
|
private static OkHttpClient mClient = null;
|
||||||
|
|
||||||
protected RemoteOperation(OCContext context) {
|
protected RemoteOperation(OCContext context) {
|
||||||
@ -45,10 +45,18 @@ public abstract class RemoteOperation {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Uri.Builder getBaseUriBuilder() {
|
private Uri.Builder getBaseUriBuilder() {
|
||||||
return mContext.getOCAccount().getBaseUri().buildUpon();
|
return mContext.getOCAccount().getBaseUri().buildUpon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected HttpUrl getHttpUrl(String endpointPath) {
|
||||||
|
return UrlUtils.INSTANCE.omitTrailingSlash(HttpUrl.parse(
|
||||||
|
getBaseUriBuilder()
|
||||||
|
.appendEncodedPath(endpointPath)
|
||||||
|
.build()
|
||||||
|
.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
protected HttpUrl getWebDavHttpUrl(String resourcePath) {
|
protected HttpUrl getWebDavHttpUrl(String resourcePath) {
|
||||||
return UrlUtils.INSTANCE.omitTrailingSlash(HttpUrl.parse(
|
return UrlUtils.INSTANCE.omitTrailingSlash(HttpUrl.parse(
|
||||||
getBaseUriBuilder()
|
getBaseUriBuilder()
|
||||||
|
@ -35,6 +35,7 @@ import android.net.Uri;
|
|||||||
|
|
||||||
import com.owncloud.android.lib.refactor.Log_OC;
|
import com.owncloud.android.lib.refactor.Log_OC;
|
||||||
import com.owncloud.android.lib.refactor.OCContext;
|
import com.owncloud.android.lib.refactor.OCContext;
|
||||||
|
import com.owncloud.android.lib.refactor.RemoteOperation;
|
||||||
import com.owncloud.android.lib.refactor.authentication.credentials.OCBasicCredentials;
|
import com.owncloud.android.lib.refactor.authentication.credentials.OCBasicCredentials;
|
||||||
import com.owncloud.android.lib.refactor.authentication.credentials.OCBearerCredentials;
|
import com.owncloud.android.lib.refactor.authentication.credentials.OCBearerCredentials;
|
||||||
import com.owncloud.android.lib.refactor.authentication.credentials.OCCredentials;
|
import com.owncloud.android.lib.refactor.authentication.credentials.OCCredentials;
|
||||||
@ -65,7 +66,7 @@ public class AccountUtils {
|
|||||||
public static String getWebDavUrlForAccount(Context context, Account account)
|
public static String getWebDavUrlForAccount(Context context, Account account)
|
||||||
throws AccountNotFoundException {
|
throws AccountNotFoundException {
|
||||||
|
|
||||||
return getBaseUrlForAccount(context, account) + OCContext.WEBDAV_PATH_4_0;
|
return getBaseUrlForAccount(context, account) + RemoteOperation.WEBDAV_PATH_4_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,10 +91,7 @@ public class OAuth2GetAccessTokenOperation extends RemoteOperation {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
final Request request = getRequestBuilder()
|
final Request request = getRequestBuilder()
|
||||||
.url(getBaseUriBuilder()
|
.url(getHttpUrl(mAccessTokenEndpointPath))
|
||||||
.appendEncodedPath(mAccessTokenEndpointPath)
|
|
||||||
.build()
|
|
||||||
.toString())
|
|
||||||
.method("POST", requestBody)
|
.method("POST", requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -86,10 +86,7 @@ public class OAuth2RefreshAccessTokenOperation extends RemoteOperation {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
final Request request = getRequestBuilder()
|
final Request request = getRequestBuilder()
|
||||||
.url(getBaseUriBuilder()
|
.url(getHttpUrl(mAccessTokenEndpointPath))
|
||||||
.appendEncodedPath(mAccessTokenEndpointPath)
|
|
||||||
.build()
|
|
||||||
.toString())
|
|
||||||
.method("POST", requestBody)
|
.method("POST", requestBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user