mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Merge pull request #515 from owncloud/feature/handle_425_response
Handle 425 TOO EARLY propfind responses
This commit is contained in:
commit
c2f7426a3e
@ -184,6 +184,7 @@ public class HttpConstants {
|
||||
public static final int HTTP_LOCKED = 423;
|
||||
// 424 Failed Dependency (WebDAV - RFC 2518)
|
||||
public static final int HTTP_FAILED_DEPENDENCY = 424;
|
||||
public static final int HTTP_TOO_EARLY = 425;
|
||||
|
||||
/**
|
||||
* 5xx Client Error
|
||||
|
@ -237,6 +237,10 @@ public class RemoteOperationResult<T>
|
||||
httpMethod.getResponseBodyAsString(),
|
||||
ResultCode.SPECIFIC_METHOD_NOT_ALLOWED
|
||||
);
|
||||
break;
|
||||
case HttpConstants.HTTP_TOO_EARLY:
|
||||
mCode = ResultCode.TOO_EARLY;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -583,6 +587,7 @@ public class RemoteOperationResult<T>
|
||||
SPECIFIC_SERVICE_UNAVAILABLE,
|
||||
SPECIFIC_UNSUPPORTED_MEDIA_TYPE,
|
||||
SPECIFIC_METHOD_NOT_ALLOWED,
|
||||
SPECIFIC_BAD_REQUEST
|
||||
SPECIFIC_BAD_REQUEST,
|
||||
TOO_EARLY,
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public class RemoteFile implements Parcelable, Serializable {
|
||||
|
||||
public RemoteFile(final Response davResource, String userId) {
|
||||
this(RemoteFileUtil.Companion.getRemotePathFromUrl(davResource.getHref(), userId));
|
||||
final List<Property> properties = davResource.getProperties();
|
||||
final List<Property> properties = RemoteFileUtil.Companion.getProperties(davResource);
|
||||
|
||||
for (Property property : properties) {
|
||||
if (property instanceof CreationDate) {
|
||||
|
@ -24,7 +24,11 @@
|
||||
package com.owncloud.android.lib.resources.files
|
||||
|
||||
import android.net.Uri
|
||||
import at.bitfire.dav4jvm.PropStat
|
||||
import at.bitfire.dav4jvm.Property
|
||||
import at.bitfire.dav4jvm.Response
|
||||
import com.owncloud.android.lib.common.OwnCloudClient
|
||||
import com.owncloud.android.lib.common.http.HttpConstants
|
||||
import okhttp3.HttpUrl
|
||||
|
||||
class RemoteFileUtil {
|
||||
@ -45,5 +49,14 @@ class RemoteFileUtil {
|
||||
val pathToOc = absoluteDavPath.split(davFilesPath)[0]
|
||||
return absoluteDavPath.replace(pathToOc + davFilesPath, "")
|
||||
}
|
||||
|
||||
fun getProperties(response: Response): List<Property> {
|
||||
return if (response.isSuccess())
|
||||
response.propstat.filter { propStat -> propStat.isSuccessOrPostProcessing() }.map { it.properties }.flatten()
|
||||
else
|
||||
emptyList()
|
||||
}
|
||||
|
||||
private fun PropStat.isSuccessOrPostProcessing() = (status.code / 100 == 2 || status.code == HttpConstants.HTTP_TOO_EARLY)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user