mirror of
https://github.com/etesync/android
synced 2025-04-01 15:25:47 +00:00
Add support for associate accounts.
This commit is contained in:
parent
3ab441b9d4
commit
5dbca6e00f
@ -29,8 +29,12 @@ abstract class BaseManager {
|
||||
when (response.code()) {
|
||||
HttpURLConnection.HTTP_UNAVAILABLE -> throw Exceptions.ServiceUnavailableException(response, "Service unavailable")
|
||||
HttpURLConnection.HTTP_UNAUTHORIZED -> throw Exceptions.UnauthorizedException(response, "Unauthorized auth token")
|
||||
HttpURLConnection.HTTP_FORBIDDEN -> if (apiError.code == "service_inactive") {
|
||||
throw Exceptions.UserInactiveException(response, apiError.detail)
|
||||
HttpURLConnection.HTTP_FORBIDDEN -> {
|
||||
if (apiError.code == "service_inactive") {
|
||||
throw Exceptions.UserInactiveException(response, apiError.detail)
|
||||
} else if (apiError.code == "associate_not_allowed") {
|
||||
throw Exceptions.AssociateNotAllowedException(response, apiError.detail)
|
||||
}
|
||||
}
|
||||
}// Fall through. We want to always throw when unsuccessful.
|
||||
|
||||
|
@ -8,6 +8,8 @@ import java.io.Serializable
|
||||
import java.security.GeneralSecurityException
|
||||
|
||||
class Exceptions {
|
||||
class AssociateNotAllowedException(response: Response, message: String?) : HttpException(response, message)
|
||||
|
||||
class UnauthorizedException(response: Response, message: String?) : HttpException(response, message)
|
||||
|
||||
class UserInactiveException(response: Response, message: String?) : HttpException(response, message)
|
||||
|
@ -134,13 +134,17 @@ abstract class SyncAdapterService : Service() {
|
||||
}
|
||||
|
||||
if (journals.isEmpty()) {
|
||||
val info = CollectionInfo.defaultForServiceType(serviceType)
|
||||
val uid = JournalManager.Journal.genUid()
|
||||
info.uid = uid
|
||||
val crypto = Crypto.CryptoManager(info.version, settings.password(), uid)
|
||||
val journal = JournalManager.Journal(crypto, info.toJson(), uid)
|
||||
journalsManager.create(journal)
|
||||
journals.add(Pair(journal, info))
|
||||
try {
|
||||
val info = CollectionInfo.defaultForServiceType(serviceType)
|
||||
val uid = JournalManager.Journal.genUid()
|
||||
info.uid = uid
|
||||
val crypto = Crypto.CryptoManager(info.version, settings.password(), uid)
|
||||
val journal = JournalManager.Journal(crypto, info.toJson(), uid)
|
||||
journalsManager.create(journal)
|
||||
journals.add(Pair(journal, info))
|
||||
} catch (e: Exceptions.AssociateNotAllowedException) {
|
||||
// Skip for now
|
||||
}
|
||||
}
|
||||
|
||||
saveCollections(journals)
|
||||
|
@ -131,6 +131,8 @@ class CreateCollectionFragment : DialogFragment(), LoaderManager.LoaderCallbacks
|
||||
return e
|
||||
} catch (e: Exceptions.GenericCryptoException) {
|
||||
return e
|
||||
} catch (e: Exceptions.AssociateNotAllowedException) {
|
||||
return e
|
||||
}
|
||||
|
||||
return null
|
||||
|
Loading…
Reference in New Issue
Block a user