mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 10:27:45 +00:00 
			
		
		
		
	Refactored handle of ownCloud URIs inside OwnCloudClient; rest of library adapted
This commit is contained in:
		
							parent
							
								
									0fa6919761
								
							
						
					
					
						commit
						b28701ca30
					
				| @ -43,6 +43,7 @@ import org.apache.commons.httpclient.params.HttpMethodParams; | |||||||
| import org.apache.http.HttpStatus; | import org.apache.http.HttpStatus; | ||||||
| import org.apache.http.params.CoreProtocolPNames; | import org.apache.http.params.CoreProtocolPNames; | ||||||
| 
 | 
 | ||||||
|  | import com.owncloud.android.lib.common.accounts.AccountUtils; | ||||||
| import com.owncloud.android.lib.common.network.WebdavUtils; | import com.owncloud.android.lib.common.network.WebdavUtils; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -66,15 +67,20 @@ public class OwnCloudClient extends HttpClient { | |||||||
|     //private String mSsoSessionCookie = null; |     //private String mSsoSessionCookie = null; | ||||||
|     private int mInstanceNumber = 0; |     private int mInstanceNumber = 0; | ||||||
|      |      | ||||||
|     private Uri mUri; |     private Uri mBaseUri; | ||||||
|     private Uri mWebdavUri; |     //private Uri mWebdavUri; | ||||||
|      |      | ||||||
|     /** |     /** | ||||||
|      * Constructor |      * Constructor | ||||||
|      */ |      */ | ||||||
|     public OwnCloudClient(HttpConnectionManager connectionMgr) { |     public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr) { | ||||||
|         super(connectionMgr); |         super(connectionMgr); | ||||||
|          |          | ||||||
|  |         if (baseUri == null) { | ||||||
|  |         	throw new IllegalArgumentException("Parameter 'baseUri' cannot be NULL"); | ||||||
|  |         } | ||||||
|  |         mBaseUri = baseUri; | ||||||
|  |          | ||||||
|         mInstanceNumber = sIntanceCounter++; |         mInstanceNumber = sIntanceCounter++; | ||||||
|         Log.d(TAG + " #" + mInstanceNumber, "Creating OwnCloudClient"); |         Log.d(TAG + " #" + mInstanceNumber, "Creating OwnCloudClient"); | ||||||
|          |          | ||||||
| @ -131,7 +137,7 @@ public class OwnCloudClient extends HttpClient { | |||||||
|     /* |     /* | ||||||
|     public void setSsoSessionCookie(String accessToken) { |     public void setSsoSessionCookie(String accessToken) { | ||||||
|         Log.d(TAG + " #" + mInstanceNumber, "Setting session cookie: " + accessToken); |         Log.d(TAG + " #" + mInstanceNumber, "Setting session cookie: " + accessToken); | ||||||
|         Log.e(TAG + " #" + mInstanceNumber, "BASE URL: " + mUri); |         Log.e(TAG + " #" + mInstanceNumber, "BASE URL: " + mBaseUri); | ||||||
|         Log.e(TAG + " #" + mInstanceNumber, "WebDAV URL: " + mWebdavUri); |         Log.e(TAG + " #" + mInstanceNumber, "WebDAV URL: " + mWebdavUri); | ||||||
|          |          | ||||||
|         if (accessToken != null && accessToken.length() > 0) { |         if (accessToken != null && accessToken.length() > 0) { | ||||||
| @ -141,7 +147,7 @@ public class OwnCloudClient extends HttpClient { | |||||||
| 	        mSsoSessionCookie = accessToken; | 	        mSsoSessionCookie = accessToken; | ||||||
| 	        mCredentials = null; | 	        mCredentials = null; | ||||||
| 	 | 	 | ||||||
| 	        Uri serverUri = (mUri != null)? mUri : mWebdavUri; | 	        Uri serverUri = (mBaseUri != null)? mBaseUri : mWebdavUri; | ||||||
| 	        	// TODO refactoring the mess of URIs | 	        	// TODO refactoring the mess of URIs | ||||||
| 	         | 	         | ||||||
| 	        String[] cookies = mSsoSessionCookie.split(";"); | 	        String[] cookies = mSsoSessionCookie.split(";"); | ||||||
| @ -183,7 +189,7 @@ public class OwnCloudClient extends HttpClient { | |||||||
|      * @throws  Exception   When the existence could not be determined |      * @throws  Exception   When the existence could not be determined | ||||||
|      */ |      */ | ||||||
|     public boolean existsFile(String path) throws IOException, HttpException { |     public boolean existsFile(String path) throws IOException, HttpException { | ||||||
|         HeadMethod head = new HeadMethod(mWebdavUri.toString() + WebdavUtils.encodePath(path)); |         HeadMethod head = new HeadMethod(getWebdavUri() + WebdavUtils.encodePath(path)); | ||||||
|         try { |         try { | ||||||
|             int status = executeMethod(head); |             int status = executeMethod(head); | ||||||
|             Log.d(TAG, "HEAD to " + path + " finished with HTTP status " + status + |             Log.d(TAG, "HEAD to " + path + " finished with HTTP status " + status + | ||||||
| @ -323,31 +329,27 @@ public class OwnCloudClient extends HttpClient { | |||||||
|             getHttpConnectionManager().getParams().setConnectionTimeout(defaultConnectionTimeout); |             getHttpConnectionManager().getParams().setConnectionTimeout(defaultConnectionTimeout); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * Sets the Webdav URI for the helper methods that receive paths as parameters,  |  | ||||||
|      * instead of full URLs |  | ||||||
|      * @param uri |  | ||||||
|      */ |  | ||||||
|     public void setWebdavUri(Uri uri) { |  | ||||||
|         mWebdavUri = uri; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public Uri getWebdavUri() { |     public Uri getWebdavUri() { | ||||||
|         return mWebdavUri; |     	if (mCredentials instanceof OwnCloudBearerCredentials) { | ||||||
|  |     		return Uri.parse(mBaseUri + AccountUtils.ODAV_PATH); | ||||||
|  |     	} else { | ||||||
|  |     		return Uri.parse(mBaseUri + AccountUtils.WEBDAV_PATH_4_0); | ||||||
|  |     	} | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     /** |     /** | ||||||
|      * Sets the base URI for the helper methods that receive paths as parameters,  |      * Sets the root URI to the ownCloud server.    | ||||||
|      * instead of full URLs |      * | ||||||
|  |      * Use with care.  | ||||||
|      *  |      *  | ||||||
|      * @param uri |      * @param uri | ||||||
|      */ |      */ | ||||||
|     public void setBaseUri(Uri uri) { |     public void setBaseUri(Uri uri) { | ||||||
|         mUri = uri; |         mBaseUri = uri; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Uri getBaseUri() { |     public Uri getBaseUri() { | ||||||
|         return mUri; |         return mBaseUri; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /* |     /* | ||||||
|  | |||||||
| @ -72,14 +72,11 @@ public class OwnCloudClientFactory { | |||||||
|      */ |      */ | ||||||
|     public static OwnCloudClient createOwnCloudClient (Account account, Context appContext) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { |     public static OwnCloudClient createOwnCloudClient (Account account, Context appContext) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { | ||||||
|         //Log_OC.d(TAG, "Creating OwnCloudClient associated to " + account.name); |         //Log_OC.d(TAG, "Creating OwnCloudClient associated to " + account.name); | ||||||
|         |         Uri baseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(appContext, account)); | ||||||
|         Uri webdavUri = Uri.parse(AccountUtils.constructFullURLForAccount(appContext, account)); |  | ||||||
|         Uri uri = Uri.parse(AccountUtils.getBaseUrlForAccount(appContext, account)); |  | ||||||
|         AccountManager am = AccountManager.get(appContext); |         AccountManager am = AccountManager.get(appContext); | ||||||
|         boolean isOauth2 = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2) != null;   // TODO avoid calling to getUserData here |         boolean isOauth2 = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2) != null;   // TODO avoid calling to getUserData here | ||||||
|         boolean isSamlSso = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; |         boolean isSamlSso = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; | ||||||
|         OwnCloudClient client = createOwnCloudClient(webdavUri, appContext, !isSamlSso); |         OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); | ||||||
|         client.setBaseUri(uri); |  | ||||||
|          |          | ||||||
|         if (isOauth2) {     |         if (isOauth2) {     | ||||||
|             String accessToken = am.blockingGetAuthToken( |             String accessToken = am.blockingGetAuthToken( | ||||||
| @ -123,13 +120,11 @@ public class OwnCloudClientFactory { | |||||||
|      |      | ||||||
|      |      | ||||||
|     public static OwnCloudClient createOwnCloudClient (Account account, Context appContext, Activity currentActivity) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { |     public static OwnCloudClient createOwnCloudClient (Account account, Context appContext, Activity currentActivity) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException { | ||||||
|         Uri webdavUri = Uri.parse(AccountUtils.constructFullURLForAccount(appContext, account)); |         Uri baseUri = Uri.parse(AccountUtils.getBaseUrlForAccount(appContext, account)); | ||||||
|         Uri uri = Uri.parse(AccountUtils.getBaseUrlForAccount(appContext, account)); |  | ||||||
|         AccountManager am = AccountManager.get(appContext); |         AccountManager am = AccountManager.get(appContext); | ||||||
|         boolean isOauth2 = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2) != null;   // TODO avoid calling to getUserData here |         boolean isOauth2 = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_OAUTH2) != null;   // TODO avoid calling to getUserData here | ||||||
|         boolean isSamlSso = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; |         boolean isSamlSso = am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; | ||||||
|         OwnCloudClient client = createOwnCloudClient(webdavUri, appContext, !isSamlSso); |         OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); | ||||||
|         client.setBaseUri(uri); |  | ||||||
|          |          | ||||||
|         if (isOauth2) {    // TODO avoid a call to getUserData here |         if (isOauth2) {    // TODO avoid a call to getUserData here | ||||||
|             AccountManagerFuture<Bundle> future =  am.getAuthToken( |             AccountManagerFuture<Bundle> future =  am.getAuthToken( | ||||||
| @ -192,7 +187,7 @@ public class OwnCloudClientFactory { | |||||||
|     /** |     /** | ||||||
|      * Creates a OwnCloudClient to access a URL and sets the desired parameters for ownCloud client connections. |      * Creates a OwnCloudClient to access a URL and sets the desired parameters for ownCloud client connections. | ||||||
|      *  |      *  | ||||||
|      * @param uri       URL to the ownCloud server |      * @param uri       URL to the ownCloud server; BASE ENTRY POINT, not WebDavPATH | ||||||
|      * @param context   Android context where the OwnCloudClient is being created. |      * @param context   Android context where the OwnCloudClient is being created. | ||||||
|      * @return          A OwnCloudClient object ready to be used |      * @return          A OwnCloudClient object ready to be used | ||||||
|      */ |      */ | ||||||
| @ -206,10 +201,8 @@ public class OwnCloudClientFactory { | |||||||
|             Log.e(TAG, "The local server truststore could not be read. Default SSL management in the system will be used for HTTPS connections", e); |             Log.e(TAG, "The local server truststore could not be read. Default SSL management in the system will be used for HTTPS connections", e); | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         OwnCloudClient client = new OwnCloudClient(NetworkUtils.getMultiThreadedConnManager()); |         OwnCloudClient client = new OwnCloudClient(uri, NetworkUtils.getMultiThreadedConnManager()); | ||||||
|          |  | ||||||
|         client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); |         client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); | ||||||
|         client.setWebdavUri(uri); |  | ||||||
|         client.setFollowRedirects(followRedirects); |         client.setFollowRedirects(followRedirects); | ||||||
|          |          | ||||||
|         return client; |         return client; | ||||||
|  | |||||||
| @ -45,7 +45,7 @@ public class AccountUtils { | |||||||
|     public static final String WEBDAV_PATH_1_2 = "/webdav/owncloud.php"; |     public static final String WEBDAV_PATH_1_2 = "/webdav/owncloud.php"; | ||||||
|     public static final String WEBDAV_PATH_2_0 = "/files/webdav.php"; |     public static final String WEBDAV_PATH_2_0 = "/files/webdav.php"; | ||||||
|     public static final String WEBDAV_PATH_4_0 = "/remote.php/webdav"; |     public static final String WEBDAV_PATH_4_0 = "/remote.php/webdav"; | ||||||
|     private static final String ODAV_PATH = "/remote.php/odav"; |     public static final String ODAV_PATH = "/remote.php/odav"; | ||||||
|     private static final String SAML_SSO_PATH = "/remote.php/webdav"; |     private static final String SAML_SSO_PATH = "/remote.php/webdav"; | ||||||
|     public static final String CARDDAV_PATH_2_0 = "/apps/contacts/carddav.php"; |     public static final String CARDDAV_PATH_2_0 = "/apps/contacts/carddav.php"; | ||||||
|     public static final String CARDDAV_PATH_4_0 = "/remote/carddav.php"; |     public static final String CARDDAV_PATH_4_0 = "/remote/carddav.php"; | ||||||
| @ -81,11 +81,15 @@ public class AccountUtils { | |||||||
|      |      | ||||||
|     /** |     /** | ||||||
|      * Constructs full url to host and webdav resource basing on host version |      * Constructs full url to host and webdav resource basing on host version | ||||||
|  |      *  | ||||||
|  |      * @deprecated 		To be removed in release 1.0.  | ||||||
|  |      *  | ||||||
|      * @param context |      * @param context | ||||||
|      * @param account |      * @param account | ||||||
|      * @return url or null on failure |      * @return url or null on failure | ||||||
|      * @throws AccountNotFoundException     When 'account' is unknown for the AccountManager |      * @throws AccountNotFoundException     When 'account' is unknown for the AccountManager | ||||||
|      */ |      */ | ||||||
|  |     @Deprecated | ||||||
|     public static String constructFullURLForAccount(Context context, Account account) throws AccountNotFoundException { |     public static String constructFullURLForAccount(Context context, Account account) throws AccountNotFoundException { | ||||||
|         AccountManager ama = AccountManager.get(context); |         AccountManager ama = AccountManager.get(context); | ||||||
|         String baseurl = ama.getUserData(account, Constants.KEY_OC_BASE_URL); |         String baseurl = ama.getUserData(account, Constants.KEY_OC_BASE_URL); | ||||||
|  | |||||||
| @ -59,37 +59,39 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|     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 String mUrl; |  | ||||||
|     private RemoteOperationResult mLatestResult; |     private RemoteOperationResult mLatestResult; | ||||||
|     private Context mContext; |     private Context mContext; | ||||||
| 
 | 
 | ||||||
|     public GetRemoteStatusOperation(String url, Context context) { |     public GetRemoteStatusOperation(Context context) { | ||||||
|         mUrl = url; |  | ||||||
|         mContext = context; |         mContext = context; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     private boolean tryConnection(OwnCloudClient wc, String urlSt) { |     private boolean tryConnection(OwnCloudClient client) { | ||||||
|         boolean retval = false; |         boolean retval = false; | ||||||
|         GetMethod get = null; |         GetMethod get = null; | ||||||
|  |         String baseUrlSt = client.getBaseUri().toString(); | ||||||
|         try { |         try { | ||||||
|             get = new GetMethod(urlSt); |             get = new GetMethod(baseUrlSt + AccountUtils.STATUS_PATH); | ||||||
|             int status = wc.executeMethod(get, TRY_CONNECTION_TIMEOUT, TRY_CONNECTION_TIMEOUT); |             int status = client.executeMethod(get, TRY_CONNECTION_TIMEOUT, TRY_CONNECTION_TIMEOUT); | ||||||
|             String response = get.getResponseBodyAsString(); |             String response = get.getResponseBodyAsString(); | ||||||
|             if (status == HttpStatus.SC_OK) { |             if (status == HttpStatus.SC_OK) { | ||||||
|                 JSONObject json = new JSONObject(response); |                 JSONObject json = new JSONObject(response); | ||||||
|                 if (!json.getBoolean(NODE_INSTALLED)) { |                 if (!json.getBoolean(NODE_INSTALLED)) { | ||||||
|                     mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); |                     mLatestResult = new RemoteOperationResult( | ||||||
|  |                     		RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); | ||||||
|                 } else { |                 } else { | ||||||
|                     String version = json.getString(NODE_VERSION); |                     String version = json.getString(NODE_VERSION); | ||||||
| 					OwnCloudVersion ocVersion = new OwnCloudVersion(version); | 					OwnCloudVersion ocVersion = new OwnCloudVersion(version); | ||||||
|                     if (!ocVersion.isVersionValid()) { |                     if (!ocVersion.isVersionValid()) { | ||||||
|                         mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.BAD_OC_VERSION); |                         mLatestResult = new RemoteOperationResult( | ||||||
|  |                         		RemoteOperationResult.ResultCode.BAD_OC_VERSION); | ||||||
|                          |                          | ||||||
|                     } else { |                     } else { | ||||||
|                         mLatestResult = new RemoteOperationResult(urlSt.startsWith("https://") ?  |                         mLatestResult = new RemoteOperationResult( | ||||||
|                                                                     RemoteOperationResult.ResultCode.OK_SSL :  |                         		baseUrlSt.startsWith("https://") ? | ||||||
|                                                                     RemoteOperationResult.ResultCode.OK_NO_SSL |                         				RemoteOperationResult.ResultCode.OK_SSL : | ||||||
|                             ); |                     					RemoteOperationResult.ResultCode.OK_NO_SSL | ||||||
|  |                         ); | ||||||
| 
 | 
 | ||||||
|                         ArrayList<Object> data = new ArrayList<Object>(); |                         ArrayList<Object> data = new ArrayList<Object>(); | ||||||
|                         data.add(ocVersion); |                         data.add(ocVersion); | ||||||
| @ -103,7 +105,8 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|         } catch (JSONException e) { |         } catch (JSONException e) { | ||||||
|             mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); |             mLatestResult = new RemoteOperationResult( | ||||||
|  |             		RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED); | ||||||
|              |              | ||||||
|         } catch (Exception e) { |         } catch (Exception e) { | ||||||
|             mLatestResult = new RemoteOperationResult(e); |             mLatestResult = new RemoteOperationResult(e); | ||||||
| @ -114,13 +117,13 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|         } |         } | ||||||
|          |          | ||||||
|         if (mLatestResult.isSuccess()) { |         if (mLatestResult.isSuccess()) { | ||||||
|             Log.i(TAG, "Connection check at " + urlSt + ": " + mLatestResult.getLogMessage()); |             Log.i(TAG, "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage()); | ||||||
|              |              | ||||||
|         } else if (mLatestResult.getException() != null) { |         } else if (mLatestResult.getException() != null) { | ||||||
|             Log.e(TAG, "Connection check at " + urlSt + ": " + mLatestResult.getLogMessage(), mLatestResult.getException()); |             Log.e(TAG, "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage(), mLatestResult.getException()); | ||||||
|              |              | ||||||
|         } else { |         } else { | ||||||
|             Log.e(TAG, "Connection check at " + urlSt + ": " + mLatestResult.getLogMessage()); |             Log.e(TAG, "Connection check at " + baseUrlSt + ": " + mLatestResult.getLogMessage()); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return retval; |         return retval; | ||||||
| @ -138,16 +141,17 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
|         if (!isOnline()) { |         if (!isOnline()) { | ||||||
|         	return new RemoteOperationResult(RemoteOperationResult.ResultCode.NO_NETWORK_CONNECTION); |         	return new RemoteOperationResult(RemoteOperationResult.ResultCode.NO_NETWORK_CONNECTION); | ||||||
|         } |         } | ||||||
|         if (mUrl.startsWith("http://") || mUrl.startsWith("https://")) { |         String baseUriStr = client.getBaseUri().toString(); | ||||||
|             tryConnection(client, mUrl + AccountUtils.STATUS_PATH); |         if (baseUriStr.startsWith("http://") || baseUriStr.startsWith("https://")) { | ||||||
|  |             tryConnection(client); | ||||||
|              |              | ||||||
|         } else { |         } else { | ||||||
|             client.setWebdavUri(Uri.parse("https://" + mUrl + AccountUtils.STATUS_PATH)); |             client.setBaseUri(Uri.parse("https://" + baseUriStr)); | ||||||
|             boolean httpsSuccess = tryConnection(client, "https://" + mUrl + AccountUtils.STATUS_PATH);  |             boolean httpsSuccess = tryConnection(client);  | ||||||
|             if (!httpsSuccess && !mLatestResult.isSslRecoverableException()) { |             if (!httpsSuccess && !mLatestResult.isSslRecoverableException()) { | ||||||
|                 Log.d(TAG, "establishing secure connection failed, trying non secure connection"); |                 Log.d(TAG, "establishing secure connection failed, trying non secure connection"); | ||||||
|                 client.setWebdavUri(Uri.parse("http://" + mUrl + AccountUtils.STATUS_PATH)); |                 client.setBaseUri(Uri.parse("http://" + baseUriStr)); | ||||||
|                 tryConnection(client, "http://" + mUrl + AccountUtils.STATUS_PATH); |                 tryConnection(client); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return mLatestResult; |         return mLatestResult; | ||||||
|  | |||||||
| @ -78,7 +78,7 @@ public class GetRemoteUserNameOperation extends RemoteOperation { | |||||||
| 
 | 
 | ||||||
| 		//Get the user | 		//Get the user | ||||||
| 		try { | 		try { | ||||||
| 			get = new GetMethod(client.getWebdavUri() + OCS_ROUTE); | 			get = new GetMethod(client.getBaseUri() + OCS_ROUTE); | ||||||
| 			get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | 			get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); | ||||||
| 			status = client.executeMethod(get); | 			status = client.executeMethod(get); | ||||||
| 			if(isSuccess(status)) { | 			if(isSuccess(status)) { | ||||||
|  | |||||||
| @ -74,7 +74,6 @@ public class TestActivity extends Activity { | |||||||
| 	private String mPass; | 	private String mPass; | ||||||
| 	private boolean mChunked; | 	private boolean mChunked; | ||||||
| 	 | 	 | ||||||
| 	private static final String WEBDAV_PATH = "/remote.php/webdav"; |  | ||||||
| 	private static final int BUFFER_SIZE = 1024; | 	private static final int BUFFER_SIZE = 1024; | ||||||
| 	 | 	 | ||||||
| 	public static final String ASSETS__TEXT_FILE_NAME = "textFile.txt"; | 	public static final String ASSETS__TEXT_FILE_NAME = "textFile.txt"; | ||||||
| @ -107,12 +106,10 @@ public class TestActivity extends Activity { | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		Uri uri = Uri.parse(mServerUri + WEBDAV_PATH); | 		mClient = new OwnCloudClient(Uri.parse(mServerUri), NetworkUtils.getMultiThreadedConnManager()); | ||||||
| 		mClient = new OwnCloudClient(NetworkUtils.getMultiThreadedConnManager()); |  | ||||||
| 		mClient.setDefaultTimeouts( | 		mClient.setDefaultTimeouts( | ||||||
| 				OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT,  | 				OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT,  | ||||||
| 				OwnCloudClientFactory.DEFAULT_CONNECTION_TIMEOUT); | 				OwnCloudClientFactory.DEFAULT_CONNECTION_TIMEOUT); | ||||||
| 		mClient.setWebdavUri(uri); |  | ||||||
| 		mClient.setFollowRedirects(true); | 		mClient.setFollowRedirects(true); | ||||||
| 		mClient.setCredentials( | 		mClient.setCredentials( | ||||||
| 				OwnCloudCredentialsFactory.newBasicCredentials( | 				OwnCloudCredentialsFactory.newBasicCredentials( | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user