mirror of
https://github.com/owncloud/android-library.git
synced 2025-07-23 01:45:50 +00:00
A little cleanup and improve some log messages
This commit is contained in:
parent
1536a455a6
commit
7e6b63db1f
@ -37,10 +37,8 @@ import java.util.Locale;
|
||||
import static com.owncloud.android.lib.common.OwnCloudClient.WEBDAV_PATH_4_0_AND_LATER;
|
||||
|
||||
public class WebdavUtils {
|
||||
public static final SimpleDateFormat DISPLAY_DATE_FORMAT = new SimpleDateFormat(
|
||||
"dd.MM.yyyy hh:mm");
|
||||
|
||||
private static final SimpleDateFormat DATETIME_FORMATS[] = {
|
||||
private static final SimpleDateFormat[] DATETIME_FORMATS = {
|
||||
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US),
|
||||
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
|
||||
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'", Locale.US),
|
||||
@ -52,11 +50,11 @@ public class WebdavUtils {
|
||||
};
|
||||
|
||||
public static Date parseResponseDate(String date) {
|
||||
Date returnDate = null;
|
||||
SimpleDateFormat format = null;
|
||||
for (int i = 0; i < DATETIME_FORMATS.length; ++i) {
|
||||
Date returnDate;
|
||||
SimpleDateFormat format;
|
||||
for (SimpleDateFormat datetimeFormat : DATETIME_FORMATS) {
|
||||
try {
|
||||
format = DATETIME_FORMATS[i];
|
||||
format = datetimeFormat;
|
||||
synchronized (format) {
|
||||
returnDate = format.parse(date);
|
||||
}
|
||||
@ -84,23 +82,6 @@ public class WebdavUtils {
|
||||
return encodedPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rawEtag
|
||||
* @return
|
||||
*/
|
||||
public static String parseEtag(String rawEtag) {
|
||||
if (rawEtag == null || rawEtag.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
if (rawEtag.endsWith("-gzip")) {
|
||||
rawEtag = rawEtag.substring(0, rawEtag.length() - 5);
|
||||
}
|
||||
if (rawEtag.length() >= 2 && rawEtag.startsWith("\"") && rawEtag.endsWith("\"")) {
|
||||
rawEtag = rawEtag.substring(1, rawEtag.length() - 1);
|
||||
}
|
||||
return rawEtag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param httpBaseMethod from which to get the etag
|
||||
* @return etag from response
|
||||
|
@ -82,20 +82,23 @@ class GetRemoteStatusOperation : RemoteOperation<OwnCloudVersion>() {
|
||||
latestResult =
|
||||
if (isSuccess(status)) RemoteOperationResult(ResultCode.OK)
|
||||
else RemoteOperationResult(getMethod)
|
||||
|
||||
} catch (sslE: SSLException) {
|
||||
latestResult = RemoteOperationResult(sslE)
|
||||
return successfulConnection
|
||||
}
|
||||
|
||||
var redirectedLocation = latestResult.redirectedLocation
|
||||
while (!redirectedLocation.isNullOrEmpty() && !latestResult.isSuccess) {
|
||||
isRedirectToNonSecureConnection =
|
||||
isRedirectToNonSecureConnection or
|
||||
isRedirectToNonSecureConnection ||
|
||||
(baseUrlSt.startsWith(HTTPS_PREFIX) && redirectedLocation.startsWith(HTTP_PREFIX))
|
||||
|
||||
getMethod = GetMethod(URL(redirectedLocation)).apply {
|
||||
setReadTimeout(TRY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
||||
setConnectionTimeout(TRY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
||||
}
|
||||
|
||||
status = client.executeHttpMethod(getMethod)
|
||||
latestResult = RemoteOperationResult(getMethod)
|
||||
redirectedLocation = latestResult.redirectedLocation
|
||||
@ -128,12 +131,12 @@ class GetRemoteStatusOperation : RemoteOperation<OwnCloudVersion>() {
|
||||
latestResult = RemoteOperationResult(e)
|
||||
}
|
||||
when {
|
||||
latestResult.isSuccess -> Timber.i("Connection check at $baseUrlSt: ${latestResult.logMessage}")
|
||||
latestResult.isSuccess -> Timber.i("Connection check at $baseUrlSt successful: ${latestResult.logMessage}")
|
||||
|
||||
latestResult.isException ->
|
||||
Timber.e(latestResult.exception, "Connection check at $baseUrlSt: ${latestResult.logMessage}")
|
||||
|
||||
else -> Timber.e("Connection check at $baseUrlSt: ${latestResult.logMessage}")
|
||||
else -> Timber.e("Connection check at $baseUrlSt failed: ${latestResult.logMessage}")
|
||||
}
|
||||
return successfulConnection
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class GetRemoteUserInfoOperation : RemoteOperation<RemoteUserInfo>() {
|
||||
val commonResponse: CommonOcsResponse<UserInfoResponse>? = adapter.fromJson(response)
|
||||
|
||||
result = RemoteOperationResult(ResultCode.OK)
|
||||
result.setData(commonResponse?.ocs?.data?.toRemoteUserInfo())
|
||||
result.data = commonResponse?.ocs?.data?.toRemoteUserInfo()
|
||||
} else {
|
||||
result = RemoteOperationResult(getMethod)
|
||||
Timber.e("Failed response while getting user information status code: $status, response: $response")
|
||||
|
Loading…
x
Reference in New Issue
Block a user