mirror of
https://github.com/owncloud/android-library.git
synced 2025-07-23 18:06:17 +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;
|
import static com.owncloud.android.lib.common.OwnCloudClient.WEBDAV_PATH_4_0_AND_LATER;
|
||||||
|
|
||||||
public class WebdavUtils {
|
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("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US),
|
||||||
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", 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),
|
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) {
|
public static Date parseResponseDate(String date) {
|
||||||
Date returnDate = null;
|
Date returnDate;
|
||||||
SimpleDateFormat format = null;
|
SimpleDateFormat format;
|
||||||
for (int i = 0; i < DATETIME_FORMATS.length; ++i) {
|
for (SimpleDateFormat datetimeFormat : DATETIME_FORMATS) {
|
||||||
try {
|
try {
|
||||||
format = DATETIME_FORMATS[i];
|
format = datetimeFormat;
|
||||||
synchronized (format) {
|
synchronized (format) {
|
||||||
returnDate = format.parse(date);
|
returnDate = format.parse(date);
|
||||||
}
|
}
|
||||||
@ -84,23 +82,6 @@ public class WebdavUtils {
|
|||||||
return encodedPath;
|
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
|
* @param httpBaseMethod from which to get the etag
|
||||||
* @return etag from response
|
* @return etag from response
|
||||||
|
@ -82,20 +82,23 @@ class GetRemoteStatusOperation : RemoteOperation<OwnCloudVersion>() {
|
|||||||
latestResult =
|
latestResult =
|
||||||
if (isSuccess(status)) RemoteOperationResult(ResultCode.OK)
|
if (isSuccess(status)) RemoteOperationResult(ResultCode.OK)
|
||||||
else RemoteOperationResult(getMethod)
|
else RemoteOperationResult(getMethod)
|
||||||
|
|
||||||
} catch (sslE: SSLException) {
|
} catch (sslE: SSLException) {
|
||||||
latestResult = RemoteOperationResult(sslE)
|
latestResult = RemoteOperationResult(sslE)
|
||||||
return successfulConnection
|
return successfulConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
var redirectedLocation = latestResult.redirectedLocation
|
var redirectedLocation = latestResult.redirectedLocation
|
||||||
while (!redirectedLocation.isNullOrEmpty() && !latestResult.isSuccess) {
|
while (!redirectedLocation.isNullOrEmpty() && !latestResult.isSuccess) {
|
||||||
isRedirectToNonSecureConnection =
|
isRedirectToNonSecureConnection =
|
||||||
isRedirectToNonSecureConnection or
|
isRedirectToNonSecureConnection ||
|
||||||
(baseUrlSt.startsWith(HTTPS_PREFIX) && redirectedLocation.startsWith(HTTP_PREFIX))
|
(baseUrlSt.startsWith(HTTPS_PREFIX) && redirectedLocation.startsWith(HTTP_PREFIX))
|
||||||
|
|
||||||
getMethod = GetMethod(URL(redirectedLocation)).apply {
|
getMethod = GetMethod(URL(redirectedLocation)).apply {
|
||||||
setReadTimeout(TRY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
setReadTimeout(TRY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
||||||
setConnectionTimeout(TRY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
setConnectionTimeout(TRY_CONNECTION_TIMEOUT, TimeUnit.SECONDS)
|
||||||
}
|
}
|
||||||
|
|
||||||
status = client.executeHttpMethod(getMethod)
|
status = client.executeHttpMethod(getMethod)
|
||||||
latestResult = RemoteOperationResult(getMethod)
|
latestResult = RemoteOperationResult(getMethod)
|
||||||
redirectedLocation = latestResult.redirectedLocation
|
redirectedLocation = latestResult.redirectedLocation
|
||||||
@ -128,12 +131,12 @@ class GetRemoteStatusOperation : RemoteOperation<OwnCloudVersion>() {
|
|||||||
latestResult = RemoteOperationResult(e)
|
latestResult = RemoteOperationResult(e)
|
||||||
}
|
}
|
||||||
when {
|
when {
|
||||||
latestResult.isSuccess -> Timber.i("Connection check at $baseUrlSt: ${latestResult.logMessage}")
|
latestResult.isSuccess -> Timber.i("Connection check at $baseUrlSt successful: ${latestResult.logMessage}")
|
||||||
|
|
||||||
latestResult.isException ->
|
latestResult.isException ->
|
||||||
Timber.e(latestResult.exception, "Connection check at $baseUrlSt: ${latestResult.logMessage}")
|
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
|
return successfulConnection
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class GetRemoteUserInfoOperation : RemoteOperation<RemoteUserInfo>() {
|
|||||||
val commonResponse: CommonOcsResponse<UserInfoResponse>? = adapter.fromJson(response)
|
val commonResponse: CommonOcsResponse<UserInfoResponse>? = adapter.fromJson(response)
|
||||||
|
|
||||||
result = RemoteOperationResult(ResultCode.OK)
|
result = RemoteOperationResult(ResultCode.OK)
|
||||||
result.setData(commonResponse?.ocs?.data?.toRemoteUserInfo())
|
result.data = commonResponse?.ocs?.data?.toRemoteUserInfo()
|
||||||
} else {
|
} else {
|
||||||
result = RemoteOperationResult(getMethod)
|
result = RemoteOperationResult(getMethod)
|
||||||
Timber.e("Failed response while getting user information status code: $status, response: $response")
|
Timber.e("Failed response while getting user information status code: $status, response: $response")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user