X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/301b2760ba37347ad98e896058fceb0c0bc349e4..261aaf50019732a4e766d6b3e9e07576a64f5504:/src/com/owncloud/android/operations/RemoteOperationResult.java?ds=inline diff --git a/src/com/owncloud/android/operations/RemoteOperationResult.java b/src/com/owncloud/android/operations/RemoteOperationResult.java index 1803f4cf..03afda55 100644 --- a/src/com/owncloud/android/operations/RemoteOperationResult.java +++ b/src/com/owncloud/android/operations/RemoteOperationResult.java @@ -10,6 +10,10 @@ import javax.net.ssl.SSLException; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.HttpStatus; +import android.util.Log; + +import com.owncloud.android.network.CertificateCombinedException; + public class RemoteOperationResult { @@ -29,6 +33,8 @@ public class RemoteOperationResult { SSL_ERROR, BAD_OC_VERSION, } + + private static final String TAG = null; private boolean mSuccess = false; private int mHttpCode = -1; @@ -66,30 +72,31 @@ public class RemoteOperationResult { if (e instanceof SocketException) { mCode = ResultCode.WRONG_CONNECTION; - //Log.e(TAG, "Socket exception while trying connection", e); + Log.e(TAG, "Socket exception", e); } else if (e instanceof SocketTimeoutException) { mCode = ResultCode.TIMEOUT; - //Log.e(TAG, "Socket timeout exception while trying connection", e); + Log.e(TAG, "Socket timeout exception", e); } else if (e instanceof ConnectTimeoutException) { mCode = ResultCode.TIMEOUT; - //Log.e(TAG, "Socket timeout exception while trying connection", e); + Log.e(TAG, "Connect timeout exception", e); } else if (e instanceof MalformedURLException) { mCode = ResultCode.INCORRECT_ADDRESS; - //Log.e(TAG, "Connect exception while trying connection", e); + Log.e(TAG, "Malformed URL exception", e); } else if (e instanceof UnknownHostException) { mCode = ResultCode.HOST_NOT_AVAILABLE; - //Log.e(TAG, "Unknown host exception while trying connection", e); + Log.e(TAG, "Unknown host exception", e); } else if (e instanceof SSLException) { mCode = ResultCode.SSL_ERROR; - //Log.e(TAG, "SSL exception while trying connection", e); + Log.e(TAG, "SSL exception", e); } else { mCode = ResultCode.UNKNOWN_ERROR; + Log.e(TAG, "Unknown exception", e); } /* } catch (HttpException e) { // other specific exceptions from org.apache.commons.httpclient @@ -118,4 +125,28 @@ public class RemoteOperationResult { return mException; } + public boolean isSslRecoverableException() { + return (getSslRecoverableException() != null); + } + + public CertificateCombinedException getSslRecoverableException() { + CertificateCombinedException result = null; + if (mCode == ResultCode.SSL_ERROR) { + if (mException instanceof CertificateCombinedException) + result = (CertificateCombinedException)mException; + Throwable cause = mException.getCause(); + Throwable previousCause = null; + while (cause != null && cause != previousCause && !(cause instanceof CertificateCombinedException)) { + previousCause = cause; + cause = cause.getCause(); + } + if (cause != null && cause instanceof CertificateCombinedException) + result = (CertificateCombinedException)cause; + } + if (result != null && result.isRecoverable()) + return result; + else + return null; + } + }