|
|
|
@ -16,20 +16,21 @@ import at.bitfire.ical4android.CalendarStorageException
|
|
|
|
|
import at.bitfire.vcard4android.BatchOperation
|
|
|
|
|
import at.bitfire.vcard4android.Contact
|
|
|
|
|
import at.bitfire.vcard4android.ContactsStorageException
|
|
|
|
|
import com.etesync.journalmanager.Exceptions
|
|
|
|
|
import com.etesync.journalmanager.JournalEntryManager
|
|
|
|
|
import com.etesync.journalmanager.model.SyncEntry
|
|
|
|
|
import com.etesync.syncadapter.AccountSettings
|
|
|
|
|
import com.etesync.syncadapter.Constants
|
|
|
|
|
import com.etesync.syncadapter.HttpClient
|
|
|
|
|
import com.etesync.syncadapter.R
|
|
|
|
|
import com.etesync.journalmanager.Exceptions
|
|
|
|
|
import com.etesync.journalmanager.JournalEntryManager
|
|
|
|
|
import com.etesync.syncadapter.log.Logger
|
|
|
|
|
import com.etesync.syncadapter.model.CollectionInfo
|
|
|
|
|
import com.etesync.journalmanager.model.SyncEntry
|
|
|
|
|
import com.etesync.syncadapter.resource.LocalAddress
|
|
|
|
|
import com.etesync.syncadapter.resource.LocalAddressBook
|
|
|
|
|
import com.etesync.syncadapter.resource.LocalContact
|
|
|
|
|
import com.etesync.syncadapter.resource.LocalGroup
|
|
|
|
|
import okhttp3.HttpUrl
|
|
|
|
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
|
|
|
|
import okhttp3.Request
|
|
|
|
|
import org.apache.commons.collections4.SetUtils
|
|
|
|
|
import java.io.FileNotFoundException
|
|
|
|
@ -215,14 +216,14 @@ constructor(context: Context, account: Account, settings: AccountSettings, extra
|
|
|
|
|
class ResourceDownloader(internal var context: Context) : Contact.Downloader {
|
|
|
|
|
|
|
|
|
|
override fun download(url: String, accepts: String): ByteArray? {
|
|
|
|
|
val httpUrl = HttpUrl.parse(url)
|
|
|
|
|
val httpUrl = url.toHttpUrlOrNull()
|
|
|
|
|
|
|
|
|
|
if (httpUrl == null) {
|
|
|
|
|
Logger.log.log(Level.SEVERE, "Invalid external resource URL", url)
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val host = httpUrl.host()
|
|
|
|
|
val host = httpUrl.host
|
|
|
|
|
if (host == null) {
|
|
|
|
|
Logger.log.log(Level.SEVERE, "External resource URL doesn't specify a host name", url)
|
|
|
|
|
return null
|
|
|
|
@ -236,7 +237,7 @@ constructor(context: Context, account: Account, settings: AccountSettings, extra
|
|
|
|
|
.url(httpUrl)
|
|
|
|
|
.build()).execute()
|
|
|
|
|
|
|
|
|
|
val body = response.body()
|
|
|
|
|
val body = response.body
|
|
|
|
|
if (body != null) {
|
|
|
|
|
return body.bytes()
|
|
|
|
|
}
|
|
|
|
|