SearchFolderService

Extends \OCA\Gallery\Service\FilesService

Looks for the folder to use, based on the request made by the client

This is to make sure we were not:

  • given a file
  • given a folder name with a typo
package

OCA\Gallery\Service

Methods

Constructor

__construct(string $appName, \OCA\Gallery\Environment\Environment $environment, \OCP\ILogger $logger) 
inherited

Arguments

$appName

string

$logger

\OCP\ILogger

This returns the current folder node based on a path

findFolder(string $location, integer $depth) : array

If the path leads to a file, we'll return the node of the containing folder

If we can't find anything, we try with the parent folder, up to the root or until we reach our recursive limit

Arguments

$location

string

$depth

integer

Response

array

<string,Folder,bool>

Returns an array containing information about a node

formatNodeData(string $imagePath, integer $nodeId, integer $mTime, string $etag, integer $size, boolean $sharedWithUser,  $ownerData, integer $permissions) : array
inherited

Arguments

$imagePath

string

$nodeId

integer

$mTime

integer

$etag

string

$size

integer

$sharedWithUser

boolean

$ownerData

$permissions

integer

Response

array

Returns the node if it's a folder we have access to

getAllowedSubFolder(\OCP\Files\Folder $node, string $nodeType) : array|\OCP\Files\Folder
inherited

Arguments

$node

\OCP\Files\Folder

$nodeType

string

Response

array|\OCP\Files\Folder

This returns what we think is the current folder node based on a given path

getCurrentFolder(string $location, array<mixed,string> $features) : array

Arguments

$location

string

$features

array<mixed,string>

Response

array

<string,Folder,bool>

Returns the file matching the given ID

getFile(integer $nodeId) : \OCP\Files\Node
inherited
Throws
\OCA\Gallery\Service\NotFoundServiceException

Arguments

$nodeId

integer

ID of the resource to locate

Response

\OCP\Files\Node

Returns various information about a folder

getFolderData(\OCP\Files\Folder $node) : \OCA\Gallery\Service\array<string,int|string|boolean|\OCA\Gallery\Service\array<string,int|\OCA\Gallery\Service\string>>
inherited

Arguments

$node

\OCP\Files\Folder

Response

\OCA\Gallery\Service\array>

Returns the node matching the given ID

getNode(integer $nodeId) : \OCP\Files\Node
inherited
Throws
\OCA\Gallery\Service\NotFoundServiceException

Arguments

$nodeId

integer

ID of the resource to locate

Response

\OCP\Files\Node

Returns various information about a node

getNodeData(\OCP\Files\Node|\OCP\Files\File|\OCP\Files\Folder $node) : \OCA\Gallery\Service\array<string,int|string|boolean|\OCA\Gallery\Service\array<string,int|\OCA\Gallery\Service\string>>
inherited

Arguments

$node

\OCP\Files\Node|\OCP\Files\File|\OCP\Files\Folder

Response

\OCA\Gallery\Service\array>

Retrieves all files and sub-folders contained in a folder

getNodes(\OCP\Files\Folder $folder, integer $subDepth) : array
inherited

If we can't find anything in the current folder, we throw an exception as there is no point in doing any more work, but if we're looking at a sub-folder, we return an empty array so that it can be simply ignored

Arguments

$folder

\OCP\Files\Folder

$subDepth

integer

Response

array

Returns the node type, either 'dir' or 'file'

getNodeType(\OCP\Files\Node $node) : string
inherited

If there is a problem, we return an empty string so that the node can be ignored

Arguments

$node

\OCP\Files\Node

Response

string

Returns what we known about the owner of a node

getOwnerData(\OCP\Files\Node $node) : null|\OCA\Gallery\Service\array<string,int|\OCA\Gallery\Service\string>
inherited

Arguments

$node

\OCP\Files\Node

Response

null|\OCA\Gallery\Service\array

Determines if we can consider the node mounted locally or if it's been authorised to be scanned

isAllowed(\OCP\Files\Node $node) : boolean
inherited

Arguments

$node

\OCP\Files\Node

Response

boolean

Determines if the files are hosted locally (shared or not) and can be used by the preview system

isAllowedAndAvailable(\OCP\Files\Node $node) : boolean
inherited

isMounted() doesn't include externally hosted shares, so we need to exclude those from the non-mounted nodes

Arguments

$node

\OCP\Files\Node

Response

boolean

Determines if the node is available, as in readable

isAvailable(\OCP\Files\Node $node) : boolean
inherited
todo

Test to see by how much using file_exists slows things down

Arguments

$node

\OCP\Files\Node

Response

boolean

Determines if the node is a share which is hosted externally

isExternalShare(\OCP\Files\Node $node) : boolean
inherited

Arguments

$node

\OCP\Files\Node

Response

boolean

Determines if the user has allowed the use of external shares

isExternalShareAllowed() : boolean
inherited

Response

boolean

Determines if we've reached the root folder

isRootFolder(\OCP\Files\Folder $folder, integer $level) : boolean
inherited

Arguments

$folder

\OCP\Files\Folder

$level

integer

Response

boolean

Throws an exception if this problem occurs in the current folder, otherwise just ignores the sub-folder

recoverFromGetNodesError(integer $subDepth, \Exception $exception) : array
inherited
Throws
\OCA\Gallery\Service\NotFoundServiceException

Arguments

$subDepth

integer

$exception

\Exception

Response

array

Makes sure that the folder is not empty, does meet our requirements in terms of location and returns details about it

sendFolder(string $path, \OCP\Files\Folder $node) : array
Throws
\OCA\Gallery\Service\ForbiddenServiceException|\OCA\Gallery\Service\NotFoundServiceException

Arguments

$path

string

$node

\OCP\Files\Folder

Response

array

<string,Folder,bool>

Makes sure we don't go too far up before giving up

validateLocation(string $location, integer $depth) : string

Arguments

$location

string

$depth

integer

Response

string

Makes extra sure that we can actually do something with the file

validateNode(\OCP\Files\Node $node) 
inherited
Throws
\OCA\Gallery\Service\NotFoundServiceException

Arguments

$node

\OCP\Files\Node

Properties

virtualRootLevel

virtualRootLevel : integer
inherited
var

Type(s)

integer

features

features : array<mixed,string>
inherited
var

Type(s)

array<mixed,string>

ignoreAlbum

ignoreAlbum : string
inherited
var

Type(s)

string

appName

appName : string
inherited
var

Type(s)

string

environment

environment : \OCA\Gallery\Environment\Environment
inherited

logger

logger : \OCP\ILogger
inherited
var

Type(s)

\OCP\ILogger