mirror of
https://github.com/owncloud/android-library.git
synced 2025-07-22 17:36:02 +00:00
Apply CR changes
This commit is contained in:
parent
a28f58f0fe
commit
64f5f08ded
@ -72,7 +72,7 @@ class CreateRemoteShareOperation
|
||||
private val shareWith: String,
|
||||
private val permissions: Int
|
||||
) : RemoteOperation<ShareParserResult>() {
|
||||
var getShareDetails = false // To retrieve more info about the just created share
|
||||
var retrieveShareDetails = false // To retrieve more info about the just created share
|
||||
|
||||
var name = "" // Name to set for the public link
|
||||
|
||||
@ -83,7 +83,7 @@ class CreateRemoteShareOperation
|
||||
var publicUpload: Boolean = false // Upload permissions for the public link (only folders)
|
||||
|
||||
init {
|
||||
getShareDetails = false // defaults to false for backwards compatibility
|
||||
retrieveShareDetails = false // defaults to false for backwards compatibility
|
||||
}
|
||||
|
||||
override fun run(client: OwnCloudClient): RemoteOperationResult<ShareParserResult> {
|
||||
@ -140,7 +140,7 @@ class CreateRemoteShareOperation
|
||||
parser.serverBaseUri = client.baseUri
|
||||
result = parser.parse(postMethod.responseBodyAsString)
|
||||
|
||||
if (result.isSuccess && getShareDetails) {
|
||||
if (result.isSuccess && retrieveShareDetails) {
|
||||
|
||||
// TODO Use executeHttpMethod
|
||||
// retrieve more info - POST only returns the index of the new share
|
||||
|
@ -25,6 +25,4 @@
|
||||
|
||||
package com.owncloud.android.lib.resources.shares
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class ShareParserResult(val shares: ArrayList<RemoteShare>)
|
||||
class ShareParserResult(val shares: List<RemoteShare>)
|
||||
|
@ -58,47 +58,52 @@ class ShareToRemoteOperationResultParser(private var shareXmlParser: ShareXMLPar
|
||||
}
|
||||
val shares = shareXmlParser?.parseXMLResponse(byteArrayServerResponse)
|
||||
|
||||
if (shareXmlParser?.isSuccess!!) {
|
||||
if (!shares.isNullOrEmpty() || !oneOrMoreSharesRequired) {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.OK)
|
||||
when {
|
||||
shareXmlParser?.isSuccess!! -> {
|
||||
if (!shares.isNullOrEmpty() || !oneOrMoreSharesRequired) {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.OK)
|
||||
|
||||
resultData = shares?.map { share ->
|
||||
if (share.shareType != ShareType.PUBLIC_LINK ||
|
||||
share.shareLink.isNotEmpty() ||
|
||||
share.token.isEmpty()) {
|
||||
return@map share
|
||||
resultData = shares?.map { share ->
|
||||
if (share.shareType != ShareType.PUBLIC_LINK ||
|
||||
share.shareLink.isNotEmpty() ||
|
||||
share.token.isEmpty()
|
||||
) {
|
||||
return@map share
|
||||
}
|
||||
|
||||
if (serverBaseUri != null) {
|
||||
val sharingLinkPath = ShareUtils.getSharingLinkPath(ownCloudVersion)
|
||||
share.shareLink = serverBaseUri.toString() + sharingLinkPath + share.token
|
||||
} else {
|
||||
Log_OC.e(TAG, "Couldn't build link for public share :(")
|
||||
}
|
||||
|
||||
share
|
||||
}
|
||||
|
||||
if (serverBaseUri != null) {
|
||||
val sharingLinkPath = ShareUtils.getSharingLinkPath(ownCloudVersion)
|
||||
share.shareLink = serverBaseUri.toString() + sharingLinkPath + share.token
|
||||
} else {
|
||||
Log_OC.e(TAG, "Couldn't build link for public share :(")
|
||||
}
|
||||
result.setData(ShareParserResult(ArrayList(resultData)))
|
||||
|
||||
share
|
||||
} else {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE)
|
||||
Log_OC.e(TAG, "Successful status with no share in the response")
|
||||
}
|
||||
|
||||
result.setData(ShareParserResult(ArrayList(resultData)))
|
||||
|
||||
} else {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE)
|
||||
Log_OC.e(TAG, "Successful status with no share in the response")
|
||||
}
|
||||
|
||||
} else if (shareXmlParser?.isWrongParameter!!) {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_WRONG_PARAMETER)
|
||||
result.httpPhrase = shareXmlParser?.message
|
||||
} else if (shareXmlParser?.isNotFound!!) {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND)
|
||||
result.httpPhrase = shareXmlParser?.message
|
||||
} else if (shareXmlParser?.isForbidden!!) {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_FORBIDDEN)
|
||||
result.httpPhrase = shareXmlParser?.message
|
||||
} else {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE)
|
||||
shareXmlParser?.isWrongParameter!! -> {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_WRONG_PARAMETER)
|
||||
result.httpPhrase = shareXmlParser?.message
|
||||
}
|
||||
shareXmlParser?.isNotFound!! -> {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND)
|
||||
result.httpPhrase = shareXmlParser?.message
|
||||
}
|
||||
shareXmlParser?.isForbidden!! -> {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_FORBIDDEN)
|
||||
result.httpPhrase = shareXmlParser?.message
|
||||
}
|
||||
else -> {
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e: XmlPullParserException) {
|
||||
Log_OC.e(TAG, "Error parsing response from server ", e)
|
||||
result = RemoteOperationResult(RemoteOperationResult.ResultCode.WRONG_SERVER_RESPONSE)
|
||||
|
@ -87,6 +87,11 @@ class OwnCloudVersion(version: String) : Comparable<OwnCloudVersion>, Parcelable
|
||||
val isPublicSharingWriteOnlySupported: Boolean
|
||||
get() = mVersion >= MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING
|
||||
|
||||
val isPublicUploadPermissionNeeded: Boolean
|
||||
get() = mVersion >= MINIMUN_MAJOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION &&
|
||||
(mVersion > MINIMUN_MINOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION ||
|
||||
mVersion > MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION)
|
||||
|
||||
init {
|
||||
var version = version
|
||||
mVersion = 0
|
||||
@ -171,34 +176,39 @@ class OwnCloudVersion(version: String) : Comparable<OwnCloudVersion>, Parcelable
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MINIMUN_MINOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0x01000000 // 1.0.0
|
||||
|
||||
val MINIMUN_VERSION_FOR_CHUNKED_UPLOADS = 0x04050000 // 4.5
|
||||
private const val MINIMUN_MICRO_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0x03000000 // 3.0.0
|
||||
|
||||
val MINIMUM_VERSION_FOR_SHARING_API = 0x05001B00 // 5.0.27
|
||||
const val MINIMUN_VERSION_FOR_CHUNKED_UPLOADS = 0x04050000 // 4.5
|
||||
|
||||
val MINIMUM_VERSION_WITH_FORBIDDEN_CHARS = 0x08010000 // 8.1
|
||||
const val MINIMUM_VERSION_FOR_SHARING_API = 0x05001B00 // 5.0.27
|
||||
|
||||
val MINIMUM_SERVER_VERSION_FOR_REMOTE_THUMBNAILS = 0x07080000 // 7.8.0
|
||||
const val MINIMUM_VERSION_WITH_FORBIDDEN_CHARS = 0x08010000 // 8.1
|
||||
|
||||
val MINIMUM_VERSION_FOR_SEARCHING_USERS = 0x08020000 //8.2
|
||||
const val MINIMUM_SERVER_VERSION_FOR_REMOTE_THUMBNAILS = 0x07080000 // 7.8.0
|
||||
|
||||
val VERSION_8 = 0x08000000 // 8.0
|
||||
const val MINIMUM_VERSION_FOR_SEARCHING_USERS = 0x08020000 //8.2
|
||||
|
||||
val MINIMUM_VERSION_CAPABILITIES_API = 0x08010000 // 8.1
|
||||
const val VERSION_8 = 0x08000000 // 8.0
|
||||
|
||||
private val MINIMUM_VERSION_WITH_NOT_RESHAREABLE_FEDERATED = 0x09010000 // 9.1
|
||||
const val MINIMUM_VERSION_CAPABILITIES_API = 0x08010000 // 8.1
|
||||
|
||||
private val MINIMUM_VERSION_WITH_SESSION_MONITORING = 0x09010000 // 9.1
|
||||
private const val MINIMUM_VERSION_WITH_NOT_RESHAREABLE_FEDERATED = 0x09010000 // 9.1
|
||||
|
||||
private val MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301
|
||||
private const val MINIMUM_VERSION_WITH_SESSION_MONITORING = 0x09010000 // 9.1
|
||||
|
||||
private const val MINIMUM_VERSION_WITH_SESSION_MONITORING_WORKING_IN_PREEMPTIVE_MODE = 0x09010301
|
||||
// 9.1.3.1, final 9.1.3: https://github.com/owncloud/core/commit/f9a867b70c217463289a741d4d26079eb2a80dfd
|
||||
|
||||
private val MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING = 0xA000000 // 10.0.0
|
||||
private const val MINIMUM_VERSION_WITH_MULTIPLE_PUBLIC_SHARING = 0xA000000 // 10.0.0
|
||||
|
||||
private val MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING = 0xA000100 // 10.0.1
|
||||
private const val MINIMUN_MAJOR_VERSION_WITHOUT_PUBLIC_UPLOAD_PERMISSION = 0xA000000 // 10.0.0
|
||||
|
||||
private val INVALID_ZERO_VERSION = "0.0.0"
|
||||
private const val MINIMUM_VERSION_WITH_WRITE_ONLY_PUBLIC_SHARING = 0xA000100 // 10.0.1
|
||||
|
||||
private val MAX_DOTS = 3
|
||||
private const val INVALID_ZERO_VERSION = "0.0.0"
|
||||
|
||||
private const val MAX_DOTS = 3
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user