Creates an exception for a UUID that exists already.

@param Uuid           $uuid  The UUID of the mapping.
@param Exception|null $cause The exception that caused this exception.

@return static The created exception.
341483
public static function forUuid(Uuid $uuid, Exception $cause = null)
    {
        return new static(sprintf(
            'The asset mapping "%s" exists already.',
            $uuid->toString()
        ), 0, $cause);
    }
246292
public static ResourceManagerId fromUuidOrNull(@Nullable UUID uuid) {
		return  uuid == null ? null : new ResourceManagerId(uuid);
	}
821746
@Override
	public int countByUuid(String uuid) {
		FinderPath finderPath = FINDER_PATH_COUNT_BY_UUID;

		Object[] finderArgs = new Object[] { uuid };

		Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);

		if (count == null) {
			StringBundler query = new StringBundler(2);

			query.append(_SQL_COUNT_COMMERCENOTIFICATIONATTACHMENT_WHERE);

			boolean bindUuid = false;

			if (uuid == null) {
				query.append(_FINDER_COLUMN_UUID_UUID_1);
			}
			else if (uuid.equals("")) {
				query.append(_FINDER_COLUMN_UUID_UUID_3);
			}
			else {
				bindUuid = true;

				query.append(_FINDER_COLUMN_UUID_UUID_2);
			}

			String sql = query.toString();

			Session session = null;

			try {
				session = openSession();

				Query q = session.createQuery(sql);

				QueryPos qPos = QueryPos.getInstance(q);

				if (bindUuid) {
					qPos.add(uuid);
				}

				count = (Long)q.uniqueResult();

				finderCache.putResult(finderPath, finderArgs, count);
			}
			catch (Exception e) {
				finderCache.removeResult(finderPath, finderArgs);

				throw processException(e);
			}
			finally {
				closeSession(session);
			}
		}

		return count.intValue();
	}
1187757
public function fromHex(string $uuid): BigNumber
    {
        $uuidBase10 = BigNumber::convertToBase10($uuid, 16);

        return new BigNumber($uuidBase10);
    }
222376
public function patch($uuid, Request $request)
    {
        $model = static::$model::findOrFail($uuid);

        $this->authorizeUserAction('update', $model);

        $this->restfulService->validateResourceUpdate($model, $request->input());

        $this->restfulService->patch($model, $request->input());

        if ($this->shouldTransform()) {
            $response = $this->response->item($model, $this->getTransformer());
        } else {
            $response = $model;
        }

        return $response;
    }
579523
public static function hipChatRespondedWithAnError(ClientException $exception)
    {
        return new static(sprintf(
            'HipChat responded with an error %s - %s',
            $exception->getResponse()->getStatusCode(),
            $exception->getResponse()->getBody()
        ));
    }
649676
public static function existsAlready($name, Exception $cause = null)
    {
        return new static(sprintf(
            'An argument named "%s" exists already.',
            $name
        ), self::EXISTS_ALREADY, $cause);
    }
659379
public function get($parentUuid, $uuid)
    {
        // Check parent exists
        $parentModel = static::$parentModel;
        $parentResource = $parentModel::findOrFail($parentUuid);

        // Authorize ability to view children model for parent
        $this->authorizeUserAction($this->parentAbilitiesRequired['view'], $parentResource);

        // Get resource
        $model = new static::$model;
        $resource = $model::with($model::$localWith)->where($model->getKeyName(), '=', $uuid)->firstOrFail();

        // Check resource belongs to parent
        if ($resource->getAttribute(($parentResource->getKeyName())) != $parentResource->getKey()) {
            throw new AccessDeniedHttpException('Resource \'' . class_basename(static::$model) . '\' with given UUID ' . $uuid . ' does not belong to ' .
                'resource \'' . class_basename(static::$parentModel) . '\' with given UUID ' . $parentUuid . '; ');
        }

        if (! $resource) {
            throw new NotFoundHttpException('Resource \'' . class_basename(static::$model) . '\' with given UUID ' . $uuid . ' not found');
        }

        // Authorize ability to create this model
        $this->authorizeUserAction('view', $resource);

        return $this->response->item($resource, $this->getTransformer());
    }
770055
public static DeleteException fromThrowable(Throwable cause) {
    return (cause instanceof DeleteException)
                   ? (DeleteException) cause
                   : new DeleteException(cause);
  }
491177
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!Uuid::isValid($input->getArgument('uuid'))) {
            throw new Exception('Invalid UUID (' . $input->getArgument('uuid') . ')');
        }

        $uuid = Uuid::fromString($input->getArgument('uuid'));

        $table = $this->getHelperSet()->get('table');
        $table->setLayout(TableHelper::LAYOUT_BORDERLESS);

        $table->addRows(array(
            array('encode:', 'STR:', (string) $uuid),
            array('',        'INT:', (string) $uuid->getInteger()),
        ));

        if ($uuid->getVariant() != Uuid::RFC_4122) {
            $table->addRows(array(
                array('decode:', 'variant:', 'Not an RFC 4122 UUID'),
            ));

            $table->render($output);

            return;
        }

        switch ($uuid->getVersion()) {
            case 1:
                $version = '1 (time and node based)';
                break;
            case 2:
                $version = '2 (DCE security based)';
                break;
            case 3:
                $version = '3 (name based, MD5)';
                break;
            case 4:
                $version = '4 (random data based)';
                break;
            case 5:
                $version = '5 (name based, SHA-1)';
                break;
        }

        $table->addRows(array(
            array('decode:', 'variant:', 'RFC 4122'),
            array('',        'version:', $version),
        ));

        if ($uuid->getVersion() == 1) {
            $table->addRows(array(
                array('', 'content:', 'time:  ' . $uuid->getDateTime()->format('c')),
                array('', '', 'clock: ' . $uuid->getClockSequence() . ' (usually random)'),
                array('', '', 'node:  ' . substr(chunk_split($uuid->getNodeHex(), 2, ':'), 0, -1)),
            ));
        }

        if ($uuid->getVersion() == 4) {
            $table->addRows(array(
                array('', 'content:', substr(chunk_split($uuid->getHex(), 2, ':'), 0, -1)),
                array('', '', '(no semantics: random data only)'),
            ));
        }

        if ($uuid->getVersion() == 3 || $uuid->getVersion() == 5) {
            $table->addRows(array(
                array('', 'content:', substr(chunk_split($uuid->getHex(), 2, ':'), 0, -1)),
                array('', '', '(not decipherable: MD5 message digest only)'),
            ));
        }

        $table->render($output);
    }
239979
public function byUuid(AggregateUuid $uuid, $returnType = self::RETURN_AS_ARRAY)
    {
        $uuid = (string) $uuid;
        $query = 'SELECT
                  `uuid`,
                  `version`,
                  `payload`,
                  `type`,
                  `body`,
                  `occurred_on`
                FROM `'.PdoDriver::EVENTSTORE_TABLE_NAME.'` 
                WHERE `uuid` = :uuid
                ORDER BY `occurred_on` ASC';
        $stmt = $this->pdo->prepare($query);
        $stmt->bindParam(':uuid', $uuid);
        $stmt->execute();

        $row = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        if (!empty($row)) {
            return $this->buildEventAggregate($row, $returnType);
        }

        return null;
    }
1023217
public function hasAccessEntityForUuid($class, $uuid)
    {
        try {
             $em = $this->entityManager->getDoctrineEntityManager();
             $data = $em->getRepository($class)->findOneBy(array(
                 'uuid' => $uuid,
             ));
             
             if ($data !== null) {
                 return true;
             }
             
             return false;
        } catch (\Exception $e) {
            throw new Exception('Cannot check if there is an access entitiy for the given uuid "' . $uuid . '".', 0, $e);
        }
    }
855257
public static function get($uuid, $client = null) {
    return Recurly_Base::_get(Recurly_Transaction::uriForTransaction($uuid), $client);
  }
185021
private function resolvePathByUuid($uuid)
    {
        $queryBuilder = new QueryBuilder($this->qomFactory);

        $queryBuilder
            ->select('node', 'jcr:uuid', 'uuid')
            ->from($this->qomFactory->selector('node', 'nt:unstructured'))
            ->where(
                $this->qomFactory->comparison(
                    $this->qomFactory->propertyValue('node', 'jcr:uuid'),
                    '=',
                    $this->qomFactory->literal($uuid)
                )
            );

        $rows = $queryBuilder->execute();

        if (1 !== count(iterator_to_array($rows->getRows()))) {
            throw new ItemNotFoundException();
        }

        return $rows->getRows()->current()->getPath();
    }
887353
public function findOrFailByUuid($uuid, $columns = ['*'])
    {
        $result = $this->findByUuid($uuid, $columns);

        if (is_array($uuid)) {
            if (count($result) == count(array_unique($uuid))) {
                return $result;
            }
        } elseif (! is_null($result)) {
            return $result;
        }

        throw new NotFoundHttpException('Resource \'' . class_basename(get_class($this->model)) . '\' with given UUID ' . $uuid . ' not found');
    }
593428
public function exception($exception = null)
    {
        if (!func_num_args()) {
            return $this->_exception;
        }
        $this->_exception = $exception;
        return $this;
    }
1073940
public static function create(
        AppUUID $appUUID = null,
        IndexUUID $indexUUID = null
    ): RepositoryReference {
        return new self($appUUID, $indexUUID);
    }