- HeadMethod head = null;
- try {
- head = new HeadMethod(client.getWebdavUri() + WebdavUtils.encodePath(mPath));
- int status = client.executeMethod(head, TIMEOUT, TIMEOUT);
- client.exhaustResponse(head.getResponseBodyAsStream());
- boolean success = (status == HttpStatus.SC_OK && !mSuccessIfAbsent) || (status == HttpStatus.SC_NOT_FOUND && mSuccessIfAbsent);
- result = new RemoteOperationResult(success, status, head.getResponseHeaders());
- Log.d(TAG, "Existence check for " + client.getWebdavUri() + WebdavUtils.encodePath(mPath) + " targeting for " + (mSuccessIfAbsent ? " absence " : " existence ") + "finished with HTTP status " + status + (!success?"(FAIL)":""));
+ AuthenticationMethod authMethod = AuthenticationMethod.UNKNOWN;
+
+ RemoteOperation operation = new ExistenceCheckRemoteOperation("", mContext, false);
+ client.setBasicCredentials("", "");
+ client.setFollowRedirects(false);
+
+ // try to access the root folder, following redirections but not SAML SSO redirections
+ do {
+ result = operation.execute(client);
+ client.setBaseUri(Uri.parse(result.getRedirectedLocation()));