-
Notifications
You must be signed in to change notification settings - Fork 99
Sensitivity labels #2083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Sensitivity labels #2083
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...a/com/nextcloud/android/lib/resources/governance/GetAllSelectableLabelsRemoteOperation.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.governance | ||
|
|
||
| import com.nextcloud.android.lib.resources.governance.model.EntityLabels | ||
| import com.nextcloud.common.NextcloudClient | ||
| import com.nextcloud.operations.GetMethod | ||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||
| import com.owncloud.android.lib.common.utils.Log_OC | ||
| import com.owncloud.android.lib.ocs.OcsKotlinResponse | ||
| import com.owncloud.android.lib.ocs.SEPARATOR | ||
| import com.owncloud.android.lib.ocs.ocsJson | ||
| import com.owncloud.android.lib.resources.OCSRemoteOperation | ||
| import org.apache.commons.httpclient.HttpStatus | ||
|
|
||
| class GetAllSelectableLabelsRemoteOperation( | ||
| private val entityType: String, | ||
| private val entityId: Long | ||
| ) : OCSRemoteOperation<EntityLabels>() { | ||
| @Suppress("TooGenericExceptionCaught") | ||
| override fun run(client: NextcloudClient): RemoteOperationResult<EntityLabels> { | ||
| val getMethod = | ||
| GetMethod( | ||
| client.baseUri.toString() + ENDPOINT + entityType + SEPARATOR + entityId + AVAILABLE + JSON_FORMAT, | ||
| true | ||
| ) | ||
| return try { | ||
| val status = client.execute(getMethod) | ||
| if (status != HttpStatus.SC_OK) { | ||
| return RemoteOperationResult(false, getMethod) | ||
| } | ||
| val response = | ||
| ocsJson.decodeFromString<OcsKotlinResponse<EntityLabels>>( | ||
| getMethod.getResponseBodyAsString() | ||
| ) | ||
| val data = response.ocs.data | ||
| RemoteOperationResult<EntityLabels>(true, getMethod).apply { resultData = data } | ||
| } catch (e: Exception) { | ||
| failure(e) | ||
| } finally { | ||
| getMethod.releaseConnection() | ||
| } | ||
| } | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| private fun failure(e: Exception): RemoteOperationResult<EntityLabels> = | ||
| RemoteOperationResult<EntityLabels>(e).also { | ||
| Log_OC.e(TAG, "Get all selectable labels failed: " + it.logMessage, it.exception) | ||
| } | ||
|
|
||
| companion object { | ||
| private val TAG = GetAllSelectableLabelsRemoteOperation::class.java.simpleName | ||
| private const val ENDPOINT = "/ocs/v2.php/apps/governance/v1/labels/" | ||
| private const val AVAILABLE = "/available" | ||
| } | ||
| } |
62 changes: 62 additions & 0 deletions
62
...a/com/nextcloud/android/lib/resources/governance/GetAvailableHoldLabelsRemoteOperation.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.governance | ||
|
|
||
| import com.nextcloud.android.lib.resources.governance.model.HoldLabelInfo | ||
| import com.nextcloud.common.NextcloudClient | ||
| import com.nextcloud.operations.GetMethod | ||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||
| import com.owncloud.android.lib.common.utils.Log_OC | ||
| import com.owncloud.android.lib.ocs.OcsKotlinResponse | ||
| import com.owncloud.android.lib.ocs.SEPARATOR | ||
| import com.owncloud.android.lib.ocs.ocsJson | ||
| import com.owncloud.android.lib.resources.OCSRemoteOperation | ||
| import org.apache.commons.httpclient.HttpStatus | ||
|
|
||
| class GetAvailableHoldLabelsRemoteOperation( | ||
| private val entityType: String, | ||
| private val entityId: Long | ||
| ) : OCSRemoteOperation<List<HoldLabelInfo>>() { | ||
| @Suppress("TooGenericExceptionCaught") | ||
| override fun run(client: NextcloudClient): RemoteOperationResult<List<HoldLabelInfo>> { | ||
| val getMethod = | ||
| GetMethod( | ||
| client.baseUri.toString() + ENDPOINT + entityType + SEPARATOR + entityId + | ||
| HOLD_AVAILABLE + JSON_FORMAT, | ||
| true | ||
| ) | ||
| return try { | ||
| val status = client.execute(getMethod) | ||
| if (status != HttpStatus.SC_OK) { | ||
| return RemoteOperationResult(false, getMethod) | ||
| } | ||
| val response = | ||
| ocsJson.decodeFromString<OcsKotlinResponse<List<HoldLabelInfo>>>( | ||
| getMethod.getResponseBodyAsString() | ||
| ) | ||
| val data = response.ocs.data | ||
| RemoteOperationResult<List<HoldLabelInfo>>(true, getMethod).apply { resultData = data } | ||
| } catch (e: Exception) { | ||
| failure(e) | ||
| } finally { | ||
| getMethod.releaseConnection() | ||
| } | ||
| } | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| private fun failure(e: Exception): RemoteOperationResult<List<HoldLabelInfo>> = | ||
| RemoteOperationResult<List<HoldLabelInfo>>(e).also { | ||
| Log_OC.e(TAG, "Get available hold labels failed: " + it.logMessage, it.exception) | ||
| } | ||
|
|
||
| companion object { | ||
| private val TAG = GetAvailableHoldLabelsRemoteOperation::class.java.simpleName | ||
| private const val ENDPOINT = "/ocs/v2.php/apps/governance/v1/labels/" | ||
| private const val HOLD_AVAILABLE = "/hold/available" | ||
| } | ||
| } |
62 changes: 62 additions & 0 deletions
62
.../nextcloud/android/lib/resources/governance/GetAvailableRetentionLabelsRemoteOperation.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.governance | ||
|
|
||
| import com.nextcloud.android.lib.resources.governance.model.RetentionLabelInfo | ||
| import com.nextcloud.common.NextcloudClient | ||
| import com.nextcloud.operations.GetMethod | ||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||
| import com.owncloud.android.lib.common.utils.Log_OC | ||
| import com.owncloud.android.lib.ocs.OcsKotlinResponse | ||
| import com.owncloud.android.lib.ocs.SEPARATOR | ||
| import com.owncloud.android.lib.ocs.ocsJson | ||
| import com.owncloud.android.lib.resources.OCSRemoteOperation | ||
| import org.apache.commons.httpclient.HttpStatus | ||
|
|
||
| class GetAvailableRetentionLabelsRemoteOperation( | ||
| private val entityType: String, | ||
| private val entityId: Long | ||
| ) : OCSRemoteOperation<List<RetentionLabelInfo>>() { | ||
| @Suppress("TooGenericExceptionCaught") | ||
| override fun run(client: NextcloudClient): RemoteOperationResult<List<RetentionLabelInfo>> { | ||
| val getMethod = | ||
| GetMethod( | ||
| client.baseUri.toString() + ENDPOINT + entityType + SEPARATOR + entityId + | ||
| RETENTION_AVAILABLE + JSON_FORMAT, | ||
| true | ||
| ) | ||
| return try { | ||
| val status = client.execute(getMethod) | ||
| if (status != HttpStatus.SC_OK) { | ||
| return RemoteOperationResult(false, getMethod) | ||
| } | ||
| val response = | ||
| ocsJson.decodeFromString<OcsKotlinResponse<List<RetentionLabelInfo>>>( | ||
| getMethod.getResponseBodyAsString() | ||
| ) | ||
| val data = response.ocs.data | ||
| RemoteOperationResult<List<RetentionLabelInfo>>(true, getMethod).apply { resultData = data } | ||
| } catch (e: Exception) { | ||
| failure(e) | ||
| } finally { | ||
| getMethod.releaseConnection() | ||
| } | ||
| } | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| private fun failure(e: Exception): RemoteOperationResult<List<RetentionLabelInfo>> = | ||
| RemoteOperationResult<List<RetentionLabelInfo>>(e).also { | ||
| Log_OC.e(TAG, "Get available retention labels failed: " + it.logMessage, it.exception) | ||
| } | ||
|
|
||
| companion object { | ||
| private val TAG = GetAvailableRetentionLabelsRemoteOperation::class.java.simpleName | ||
| private const val ENDPOINT = "/ocs/v2.php/apps/governance/v1/labels/" | ||
| private const val RETENTION_AVAILABLE = "/retention/available" | ||
| } | ||
| } | ||
62 changes: 62 additions & 0 deletions
62
...extcloud/android/lib/resources/governance/GetAvailableSensitivityLabelsRemoteOperation.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.governance | ||
|
|
||
| import com.nextcloud.android.lib.resources.governance.model.SensitivityLabelInfo | ||
| import com.nextcloud.common.NextcloudClient | ||
| import com.nextcloud.operations.GetMethod | ||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||
| import com.owncloud.android.lib.common.utils.Log_OC | ||
| import com.owncloud.android.lib.ocs.OcsKotlinResponse | ||
| import com.owncloud.android.lib.ocs.SEPARATOR | ||
| import com.owncloud.android.lib.ocs.ocsJson | ||
| import com.owncloud.android.lib.resources.OCSRemoteOperation | ||
| import org.apache.commons.httpclient.HttpStatus | ||
|
|
||
| class GetAvailableSensitivityLabelsRemoteOperation( | ||
|
alperozturk96 marked this conversation as resolved.
|
||
| private val entityType: String, | ||
| private val entityId: Long | ||
| ) : OCSRemoteOperation<List<SensitivityLabelInfo>>() { | ||
| @Suppress("TooGenericExceptionCaught") | ||
| override fun run(client: NextcloudClient): RemoteOperationResult<List<SensitivityLabelInfo>> { | ||
| val getMethod = | ||
| GetMethod( | ||
| client.baseUri.toString() + ENDPOINT + entityType + SEPARATOR + entityId + | ||
| SENSITIVITY_AVAILABLE + JSON_FORMAT, | ||
| true | ||
| ) | ||
| return try { | ||
| val status = client.execute(getMethod) | ||
| if (status != HttpStatus.SC_OK) { | ||
| return RemoteOperationResult(false, getMethod) | ||
| } | ||
| val response = | ||
| ocsJson.decodeFromString<OcsKotlinResponse<List<SensitivityLabelInfo>>>( | ||
| getMethod.getResponseBodyAsString() | ||
| ) | ||
| val data = response.ocs.data | ||
| RemoteOperationResult<List<SensitivityLabelInfo>>(true, getMethod).apply { resultData = data } | ||
| } catch (e: Exception) { | ||
| failure(e) | ||
| } finally { | ||
| getMethod.releaseConnection() | ||
| } | ||
| } | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| private fun failure(e: Exception): RemoteOperationResult<List<SensitivityLabelInfo>> = | ||
| RemoteOperationResult<List<SensitivityLabelInfo>>(e).also { | ||
| Log_OC.e(TAG, "Get available sensitivity labels failed: " + it.logMessage, it.exception) | ||
| } | ||
|
|
||
| companion object { | ||
| private val TAG = GetAvailableSensitivityLabelsRemoteOperation::class.java.simpleName | ||
| private const val ENDPOINT = "/ocs/v2.php/apps/governance/v1/labels/" | ||
| private const val SENSITIVITY_AVAILABLE = "/sensitivity/available" | ||
| } | ||
| } | ||
60 changes: 60 additions & 0 deletions
60
...ain/java/com/nextcloud/android/lib/resources/governance/GetEntityLabelsRemoteOperation.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.governance | ||
|
|
||
| import com.nextcloud.android.lib.resources.governance.model.EntityLabels | ||
| import com.nextcloud.common.NextcloudClient | ||
| import com.nextcloud.operations.GetMethod | ||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||
| import com.owncloud.android.lib.common.utils.Log_OC | ||
| import com.owncloud.android.lib.ocs.OcsKotlinResponse | ||
| import com.owncloud.android.lib.ocs.SEPARATOR | ||
| import com.owncloud.android.lib.ocs.ocsJson | ||
| import com.owncloud.android.lib.resources.OCSRemoteOperation | ||
| import org.apache.commons.httpclient.HttpStatus | ||
|
|
||
| class GetEntityLabelsRemoteOperation( | ||
|
alperozturk96 marked this conversation as resolved.
|
||
| private val entityType: String, | ||
| private val entityId: String | ||
| ) : OCSRemoteOperation<EntityLabels>() { | ||
| @Suppress("TooGenericExceptionCaught") | ||
| override fun run(client: NextcloudClient): RemoteOperationResult<EntityLabels> { | ||
| val getMethod = | ||
| GetMethod( | ||
| client.baseUri.toString() + ENDPOINT + entityType + SEPARATOR + entityId + JSON_FORMAT, | ||
| true | ||
| ) | ||
| return try { | ||
| val status = client.execute(getMethod) | ||
| if (status != HttpStatus.SC_OK) { | ||
| return RemoteOperationResult(false, getMethod) | ||
| } | ||
| val response = | ||
| ocsJson.decodeFromString<OcsKotlinResponse<EntityLabels>>( | ||
| getMethod.getResponseBodyAsString() | ||
| ) | ||
| val data = response.ocs.data | ||
| RemoteOperationResult<EntityLabels>(true, getMethod).apply { resultData = data } | ||
| } catch (e: Exception) { | ||
| failure(e) | ||
| } finally { | ||
| getMethod.releaseConnection() | ||
| } | ||
| } | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| private fun failure(e: Exception): RemoteOperationResult<EntityLabels> = | ||
| RemoteOperationResult<EntityLabels>(e).also { | ||
| Log_OC.e(TAG, "Get entity labels failed: " + it.logMessage, it.exception) | ||
| } | ||
|
|
||
| companion object { | ||
| private val TAG = GetEntityLabelsRemoteOperation::class.java.simpleName | ||
| private const val ENDPOINT = "/ocs/v2.php/apps/governance/v1/labels/" | ||
| } | ||
| } | ||
64 changes: 64 additions & 0 deletions
64
...rc/main/java/com/nextcloud/android/lib/resources/governance/RemoveLabelRemoteOperation.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Nextcloud Android Library | ||
| * | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package com.nextcloud.android.lib.resources.governance | ||
|
|
||
| import com.nextcloud.android.lib.resources.governance.model.GovernanceLabelResponse | ||
| import com.nextcloud.android.lib.resources.governance.model.LabelType | ||
| import com.nextcloud.common.NextcloudClient | ||
| import com.nextcloud.operations.DeleteMethod | ||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||
| import com.owncloud.android.lib.common.utils.Log_OC | ||
| import com.owncloud.android.lib.ocs.OcsKotlinResponse | ||
| import com.owncloud.android.lib.ocs.ocsJson | ||
| import com.owncloud.android.lib.resources.OCSRemoteOperation | ||
| import org.apache.commons.httpclient.HttpStatus | ||
|
|
||
| class RemoveLabelRemoteOperation( | ||
|
alperozturk96 marked this conversation as resolved.
|
||
| private val entityType: String, | ||
| private val entityId: Long, | ||
| private val labelType: LabelType, | ||
| private val labelId: String | ||
| ) : OCSRemoteOperation<GovernanceLabelResponse>() { | ||
| @Suppress("TooGenericExceptionCaught") | ||
| override fun run(client: NextcloudClient): RemoteOperationResult<GovernanceLabelResponse> { | ||
| val deleteMethod = | ||
| DeleteMethod( | ||
| client.baseUri.toString() + ENDPOINT + entityType + SEPARATOR + entityId + SEPARATOR + | ||
| labelType.value + SEPARATOR + labelId + JSON_FORMAT, | ||
| true | ||
| ) | ||
| return try { | ||
| val status = client.execute(deleteMethod) | ||
| if (status != HttpStatus.SC_OK) { | ||
| return RemoteOperationResult(false, deleteMethod) | ||
| } | ||
| val response = | ||
| ocsJson.decodeFromString<OcsKotlinResponse<GovernanceLabelResponse>>( | ||
| deleteMethod.getResponseBodyAsString() | ||
| ) | ||
| val data = response.ocs.data | ||
| RemoteOperationResult<GovernanceLabelResponse>(true, deleteMethod).apply { resultData = data } | ||
| } catch (e: Exception) { | ||
| failure(e) | ||
| } finally { | ||
| deleteMethod.releaseConnection() | ||
| } | ||
| } | ||
|
|
||
| @Suppress("DEPRECATION") | ||
| private fun failure(e: Exception): RemoteOperationResult<GovernanceLabelResponse> = | ||
| RemoteOperationResult<GovernanceLabelResponse>(e).also { | ||
| Log_OC.e(TAG, "Remove label from entity failed: " + it.logMessage, it.exception) | ||
| } | ||
|
|
||
| companion object { | ||
| private val TAG = RemoveLabelRemoteOperation::class.java.simpleName | ||
| private const val ENDPOINT = "/ocs/v2.php/apps/governance/v1/labels/" | ||
| private const val SEPARATOR = "/" | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.