123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- <?php
- 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/>.
- *
- */
- namespace OCP\FilesMetadata\Model;
- use JsonSerializable;
- use OCP\FilesMetadata\Exceptions\FilesMetadataNotFoundException;
- use OCP\FilesMetadata\Exceptions\FilesMetadataTypeException;
- /**
- * Model that represent metadata linked to a specific file.
- *
- * Example of json stored in the database
- * {
- * "mymeta": {
- * "value": "this is a test",
- * "type": "string",
- * "etag": "abcd1234",
- * "indexed": false,
- * "editPermission": 1
- * },
- * "myapp-anothermeta": {
- * "value": 42,
- * "type": "int",
- * "etag": "0987zyxw",
- * "indexed": true,
- * "editPermission": 0
- * }
- * }
- *
- * @see IMetadataValueWrapper
- * @since 28.0.0
- */
- interface IFilesMetadata extends JsonSerializable {
- /**
- * returns the file id linked to this metadata
- *
- * @return int related file id
- * @since 28.0.0
- */
- public function getFileId(): int;
- /**
- * returns last time metadata were updated in the database
- *
- * @return int timestamp
- * @since 28.0.0
- */
- public function lastUpdateTimestamp(): int;
- /**
- * returns the token known at the time the metadata were extracted from database
- *
- * @return string token
- * @since 28.0.0
- */
- public function getSyncToken(): string;
- /**
- * returns all current metadata keys
- *
- * @return string[] list of keys
- * @since 28.0.0
- */
- public function getKeys(): array;
- /**
- * returns true if search metadata key exists
- *
- * @param string $needle metadata key to search
- *
- * @return bool TRUE if key exist
- * @since 28.0.0
- */
- public function hasKey(string $needle): bool;
- /**
- * return the list of metadata keys set as indexed
- *
- * @return string[] list of indexes
- * @since 28.0.0
- */
- public function getIndexes(): array;
- /**
- * returns true if key exists and is set as indexed
- *
- * @param string $key metadata key
- *
- * @return bool
- * @since 28.0.0
- */
- public function isIndex(string $key): bool;
- /**
- * returns file etag stored during the last update of the metadata key
- *
- * @param string $key metadata key
- * @return string
- * @since 29.0.0
- */
- public function getEtag(string $key): string;
- /**
- * set file etag
- *
- * @param string $key metadata key
- * @since 29.0.0
- */
- public function setEtag(string $key, string $etag): void;
- /**
- * set remote edit permission
- * (Webdav PROPPATCH)
- *
- * @param string $key metadata key
- * @param int $permission remote edit permission
- *
- * @since 28.0.0
- */
- public function setEditPermission(string $key, int $permission): void;
- /**
- * returns remote edit permission
- * (Webdav PROPPATCH)
- *
- * @param string $key metadata key
- *
- * @return int
- * @since 28.0.0
- */
- public function getEditPermission(string $key): int;
- /**
- * returns string value for a metadata key
- *
- * @param string $key metadata key
- *
- * @return string metadata value
- * @throws FilesMetadataNotFoundException
- * @throws FilesMetadataTypeException
- * @since 28.0.0
- */
- public function getString(string $key): string;
- /**
- * returns int value for a metadata key
- *
- * @param string $key metadata key
- *
- * @return int metadata value
- * @throws FilesMetadataNotFoundException
- * @throws FilesMetadataTypeException
- * @since 28.0.0
- */
- public function getInt(string $key): int;
- /**
- * returns float value for a metadata key
- *
- * @param string $key metadata key
- *
- * @return float metadata value
- * @throws FilesMetadataNotFoundException
- * @throws FilesMetadataTypeException
- * @since 28.0.0
- */
- public function getFloat(string $key): float;
- /**
- * returns bool value for a metadata key
- *
- * @param string $key metadata key
- *
- * @return bool metadata value
- * @throws FilesMetadataNotFoundException
- * @throws FilesMetadataTypeException
- * @since 28.0.0
- */
- public function getBool(string $key): bool;
- /**
- * returns array for a metadata key
- *
- * @param string $key metadata key
- *
- * @return array metadata value
- * @throws FilesMetadataNotFoundException
- * @throws FilesMetadataTypeException
- * @since 28.0.0
- */
- public function getArray(string $key): array;
- /**
- * returns string[] value for a metadata key
- *
- * @param string $key metadata key
- *
- * @return string[] metadata value
- * @throws FilesMetadataNotFoundException
- * @throws FilesMetadataTypeException
- * @since 28.0.0
- */
- public function getStringList(string $key): array;
- /**
- * returns int[] value for a metadata key
- *
- * @param string $key metadata key
- *
- * @return int[] metadata value
- * @throws FilesMetadataNotFoundException
- * @throws FilesMetadataTypeException
- * @since 28.0.0
- */
- public function getIntList(string $key): array;
- /**
- * returns the value type of the metadata (string, int, ...)
- *
- * @param string $key metadata key
- *
- * @return string value type
- * @throws FilesMetadataNotFoundException
- * @see IMetadataValueWrapper::TYPE_STRING
- * @see IMetadataValueWrapper::TYPE_INT
- * @see IMetadataValueWrapper::TYPE_FLOAT
- * @see IMetadataValueWrapper::TYPE_BOOL
- * @see IMetadataValueWrapper::TYPE_ARRAY
- * @see IMetadataValueWrapper::TYPE_STRING_LIST
- * @see IMetadataValueWrapper::TYPE_INT_LIST
- * @since 28.0.0
- */
- public function getType(string $key): string;
- /**
- * set a metadata key/value pair for string value
- *
- * @param string $key metadata key
- * @param string $value metadata value
- * @param bool $index set TRUE if value must be indexed
- *
- * @return self
- * @since 28.0.0
- */
- public function setString(string $key, string $value, bool $index = false): self;
- /**
- * set a metadata key/value pair for int value
- *
- * @param string $key metadata key
- * @param int $value metadata value
- * @param bool $index set TRUE if value must be indexed
- *
- * @return self
- * @since 28.0.0
- */
- public function setInt(string $key, int $value, bool $index = false): self;
- /**
- * set a metadata key/value pair for float value
- *
- * @param string $key metadata key
- * @param float $value metadata value
- *
- * @return self
- * @since 28.0.0
- */
- public function setFloat(string $key, float $value): self;
- /**
- * set a metadata key/value pair for bool value
- *
- * @param string $key metadata key
- * @param bool $value metadata value
- * @param bool $index set TRUE if value must be indexed
- *
- * @return self
- * @since 28.0.0
- */
- public function setBool(string $key, bool $value, bool $index = false): self;
- /**
- * set a metadata key/value pair for array
- *
- * @param string $key metadata key
- * @param array $value metadata value
- *
- * @return self
- * @since 28.0.0
- */
- public function setArray(string $key, array $value): self;
- /**
- * set a metadata key/value pair for list of string
- *
- * @param string $key metadata key
- * @param string[] $value metadata value
- * @param bool $index set TRUE if each values from the list must be indexed
- *
- * @return self
- * @since 28.0.0
- */
- public function setStringList(string $key, array $value, bool $index = false): self;
- /**
- * set a metadata key/value pair for list of int
- *
- * @param string $key metadata key
- * @param int[] $value metadata value
- * @param bool $index set TRUE if each values from the list must be indexed
- *
- * @return self
- * @since 28.0.0
- */
- public function setIntList(string $key, array $value, bool $index = false): self;
- /**
- * unset a metadata
- *
- * @param string $key metadata key
- *
- * @return self
- * @since 28.0.0
- */
- public function unset(string $key): self;
- /**
- * unset metadata with key starting with prefix
- *
- * @param string $keyPrefix metadata key prefix
- *
- * @return self
- * @since 28.0.0
- */
- public function removeStartsWith(string $keyPrefix): self;
- /**
- * returns true if object have been updated since last import
- *
- * @return bool TRUE if metadata have been modified
- * @since 28.0.0
- */
- public function updated(): bool;
- /**
- * returns metadata in a simple array with METADATA_KEY => METADATA_VALUE
- *
- * @return array metadata
- * @since 28.0.0
- */
- public function asArray(): array;
- /**
- * deserialize the object from a json
- *
- * @param array $data serialized version of the object
- *
- * @return self
- * @see jsonSerialize
- * @since 28.0.0
- */
- public function import(array $data): self;
- }
|