aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/FilesMetadata/Model/MetadataValueWrapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/FilesMetadata/Model/MetadataValueWrapper.php')
-rw-r--r--lib/private/FilesMetadata/Model/MetadataValueWrapper.php61
1 files changed, 34 insertions, 27 deletions
diff --git a/lib/private/FilesMetadata/Model/MetadataValueWrapper.php b/lib/private/FilesMetadata/Model/MetadataValueWrapper.php
index 90f1554180d..710a8129340 100644
--- a/lib/private/FilesMetadata/Model/MetadataValueWrapper.php
+++ b/lib/private/FilesMetadata/Model/MetadataValueWrapper.php
@@ -2,25 +2,8 @@
declare(strict_types=1);
/**
- * @copyright 2023 Maxence Lange <maxence@artificial-owl.com>
- *
- * @author Maxence Lange <maxence@artificial-owl.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\FilesMetadata\Model;
@@ -38,6 +21,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
private string $type;
/** @var string|int|float|bool|array|string[]|int[] */
private mixed $value = null;
+ private string $etag = '';
private bool $indexed = false;
private int $editPermission = self::EDIT_FORBIDDEN;
@@ -233,7 +217,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
*/
public function getValueString(): string {
$this->assertType(self::TYPE_STRING);
- if (null === $this->value) {
+ if ($this->value === null) {
throw new FilesMetadataNotFoundException('value is not set');
}
@@ -249,7 +233,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
*/
public function getValueInt(): int {
$this->assertType(self::TYPE_INT);
- if (null === $this->value) {
+ if ($this->value === null) {
throw new FilesMetadataNotFoundException('value is not set');
}
@@ -265,7 +249,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
*/
public function getValueFloat(): float {
$this->assertType(self::TYPE_FLOAT);
- if (null === $this->value) {
+ if ($this->value === null) {
throw new FilesMetadataNotFoundException('value is not set');
}
@@ -281,7 +265,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
*/
public function getValueBool(): bool {
$this->assertType(self::TYPE_BOOL);
- if (null === $this->value) {
+ if ($this->value === null) {
throw new FilesMetadataNotFoundException('value is not set');
}
@@ -297,7 +281,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
*/
public function getValueArray(): array {
$this->assertType(self::TYPE_ARRAY);
- if (null === $this->value) {
+ if ($this->value === null) {
throw new FilesMetadataNotFoundException('value is not set');
}
@@ -313,7 +297,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
*/
public function getValueStringList(): array {
$this->assertType(self::TYPE_STRING_LIST);
- if (null === $this->value) {
+ if ($this->value === null) {
throw new FilesMetadataNotFoundException('value is not set');
}
@@ -329,7 +313,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
*/
public function getValueIntList(): array {
$this->assertType(self::TYPE_INT_LIST);
- if (null === $this->value) {
+ if ($this->value === null) {
throw new FilesMetadataNotFoundException('value is not set');
}
@@ -343,7 +327,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
* @since 28.0.0
*/
public function getValueAny(): mixed {
- if (null === $this->value) {
+ if ($this->value === null) {
throw new FilesMetadataNotFoundException('value is not set');
}
@@ -351,6 +335,27 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
}
/**
+ * @inheritDoc
+ * @return string stored etag
+ * @since 29.0.0
+ */
+ public function getEtag(): string {
+ return $this->etag;
+ }
+
+ /**
+ * @param string $etag etag value
+ *
+ * @inheritDoc
+ * @return self
+ * @since 29.0.0
+ */
+ public function setEtag(string $etag): self {
+ $this->etag = $etag;
+ return $this;
+ }
+
+ /**
* @param bool $indexed TRUE to set the stored value as an indexed value
*
* @inheritDoc
@@ -405,6 +410,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
public function import(array $data): self {
$this->value = $data['value'] ?? null;
$this->type = $data['type'] ?? '';
+ $this->setEtag($data['etag'] ?? '');
$this->setIndexed($data['indexed'] ?? false);
$this->setEditPermission($data['editPermission'] ?? self::EDIT_FORBIDDEN);
return $this;
@@ -414,6 +420,7 @@ class MetadataValueWrapper implements IMetadataValueWrapper {
return [
'value' => ($emptyValues) ? null : $this->value,
'type' => $this->getType(),
+ 'etag' => $this->getEtag(),
'indexed' => $this->isIndexed(),
'editPermission' => $this->getEditPermission()
];