Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

package com.nextcloud.android.lib.resources.governance

data class EntityLabels(
val sensitivity: SensitivityLabelInfo?,
val retention: List<RetentionLabelInfo>,
val hold: List<HoldLabelInfo>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

package com.nextcloud.android.lib.resources.governance

import com.google.gson.reflect.TypeToken
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.ServerResponse
import com.owncloud.android.lib.resources.OCSRemoteOperation
import org.apache.commons.httpclient.HttpStatus

/**
* Get the hold labels the user may apply to an entity
*/
class GetAvailableHoldLabelsRemoteOperation(
private val entityType: String,
private val entityId: Long
) : OCSRemoteOperation<List<HoldLabelInfo>>() {
@Suppress("TooGenericExceptionCaught")
override fun run(client: NextcloudClient): RemoteOperationResult<List<HoldLabelInfo>> {
var result: RemoteOperationResult<List<HoldLabelInfo>>
var getMethod: GetMethod? = null
try {
getMethod =
GetMethod(
client.baseUri.toString() + ENDPOINT + entityType + "/" + entityId +
HOLD_AVAILABLE + JSON_FORMAT,
true
)
val status = client.execute(getMethod)
if (status == HttpStatus.SC_OK) {
val labels =
getServerResponse(
getMethod,
object : TypeToken<ServerResponse<List<HoldLabelInfo>>>() {}
)?.ocs?.data

if (labels != null) {
result = RemoteOperationResult(true, getMethod)
result.setResultData(labels)
} else {
result = RemoteOperationResult(false, getMethod)
}
} else {
result = RemoteOperationResult(false, getMethod)
}
} catch (e: Exception) {
result = RemoteOperationResult(e)
Log_OC.e(
TAG,
"Get available hold labels failed: " + result.logMessage,
result.exception
)
} finally {
getMethod?.releaseConnection()
}
return result
}

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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

package com.nextcloud.android.lib.resources.governance

import com.google.gson.reflect.TypeToken
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.ServerResponse
import com.owncloud.android.lib.resources.OCSRemoteOperation
import org.apache.commons.httpclient.HttpStatus

/**
* Get the retention labels the user may apply to an entity
*/
class GetAvailableRetentionLabelsRemoteOperation(
private val entityType: String,
private val entityId: Long
) : OCSRemoteOperation<List<RetentionLabelInfo>>() {
@Suppress("TooGenericExceptionCaught")
override fun run(client: NextcloudClient): RemoteOperationResult<List<RetentionLabelInfo>> {
var result: RemoteOperationResult<List<RetentionLabelInfo>>
var getMethod: GetMethod? = null
try {
getMethod =
GetMethod(
client.baseUri.toString() + ENDPOINT + entityType + "/" + entityId +
RETENTION_AVAILABLE + JSON_FORMAT,
true
)
val status = client.execute(getMethod)
if (status == HttpStatus.SC_OK) {
val labels =
getServerResponse(
getMethod,
object : TypeToken<ServerResponse<List<RetentionLabelInfo>>>() {}
)?.ocs?.data

if (labels != null) {
result = RemoteOperationResult(true, getMethod)
result.setResultData(labels)
} else {
result = RemoteOperationResult(false, getMethod)
}
} else {
result = RemoteOperationResult(false, getMethod)
}
} catch (e: Exception) {
result = RemoteOperationResult(e)
Log_OC.e(
TAG,
"Get available retention labels failed: " + result.logMessage,
result.exception
)
} finally {
getMethod?.releaseConnection()
}
return result
}

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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

package com.nextcloud.android.lib.resources.governance

import com.google.gson.reflect.TypeToken
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.ServerResponse
import com.owncloud.android.lib.resources.OCSRemoteOperation
import org.apache.commons.httpclient.HttpStatus

/**
* Get the sensitivity labels the user may apply to an entity
*/
class GetAvailableSensitivityLabelsRemoteOperation(
private val entityType: String,
private val entityId: Long
) : OCSRemoteOperation<List<SensitivityLabelInfo>>() {
@Suppress("TooGenericExceptionCaught")
override fun run(client: NextcloudClient): RemoteOperationResult<List<SensitivityLabelInfo>> {
var result: RemoteOperationResult<List<SensitivityLabelInfo>>
var getMethod: GetMethod? = null
try {
getMethod =
GetMethod(
client.baseUri.toString() + ENDPOINT + entityType + "/" + entityId +
SENSITIVITY_AVAILABLE + JSON_FORMAT,
true
)
val status = client.execute(getMethod)
if (status == HttpStatus.SC_OK) {
val labels =
getServerResponse(
getMethod,
object : TypeToken<ServerResponse<List<SensitivityLabelInfo>>>() {}
)?.ocs?.data

if (labels != null) {
result = RemoteOperationResult(true, getMethod)
result.setResultData(labels)
} else {
result = RemoteOperationResult(false, getMethod)
}
} else {
result = RemoteOperationResult(false, getMethod)
}
} catch (e: Exception) {
result = RemoteOperationResult(e)
Log_OC.e(
TAG,
"Get available sensitivity labels failed: " + result.logMessage,
result.exception
)
} finally {
getMethod?.releaseConnection()
}
return result
}

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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

package com.nextcloud.android.lib.resources.governance

import com.google.gson.reflect.TypeToken
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.ServerResponse
import com.owncloud.android.lib.resources.OCSRemoteOperation
import org.apache.commons.httpclient.HttpStatus

/**
* Get all labels applied to an entity, grouped by type, filtered to those visible to the calling user
*/
class GetEntityLabelsRemoteOperation(
private val entityType: String,
private val entityId: String
) : OCSRemoteOperation<EntityLabels>() {
@Suppress("TooGenericExceptionCaught")
override fun run(client: NextcloudClient): RemoteOperationResult<EntityLabels> {
var result: RemoteOperationResult<EntityLabels>
var getMethod: GetMethod? = null
try {
getMethod =
GetMethod(
client.baseUri.toString() + ENDPOINT + entityType + "/" + entityId + JSON_FORMAT,
true
)
val status = client.execute(getMethod)
if (status == HttpStatus.SC_OK) {
val entityLabels =
getServerResponse(
getMethod,
object : TypeToken<ServerResponse<EntityLabels>>() {}
)?.ocs?.data

if (entityLabels != null) {
result = RemoteOperationResult(true, getMethod)
result.setResultData(entityLabels)
} else {
result = RemoteOperationResult(false, getMethod)
}
} else {
result = RemoteOperationResult(false, getMethod)
}
} catch (e: Exception) {
result = RemoteOperationResult(e)
Log_OC.e(
TAG,
"Get entity labels failed: " + result.logMessage,
result.exception
)
} finally {
getMethod?.releaseConnection()
}
return result
}

companion object {
private val TAG = GetEntityLabelsRemoteOperation::class.java.simpleName
private const val ENDPOINT = "/ocs/v2.php/apps/governance/v1/labels/"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

package com.nextcloud.android.lib.resources.governance

data class GovernanceLabelResponse(
val message: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

package com.nextcloud.android.lib.resources.governance

data class HoldLabelInfo(
val id: String,
val name: String,
val priority: Long,
val description: String,
val color: String,
val scopes: List<LabelScope>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

package com.nextcloud.android.lib.resources.governance

import com.google.gson.annotations.SerializedName

enum class LabelScope {
@SerializedName("FILES")
FILES,

@SerializedName("MAILS")
MAILS
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Nextcloud Android Library
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: MIT
*/

package com.nextcloud.android.lib.resources.governance

enum class LabelType(val value: String) {
SENSITIVITY("SENSITIVITY"),
RETENTION("RETENTION"),
HOLD("HOLD")
}
Loading
Loading