/**
  * @dataProvider updateTagProvider
  * @expectedException \OCP\SystemTag\TagAlreadyExistsException
  */
 public function testUpdateTagDuplicate($tagCreate, $tagUpdated)
 {
     $this->tagManager->createTag($tagCreate[0], $tagCreate[1], $tagCreate[2]);
     $tag2 = $this->tagManager->createTag($tagUpdated[0], $tagUpdated[1], $tagUpdated[2]);
     // update to match the first tag
     $this->tagManager->updateTag($tag2->getId(), $tagCreate[0], $tagCreate[1], $tagCreate[2]);
 }
Exemple #2
0
 /**
  * Update tag
  *
  * @param string $name new tag name
  * @param bool $userVisible user visible
  * @param bool $userAssignable user assignable
  * @throws NotFound whenever the given tag id does not exist
  * @throws Conflict whenever a tag already exists with the given attributes
  */
 public function update($name, $userVisible, $userAssignable)
 {
     try {
         $this->tagManager->updateTag($this->tag->getId(), $name, $userVisible, $userAssignable);
     } catch (TagNotFoundException $e) {
         throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist');
     } catch (TagAlreadyExistsException $e) {
         throw new Conflict('Tag with the properties "' . $name . '", ' . $userVisible . ', ' . $userAssignable . ' already exists');
     }
 }
 /**
  * Update tag
  *
  * @param string $name new tag name
  * @param bool $userVisible user visible
  * @param bool $userAssignable user assignable
  * @throws NotFound whenever the given tag id does not exist
  * @throws Forbidden whenever there is no permission to update said tag
  * @throws Conflict whenever a tag already exists with the given attributes
  */
 public function update($name, $userVisible, $userAssignable)
 {
     try {
         if (!$this->isAdmin) {
             if (!$this->tag->isUserVisible()) {
                 throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist');
             }
             if (!$this->tag->isUserAssignable()) {
                 throw new Forbidden('No permission to update tag ' . $this->tag->getId());
             }
             // only renaming is allowed for regular users
             if ($userVisible !== $this->tag->isUserVisible() || $userAssignable !== $this->tag->isUserAssignable()) {
                 throw new Forbidden('No permission to update permissions for tag ' . $this->tag->getId());
             }
         }
         $this->tagManager->updateTag($this->tag->getId(), $name, $userVisible, $userAssignable);
     } catch (TagNotFoundException $e) {
         throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist');
     } catch (TagAlreadyExistsException $e) {
         throw new Conflict('Tag with the properties "' . $name . '", ' . $userVisible . ', ' . $userAssignable . ' already exists');
     }
 }