/**
  * Find file ids matching the given filter rules
  *
  * @param array $filterRules
  * @return array array of unique file id results
  *
  * @throws TagNotFoundException whenever a tag was not found
  */
 public function processFilterRules($filterRules)
 {
     $ns = '{' . $this::NS_OWNCLOUD . '}';
     $resultFileIds = null;
     $systemTagIds = [];
     foreach ($filterRules as $filterRule) {
         if ($filterRule['name'] === $ns . 'systemtag') {
             $systemTagIds[] = $filterRule['value'];
         }
     }
     // check user permissions, if applicable
     if (!$this->isAdmin()) {
         // check visibility/permission
         $tags = $this->tagManager->getTagsByIds($systemTagIds);
         $unknownTagIds = [];
         foreach ($tags as $tag) {
             if (!$tag->isUserVisible()) {
                 $unknownTagIds[] = $tag->getId();
             }
         }
         if (!empty($unknownTagIds)) {
             throw new TagNotFoundException('Tag with ids ' . implode(', ', $unknownTagIds) . ' not found');
         }
     }
     // fetch all file ids and intersect them
     foreach ($systemTagIds as $systemTagId) {
         $fileIds = $this->tagMapper->getObjectIdsForTags($systemTagId, 'files');
         if (empty($fileIds)) {
             // This tag has no files, nothing can ever show up
             return [];
         }
         // first run ?
         if ($resultFileIds === null) {
             $resultFileIds = $fileIds;
         } else {
             $resultFileIds = array_intersect($resultFileIds, $fileIds);
         }
         if (empty($resultFileIds)) {
             // Empty intersection, nothing can show up anymore
             return [];
         }
     }
     return $resultFileIds;
 }
 /**
  * @expectedException \OCP\SystemTag\TagNotFoundException
  */
 public function testGetObjectsForNonExistingTag()
 {
     $this->tagMapper->getObjectIdsForTags([100], 'testtype');
 }