mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 10:27:45 +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; | ||||
|     // TODO Move to a constants file | ||||
|     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; | ||||
| 
 | ||||
|     protected RemoteOperation(OCContext context) { | ||||
| @ -45,10 +45,18 @@ public abstract class RemoteOperation { | ||||
|                 .build(); | ||||
|     } | ||||
| 
 | ||||
|     protected Uri.Builder getBaseUriBuilder() { | ||||
|     private Uri.Builder getBaseUriBuilder() { | ||||
|         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) { | ||||
|         return UrlUtils.INSTANCE.omitTrailingSlash(HttpUrl.parse( | ||||
|                 getBaseUriBuilder() | ||||
|  | ||||
| @ -35,6 +35,7 @@ import android.net.Uri; | ||||
| 
 | ||||
| import com.owncloud.android.lib.refactor.Log_OC; | ||||
| 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.OCBearerCredentials; | ||||
| import com.owncloud.android.lib.refactor.authentication.credentials.OCCredentials; | ||||
| @ -65,7 +66,7 @@ public class AccountUtils { | ||||
|     public static String getWebDavUrlForAccount(Context context, Account account) | ||||
|         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(); | ||||
| 
 | ||||
|             final Request request = getRequestBuilder() | ||||
|                     .url(getBaseUriBuilder() | ||||
|                             .appendEncodedPath(mAccessTokenEndpointPath) | ||||
|                             .build() | ||||
|                             .toString()) | ||||
|                     .url(getHttpUrl(mAccessTokenEndpointPath)) | ||||
|                     .method("POST", requestBody) | ||||
|                     .build(); | ||||
| 
 | ||||
|  | ||||
| @ -86,10 +86,7 @@ public class OAuth2RefreshAccessTokenOperation extends RemoteOperation { | ||||
|                     .build(); | ||||
| 
 | ||||
|             final Request request = getRequestBuilder() | ||||
|                     .url(getBaseUriBuilder() | ||||
|                             .appendEncodedPath(mAccessTokenEndpointPath) | ||||
|                             .build() | ||||
|                             .toString()) | ||||
|                     .url(getHttpUrl(mAccessTokenEndpointPath)) | ||||
|                     .method("POST", requestBody) | ||||
|                     .build(); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user