Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c7523be authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Add ForbiddenException and some static Errors (original patch from Matt Jacobsen, thanks)

parent cad85fee
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,4 +29,5 @@ Email: [play@bitfire.at](mailto:play@bitfire.at)

  * Ricki Hirner (initial contributor)
  * David González Verdugo (dgonzalez@owncloud.com)
  * Matt Jacobsen (https://gitlab.com/mattjacobsen)
+2 −2
Original line number Diff line number Diff line

buildscript {
    ext.kotlin_version = '1.3.10'
    ext.kotlin_version = '1.3.11'
    ext.dokka_version = '0.9.17'

    repositories {
@@ -61,7 +61,7 @@ dependencies {
    api "com.squareup.okhttp3:okhttp:$okhttp_version"

    androidTestImplementation "com.squareup.okhttp3:mockwebserver:$okhttp_version"
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test:runner:1.1.1'

    testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
    testImplementation 'junit:junit:4.12'
+2 −0
Original line number Diff line number Diff line
@@ -350,6 +350,8 @@ open class DavResource @JvmOverloads constructor(
        throw when (code) {
            HttpURLConnection.HTTP_UNAUTHORIZED ->
                if (response != null) UnauthorizedException(response) else UnauthorizedException(message)
            HttpURLConnection.HTTP_FORBIDDEN ->
                if (response != null) ForbiddenException(response) else ForbiddenException(message)
            HttpURLConnection.HTTP_NOT_FOUND ->
                if (response != null) NotFoundException(response) else NotFoundException(message)
            HttpURLConnection.HTTP_CONFLICT ->
+11 −0
Original line number Diff line number Diff line
@@ -37,6 +37,17 @@ class Error(
            return names.map { Error(it) }
        }


        // some pre-defined errors

        val NEED_PRIVILEGES = Error(Property.Name(XmlUtils.NS_WEBDAV, "need-privileges"))
        val VALID_SYNC_TOKEN = Error(Property.Name(XmlUtils.NS_WEBDAV, "valid-sync-token"))

    }

    override fun equals(other: Any?) =
            (other is Error) && other.name == name

    override fun hashCode() = name.hashCode()

}
+17 −0
Original line number Diff line number Diff line
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package at.bitfire.dav4android.exception

import okhttp3.Response
import java.net.HttpURLConnection

class ForbiddenException: HttpException {

    constructor(response: Response): super(response)
    constructor(message: String?): super(HttpURLConnection.HTTP_FORBIDDEN, message)

}
Loading