rollback() public method

Rollback transaction, or throw exceptions if no transactions has been started.
public rollback ( )
 /**
  * Removes a relation of type COMMON from a draft.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version
  * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination
  *
  * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
  * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent
  */
 public function deleteRelation(APIVersionInfo $sourceVersion, ContentInfo $destinationContent)
 {
     $sourceVersion = $this->loadVersionInfoById($sourceVersion->contentInfo->id, $sourceVersion->versionNo);
     if ($sourceVersion->status !== APIVersionInfo::STATUS_DRAFT) {
         throw new BadStateException('$sourceVersion', 'Relations of type common can only be removed from versions of status draft');
     }
     if (!$this->repository->canUser('content', 'edit', $sourceVersion)) {
         throw new UnauthorizedException('content', 'edit', array('contentId' => $sourceVersion->contentInfo->id));
     }
     $spiRelations = $this->persistenceHandler->contentHandler()->loadRelations($sourceVersion->getContentInfo()->id, $sourceVersion->versionNo, APIRelation::COMMON);
     if (empty($spiRelations)) {
         throw new InvalidArgumentException('$sourceVersion', 'There are no relations of type COMMON for the given destination');
     }
     // there should be only one relation of type COMMON for each destination,
     // but in case there were ever more then one, we will remove them all
     // @todo: alternatively, throw BadStateException?
     $this->repository->beginTransaction();
     try {
         foreach ($spiRelations as $spiRelation) {
             if ($spiRelation->destinationContentId == $destinationContent->id) {
                 $this->persistenceHandler->contentHandler()->removeRelation($spiRelation->id, APIRelation::COMMON);
             }
         }
         $this->repository->commit();
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
 }
 /**
  * Deletes $location and all its descendants.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user is not allowed to delete this location or a descendant
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  */
 public function deleteLocation(APILocation $location)
 {
     $location = $this->loadLocation($location->id);
     if (!$this->repository->canUser('content', 'manage_locations', $location->getContentInfo())) {
         throw new UnauthorizedException('content', 'manage_locations');
     }
     if (!$this->repository->canUser('content', 'remove', $location->getContentInfo(), $location)) {
         throw new UnauthorizedException('content', 'remove');
     }
     /** Check remove access to descendants
      * @var boolean|\eZ\Publish\API\Repository\Values\Content\Query\Criterion $contentReadCriterion
      */
     $contentReadCriterion = $this->permissionsCriterionHandler->getPermissionsCriterion('content', 'remove');
     if ($contentReadCriterion === false) {
         throw new UnauthorizedException('content', 'remove');
     } else {
         if ($contentReadCriterion !== true) {
             // Query if there are any content in subtree current user don't have access to
             $query = new Query(array('limit' => 0, 'filter' => new CriterionLogicalAnd(array(new CriterionSubtree($location->pathString), new CriterionLogicalNot($contentReadCriterion)))));
             $result = $this->repository->getSearchService()->findContent($query, array(), false);
             if ($result->totalCount > 0) {
                 throw new UnauthorizedException('content', 'remove');
             }
         }
     }
     $this->repository->beginTransaction();
     try {
         $this->persistenceHandler->locationHandler()->removeSubtree($location->id);
         $this->persistenceHandler->urlAliasHandler()->locationDeleted($location->id);
         $this->repository->commit();
     } catch (Exception $e) {
         $this->repository->rollback();
         throw $e;
     }
 }